From 538c0e7e2ebc18f11ef8cbdf719f2e5deb80e7f6 Mon Sep 17 00:00:00 2001 From: Chi Huu Huynh <73843190+Chi-EEE@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:50:52 +0100 Subject: [PATCH] glob: use ghc option (#5118) * glob: use ghc option * glob: add option * glob: add requested changes * glob: re-add `package:add("defines", "GLOB_USE_GHC_FILESYSTEM")` in on_install * glob: remove `package:add("defines", "GLOB_USE_GHC_FILESYSTEM")` * glob: move `add_defines("GLOB_USE_GHC_FILESYSTEM")` * Update xmake.lua --------- Co-authored-by: star9029 --- packages/g/glob/xmake.lua | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/g/glob/xmake.lua b/packages/g/glob/xmake.lua index c383c9ae9..3791c34ba 100644 --- a/packages/g/glob/xmake.lua +++ b/packages/g/glob/xmake.lua @@ -13,6 +13,7 @@ package("glob") on_load(function (package) if package:config("ghc_filesystem") then package:add("deps", "ghc_filesystem") + package:add("defines", "GLOB_USE_GHC_FILESYSTEM") end if package:config("header_only") then package:set("kind", "library", {headeronly = true}) @@ -20,22 +21,34 @@ package("glob") end) on_install(function (package) - if package:config("ghc_filesystem") then - package:add("defines", "GLOB_USE_GHC_FILESYSTEM") - end if package:config("header_only") then os.cp("single_include/glob", package:installdir("include")) else + local configs = {} + if package:config("ghc_filesystem") then + configs.ghc_filesystem = true + end io.writefile("xmake.lua", [[ add_rules("mode.debug", "mode.release") + option("ghc_filesystem", {default = false, showmenu = true, description = "Use ghc_filesystem"}) + if has_config("ghc_filesystem") then + add_requires("ghc_filesystem") + add_defines("GLOB_USE_GHC_FILESYSTEM") + end target("glob") set_kind("$(kind)") set_languages("cxx17") + if has_config("ghc_filesystem") then + add_packages("ghc_filesystem") + end add_headerfiles("include/(glob/*.h)") add_files("source/*.cpp") add_includedirs("include", {public = true}) + if is_plat("windows") and is_kind("shared") then + add_rules("utils.symbols.export_all", {export_classes = true}) + end ]]) - import("package.tools.xmake").install(package) + import("package.tools.xmake").install(package, configs) end end)