diff options
Diffstat (limited to 'xmake.lua')
-rw-r--r-- | xmake.lua | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/xmake.lua b/xmake.lua new file mode 100644 index 0000000..d5f481c --- /dev/null +++ b/xmake.lua @@ -0,0 +1,153 @@ +add_rules("mode.debug", "mode.release", "mode.releasedbg", "mode.minsizerel") + +add_requires("nuklear", "nuklear_glfw_gl3", "nuklear_fonts", "glew", "glfw", "libcurl", "nativefiledialog-extended", + "c11threads", "pcre2", + "cjson") + +if is_plat("linux") then + set_toolchains("clang") +end + +target("hinata") +set_kind("binary") +add_files("src/*.c") +add_files("src/*/*.c") +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", + "c11threads", "pcre2", + "cjson") + + +package("nativefiledialog-extended") + +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.") + +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_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 }) +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) +end) + +on_test(function(package) + assert(package:check_cxxsnippets({ + test = [[ + 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(); + } + ]] + }, { includes = "nfd.h" })) +end) + +package("c11threads") + +set_homepage("https://github.com/jtsiomb/c11threads") +set_description("Portable C11 threads implementation over POSIX threads and win32 threads.") + +add_urls("https://github.com/jtsiomb/c11threads/archive/ec95e1aa82079aefe109d18e5069b79711692064.zip") +add_versions("1.0-ec95e1a", "9eb5eab9db4c32418eea39543d4883022c81167ea5e37f820f5af972bea7a30e") + +on_install("linux", "macosx", function(package) + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + target("c11threads") + set_kind("static") + add_headerfiles("c11threads.h") + ]]) + import("package.tools.xmake").install(package) +end) + +on_install("windows", "mingw", function(package) + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + target("c11threads") + set_kind("static") + add_files("c11threads_win32.c") + add_headerfiles("c11threads.h") + ]]) + import("package.tools.xmake").install(package) +end) + +package("nuklear_glfw_gl3") + +set_homepage("https://github.com/Immediate-Mode-UI/Nuklear") +set_description("A single-header ANSI C immediate mode cross-platform GUI library (GLFW OpenGL 3 Binding)") +set_license("MIT") + +add_urls("https://github.com/Immediate-Mode-UI/Nuklear/archive/refs/tags/$(version).tar.gz", + "https://github.com/Immediate-Mode-UI/Nuklear.git") + +add_versions("4.10.5", "6c80cbd0612447421fa02ad92f4207da2cd019a14d94885dfccac1aadc57926a") + +on_install(function(package) + os.cp("demo/glfw_opengl3/nuklear_glfw_gl3.h", package:installdir("include")) +end) + +package("nuklear_fonts") + +add_urls( +"https://gist.github.com/135e2/656614a4a86cf6f8e9aea9f0de850634/archive/8d1dc2a079cef20d97acbc2a9874b1b77b25070b.zip") + +add_versions("8d1dc2a", "3dedfd45900cf68fed49ee50963c37c59af01c7f8deb327224f710c010565f87") + +on_install(function(package) + os.cp("unifont.h", package:installdir("include")) + os.cp("NotoSansCJK.h", package:installdir("include")) +end) + +package("cjson") + +set_homepage("https://github.com/DaveGamble/cJSON") +set_description("Ultralightweight JSON parser in ANSI C.") +set_license("MIT") + +set_urls("https://github.com/DaveGamble/cJSON/archive/v$(version).zip", + "https://github.com/DaveGamble/cJSON.git") + +add_versions("1.7.16", "ea60a2477e5b7f41418eeb70488f437c56c56f998802e23be22b859e4be3ef44") + +add_deps("cmake") + +on_install("windows", "macosx", "linux", "mingw", "iphoneos", "android", function(package) + local configs = { "-DENABLE_CJSON_TEST=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")) + import("package.tools.cmake").install(package, configs) +end) + +on_test(function(package) + assert(package:has_cfuncs("cJSON_malloc", { includes = "cjson/cJSON.h" })) +end) |