This commit is contained in:
SirLynix
2022-12-06 20:10:10 +01:00
committed by Jérôme Leclercq
parent b379518479
commit 292ca60592
34 changed files with 1995 additions and 60 deletions

View File

@@ -0,0 +1,56 @@
diff --git a/include/assimp/defs.h b/include/assimp/defs.h
index 05a5e3fd4..8b90edfca 100644
--- a/include/assimp/defs.h
+++ b/include/assimp/defs.h
@@ -126,7 +126,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* GENBOUNDINGBOXES */
//////////////////////////////////////////////////////////////////////////
-#ifdef _MSC_VER
+#ifdef _WIN32
# undef ASSIMP_API
//////////////////////////////////////////////////////////////////////////
@@ -135,7 +135,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ifdef ASSIMP_BUILD_DLL_EXPORT
# define ASSIMP_API __declspec(dllexport)
# define ASSIMP_API_WINONLY __declspec(dllexport)
-# pragma warning (disable : 4251)
+# ifdef _MSC_VER
+# pragma warning (disable : 4251)
+# endif
//////////////////////////////////////////////////////////////////////////
/* Define 'ASSIMP_DLL' before including Assimp to link to ASSIMP in
@@ -149,6 +151,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# define ASSIMP_API_WINONLY
# endif
+# ifdef _MSC_VER
+
/* Force the compiler to inline a function, if possible
*/
# define AI_FORCE_INLINE __forceinline
@@ -157,6 +161,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* to skip dead paths (e.g. after an assertion evaluated to false). */
# define AI_WONT_RETURN __declspec(noreturn)
+# else
+
+# define AI_FORCE_INLINE inline
+# define AI_WONT_RETURN
+
+# endif
+
#elif defined(SWIG)
/* Do nothing, the relevant defines are all in AssimpSwigPort.i */
@@ -170,7 +181,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# define AI_FORCE_INLINE inline
#endif // (defined _MSC_VER)
-#ifdef __GNUC__
+#if defined(__GNUC__) || defined(__MINGW32__)
# define AI_WONT_RETURN_SUFFIX __attribute__((noreturn))
#else
# define AI_WONT_RETURN_SUFFIX

View File

