summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-07-12 00:54:47 +0800
committerruki <[email protected]>2024-07-15 12:21:42 +0800
commit370950a092310a934b37bc853fe0587286422159 (patch)
tree2114b71cc477c01f3320d04fc6ffcfe38cb167b7
parent2ae6ada73e544bba9f547b022393f1e3c5093ec6 (diff)
improve install dir
-rw-r--r--xmake/core/project/target.lua10
-rw-r--r--xmake/modules/target/action/install/unix.lua10
-rw-r--r--xmake/modules/target/action/install/windows.lua18
3 files changed, 18 insertions, 20 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index fb7801f3c..a404f04bd 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -1666,11 +1666,13 @@ function _instance:installdir(...)
installdir = installdir:trim()
end
end
- local prefixdir = self:prefixdir()
- if prefixdir then
- installdir = path.join(installdir, prefixdir)
+ if installdir then
+ local prefixdir = self:prefixdir()
+ if prefixdir then
+ installdir = path.join(installdir, prefixdir)
+ end
+ return path.normalize(path.join(installdir, ...))
end
- return path.normalize(path.join(installdir, ...))
end
-- get package directory
diff --git a/xmake/modules/target/action/install/unix.lua b/xmake/modules/target/action/install/unix.lua
index 71a6df42b..5b4507622 100644
--- a/xmake/modules/target/action/install/unix.lua
+++ b/xmake/modules/target/action/install/unix.lua
@@ -23,7 +23,7 @@ import("core.base.option")
-- install headers
function _install_headers(target, opt)
- local includedir = path.join(target:installdir(), opt and opt.includedir or "include")
+ local includedir = target:includedir()
os.mkdir(includedir)
local srcheaders, dstheaders = target:headerfiles(includedir, {installonly = true})
if srcheaders and dstheaders then
@@ -81,12 +81,12 @@ end
function install_binary(target, opt)
-- install binary
- local binarydir = path.join(target:installdir(), opt and opt.bindir or "bin")
+ local binarydir = target:bindir()
os.mkdir(binarydir)
os.vcp(target:targetfile(), binarydir)
-- install libraries
- local librarydir = path.join(target:installdir(), opt and opt.libdir or "lib")
+ local librarydir = target:libdir()
os.mkdir(librarydir)
-- install the dependent shared (*.so) target
@@ -110,7 +110,7 @@ end
function install_shared(target, opt)
-- install libraries
- local librarydir = path.join(target:installdir(), opt and opt.libdir or "lib")
+ local librarydir = target:libdir()
os.mkdir(librarydir)
local targetfile = target:targetfile()
if os.islink(targetfile) then
@@ -142,7 +142,7 @@ end
function install_static(target, opt)
-- install libraries
- local librarydir = path.join(target:installdir(), opt and opt.libdir or "lib")
+ local librarydir = target:libdir()
os.mkdir(librarydir)
os.vcp(target:targetfile(), librarydir)
diff --git a/xmake/modules/target/action/install/windows.lua b/xmake/modules/target/action/install/windows.lua
index d7b71387c..7474f1411 100644
--- a/xmake/modules/target/action/install/windows.lua
+++ b/xmake/modules/target/action/install/windows.lua
@@ -22,16 +22,14 @@
import("core.base.option")
import("lib.detect.find_file")
--- get install directory
-function _get_installdir(target)
- local installdir = assert(target:installdir(), "please use `xmake install -o installdir` or `set_installdir` to set install directory on windows.")
- return installdir
+-- check install directory
+function _check_installdir(installdir)
+ return assert(installdir, "please use `xmake install -o installdir` or `set_installdir` to set install directory on windows.")
end
-- install headers
function _install_headers(target, opt)
- local installdir = _get_installdir(target)
- local includedir = path.join(installdir, opt and opt.includedir or "include")
+ local includedir = _check_installdir(target:includedir())
os.mkdir(includedir)
local srcheaders, dstheaders = target:headerfiles(includedir, {installonly = true})
if srcheaders and dstheaders then
@@ -115,8 +113,7 @@ end
function install_shared(target, opt)
-- install dll library to the binary directory
- local installdir = _get_installdir(target)
- local binarydir = path.join(installdir, opt and opt.bindir or "bin")
+ local binarydir = _check_installdir(target:bindir())
os.mkdir(binarydir)
os.vcp(target:targetfile(), binarydir)
os.trycp(target:symbolfile(), binarydir)
@@ -124,7 +121,7 @@ function install_shared(target, opt)
-- install *.lib for shared/windows (*.dll) target
-- @see https://github.com/xmake-io/xmake/issues/714
local targetfile = target:targetfile()
- local librarydir = path.join(target:installdir(), opt and opt.libdir or "lib")
+ local librarydir = _check_installdir(target:libdir())
local targetfile_lib = path.join(path.directory(targetfile), path.basename(targetfile) .. (target:is_plat("mingw") and ".dll.a" or ".lib"))
if os.isfile(targetfile_lib) then
os.mkdir(librarydir)
@@ -142,8 +139,7 @@ end
function install_static(target, opt)
-- install library
- local installdir = _get_installdir(target)
- local librarydir = path.join(installdir, opt and opt.libdir or "lib")
+ local librarydir = _check_installdir(target:libdir())
os.mkdir(librarydir)
os.vcp(target:targetfile(), librarydir)
os.trycp(target:symbolfile(), librarydir)