diff --git a/examples/log/console-logger/xmake.lua b/examples/log/console-logger/xmake.lua index 25c75f36..72fe75a8 100644 --- a/examples/log/console-logger/xmake.lua +++ b/examples/log/console-logger/xmake.lua @@ -13,4 +13,12 @@ target("console-logger") add_files("src/main.cpp") + add_ldflags("-Wl,--as-needed") + add_shflags("-Wl,--as-needed") + + if has_config("mold") then + add_ldflags("-Wl,-fuse-ld=mold") + add_shflags("-Wl,-fuse-ld=mold") + end + set_group("examples/stormkit-log") diff --git a/examples/log/file-logger/xmake.lua b/examples/log/file-logger/xmake.lua index d4a4cb78..a6689eec 100644 --- a/examples/log/file-logger/xmake.lua +++ b/examples/log/file-logger/xmake.lua @@ -13,4 +13,12 @@ target("file-logger") add_files("src/main.cpp") + add_ldflags("-Wl,--as-needed") + add_shflags("-Wl,--as-needed") + + if has_config("mold") then + add_ldflags("-Wl,-fuse-ld=mold") + add_shflags("-Wl,-fuse-ld=mold") + end + set_group("examples/stormkit-log") diff --git a/examples/wsi/event_handler/xmake.lua b/examples/wsi/event_handler/xmake.lua index 38ac1bc5..e45f0977 100644 --- a/examples/wsi/event_handler/xmake.lua +++ b/examples/wsi/event_handler/xmake.lua @@ -16,4 +16,12 @@ target("event_handler") add_files("win32/*.manifest") end + add_ldflags("-Wl,--as-needed") + add_shflags("-Wl,--as-needed") + + if has_config("mold") then + add_ldflags("-Wl,-fuse-ld=mold") + add_shflags("-Wl,-fuse-ld=mold") + end + set_group("examples/stormkit-wsi") diff --git a/examples/wsi/polling/xmake.lua b/examples/wsi/polling/xmake.lua index d7323da9..69d82fc6 100644 --- a/examples/wsi/polling/xmake.lua +++ b/examples/wsi/polling/xmake.lua @@ -16,4 +16,12 @@ target("polling") add_files("win32/*.manifest") end + add_ldflags("-Wl,--as-needed") + add_shflags("-Wl,--as-needed") + + if has_config("mold") then + add_ldflags("-Wl,-fuse-ld=mold") + add_shflags("-Wl,-fuse-ld=mold") + end + set_group("examples/stormkit-wsi") diff --git a/tests/xmake.lua b/tests/xmake.lua index afc194a7..a75d9d31 100644 --- a/tests/xmake.lua +++ b/tests/xmake.lua @@ -2,13 +2,21 @@ local enabled_tests = {} for name, _ in pairs(modules) do if name == "core" or has_config("enable_" .. name) then target(name .. "-tests") - set_group("tests") - set_kind("binary") - set_languages("cxxlatest", "clatest") + set_group("tests") + set_kind("binary") + set_languages("cxxlatest", "clatest") - add_files("src/main.cpp", path.join("src", name, "**.cpp"), "src/Test.mpp", "src/Test.cpp") + add_files("src/main.cpp", path.join("src", name, "**.cpp"), "src/Test.mpp", "src/Test.cpp") - add_deps("stormkit-" .. name) + add_ldflags("-Wl,--as-needed") + add_shflags("-Wl,--as-needed") + + if has_config("mold") then + add_ldflags("-Wl,-fuse-ld=mold") + add_shflags("-Wl,-fuse-ld=mold") + end + + add_deps("stormkit-" .. name) target_end() table.append(enabled_tests, name .. "-tests") @@ -16,12 +24,12 @@ for name, _ in pairs(modules) do end target("tests") - set_group("tests") - set_kind("phony") - add_deps(table.unwrap(enabled_tests)) +set_group("tests") +set_kind("phony") +add_deps(table.unwrap(enabled_tests)) - on_run(function(target) - for _, subtarget in ipairs(target:deps()) do - subtarget:run() - end - end) +on_run(function(target) + for _, subtarget in ipairs(target:deps()) do + subtarget:run() + end +end) diff --git a/xmake.lua b/xmake.lua index 6ca0b8cb..002d555f 100644 --- a/xmake.lua +++ b/xmake.lua @@ -47,7 +47,7 @@ modules = { image = { packages = { "gli", "libpng", "libjpeg-turbo" }, modulename = "Image", - public_deps = { "stormkit-core" } + public_deps = { "stormkit-core" }, }, main = { modulename = "Main", @@ -58,17 +58,19 @@ modules = { modulename = "Wsi", public_deps = { "stormkit-core" }, deps = { "stormkit-log" }, - packages = is_plat("linux") and { "libxkbcommon", - "libxkbcommon-x11", - "libxcb", - "xcb-util-keysyms", - "xcb-util", - "xcb-util-wm", - "xcb-util-errors", - "wayland", - "wayland-protocols", - } or nil, - frameworks = is_plat("macosx") and {"CoreFoundation", "Foundation", "AppKit", "Metal", "IOKit", "QuartzCore" } or nil, + packages = is_plat("linux") and { + "libxkbcommon", + "libxkbcommon-x11", + "libxcb", + "xcb-util-keysyms", + "xcb-util", + "xcb-util-wm", + "xcb-util-errors", + "wayland", + "wayland-protocols", + } or nil, + frameworks = is_plat("macosx") and { "CoreFoundation", "Foundation", "AppKit", "Metal", "IOKit", "QuartzCore" } + or nil, custom = function() if is_plat("linux") then add_rules("wayland.protocols") @@ -124,9 +126,9 @@ modules = { -- "VULKAN_HPP_NO_EXCEPTIONS", uncomment when vk::raii is supported without exceptions }, custom = function() - remove_files("src/Gpu/Execution/**.cpp") - remove_files("modules/stormkit/Gpu/Execution.mpp") - remove_files("modules/stormkit/Gpu/Execution/**.mpp") + remove_files("src/Gpu/Execution/**.cpp") + remove_files("modules/stormkit/Gpu/Execution.mpp") + remove_files("modules/stormkit/Gpu/Execution/**.mpp") if is_plat("linux") then add_defines("VK_USE_PLATFORM_XCB_KHR") add_defines("VK_USE_PLATFORM_WAYLAND_KHR") @@ -273,14 +275,8 @@ add_cxflags( add_cxflags("-fstrict-aliasing", "-Wstrict-aliasing", { tools = { "clang", "gcc" } }) add_mxflags("-fstrict-aliasing", "-Wstrict-aliasing", { tools = { "clang", "gcc" } }) -add_cxxflags( - "-Wno-missing-field-initializers", - { tools = { "clang" } } -) -add_mxxflags( - "-Wno-missing-field-initializers", - { tools = { "clang" } } -) +add_cxxflags("-Wno-missing-field-initializers", { tools = { "clang" } }) +add_mxxflags("-Wno-missing-field-initializers", { tools = { "clang" } }) if not is_plat("windows") and not is_plat("macosx") then add_syslinks("stdc++_libbacktrace") @@ -311,8 +307,6 @@ option_end() option("mold") set_default(false) -add_ldflags("-Wl,-fuse-ld=mold") -add_shflags("-Wl,-fuse-ld=mold") option_end() if get_config("libc++") then @@ -324,13 +318,13 @@ if get_config("libc++") then set_policy("build.c++.clang.fallbackscanner", true) target("stdmodules") - set_kind("object") - set_languages("c++latest") + set_kind("object") + set_languages("c++latest") - add_files("stdmodules/**.cppm") + add_files("stdmodules/**.cppm") - add_cxxflags("-Wno-reserved-module-identifier") - set_policy("build.c++.clang.fallbackscanner", false) + add_cxxflags("-Wno-reserved-module-identifier") + set_policy("build.c++.clang.fallbackscanner", false) target_end() end @@ -479,6 +473,8 @@ for name, module in pairs(modules) do if get_config("libc++") then add_deps("stdmodules") end + add_ldflags("-Wl,--as-needed") + add_shflags("-Wl,--as-needed") target_end() end end