From b97f0bdc0c796670dd3f303c8d93b24add1ab81b Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 12 Feb 2026 23:14:44 +0800 Subject: add build.release.strip policy --- xmake/core/project/policy.lua | 2 ++ xmake/rules/mode/xmake.lua | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index a1aad6d97..38eaa3fa2 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -70,6 +70,8 @@ function policy.policies() ["build.sanitizer.undefined"] = {description = "Enable undefined sanitizer for c/c++ building.", type = "boolean"}, -- Enable build rpath ["build.rpath"] = {description = "Enable build rpath.", default = true, type = "boolean"}, + -- Strip symbols by default in release mode (mode.release) + ["build.release.strip"] = {description = "Strip symbols by default in release mode.", default = true, type = "boolean"}, -- Enable C++ modules for C++ building, even if no .mpp is involved in the compilation ["build.c++.modules"] = {description = "Enable C++ modules for C++ building.", type = "boolean"}, -- Enable non cascading changes (experimental) diff --git a/xmake/rules/mode/xmake.lua b/xmake/rules/mode/xmake.lua index b4312eb12..7f74da28e 100644 --- a/xmake/rules/mode/xmake.lua +++ b/xmake/rules/mode/xmake.lua @@ -62,7 +62,7 @@ rule("mode.release") end -- strip all symbols - if not target:get("strip") then + if target:policy("build.release.strip") and not target:get("strip") then target:set("strip", "all") end @@ -94,7 +94,7 @@ rule("mode.releasedbg") end -- strip all symbols, but it will generate debug symbol file because debug/symbols is setted - if not target:get("strip") then + if target:policy("build.release.strip") and not target:get("strip") then target:set("strip", "all") end -- cgit v1.3.1