From 90e0654c7b078c48497ae2617fcba953459678ba Mon Sep 17 00:00:00 2001 From: star9029 Date: Fri, 23 Aug 2024 08:42:05 +0800 Subject: [PATCH] libsquish: remove limit plat (#5014) * libsquish: remove limit plat * port xmake * Update xmake.lua --- packages/l/libsquish/port/xmake.lua | 26 ++++++++++++++++++++++++ packages/l/libsquish/xmake.lua | 31 ++++++++++++++++++----------- 2 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 packages/l/libsquish/port/xmake.lua diff --git a/packages/l/libsquish/port/xmake.lua b/packages/l/libsquish/port/xmake.lua new file mode 100644 index 000000000..40a6513dc --- /dev/null +++ b/packages/l/libsquish/port/xmake.lua @@ -0,0 +1,26 @@ +option("sse2", {default = false}) +option("openmp", {default = false}) + +if has_config("openmp") then + add_requires("openmp") + add_packages("openmp") + add_defines("SQUISH_USE_OPENMP") +end + +if has_config("sse2") then + add_vectorexts("sse2") + add_defines("SQUISH_USE_SSE=2") +end + +add_rules("mode.debug", "mode.release") + +set_languages("c++11") + +target("squish") + set_kind("$(kind)") + add_files("*.cpp") + add_headerfiles("squish.h") + + if is_plat("windows") and is_kind("shared") then + add_rules("utils.symbols.export_all", {export_classes = true}) + end diff --git a/packages/l/libsquish/xmake.lua b/packages/l/libsquish/xmake.lua index bb10e433f..c7c153834 100644 --- a/packages/l/libsquish/xmake.lua +++ b/packages/l/libsquish/xmake.lua @@ -1,5 +1,4 @@ package("libsquish") - set_homepage("https://sourceforge.net/projects/libsquish/") set_description("The libSquish library compresses images with the DXT standard (also known as S3TC).") set_license("MIT") @@ -7,18 +6,26 @@ package("libsquish") add_urls("https://sourceforge.net/projects/libsquish/files/libsquish-$(version).tgz") add_versions("1.15", "628796eeba608866183a61d080d46967c9dda6723bc0a3ec52324c85d2147269") - add_configs("openmp", {description = "Enable OpenMP build.", default = false, type = "boolean"}) - if is_plat("windows") then - add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) - end + add_configs("openmp", {description = "Build with OpenMP.", default = false, type = "boolean"}) + add_configs("sse2", {description = "Build with SSE2.", default = false, type = "boolean"}) + + on_load(function (package) + if package:config("openmp") then + package:add("deps", "openmp") + package:add("defines", "SQUISH_USE_OPENMP") + end + + if package:config("sse2") then + package:add("defines", "SQUISH_USE_SSE=2") + end + end) - add_deps("cmake") - on_install("windows", "macosx", "linux", 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")) - table.insert(configs, "-DBUILD_SQUISH_WITH_OPENMP=" .. (package:config("openmp") and "ON" or "OFF")) - import("package.tools.cmake").install(package, configs) + on_install(function (package) + os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua") + import("package.tools.xmake").install(package, { + openmp = package:config("openmp"), + sse2 = package:config("sse2") + }) end) on_test(function (package)