Ver Fonte

usd: support more configs (#7582)

star9029 há 1 mês atrás
pai
commit
c3281e7ae7
1 ficheiros alterados com 58 adições e 12 exclusões
  1. 58 12
      packages/u/usd/xmake.lua

+ 58 - 12
packages/u/usd/xmake.lua

@@ -14,43 +14,89 @@ package("usd")
     add_versions("v23.02", "a8eefff722db0964ce5b11b90bcdc957f3569f1cf1d44c46026ecd229ce7535d")
     add_versions("v22.11", "f34826475bb9385a9e94e2fe272cc713f517b987cbea15ee6bbc6b21db19aaae")
 
+    if is_plat("windows") then
+        add_configs("debug", {description = "Enable debug symbols.", default = false, type = "boolean", readonly = true})
+    end
     add_configs("shared", {description = "Build shared binaries.", default = true, type = "boolean", readonly = true})
     add_configs("monolithic", {description = "Build single shared library", default = false, type = "boolean"})
 
-    add_deps("cmake", "boost")
+    add_configs("image", {description = "Build imaging components", default = false, type = "boolean"})
+    add_configs("openimageio", {description = "Build OpenImageIO plugin", default = false, type = "boolean"})
+    add_configs("opencolorio", {description = "Build OpenColorIO plugin", default = false, type = "boolean"})
+
+    add_configs("vulkan", {description = "Enable Vulkan based components", default = false, type = "boolean"})
+    add_configs("python", {description = "Enable Python based components for USD", default = false, type = "boolean"})
+    add_configs("usdview", {description = "Build usdview", default = false, type = "boolean"})
+    add_configs("tools", {description = "Build tools", default = false, type = "boolean"})
+
+    add_deps("cmake")
 
     if is_plat("windows") then
         add_defines("NOMINMAX")
     end
 
     on_load(function (package)
-        if package:version():ge("v25.05") then
+        if package:version() and package:version():ge("v25.05") then
             package:add("deps", "tbb")
         else
             -- usd only support tbb 2022 now https://github.com/PixarAnimationStudios/USD/issues/1471
             package:add("deps", "tbb 2020.3")
+            package:add("deps", "boost")
+        end
+
+        if package:config("image") then
+            package:add("deps", "opensubdiv", {configs = {glfw = false, ptex = false}})
+            if package:config("vulkan") then
+                package:add("deps", "vulkansdk")
+            end
+        end
+        if package:config("openimageio") then
+            -- TODO: fix openimageio deps when link
+            package:add("deps", "openimageio", {configs = {shared = true}})
+        end
+        if package:config("opencolorio") then
+            package:add("deps", "opencolorio")
+        end
+        if package:config("python") then
+            package:add("deps", "python >=3.9")
+            package:addenv("PYTHONPATH", "lib/python")
+            if package:config("usdview") then
+                -- TODO: require pyside2/pyside6 for usdview
+            end
+        end
+        if package:config("tools") then
+            package:addenv("PATH", "bin")
         end
     end)
 
     on_install("linux", "macosx|x86_64", "windows|x64", function (package)
         local configs = {
-            "-DTBB_USE_DEBUG_BUILD=OFF",
-            "-DPXR_BUILD_ALEMBIC_PLUGIN=OFF",
-            "-DBoost_NO_BOOST_CMAKE=OFF",
-            "-DPXR_BUILD_EMBREE_PLUGIN=OFF",
-            "-DPXR_BUILD_IMAGING=OFF",
-            "-DPXR_BUILD_MONOLITHIC=OFF",
             "-DPXR_BUILD_TESTS=OFF",
-            "-DPXR_BUILD_USD_IMAGING=OFF",
-            "-DPXR_ENABLE_PYTHON_SUPPORT=OFF",
             "-DPXR_BUILD_EXAMPLES=OFF",
             "-DPXR_BUILD_TUTORIALS=OFF",
-            "-DPXR_BUILD_USD_TOOLS=OFF",
-            "-DPXR_BUILD_MONOLITHIC=" .. (package:config("monolithic") and "ON" or "OFF")
+            "-DTBB_USE_DEBUG_BUILD=OFF",
+            "-DBoost_NO_BOOST_CMAKE=OFF",
+            "-DPXR_BUILD_ALEMBIC_PLUGIN=OFF",
+            "-DPXR_BUILD_EMBREE_PLUGIN=OFF",
+            "-DPXR_ENABLE_PRECOMPILED_HEADERS=OFF",
         }
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
+        table.insert(configs, "-DPXR_BUILD_MONOLITHIC=" .. (package:config("monolithic") and "ON" or "OFF"))
+
+        table.insert(configs, "-DPXR_BUILD_IMAGING=" .. (package:config("image") and "ON" or "OFF"))
+        table.insert(configs, "-DPXR_BUILD_USD_IMAGING=" .. (package:config("image") and "ON" or "OFF"))
+        table.insert(configs, "-DPXR_BUILD_OPENIMAGEIO_PLUGIN=" .. (package:config("openimageio") and "ON" or "OFF"))
+        table.insert(configs, "-DPXR_BUILD_OPENCOLORIO_PLUGIN=" .. (package:config("opencolorio") and "ON" or "OFF"))
+
+        table.insert(configs, "-DPXR_ENABLE_VULKAN_SUPPORT=" .. (package:config("vulkan") and "ON" or "OFF"))
+        table.insert(configs, "-DPXR_ENABLE_PYTHON_SUPPORT=" .. (package:config("python") and "ON" or "OFF"))
+        table.insert(configs, "-DPXR_BUILD_USDVIEW=" .. (package:config("usdview") and "ON" or "OFF"))
+        table.insert(configs, "-DPXR_BUILD_USD_TOOLS=" .. (package:config("tools") and "ON" or "OFF"))
+
         import("package.tools.cmake").install(package, configs)
+        -- If use mv, we need to fix `xxx.cmake` file
+        os.cp(package:installdir("lib/*.dll"), package:installdir("bin"))
     end)
 
     on_test(function (package)