Skip to content

Commit 4786482

Browse files
authored
Merge pull request #5611 from xmake-io/install
add install.strip_packagelibs
2 parents decc680 + 252dbbe commit 4786482

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

xmake/core/project/policy.lua

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ function policy.policies()
100100
["run.autobuild"] = {description = "Automatically build before running.", type = "boolean"},
101101
-- Enable install rpath
102102
["install.rpath"] = {description = "Enable install rpath.", default = true, type = "boolean"},
103+
-- Strip package libraries for installation
104+
["install.strip_packagelibs"] = {description = "Strip package libraries for installation.", default = true, type = "boolean"},
103105
-- Preprocessor configuration for ccache/distcc, we can disable linemarkers to speed up preprocess
104106
["preprocessor.linemarkers"] = {description = "Enable linemarkers for preprocessor.", default = true, type = "boolean"},
105107
-- Preprocessor configuration for ccache/distcc, we can disable it to avoid cache object file with __DATE__, __TIME__

xmake/modules/target/action/install/main.lua

+7-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
-- imports
2222
import("core.base.option")
2323
import("core.base.hashset")
24+
import("core.project.project")
2425
import("utils.binary.deplibs", {alias = "get_depend_libraries"})
2526
import("utils.binary.rpath", {alias = "rpath_utils"})
2627

@@ -60,10 +61,12 @@ function _get_target_package_libfiles(target, opt)
6061
end
6162
end
6263
-- we can only reserve used libraries
63-
if target:is_binary() or target:is_shared() then
64-
local depends = hashset.new()
65-
_get_target_package_deplibs(target, depends, libfiles, target:targetfile())
66-
table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end)
64+
if project.policy("install.strip_packagelibs") then
65+
if target:is_binary() or target:is_shared() then
66+
local depends = hashset.new()
67+
_get_target_package_deplibs(target, depends, libfiles, target:targetfile())
68+
table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end)
69+
end
6770
end
6871
return libfiles
6972
end

xmake/modules/target/action/uninstall/main.lua

+7-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
-- imports
2222
import("core.base.option")
2323
import("core.base.hashset")
24+
import("core.project.project")
2425
import("utils.binary.deplibs", {alias = "get_depend_libraries"})
2526
import("private.action.clean.remove_files")
2627

@@ -61,10 +62,12 @@ function _get_target_package_libfiles(target, opt)
6162
end
6263
end
6364
-- we can only reserve used libraries
64-
if target:is_binary() or target:is_shared() then
65-
local depends = hashset.new()
66-
_get_target_package_deplibs(target, depends, libfiles, target:targetfile())
67-
table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end)
65+
if project.policy("install.strip_packagelibs") then
66+
if target:is_binary() or target:is_shared() then
67+
local depends = hashset.new()
68+
_get_target_package_deplibs(target, depends, libfiles, target:targetfile())
69+
table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end)
70+
end
6871
end
6972
return libfiles
7073
end

0 commit comments

Comments
 (0)