Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add install.strip_packagelibs #5611

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions xmake/core/project/policy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ function policy.policies()
["run.autobuild"] = {description = "Automatically build before running.", type = "boolean"},
-- Enable install rpath
["install.rpath"] = {description = "Enable install rpath.", default = true, type = "boolean"},
-- Strip package libraries for installation
["install.strip_packagelibs"] = {description = "Strip package libraries for installation.", default = true, type = "boolean"},
-- Preprocessor configuration for ccache/distcc, we can disable linemarkers to speed up preprocess
["preprocessor.linemarkers"] = {description = "Enable linemarkers for preprocessor.", default = true, type = "boolean"},
-- Preprocessor configuration for ccache/distcc, we can disable it to avoid cache object file with __DATE__, __TIME__
Expand Down
11 changes: 7 additions & 4 deletions xmake/modules/target/action/install/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
-- imports
import("core.base.option")
import("core.base.hashset")
import("core.project.project")
import("utils.binary.deplibs", {alias = "get_depend_libraries"})
import("utils.binary.rpath", {alias = "rpath_utils"})

Expand Down Expand Up @@ -60,10 +61,12 @@ function _get_target_package_libfiles(target, opt)
end
end
-- we can only reserve used libraries
if target:is_binary() or target:is_shared() then
local depends = hashset.new()
_get_target_package_deplibs(target, depends, libfiles, target:targetfile())
table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end)
if project.policy("install.strip_packagelibs") then
if target:is_binary() or target:is_shared() then
local depends = hashset.new()
_get_target_package_deplibs(target, depends, libfiles, target:targetfile())
table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end)
end
end
return libfiles
end
Expand Down
11 changes: 7 additions & 4 deletions xmake/modules/target/action/uninstall/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
-- imports
import("core.base.option")
import("core.base.hashset")
import("core.project.project")
import("utils.binary.deplibs", {alias = "get_depend_libraries"})
import("private.action.clean.remove_files")

Expand Down Expand Up @@ -61,10 +62,12 @@ function _get_target_package_libfiles(target, opt)
end
end
-- we can only reserve used libraries
if target:is_binary() or target:is_shared() then
local depends = hashset.new()
_get_target_package_deplibs(target, depends, libfiles, target:targetfile())
table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end)
if project.policy("install.strip_packagelibs") then
if target:is_binary() or target:is_shared() then
local depends = hashset.new()
_get_target_package_deplibs(target, depends, libfiles, target:targetfile())
table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end)
end
end
return libfiles
end
Expand Down
Loading