From c4f049ce18ef1cc515cc0d07bd6b92f5115a03bb Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Fri, 26 Nov 2021 07:19:10 +0800 Subject: [PATCH] add opensubdiv (#712) * update ptex * add opensubdiv --- packages/o/opensubdiv/xmake.lua | 69 +++++++++++++++++++++++++++++++++ packages/p/ptex/xmake.lua | 1 + 2 files changed, 70 insertions(+) create mode 100644 packages/o/opensubdiv/xmake.lua diff --git a/packages/o/opensubdiv/xmake.lua b/packages/o/opensubdiv/xmake.lua new file mode 100644 index 000000000..eedd394e9 --- /dev/null +++ b/packages/o/opensubdiv/xmake.lua @@ -0,0 +1,69 @@ +package("opensubdiv") + + set_homepage("https://graphics.pixar.com/opensubdiv/docs/intro.html") + set_description("OpenSubdiv is a set of open source libraries that implement high performance subdivision surface (subdiv) evaluation on massively parallel CPU and GPU architectures.") + set_license("Apache-2.0") + + add_urls("https://github.com/PixarAnimationStudios/OpenSubdiv/archive/refs/tags/v$(version).tar.gz", {version = function (version) return version:gsub("%.", "_") end}) + add_versions("3.4.4", "20d49f80a2b778ad4d01f091ad88d8c2f91cf6c7363940c6213241ce6f1048fb") + + if is_plat("windows") then + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + end + + add_configs("glfw", {description = "Enable components depending on GLFW.", default = true, type = "boolean"}) + add_configs("ptex", {description = "Enable components depending on Ptex.", default = true, type = "boolean"}) + add_configs("tbb", {description = "Enable components depending on TBB.", default = false, type = "boolean"}) + add_configs("opencl", {description = "Enable OpenCL backend.", default = false, type = "boolean"}) + add_configs("cuda", {description = "Enable CUDA backend.", default = false, type = "boolean"}) + + add_deps("cmake") + if is_plat("windows") then + add_defines("NOMINMAX") + end + on_load("windows", "macosx", "linux", function (package) + for _, dep in ipairs({"glfw", "ptex", "tbb"}) do + if package:config(dep) then + package:add("deps", dep) + end + end + for _, dep in ipairs({"opencl", "cuda"}) do + if package:config(dep) then + package:add("deps", dep, {system = true}) + end + end + end) + + on_install("windows", "macosx", "linux", function (package) + local configs = {"-DNO_EXAMPLES=ON", "-DNO_TUTORIALS=ON", "-DNO_REGRESSION=ON", "-DNO_DOC=ON", "-DNO_CLEW=ON", "-DNO_TESTS=ON", "-DNO_GLTESTS=ON"} + 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")) + for _, dep in ipairs({"glfw", "ptex", "tbb", "opencl", "cuda"}) do + table.insert(configs, "-DNO_" .. dep:upper() .. "=" .. (package:config(dep) and "ON" or "OFF")) + end + if package:is_plat("windows") then + local vs_sdkver = import("core.tool.toolchain").load("msvc"):config("vs_sdkver") + if vs_sdkver then + local build_ver = string.match(vs_sdkver, "%d+%.%d+%.(%d+)%.?%d*") + assert(tonumber(build_ver) >= 18362, "OpenSubDiv requires Windows SDK to be at least 10.0.18362.0") + table.insert(configs, "-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=" .. vs_sdkver) + table.insert(configs, "-DCMAKE_SYSTEM_VERSION=" .. vs_sdkver) + end + table.insert(configs, "-DMSVC_STATIC_CRT=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF")) + end + import("package.tools.cmake").install(package, configs) + if package:config("shared") then + os.tryrm(path.join(package:installdir("lib"), "lib*.a")) + end + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + void test() { + OpenSubdiv::Osd::MeshBitset bits; + bits.set(OpenSubdiv::Osd::MeshAdaptive, true); + bits.set(OpenSubdiv::Osd::MeshUseSingleCreasePatch, true); + } + ]]}, {configs = {languages = "c++14"}})) + end) diff --git a/packages/p/ptex/xmake.lua b/packages/p/ptex/xmake.lua index 3494378f9..5348b2c48 100644 --- a/packages/p/ptex/xmake.lua +++ b/packages/p/ptex/xmake.lua @@ -7,6 +7,7 @@ package("ptex") add_urls("https://github.com/wdas/ptex/archive/$(version).tar.gz", "https://github.com/wdas/ptex.git") add_versions("v2.3.2", "30aeb85b965ca542a8945b75285cd67d8e207d23dbb57fcfeaab587bb443402b") + add_versions("v2.4.1", "664253b84121251fee2961977fe7cf336b71cd846dc235cd0f4e54a0c566084e") add_deps("zlib") if is_plat("linux") then