From 6fc145906eafdbd89f4558b79282a9e5d722afbc Mon Sep 17 00:00:00 2001 From: Mole Shang <135e2@135e2.dev> Date: Sun, 6 Aug 2023 12:54:47 +0800 Subject: xmake: migrate from NFD to tinyfiledialogs nativefiledialog-extended works great on Linux w/ portal support, but somehow is too complex to build on Windows. [1] Switch to tinyfd for simplicity. [1]: Visual Studio CL.exe would fail with MSB6001. ``` Error MSB6001: Invalid command line switch for "CL.exe". Item has already been added. Key in dictionary: 'VCInstallDir' Key being added: 'VCINSTALLDIR' ``` For further information, see below: https://social.msdn.microsoft.com/Forums/vstudio/en-US/5de6d7e3-7a38-4712-ba59-be179808bf9e/error-msb6001-invalid-command-line-switch-for-clexe https://github.com/dotnet/msbuild/issues/5726 It's been over 10 years, and Microsoft still claims that case sensitivity thing is a FEATURE. Holy M$, Thank you. --- xmake.lua | 67 +++++++++++++++++++++++++-------------------------------------- 1 file changed, 26 insertions(+), 41 deletions(-) (limited to 'xmake.lua') diff --git a/xmake.lua b/xmake.lua index f1910d1..f4e0b8f 100644 --- a/xmake.lua +++ b/xmake.lua @@ -1,6 +1,6 @@ add_rules("mode.debug", "mode.release", "mode.releasedbg", "mode.minsizerel") -add_requires("nuklear", "nuklear_glfw_gl3", "nuklear_fonts", "glew", "glfw", "nativefiledialog-extended", +add_requires("nuklear", "nuklear_glfw_gl3", "nuklear_fonts", "glew", "glfw", "tinyfiledialogs", "c11threads", "pcre2", "cjson") add_requires("libcurl", { configs = { zlib = true } }) @@ -17,60 +17,45 @@ set_languages("c11") if is_mode("debug") then add_defines("DEBUG") end -add_packages("nuklear", "nuklear_glfw_gl3", "nuklear_fonts", "glew", "glfw", "libcurl", "nativefiledialog-extended", +add_packages("nuklear", "nuklear_glfw_gl3", "nuklear_fonts", "glew", "glfw", "libcurl", "tinyfiledialogs", "c11threads", "pcre2", "cjson") -package("nativefiledialog-extended") +package("tinyfiledialogs") -set_homepage("https://github.com/btzy/nativefiledialog-extended") -set_description( - "Cross platform (Windows, Mac, Linux) native file dialog library with C and C++ bindings, based on mlabbe/nativefiledialog.") +set_homepage("https://sourceforge.net/projects/tinyfiledialogs/") +set_description("Native dialog library for WINDOWS MAC OSX GTK+ QT CONSOLE") +set_license("zlib") -add_urls("https://github.com/btzy/nativefiledialog-extended/archive/refs/tags/$(version).zip", - "https://github.com/btzy/nativefiledialog-extended.git") -add_versions("v1.1.0", "5827d17b6bddc8881406013f419c534e8459b38f34c2f266d9c1da8a7a7464bc") +add_urls("https://git.code.sf.net/p/tinyfiledialogs/code.git") -add_configs("portal", { description = "Use xdg-desktop-portal instead of GTK.", default = true, type = "boolean" }) -if is_plat("windows") then - add_configs("shared", { description = "Build shared library.", default = false, type = "boolean", readonly = true }) +if is_plat("windows", "mingw") then + add_syslinks("comdlg32", "ole32", "user32", "shell32") end - -add_deps("cmake") -if is_plat("windows") or is_plat("mingw") then - add_syslinks("shell32", "ole32", "uuid") -elseif is_plat("macosx") then - add_frameworks("AppKit", "UniformTypeIdentifiers") -end -on_load("linux", function(package) - if package:config("portal") then - package:add("deps", "dbus") - else - package:add("deps", "gtk+3") - end -end) - -on_install("windows", "macosx", "linux", "mingw", function(package) - local configs = { "-DNFD_BUILD_TESTS=OFF" } - 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")) - table.insert(configs, "-DNFD_PORTAL=" .. (package:config("portal") and "ON" or "OFF")) - import("package.tools.cmake").install(package, configs) +on_install("windows", "mingw", "linux", "macosx", function(package) + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + target("tinyfiledialogs") + set_kind("static") + add_files("tinyfiledialogs.c") + add_headerfiles("tinyfiledialogs.h") + ]]) + import("package.tools.xmake").install(package) end) on_test(function(package) - assert(package:check_cxxsnippets({ + assert(package:check_csnippets({ test = [[ + #include + #include + #include "tinyfiledialogs.h" void test() { - NFD_Init(); - nfdchar_t *outPath = NULL; - nfdfilteritem_t filterItem[2] = {{"Source code", "c,cpp,cc"}, {"Headers", "h,hpp"}}; - nfdresult_t result = NFD_OpenDialog(&outPath, filterItem, 2, NULL); - NFD_Quit(); + char const * lWillBeGraphicMode; + lWillBeGraphicMode = tinyfd_inputBox("tinyfd_query", NULL, NULL); } ]] - }, { includes = "nfd.h" })) + })) end) package("c11threads") @@ -120,7 +105,7 @@ end) package("nuklear_fonts") add_urls( -"https://gist.github.com/135e2/656614a4a86cf6f8e9aea9f0de850634/archive/8d1dc2a079cef20d97acbc2a9874b1b77b25070b.zip") + "https://gist.github.com/135e2/656614a4a86cf6f8e9aea9f0de850634/archive/8d1dc2a079cef20d97acbc2a9874b1b77b25070b.zip") add_versions("8d1dc2a", "3dedfd45900cf68fed49ee50963c37c59af01c7f8deb327224f710c010565f87") -- cgit v1.2.3