summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-09-08 22:14:53 +0800
committerGitHub <[email protected]>2021-09-08 22:14:53 +0800
commita68c603d0e1d95d372fbc99176372914d74ea4e8 (patch)
treec5b342700739678960c1c1a7276f2ab1c798934f
parent7313e0dae040ed0cff6cad8ca934649721cb46da (diff)
parentd9021ad4c05a4f968979d948ab40aa9dd89a363f (diff)
Merge pull request #1658 from SirLynix/improve-install
Improve install
-rw-r--r--xmake/modules/target/action/install/unix.lua20
-rw-r--r--xmake/modules/target/action/install/windows.lua19
2 files changed, 28 insertions, 11 deletions
diff --git a/xmake/modules/target/action/install/unix.lua b/xmake/modules/target/action/install/unix.lua
index ae06ed3bc..521ed40de 100644
--- a/xmake/modules/target/action/install/unix.lua
+++ b/xmake/modules/target/action/install/unix.lua
@@ -37,15 +37,23 @@ end
-- install shared libraries for package
function _install_shared_for_package(target, pkg, outputdir)
+ _g.installed_libfiles = _g.installed_libfiles or {}
for _, sopath in ipairs(table.wrap(pkg:get("libfiles"))) do
if sopath:endswith(".so") or sopath:match(".+%.so%..+$") or sopath:endswith(".dylib") then
- local soname = path.filename(sopath)
- if os.isfile(path.join(outputdir, soname)) then
- wprint("'%s' already exists in install dir, overwriting it from package(%s).", soname, pkg:name())
+ -- prevent packages using the same system libfiles from overwriting each other
+ if not _g.installed_libfiles[sopath] then
+ local soname = path.filename(sopath)
+ local targetname = path.join(outputdir, soname)
+ if os.isfile(targetname) then
+ wprint("'%s' already exists in install dir, overwriting it from package(%s).", soname, pkg:name())
+ -- rm because symlink cannot overwrite existing file
+ os.rm(targetname)
+ end
+ -- we need reserve symlink
+ -- @see https://github.com/xmake-io/xmake/issues/1582
+ os.vcp(sopath, outputdir, {symlink = true})
+ _g.installed_libfiles[sopath] = true
end
- -- we need reserve symlink
- -- @see https://github.com/xmake-io/xmake/issues/1582
- os.vcp(sopath, outputdir, {symlink = true})
end
end
end
diff --git a/xmake/modules/target/action/install/windows.lua b/xmake/modules/target/action/install/windows.lua
index dfb8d2bd3..609e87389 100644
--- a/xmake/modules/target/action/install/windows.lua
+++ b/xmake/modules/target/action/install/windows.lua
@@ -40,13 +40,18 @@ end
-- install shared libraries for package
function _install_shared_for_package(target, pkg, outputdir)
+ _g.installed_dllfiles = _g.installed_dllfiles or {}
for _, dllpath in ipairs(table.wrap(pkg:get("libfiles"))) do
if dllpath:endswith(".dll") then
- local dllname = path.filename(dllpath)
- if os.isfile(path.join(outputdir, dllname)) then
- wprint("'%s' already exists in install dir, overwriting it from package(%s).", dllname, pkg:name())
+ -- prevent packages using the same libfiles from overwriting each other
+ if not _g.installed_dllfiles[dllpath] then
+ local dllname = path.filename(dllpath)
+ if os.isfile(path.join(outputdir, dllname)) then
+ wprint("'%s' already exists in install dir, overwriting it from package(%s).", dllname, pkg:name())
+ end
+ os.vcp(dllpath, outputdir)
+ _g.installed_dllfiles[dllpath] = true
end
- os.vcp(dllpath, outputdir)
end
end
end
@@ -74,11 +79,15 @@ function install_binary(target, opt)
-- install the dependent shared/windows (*.dll) target
-- @see https://github.com/xmake-io/xmake/issues/961
+ _g.installed_dllfiles = _g.installed_dllfiles or {}
for _, dep in ipairs(target:orderdeps()) do
if dep:kind() == "shared" then
local depfile = dep:targetfile()
if os.isfile(depfile) then
- os.vcp(depfile, binarydir)
+ if not _g.installed_dllfiles[depfile] then
+ os.vcp(depfile, binarydir)
+ _g.installed_dllfiles[depfile] = true
+ end
end
end
-- install all shared libraries in packages in all deps