Jelajahi Sumber

update imgui (#582)

* update imgui

* improve volk and taskflow

* fix opengl3 backend

* imgui nolonger needs glad

* fix volk

* port volk
Hoildkv 4 tahun lalu
induk
melakukan
4498f11267
3 mengubah file dengan 36 tambahan dan 25 penghapusan
  1. 16 7
      packages/i/imgui/xmake.lua
  2. 1 0
      packages/t/taskflow/xmake.lua
  3. 19 18
      packages/v/volk/xmake.lua

+ 16 - 7
packages/i/imgui/xmake.lua

@@ -5,7 +5,7 @@ package("imgui")
 
     add_urls("https://github.com/ocornut/imgui/archive/$(version).tar.gz",
              "https://github.com/ocornut/imgui.git")
-
+    add_versions("v1.84.1", "292ab54cfc328c80d63a3315a242a4785d7c1cf7689fbb3d70da39b34db071ea")
     add_versions("v1.83-docking", "80b5fb51edba2fd3dea76ec3e88153e2492243d1")
     add_versions("v1.83", "ccf3e54b8d1fa30dd35682fc4f50f5d2fe340b8e29e08de71287d0452d8cc3ff")
     add_versions("v1.82", "fefa2804bd55f3d25b134af08c0e1f86d4d059ac94cef3ee7bd21e2f194e5ce5")
@@ -25,9 +25,11 @@ package("imgui")
 
     on_load("macosx", "linux", "windows", "mingw", "android", "iphoneos", function (package)
         if package:config("glfw_opengl3") then
-            package:add("deps", "glad")
+            if package:version():lt("1.84") then
+                package:add("deps", "glad")
+                package:add("defines", "IMGUI_IMPL_OPENGL_LOADER_GLAD")
+            end
             package:add("deps", "glfw")
-            package:add("defines", "IMGUI_IMPL_OPENGL_LOADER_GLAD")
         end
         if package:version_str():find("-docking", 1, true) then
             package:set("urls", {"https://github.com/ocornut/imgui.git"})
@@ -37,18 +39,25 @@ package("imgui")
     on_install("macosx", "linux", "windows", "mingw", "android", "iphoneos", function (package)
         local xmake_lua
         if package:config("glfw_opengl3") then
-            xmake_lua = [[
+            local pkgs = "\"glfw\""
+            if package:version():lt("1.84") then
+                pkgs = pkgs .. ", \"glad\""
+            end
+            xmake_lua = format([[
                 add_rules("mode.debug", "mode.release")
-                add_requires("glfw", "glad")
+                add_requires(%s)
                 target("imgui")
                     set_kind("static")
                     add_files("*.cpp", "backends/imgui_impl_glfw.cpp", "backends/imgui_impl_opengl3.cpp")
                     add_defines("IMGUI_IMPL_OPENGL_LOADER_GLAD")
-                    add_packages("glfw", "glad")
+                    add_packages(%s)
                     add_includedirs(".")
                     add_headerfiles("*.h", {prefixdir = "imgui"})
                     add_headerfiles("backends/imgui_impl_glfw.h", "backends/imgui_impl_opengl3.h")
-            ]]
+            ]], pkgs, pkgs)
+            if package:version():ge("1.84") then
+                xmake_lua = xmake_lua .. "add_headerfiles(\"backends/imgui_impl_opengl3_loader.h\")\n"
+            end
         else
             xmake_lua = [[
                 add_rules("mode.debug", "mode.release")

+ 1 - 0
packages/t/taskflow/xmake.lua

@@ -1,5 +1,6 @@
 package("taskflow")
 
+    set_kind("library", {headeronly = true})
     set_homepage("https://taskflow.github.io/")
     set_description("A fast C++ header-only library to help you quickly write parallel programs with complex task dependencies")
     set_license("MIT")

+ 19 - 18
packages/v/volk/xmake.lua

@@ -4,34 +4,35 @@ package("volk")
     set_description("volk is a meta-loader for Vulkan")
     set_license("MIT")
 
-    add_urls("https://github.com/zeux/volk/archive/$(version).tar.gz")
+    add_urls("https://github.com/zeux/volk/archive/$(version).tar.gz",
+             "https://github.com/zeux/volk.git")
     add_versions("1.2.162", "ac4d9d6e88dee5a83ad176e2da57f1989ca2c6df155a0aeb5e18e9471aa4d777")
 
-    add_deps("cmake", "vulkan-headers")
+    add_deps("vulkan-headers")
+
+    add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
 
     if is_plat("linux") then
         add_syslinks("dl")
     end
 
     on_install("windows", "linux", "macosx", function (package)
-        local configs = {}
-        if package:config("shared") then
-            table.insert(configs, "--enable-shared=yes")
-        else
-            table.insert(configs, "--enable-shared=no")
-        end
-        import("package.tools.cmake").build(package, configs, {buildir = "build", packagedeps = "vulkan-headers"})
-        if package:is_plat("windows") then
-            os.trycp("build/*.lib", package:installdir("lib"))
-            os.trycp("build/*.dll", package:installdir("bin"))
-        else
-            os.trycp("build/*.a", package:installdir("lib"))
-            os.trycp("build/*.so", package:installdir("lib"))
-        end
-        os.cp("*.h", package:installdir("include"))
+        io.writefile("xmake.lua", [[
+            add_rules("mode.debug", "mode.release")
+            add_requires("vulkan-headers")
+            target("volk")
+                set_kind("static")
+                add_files("volk.c")
+                add_headerfiles("volk.h")
+                add_packages("vulkan-headers")
+                if is_plat("linux") then
+                    add_syslinks("dl")
+                end
+        ]])
+        import("package.tools.xmake").install(package)
     end)
 
     on_test(function (package)
-        assert(package:has_cxxfuncs("volkInitialize", {configs = {languages = "c++14"}, includes = "volk.h"}))
+        assert(package:has_cfuncs("volkInitialize", {includes = "volk.h"}))
     end)