From 353ee495e68c1537d04f09bdd1c079c070919aef Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Sun, 24 Oct 2021 22:23:31 +0800 Subject: [PATCH] update libtorch (#669) * update libtorch * update harfbuzz * fix matplot++ --- packages/f/faad2/xmake.lua | 2 +- packages/f/field3d/xmake.lua | 3 ++- packages/h/harfbuzz/xmake.lua | 37 +++++++++++++++++++--------- packages/l/libtorch/xmake.lua | 21 ++++++++++++---- packages/m/matplotplusplus/xmake.lua | 5 +++- packages/m/meson/xmake.lua | 1 + 6 files changed, 50 insertions(+), 19 deletions(-) diff --git a/packages/f/faad2/xmake.lua b/packages/f/faad2/xmake.lua index b994a97f3..40996ad4e 100644 --- a/packages/f/faad2/xmake.lua +++ b/packages/f/faad2/xmake.lua @@ -14,7 +14,7 @@ package("faad2") end on_install("windows", function (package) - if is_plat("windows") then + if package:is_plat("windows") then local vs = import("core.tool.toolchain").load("msvc"):config("vs") if tonumber(vs) < 2019 then raise("Your compiler is too old to use this library.") diff --git a/packages/f/field3d/xmake.lua b/packages/f/field3d/xmake.lua index 9bbf3e70e..ebc9807d6 100644 --- a/packages/f/field3d/xmake.lua +++ b/packages/f/field3d/xmake.lua @@ -13,6 +13,7 @@ package("field3d") add_deps("hdf5", "openexr 2.x") if is_plat("windows") then + add_defines("WIN32") add_syslinks("shlwapi") end @@ -23,7 +24,7 @@ package("field3d") end) on_install("windows", "macosx", "linux", function (package) - if is_plat("windows") then + if package:is_plat("windows") then local vs = import("core.tool.toolchain").load("msvc"):config("vs") if tonumber(vs) < 2019 then raise("Your compiler is too old to use this library.") diff --git a/packages/h/harfbuzz/xmake.lua b/packages/h/harfbuzz/xmake.lua index 674f58b54..dff7f7541 100644 --- a/packages/h/harfbuzz/xmake.lua +++ b/packages/h/harfbuzz/xmake.lua @@ -8,31 +8,46 @@ package("harfbuzz") "https://github.com/harfbuzz/harfbuzz.git") add_versions("2.8.1", "b3f17394c5bccee456172b2b30ddec0bb87e9c5df38b4559a973d14ccd04509d") add_versions("2.9.0", "bf5d5bad69ee44ff1dd08800c58cb433e9b3bf4dad5d7c6f1dec5d1cf0249d04") + add_versions("3.0.0", "55f7e36671b8c5569b6438f80efed2fd663298f785ad2819e115b35b5587ef69") - add_configs("icu", {description = "Use the ICU library.", default = false, type = "boolean"}) + add_configs("icu", {description = "Enable ICU library unicode functions.", default = false, type = "boolean"}) + add_configs("freetype", {description = "Enable freetype interop helpers.", default = true, type = "boolean"}) add_deps("meson") - if not is_plat("windows") then - add_deps("freetype") - end + add_includedirs("include", "include/harfbuzz") on_load("windows", "linux", "macosx", function (package) if package:config("icu") then package:add("deps", "icu4c") end + if package:config("freetype") then + package:add("deps", "freetype") + end end) on_install("windows", "linux", "macosx", function (package) - local configs = {"-Dtests=disabled", "-Ddocs=disabled", "-Dbenchmark=disabled", "-Dcairo=disabled", "-Dfontconfig=disabled", "-Dglib=disabled", "-Dgobject=disabled"} + import("package.tools.meson") + + local configs = {"-Dtests=disabled", "-Ddocs=disabled", "-Dbenchmark=disabled", "-Dcairo=disabled", "-Dglib=disabled", "-Dgobject=disabled"} table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static")) - if package:config("icu") then - table.insert(configs, "-Dicu=enabled") - end + table.insert(configs, "-Dicu=" .. (package:config("icu") and "enabled" or "disabled")) + table.insert(configs, "-Dfreetype=" .. (package:config("freetype") and "enabled" or "disabled")) + local envs = meson.buildenvs(package) if package:is_plat("windows") then - table.insert(configs, "-Dfreetype=disabled") + for _, dep in ipairs(package:orderdeps()) do + local fetchinfo = dep:fetch() + if fetchinfo then + for _, includedir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do + envs.INCLUDE = (envs.INCLUDE or "") .. path.envsep() .. includedir + end + for _, linkdir in ipairs(fetchinfo.linkdirs) do + envs.LIB = (envs.LIB or "") .. path.envsep() .. linkdir + end + end + end end - import("package.tools.meson").install(package, configs) + meson.install(package, configs, {envs = envs}) end) on_test(function (package) - assert(package:has_cfuncs("hb_buffer_add_utf8", {includes = "harfbuzz/hb.h"})) + assert(package:has_cfuncs("hb_buffer_add_utf8", {includes = "hb.h"})) end) diff --git a/packages/l/libtorch/xmake.lua b/packages/l/libtorch/xmake.lua index 8abede1f2..446e2aac1 100644 --- a/packages/l/libtorch/xmake.lua +++ b/packages/l/libtorch/xmake.lua @@ -7,9 +7,11 @@ package("libtorch") add_urls("https://github.com/pytorch/pytorch.git") add_versions("v1.8.0", "37c1f4a7fef115d719104e871d0cf39434aa9d56") add_versions("v1.8.1", "56b43f4fec1f76953f15a627694d4bba34588969") + add_versions("v1.8.2", "e0495a7aa104471d95dc85a1b8f6473fbcc427a8") add_versions("v1.9.0", "d69c22dd61a2f006dcfe1e3ea8468a3ecaf931aa") + add_versions("v1.9.1", "dfbd030854359207cb3040b864614affeace11ce") - add_patches("v1.9.0", path.join(os.scriptdir(), "patches", "1.9.0", "gcc11.patch"), "4191bb3296f18f040c230d7c5364fb160871962d6278e4ae0f8bc481f27d8e4b") + add_patches("1.9.x", path.join(os.scriptdir(), "patches", "1.9.0", "gcc11.patch"), "4191bb3296f18f040c230d7c5364fb160871962d6278e4ae0f8bc481f27d8e4b") add_configs("python", {description = "Build python interface.", default = false, type = "boolean"}) add_configs("ninja", {description = "Use ninja as build tool.", default = true, type = "boolean"}) @@ -46,6 +48,13 @@ package("libtorch") on_install("windows|x64", "macosx", "linux", function (package) import("package.tools.cmake") + if package:is_plat("windows") then + local vs = import("core.tool.toolchain").load("msvc"):config("vs") + if tonumber(vs) < 2019 then + raise("Your compiler is too old to use this library.") + end + end + -- tackle link flags local has_cuda = package:dep("cuda"):exists() and package:dep("nvtx"):exists() local libnames = {"torch", "torch_cpu"} @@ -72,10 +81,12 @@ package("libtorch") package:add("links", lib) end end - package:add("links", "fbgemm") - package:add("links", "asmjit") - package:add("links", "cpuinfo") - package:add("links", "clog") + if not package:config("shared") then + for _, lib in ipairs({"nnpack", "pytorch_qnnpack", "qnnpack", "XNNPACK", "caffe2_protos", "protobuf-lite", "protobuf", "protoc", "onnx", "onnx_proto", "foxi_loader", "pthreadpool", "eigen_blas", "fbgemm", "cpuinfo", "clog", "dnnl", "mkldnn", "sleef", "asmjit", "fmt"}) do + package:add("links", lib) + end + end + package:add("links", "kineto") -- some patches to the third-party cmake files io.replace("third_party/fbgemm/CMakeLists.txt", "PRIVATE FBGEMM_STATIC", "PUBLIC FBGEMM_STATIC", {plain = true}) diff --git a/packages/m/matplotplusplus/xmake.lua b/packages/m/matplotplusplus/xmake.lua index 14d264808..a6a36b2c4 100644 --- a/packages/m/matplotplusplus/xmake.lua +++ b/packages/m/matplotplusplus/xmake.lua @@ -18,6 +18,9 @@ package("matplotplusplus") for config, dep in pairs(configdeps) do add_configs(config, {description = "Enable " .. config .. " support.", default = (config == "zlib"), type = "boolean"}) end + if is_plat("windows") then + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + end add_deps("cmake") add_deps("nodesoup") @@ -33,7 +36,7 @@ package("matplotplusplus") end) on_install("windows", "macosx", "linux", function (package) - if is_plat("windows") then + if package:is_plat("windows") then local vs = import("core.tool.toolchain").load("msvc"):config("vs") if tonumber(vs) < 2019 then raise("Your compiler is too old to use this library.") diff --git a/packages/m/meson/xmake.lua b/packages/m/meson/xmake.lua index 832d89d26..0989274cd 100644 --- a/packages/m/meson/xmake.lua +++ b/packages/m/meson/xmake.lua @@ -7,6 +7,7 @@ package("meson") add_urls("https://github.com/mesonbuild/meson/releases/download/$(version)/meson-$(version).tar.gz", "https://github.com/mesonbuild/meson.git") + add_versions("0.59.2", "13dee549a7ba758b7e33ce7719f28d1d337a98d10d378a4779ccc996f5a2fc49") add_versions("0.59.1", "db586a451650d46bbe10984a87b79d9bcdc1caebf38d8e189f8848f8d502356d") add_versions("0.58.1", "3144a3da662fcf79f1e5602fa929f2821cba4eba28c2c923fe0a7d3e3db04d5d") add_versions("0.58.0", "f4820df0bc969c99019fd4af8ca5f136ee94c63d8a5ad67e7eb73bdbc9182fdd")