@@ -0,0 +1,14 @@
diff --git a/code/Common/ZipArchiveIOSystem.cpp b/code/Common/ZipArchiveIOSystem.cpp
index e0c9883d2..c748b3255 100644
--- a/code/Common/ZipArchiveIOSystem.cpp
+++ b/code/Common/ZipArchiveIOSystem.cpp
@@ -196,7 +196,9 @@ zlib_filefunc_def IOSystem2Unzip::get(IOSystem *pIOHandler) {
zlib_filefunc_def mapping;
mapping.zopen_file = (open_file_func)open;
+#ifdef ZOPENDISK64
mapping.zopendisk_file = (opendisk_file_func)opendisk;
+#endif
mapping.zread_file = (read_file_func)read;
mapping.zwrite_file = (write_file_func)write;
mapping.ztell_file = (tell_file_func)tell;

View File

@@ -0,0 +1,27 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f48391edf..66f7b726d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -155,22 +155,6 @@ IF (WIN32)
# "VCRUNTIME140.dll not found. Try reinstalling the app.", but give users
# a choice to opt for the shared runtime if they want.
option(USE_STATIC_CRT "Link against the static runtime libraries." OFF)
-
- # The CMAKE_CXX_FLAGS vars can be overriden by some Visual Studio generators, so we use an alternative
- # global method here:
- if (${USE_STATIC_CRT})
- add_compile_options(
- $<$<CONFIG:>:/MT>
- $<$<CONFIG:Debug>:/MTd>
- $<$<CONFIG:Release>:/MT>
- )
- else()
- add_compile_options(
- $<$<CONFIG:>:/MD>
- $<$<CONFIG:Debug>:/MDd>
- $<$<CONFIG:Release>:/MD>
- )
- endif()
ENDIF()
ENDIF()

View File

@@ -0,0 +1,22 @@
diff --git a/code/Common/DefaultIOStream.cpp b/code/Common/DefaultIOStream.cpp
index e30f26acd3..17fc44f9a2 100644
--- a/code/Common/DefaultIOStream.cpp
+++ b/code/Common/DefaultIOStream.cpp
@@ -63,7 +63,7 @@ inline int select_fseek(FILE *file, int64_t offset, int origin) {
-#if defined _WIN64 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
+#if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
template <>
inline size_t select_ftell<8>(FILE *file) {
return (size_t)::_ftelli64(file);
@@ -149,7 +149,7 @@ size_t DefaultIOStream::FileSize() const {
//
// See here for details:
// https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file
-#if defined _WIN64 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
+#if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
struct __stat64 fileStat;
//using fileno + fstat avoids having to handle the filename
int err = _fstat64(_fileno(mFile), &fileStat);

View File

@@ -0,0 +1,120 @@
package("assimp")
set_homepage("https://assimp.org")
set_description("Portable Open-Source library to import various well-known 3D model formats in a uniform manner")
set_license("BSD-3-Clause")
set_urls("https://github.com/assimp/assimp/archive/$(version).zip",
"https://github.com/assimp/assimp.git")
add_versions("v5.2.5", "5384877d53be7b5bbf50c26ab3f054bec91b3df8614372dcd7240f44f61c509b")
add_versions("v5.2.4", "713e9aa035ae019e5f3f0de1605de308d63538897249a2ba3a2d7d40036ad2b1")
add_versions("v5.2.3", "9667cfc8ddabd5dd5e83f3aebb99dbf232fce99f17b9fe59540dccbb5e347393")
add_versions("v5.2.2", "7b833182b89917b3c6e8aee6432b74870fb71f432cc34aec5f5411bd6b56c1b5")
add_versions("v5.2.1", "636fe5c2cfe925b559b5d89e53a42412a2d2ab49a0712b7d655d1b84c51ed504")
add_versions("v5.1.4", "59a00cf72fa5ceff960460677e2b37be5cd1041e85bae9c02828c27ade7e4160")
add_versions("v5.0.1", "d10542c95e3e05dece4d97bb273eba2dfeeedb37a78fb3417fd4d5e94d879192")
add_patches("v5.0.1", path.join(os.scriptdir(), "patches", "5.0.1", "fix-mingw.patch"), "a3375489e2bbb2dd97f59be7dd84e005e7e9c628b4395d7022a6187ca66b5abb")
add_patches("v5.2.1", path.join(os.scriptdir(), "patches", "5.2.1", "fix_zlib_filefunc_def.patch"), "a9f8a9aa1975888ea751b80c8268296dee901288011eeb1addf518eac40b71b1")
add_patches("v5.2.2", path.join(os.scriptdir(), "patches", "5.2.1", "fix_zlib_filefunc_def.patch"), "a9f8a9aa1975888ea751b80c8268296dee901288011eeb1addf518eac40b71b1")
add_patches("v5.2.3", path.join(os.scriptdir(), "patches", "5.2.1", "fix_zlib_filefunc_def.patch"), "a9f8a9aa1975888ea751b80c8268296dee901288011eeb1addf518eac40b71b1")
add_patches("v5.2.3", path.join(os.scriptdir(), "patches", "5.2.3", "cmake_static_crt.patch"), "3872a69976055bed9e40814e89a24a3420692885b50e9f9438036e8d809aafb4")
add_patches("v5.2.4", path.join(os.scriptdir(), "patches", "5.2.4", "fix_x86_windows_build.patch"), "becb4039c220678cf1e888e3479f8e68d1964c49d58f14c5d247c86b4a5c3293")
if not is_host("windows") then
add_extsources("pkgconfig::assimp")
end
if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::assimp")
elseif is_plat("linux") then
add_extsources("pacman::assimp", "apt::libassimp-dev")
elseif is_plat("macosx") then
add_extsources("brew::assimp")
end
add_configs("build_tools", {description = "Build the supplementary tools for Assimp.", default = false, type = "boolean"})
add_configs("double_precision", {description = "Enable double precision processing.", default = false, type = "boolean"})
add_configs("no_export", {description = "Disable Assimp's export functionality (reduces library size).", default = false, type = "boolean"})
add_configs("android_jniiosysystem", {description = "Enable Android JNI IOSystem support.", default = false, type = "boolean"})
add_configs("asan", {description = "Enable AddressSanitizer.", default = false, type = "boolean"})
add_configs("ubsan", {description = "Enable Undefined Behavior sanitizer.", default = false, type = "boolean"})
add_deps("cmake", "zlib")
if is_plat("windows") then
add_syslinks("advapi32")
end
on_load(function (package)
if not package:gitref() and package:version():le("5.1.0") then
package:add("deps", "irrxml")
end
if package:is_plat("linux", "macosx") and package:config("shared") then
package:add("links", "assimp")
end
end)
on_install("windows", "linux", "macosx", "mingw", "wasm", function (package)
local configs = {"-DASSIMP_BUILD_SAMPLES=OFF",
"-DASSIMP_BUILD_TESTS=OFF",
"-DASSIMP_BUILD_DOCS=OFF",
"-DASSIMP_BUILD_FRAMEWORK=OFF",
"-DASSIMP_INSTALL_PDB=ON",
"-DASSIMP_INJECT_DEBUG_POSTFIX=ON",
"-DASSIMP_BUILD_ZLIB=ON",
"-DSYSTEM_IRRXML=ON",
"-DASSIMP_WARNINGS_AS_ERRORS=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
local function add_config_arg(config_name, cmake_name)
table.insert(configs, "-D" .. cmake_name .. "=" .. (package:config(config_name) and "ON" or "OFF"))
end
add_config_arg("shared", "BUILD_SHARED_LIBS")
add_config_arg("double_precision", "ASSIMP_DOUBLE_PRECISION")
add_config_arg("no_export", "ASSIMP_NO_EXPORT")
add_config_arg("asan", "ASSIMP_ASAN")
add_config_arg("ubsan", "ASSIMP_UBSAN")
if package:is_plat("android") then
add_config_arg("android_jniiosysystem", "ASSIMP_ANDROID_JNIIOSYSTEM")
end
if package:is_plat("windows", "linux", "macosx", "mingw") then
add_config_arg("build_tools", "ASSIMP_BUILD_ASSIMP_TOOLS")
else
table.insert(configs, "-DASSIMP_BUILD_ASSIMP_TOOLS=OFF")
end
if not package:gitref() and package:version():lt("v5.2.4") then
-- ASSIMP_WARNINGS_AS_ERRORS is not supported before v5.2.4
if package:is_plat("windows") then
io.replace("code/CMakeLists.txt", "TARGET_COMPILE_OPTIONS(assimp PRIVATE /W4 /WX)", "", {plain = true})
else
io.replace("code/CMakeLists.txt", "TARGET_COMPILE_OPTIONS(assimp PRIVATE -Werror)", "", {plain = true})
end
end
if package:is_plat("mingw") and package:version():lt("v5.1.5") then
-- CMAKE_COMPILER_IS_MINGW has been removed: https://github.com/assimp/assimp/pull/4311
io.replace("CMakeLists.txt", "CMAKE_COMPILER_IS_MINGW", "MINGW", {plain = true})
end
import("package.tools.cmake").install(package, configs)
-- copy pdb
if package:is_plat("windows") then
if package:config("shared") then
os.trycp(path.join(package:buildir(), "bin", "**.pdb"), package:installdir("bin"))
else
os.trycp(path.join(package:buildir(), "lib", "**.pdb"), package:installdir("lib"))
end
end
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <cassert>
void test() {
Assimp::Importer importer;
}
]]}, {configs = {languages = "c++11"}, includes = "assimp/Importer.hpp"}))
end)