Browse Source

Add ability to set user_config for ImGui at user's own risk (#350)

Andrej Redeky 4 years ago
parent
commit
7c181b043d
1 changed files with 16 additions and 3 deletions
  1. 16 3
      packages/i/imgui/xmake.lua

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

@@ -11,23 +11,36 @@ package("imgui")
     add_versions("v1.80", "d7e4e1c7233409018437a646680316040e6977b9a635c02da93d172baad94ce9")
     add_versions("v1.79", "f1908501f6dc6db8a4d572c29259847f6f882684b10488d3a8d2da31744cd0a4")
     add_versions("v1.75", "1023227fae4cf9c8032f56afcaea8902e9bfaad6d9094d6e48fb8f3903c7b866")
+    
+    add_configs("user_config", {description = "Use user config (disables test!)", default = nil, type = "string"})
 
     if is_plat("windows", "mingw") then
         add_syslinks("Imm32")
     end
 
     on_install("macosx", "linux", "windows", "mingw", "android", "iphoneos", function (package)
-        io.writefile("xmake.lua", [[
+        local xmake_lua = [[
             target("imgui")
                 set_kind("static")
                 add_files("*.cpp")
                 add_headerfiles("imgui.h", "imconfig.h")
-        ]])
+        ]]
+        
+        local user_config = package:config("user_config")
+        if user_config ~= nil then
+            if is_host("windows") then
+                user_config = user_config:gsub("\\", "\\\\")
+            end
+            xmake_lua = xmake_lua .. "add_defines(\"IMGUI_USER_CONFIG=\\\"" .. user_config .. "\\\"\")"
+        end
+
+        io.writefile("xmake.lua", xmake_lua)
         import("package.tools.xmake").install(package)
     end)
 
     on_test(function (package)
-        assert(package:check_cxxsnippets({test = [[
+        local user_config = package:config("user_config")
+        assert(user_config ~= nil or package:check_cxxsnippets({test = [[
             void test() {
                 IMGUI_CHECKVERSION();
                 ImGui::CreateContext();