Add MinGW support for assimp and freetype (#591)

* Add MinGW support for assimp and freetype

* Improve assimp package

* Improve freetype

* Rework assimp

* Add version 2.11.0 to freetype

* Rework freetype

* Remove build_framework option from assimp

* Assimp: Disable android option (android not yet supported)

* Freetype: Disable automatic fetch even when option is not enabled

* assimp: remove android option

* freetype: remove unused loop and fix code

* Assimp: Add extsources

* Fix freetype

* Final fix!
pull/594/head
Jérôme Leclercq 3 years ago committed by GitHub
parent 7753c8b6b3
commit 94d2eee1f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 56
      packages/a/assimp/patches/5.0.1/fix-mingw.patch
  2. 134
      packages/a/assimp/xmake.lua
  3. 100
      packages/f/freetype/xmake.lua

@ -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

@ -3,96 +3,96 @@ 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_urls("https://github.com/assimp/assimp/archive/v$(version).zip")
add_versions("5.0.1", "d10542c95e3e05dece4d97bb273eba2dfeeedb37a78fb3417fd4d5e94d879192")
set_urls("https://github.com/assimp/assimp/archive/$(version).zip",
"https://github.com/assimp/assimp.git")
add_versions("v5.0.1", "d10542c95e3e05dece4d97bb273eba2dfeeedb37a78fb3417fd4d5e94d879192")
add_patches("v5.0.1", path.join(os.scriptdir(), "patches", "5.0.1", "fix-mingw.patch"), "a3375489e2bbb2dd97f59be7dd84e005e7e9c628b4395d7022a6187ca66b5abb")
if not is_host("windows") then
add_extsources("pkgconfig::assimp")
end
if is_host("linux") then
add_extsources("apt::libassimp-dev")
elseif is_host("macosx") then
add_extsources("brew::assimp")
end
add_configs("shared", {description = "Generation of shared libs ( dll for windows, so for Linux ). Set this to OFF to get a static lib", default = true, type = "boolean"})
add_configs("build_framework", {description = "Build package as Mac OS X Framework bundle (macosx only)", default = false, type = "boolean"})
add_configs("double_precision", {description = "All data will be stored as double values", default = false, type = "boolean"})
add_configs("opt_build_packages", {description = "Set to true to generate CPack configuration files and packaging targets", default = false, type = "boolean"})
add_configs("android_jniiosystem", {description = "Android JNI IOSystem support is active", default = false, type = "boolean"})
add_configs("no_export", {description = "Disable Assimp's export functionality", default = false, type = "boolean"})
add_configs("build_zlib", {description = "Build your own zlib", default = false, type = "boolean"})
add_configs("build_assimp_tools", {description = "If the supplementary tools for Assimp are built in addition to the library", default = false, type = "boolean"})
add_configs("build_samples", {description = "If the official samples are built as well (needs freeglut)", default = false, type = "boolean"})
add_configs("build_tests", {description = "If the test suite for Assimp is built in addition to the library", default = true, type = "boolean"})
add_configs("coveralls", {description = "Enable this to measure test coverage", default = false, type = "boolean"})
add_configs("werror", {description = "Treat warnings as errors", default = false, type = "boolean"})
add_configs("asan", {description = "Enable AddressSanitizer", default = false, type = "boolean"})
add_configs("build_tools", {description = "If the supplementary tools for Assimp are built in addition to the library", default = false, type = "boolean"})
add_configs("double_precision", {description = "All data will be stored as double values", default = false, type = "boolean"})
add_configs("no_export", {description = "Disable Assimp's export functionality (reduces library size)", default = false, type = "boolean"})
add_configs("ubsan", {description = "Enable Undefined Behavior sanitizer", default = false, type = "boolean"})
add_configs("system_irrxml", {description = "Use system installed Irrlicht/IrrXML library", default = false, type = "boolean"})
add_configs("build_docs", {description = "Build documentation using Doxygen", default = false, type = "boolean"})
add_configs("inject_debug_postfix", {description = "Inject debug postfix in .a/.so lib names", default = false, type = "boolean"})
add_configs("ignore_git_hash", {description = "Don't call git to get the hash", default = false, type = "boolean"})
add_configs("install_pdb", {description = "Install MSVC debug files", default = false, type = "boolean"})
add_configs("with_pdb", {description = "Install MSVC debug files", default = false, type = "boolean"})
add_deps("cmake")
add_deps("cmake", "irrxml", "zlib")
on_load(function (package)
if is_plat("windows", "linux", "macosx") then
if package:config("build_samples") then
package:add("deps", "freeglut")
end
end
if not package:config("build_zlib") then
package:add("deps", "zlib")
end
if package:config("system_irrxml") then
package:add("deps", "irrxml")
end
if is_plat("linux") and package:config("shared") then
package:add("ldflags", "-Wl,--as-needed," .. package:installdir("lib", "libassimp.so"))
end
end)
on_install("windows", "linux", "macosx", function (package)
local config = {}
on_install("windows", "linux", "macosx", "mingw", function (package)
local configs = {}
table.insert(configs, "-DASSIMP_BUILD_SAMPLES=OFF")
table.insert(configs, "-DASSIMP_BUILD_TESTS=OFF")
table.insert(configs, "-DBUILD_DOCS=OFF")
table.insert(configs, "-DBUILD_FRAMEWORK=OFF")
table.insert(configs, "-DINJECT_DEBUG_POSTFIX=" .. ((package:debug()) and "ON" or "OFF"))
local function add_config_arg(config_name, cmake_name)
table.insert(config, "-D" .. cmake_name .. "=" .. (package:config(config_name) and "ON" or "OFF"))
local irrxml = package:dep("irrxml")
if irrxml then
table.insert(configs, "-DSYSTEM_IRRXML=ON")
if irrxml:is_system() then
io.replace("CMakeLists.txt", "FIND_PACKAGE( IrrXML REQUIRED )", "", {plain = true})
else
local fetchinfo = irrxml:fetch()
table.insert(configs, "-DIRRXML_INCLUDE_DIR=" .. table.concat(fetchinfo.includedirs or fetchinfo.sysincludedirs, ";"))
table.insert(configs, "-DIRRXML_LIBRARY=" .. table.concat(fetchinfo.libfiles, ";"))
end
else
table.insert(configs, "-DSYSTEM_IRRXML=OFF")
end
add_config_arg("shared", "BUILD_SHARED_LIBS")
add_config_arg("double_precision", "ASSIMP_DOUBLE_PRECISION")
add_config_arg("opt_build_packages", "ASSIMP_OPT_BUILD_PACKAGES")
add_config_arg("no_export", "ASSIMP_NO_EXPORT")
add_config_arg("build_zlib", "ASSIMP_BUILD_ZLIB")
add_config_arg("build_samples", "ASSIMP_BUILD_SAMPLES")
add_config_arg("build_tests", "ASSIMP_BUILD_TESTS")
add_config_arg("coveralls", "ASSIMP_COVERALLS")
add_config_arg("werror", "ASSIMP_WERROR")
add_config_arg("asan", "ASSIMP_ASAN")
add_config_arg("ubsan", "ASSIMP_UBSAN")
add_config_arg("system_irrxml", "SYSTEM_IRRXML")
add_config_arg("build_docs", "BUILD_DOCS")
add_config_arg("ignore_git_hash", "IGNORE_GIT_HASH")
if is_plat("macosx") then
add_config_arg("build_framework", "BUILD_FRAMEWORK")
local zlib = package:dep("zlib")
if zlib then
if not zlib:is_system() then
local fetchinfo = zlib:fetch()
io.replace("CMakeLists.txt", "FIND_PACKAGE(ZLIB)", "", {plain = true})
table.insert(configs, "-DZLIB_FOUND=TRUE")
table.insert(configs, "-DZLIB_INCLUDE_DIR=" .. table.concat(fetchinfo.includedirs or fetchinfo.sysincludedirs, ";"))
table.insert(configs, "-DZLIB_LIBRARIES=" .. table.concat(fetchinfo.libfiles, ";"))
end
else
table.insert(configs, "-DASSIMP_BUILD_ZLIB=ON")
end
if is_plat("windows") then
table.insert(config, "-DASSIMP_INSTALL_PDB=" .. ((package:debug() or package:config("install_pdb")) and "ON" or "OFF"))
local function add_config_arg(config_name, cmake_name)
table.insert(configs, "-D" .. cmake_name .. "=" .. (package:config(config_name) and "ON" or "OFF"))
end
if is_plat("linux", "macosx") then
table.insert(config, "-DINJECT_DEBUG_POSTFIX=" .. ((package:debug() or package:config("inject_debug_postfix")) and "ON" or "OFF"))
add_config_arg("asan", "ASSIMP_ASAN")
add_config_arg("double_precision", "ASSIMP_DOUBLE_PRECISION")
add_config_arg("no_export", "ASSIMP_NO_EXPORT")
add_config_arg("shared", "BUILD_SHARED_LIBS")
add_config_arg("ubsan", "ASSIMP_UBSAN")
if package:is_plat("windows") then
table.insert(configs, "-DASSIMP_INSTALL_PDB=" .. ((package:debug() or package:config("install_pdb")) and "ON" or "OFF"))
end
if is_plat("android") then
if package:is_plat("android") then
add_config_arg("android_jniiosysystem", "ASSIMP_ANDROID_JNIIOSYSTEM")
end
if is_plat("windows", "linux", "macosx") then
add_config_arg("build_assimp_tools", "ASSIMP_BUILD_ASSIMP_TOOLS")
end
if is_plat("android", "iphoneos") then
table.insert(config, "-DASSIMP_BUILD_ASSIMP_TOOLS=OFF")
end
if package:config("pic") ~= false then
table.insert(config, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
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
import("package.tools.cmake").install(package, config)
import("package.tools.cmake").install(package, configs)
end)
on_test(function (package)
assert(package:has_cxxtypes("Assimp::Importer", {configs = {languages = "c++11"}, includes = "assimp/Importer.hpp"}))
end)
end)

@ -3,50 +3,76 @@ package("freetype")
set_homepage("https://www.freetype.org")
set_description("A freely available software library to render fonts.")
if is_plat("windows") then
set_urls("https://github.com/ubawurinna/freetype-windows-binaries/archive/v$(version).tar.gz")
add_versions("2.9.1", "60f788b63f1243a30e01611694ed196ee5ad1b89d553527700e5359d57d33b82")
add_versions("2.10.4", "24d7d3ab605e9f9b338adf0c4200ab14f6601a8c41a98741b9d1ecb3e759869c")
else
set_urls("https://downloads.sourceforge.net/project/freetype/freetype2/$(version)/freetype-$(version).tar.gz",
"https://download.savannah.gnu.org/releases/freetype/freetype-$(version).tar.gz")
add_versions("2.9.1", "ec391504e55498adceb30baceebd147a6e963f636eb617424bcfc47a169898ce")
add_versions("2.10.4", "5eab795ebb23ac77001cfb68b7d4d50b5d6c7469247b0b01b2c953269f658dac")
end
set_urls("https://downloads.sourceforge.net/project/freetype/freetype2/$(version)/freetype-$(version).tar.gz",
"https://download.savannah.gnu.org/releases/freetype/freetype-$(version).tar.gz",
"https://gitlab.freedesktop.org/freetype/freetype.git")
add_versions("2.11.0", "a45c6b403413abd5706f3582f04c8339d26397c4304b78fa552f2215df64101f")
add_versions("2.10.4", "5eab795ebb23ac77001cfb68b7d4d50b5d6c7469247b0b01b2c953269f658dac")
add_versions("2.9.1", "ec391504e55498adceb30baceebd147a6e963f636eb617424bcfc47a169898ce")
local configdeps = {woff2 = "brotli",
bzip2 = "bzip2",
png = "libpng",
zlib = "zlib"}
if not is_host("windows") then
add_extsources("pkgconfig::freetype2")
end
if not is_plat("windows") then
for conf, dep in pairs(configdeps) do
add_configs(conf, {description = "Enable " .. conf .. " support.", default = false, type = "boolean"})
end
add_includedirs("include/freetype2")
if is_host("linux") then
add_extsources("apt::libfreetype6")
elseif is_host("macosx") then
add_extsources("brew::freetype")
end
if on_fetch then
on_fetch("linux", "macosx", function (package, opt)
if opt.system then
return find_package("pkgconfig::freetype2")
end
end)
add_configs("bzip2", {description = "Support bzip2 compressed fonts", default = false, type = "boolean"})
add_configs("png", {description = "Support PNG compressed OpenType embedded bitmaps", default = false, type = "boolean"})
add_configs("woff2", {description = "Use Brotli library to support decompressing WOFF2 fonts", default = false, type = "boolean"})
add_configs("zlib", {description = "Support reading gzip-compressed font files", default = false, type = "boolean"})
if is_plat("windows", "mingw") then
add_deps("cmake")
else
add_deps("pkg-config")
end
on_load("linux", "macosx", function (package)
package:add("deps", "pkg-config")
for conf, dep in pairs(configdeps) do
add_includedirs("include/freetype2")
on_load(function (package)
local function add_dep(conf, pkg)
if package:config(conf) then
package:add("deps", dep)
package:add("deps", pkg or conf)
end
end
add_dep("bzip2")
add_dep("png", "libpng")
add_dep("woff2", "brotli")
add_dep("zlib")
end)
on_install("windows", function (package)
os.cp("include", package:installdir())
os.cp(is_arch("x64") and "win64/*.lib" or "win32/*.lib", package:installdir("lib"))
os.cp(is_arch("x64") and "win64/*.dll" or "win32/*.dll", package:installdir("bin"))
on_install("windows", "mingw", function (package)
local configs = {}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
local function add_dep(dep, cmakeConf, cmakeDisableConf)
if package:config("dep") then
table.insert(configs, "-DFT_WITH_" .. cmakeConf .. "=ON")
else
table.insert(configs, "-DCMAKE_DISABLE_FIND_PACKAGE_" .. (cmakeDisableConf or cmakeConf) .. "=ON")
end
end
add_dep("bzip2", "BZIP2", "BZip2")
add_dep("png", "PNG")
add_dep("woff2", "BROTLI", "BrotliDec")
add_dep("zlib", "ZLIB")
-- brotli isn't found automatically
if package:config("woff2") then
local brotli = package:dep("brotli")
if brotli and not brotli:is_system() then
local fetchinfo = brotli:fetch()
table.insert(configs, "-DBROTLIDEC_INCLUDE_DIRS=" .. table.concat(fetchinfo.includedirs or fetchinfo.sysincludedirs, ";"))
table.insert(configs, "-DBROTLIDEC_LIBRARIES=" .. table.concat(fetchinfo.libfiles, ";"))
end
end
import("package.tools.cmake").install(package, configs)
end)
on_install("linux", "macosx", function (package)
@ -55,9 +81,13 @@ package("freetype")
"--without-harfbuzz"}
table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
for conf, dep in pairs(configdeps) do
table.insert(configs, "--with-" .. conf .. "=" .. (package:config(conf) and "yes" or "no"))
local function add_dep(conf, name)
table.insert(configs, "--with-" .. (name or conf) .. "=" .. (package:config(conf) and "yes" or "no"))
end
add_dep("bzip2")
add_dep("png")
add_dep("woff2", "brotli")
add_dep("zlib")
if package:config("pic") ~= false then
table.insert(configs, "--with-pic")
end

Loading…
Cancel
Save