From 33ad64b2091ef9f3929d0e24ca2c0ecdacba0d67 Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Tue, 15 Mar 2022 22:29:42 +0800 Subject: [PATCH] add mpdecimal (#1061) * add mpdecimal * update libcurl * update filament * fix language version --- packages/f/filament/xmake.lua | 45 +++++++++++++++------------- packages/l/libcurl/versions.lua | 1 + packages/m/mpdecimal/xmake.lua | 52 +++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 20 deletions(-) create mode 100644 packages/m/mpdecimal/xmake.lua diff --git a/packages/f/filament/xmake.lua b/packages/f/filament/xmake.lua index ccd17bd93..50577cc7a 100644 --- a/packages/f/filament/xmake.lua +++ b/packages/f/filament/xmake.lua @@ -4,33 +4,38 @@ package("filament") set_description("Filament is a real-time physically-based renderer written in C++.") set_license("Apache-2.0") - add_urls("https://github.com/google/filament/archive/refs/tags/$(version).tar.gz", - "https://github.com/google/filament.git") - add_versions("v1.9.23", "f353167208df8c2c6cf56175e863bd4d9e36d1655df7bcae36a85c107e009107") + if is_plat("windows") and is_arch("x64") then + add_urls("https://github.com/google/filament/releases/download/v$(version)/filament-v$(version)-windows.tgz") + add_versions("1.20.3", "0a3fdd5fe8662a02117f3de51dcbea3b260cff716a7cffa407ca939727d7b634") + elseif is_plat("macosx") and is_arch("x86_64") then + add_urls("https://github.com/google/filament/releases/download/v$(version)/filament-v$(version)-mac.tgz") + add_versions("1.20.3", "820f2c7b5360021b9ff361f0868b45613726d6704f9112e8c8cf92d07c7c95b7") + elseif is_plat("linux") and is_arch("x86_64") then + add_urls("https://github.com/google/filament/releases/download/v$(version)/filament-v$(version)-linux.tgz") + add_versions("1.20.3", "f57e1c967e09fe73ef69b0db8a48a09b3dab6f9ecb21b906b3f1fbe1d3a2ce3d") + end - add_configs("ninja", {description = "Use ninja to build the library.", default = false, type = "boolean"}) + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) - add_deps("cmake") - on_load("windows|x64", function (package) - if package:config("ninja") then - package:add("deps", "ninja") - end - end) + if is_plat("windows") then + add_syslinks("user32", "gdi32", "opengl32") + elseif is_plat("macosx") then + add_frameworks("Cocoa", "Metal", "CoreVideo") + elseif is_plat("linux") then + add_syslinks("pthread", "dl") + end + add_links("backend", "bluegl", "bluevk", "filabridge", "filaflat", "utils", "geometry", "smol-v", "vkshaders", "ibl") - on_install("windows|x64", function (package) - local configs = {"-DFILAMENT_ENABLE_JAVA=OFF", "-DFILAMENT_SKIP_SAMPLES=ON"} - table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) + on_install("windows|x64", "macosx|x86_64", "linux|x86_64", function (package) + os.cp("*", package:installdir()) if package:is_plat("windows") then - table.insert(configs, "-DUSE_STATIC_CRT=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF")) - end - local opt = {buildir = os.tmpdir()} - if package:config("ninja") then - opt.cmake_generator = "Ninja" + package:add("linkdirs", path.join("lib", "x86_64", package:config("vs_runtime"):lower())) + else + package:add("linkdirs", path.join("lib", "x86_64")) end - import("package.tools.cmake").install(package, configs, opt) package:addenv("PATH", "bin") end) on_test(function (package) - assert(package:has_cxxtypes("filament::Engine", {configs = {languages = "c++11"}, includes = "filament/Engine.h"})) + assert(package:has_cxxtypes("filament::Engine", {configs = {languages = "c++17"}, includes = "filament/Engine.h"})) end) diff --git a/packages/l/libcurl/versions.lua b/packages/l/libcurl/versions.lua index 42b5bfba6..ea1906e9a 100644 --- a/packages/l/libcurl/versions.lua +++ b/packages/l/libcurl/versions.lua @@ -1,4 +1,5 @@ function add_versions_list() + add_versions("7.82.0", "46d9a0400a33408fd992770b04a44a7434b3036f2e8089ac28b57573d59d371f") add_versions("7.81.0", "1e7a38d7018ec060f1f16df839854f0889e94e122c4cfa5d3a37c2dc56f1e258") add_versions("7.80.0", "dd0d150e49cd950aff35e16b628edf04927f0289df42883750cf952bb858189c") add_versions("7.78.0", "98530b317dc95ccb324bbe4f834f07bb642fbc393b794ddf3434f246a71ea44a") diff --git a/packages/m/mpdecimal/xmake.lua b/packages/m/mpdecimal/xmake.lua new file mode 100644 index 000000000..8df07c2a5 --- /dev/null +++ b/packages/m/mpdecimal/xmake.lua @@ -0,0 +1,52 @@ +package("mpdecimal") + + set_homepage("https://www.bytereef.org/mpdecimal/index.html") + set_description("mpdecimal is a package for correctly-rounded arbitrary precision decimal floating point arithmetic.") + set_license("BSD-2-Clause") + + add_urls("https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-$(version).tar.gz") + add_versions("2.5.1", "9f9cd4c041f99b5c49ffb7b59d9f12d95b683d88585608aa56a6307667b2b21f") + + on_install("windows", function (package) + for _, header in ipairs({"libmpdec/mpdecimal32vc.h", "libmpdec/mpdecimal64vc.h", "libmpdec++/decimal.hh"}) do + io.replace(header, "if defined(_DLL)", "if defined(MPDEC_DLL)", {plain = true}) + end + local configs = {} + table.insert(configs, "DEBUG=" .. (package:debug() and "1" or "0")) + table.insert(configs, "MACHINE=" .. (package:is_arch("x64") and "x64" or "ppro")) + for _, library in ipairs({"libmpdec", "libmpdec++"}) do + local oldir = os.cd(library) + os.mv("Makefile.vc", "Makefile") + io.replace("Makefile", "/MD", "/MD /DMPDEC_DLL", {plain = true}) + if package:config("vs_runtime"):startswith("MT") then + io.replace("Makefile", "/MD", "/MT", {plain = true}) + else + io.replace("Makefile", "/MT", "/MD", {plain = true}) + end + import("package.tools.nmake").build(package, configs) + if package:config("shared") then + os.cp("*.dll", package:installdir("bin")) + os.cp("*.dll.lib", package:installdir("lib")) + else + os.cp("*.lib|*.dll.lib", package:installdir("lib")) + end + os.cd(oldir) + end + io.replace("libmpdec/mpdecimal.h", "defined(MPDEC_DLL)", (package:config("shared") and "1" or "0"), {plain = true}) + os.cp("libmpdec/mpdecimal.h", package:installdir("include")) + io.replace("libmpdec++/decimal.hh", "defined(MPDEC_DLL)", (package:config("shared") and "1" or "0"), {plain = true}) + os.cp("libmpdec++/decimal.hh", package:installdir("include")) + end) + + on_install("macosx", "linux", function (package) + local configs = {} + table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no")) + import("package.tools.autoconf").install(package, configs) + if package:config("shared") then + os.rm(path.join(package:installdir("lib"), "*.a")) + end + end) + + on_test(function (package) + assert(package:has_cfuncs("mpd_version", {includes = "mpdecimal.h"})) + end)