summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-02-07 00:38:01 +0800
committerruki <[email protected]>2026-02-07 00:38:01 +0800
commitb9e7cdc673102d0ca97e271be273a16358ed158e (patch)
tree94043a3c7ec361c85d4ffdeac4af949063def9ff
parent41d6a48953038df041194bafc7cc87a7e6466b3e (diff)
add libdir,includedir,bindir support for install/uninstall
-rw-r--r--xmake/actions/install/install_admin.lua21
-rw-r--r--xmake/actions/install/main.lua4
-rw-r--r--xmake/actions/install/xmake.lua5
-rw-r--r--xmake/actions/uninstall/main.lua4
-rw-r--r--xmake/actions/uninstall/uninstall_admin.lua23
-rw-r--r--xmake/actions/uninstall/xmake.lua9
-rw-r--r--xmake/core/project/target.lua18
7 files changed, 64 insertions, 20 deletions
diff --git a/xmake/actions/install/install_admin.lua b/xmake/actions/install/install_admin.lua
index 5aab468e9..22d6da524 100644
--- a/xmake/actions/install/install_admin.lua
+++ b/xmake/actions/install/install_admin.lua
@@ -25,7 +25,7 @@ import("core.project.project")
import("core.platform.platform")
import("install")
-function main(targetname, group_pattern, installdir, prefix)
+function main(targetname, group_pattern, installdir, bindir, libdir, includedir)
local verbose = option.get("verbose")
if group_pattern and #group_pattern == 0 then
group_pattern = nil
@@ -33,6 +33,15 @@ function main(targetname, group_pattern, installdir, prefix)
if installdir and #installdir == 0 then
installdir = nil
end
+ if bindir and #bindir == 0 then
+ bindir = nil
+ end
+ if libdir and #libdir == 0 then
+ libdir = nil
+ end
+ if includedir and #includedir == 0 then
+ includedir = nil
+ end
os.cd(project.directory())
config.load()
@@ -44,8 +53,14 @@ function main(targetname, group_pattern, installdir, prefix)
if installdir then
option.set("installdir", installdir)
end
- if prefix then
- option.set("prefix", prefix)
+ if bindir then
+ option.set("bindir", bindir)
+ end
+ if libdir then
+ option.set("libdir", libdir)
+ end
+ if includedir then
+ option.set("includedir", includedir)
end
-- install target
diff --git a/xmake/actions/install/main.lua b/xmake/actions/install/main.lua
index 70a716c6c..e6c8258fc 100644
--- a/xmake/actions/install/main.lua
+++ b/xmake/actions/install/main.lua
@@ -111,7 +111,9 @@ function main()
sudo.execl(path.join(os.scriptdir(), "install_admin.lua"), {
targetname or (option.get("all") and "__all" or "__def"),
group_pattern or "", option.get("installdir") or "",
- option.get("prefix")})
+ option.get("bindir"),
+ option.get("libdir"),
+ option.get("includedir")})
cprint("${color.success}install ok!")
ok = true
end
diff --git a/xmake/actions/install/xmake.lua b/xmake/actions/install/xmake.lua
index a18b11214..3ef6a22c3 100644
--- a/xmake/actions/install/xmake.lua
+++ b/xmake/actions/install/xmake.lua
@@ -31,6 +31,9 @@ task("install")
" $ xmake install -o /usr/local",
"or $ DESTDIR=/usr/local xmake install",
"or $ INSTALLDIR=/usr/local xmake install" },
+ {nil, "bindir", "kv", nil , "Set install binaries directory in INSTALLDIR/DIR. (default: ${installdir}/bin)"},
+ {nil, "libdir", "kv", nil , "Set install libraries directory in INSTALLDIR/DIR. (default: ${installdir}/lib)"},
+ {nil, "includedir", "kv", nil , "Set install includes directory in INSTALLDIR/DIR. (default: ${installdir}/include)"},
{'g', "group", "kv", nil , "Install all targets of the given group. It support path pattern matching.",
"e.g.",
" xmake install -g test",
@@ -51,5 +54,3 @@ task("install")
}
}
-
-
diff --git a/xmake/actions/uninstall/main.lua b/xmake/actions/uninstall/main.lua
index fa8d58f3d..4fb411892 100644
--- a/xmake/actions/uninstall/main.lua
+++ b/xmake/actions/uninstall/main.lua
@@ -72,7 +72,9 @@ function main()
sudo.execl(path.join(os.scriptdir(), "uninstall_admin.lua"), {
targetname or "__all",
option.get("installdir") or "",
- option.get("prefix")})
+ option.get("bindir"),
+ option.get("libdir"),
+ option.get("includedir")})
-- trace
cprint("${color.success}uninstall ok!")
diff --git a/xmake/actions/uninstall/uninstall_admin.lua b/xmake/actions/uninstall/uninstall_admin.lua
index 4842566ec..070c1c7ad 100644
--- a/xmake/actions/uninstall/uninstall_admin.lua
+++ b/xmake/actions/uninstall/uninstall_admin.lua
@@ -25,11 +25,20 @@ import("core.project.project")
import("core.platform.platform")
import("uninstall")
-function main(targetname, installdir, prefix)
+function main(targetname, installdir, bindir, libdir, includedir)
local verbose = option.get("verbose")
if installdir and #installdir == 0 then
installdir = nil
end
+ if bindir and #bindir == 0 then
+ bindir = nil
+ end
+ if libdir and #libdir == 0 then
+ libdir = nil
+ end
+ if includedir and #includedir == 0 then
+ includedir = nil
+ end
os.cd(project.directory())
config.load()
@@ -41,11 +50,17 @@ function main(targetname, installdir, prefix)
if installdir then
option.set("installdir", installdir)
end
- if prefix then
- option.set("prefix", prefix)
+ if bindir then
+ option.set("bindir", bindir)
+ end
+ if libdir then
+ option.set("libdir", libdir)
+ end
+ if includedir then
+ option.set("includedir", includedir)
end
-
-- uninstall target
uninstall(targetname ~= "__all" and targetname or nil)
option.restore()
end
+end
diff --git a/xmake/actions/uninstall/xmake.lua b/xmake/actions/uninstall/xmake.lua
index 22f5e712a..72ba9c3f2 100644
--- a/xmake/actions/uninstall/xmake.lua
+++ b/xmake/actions/uninstall/xmake.lua
@@ -31,15 +31,14 @@ task("uninstall")
" $ xmake uninstall --installdir=/usr/local",
"or $ DESTDIR=/usr/local xmake uninstall",
"or $ INSTALLDIR=/usr/local xmake uninstall" },
+ {nil, "bindir", "kv", nil , "Set install binaries directory in INSTALLDIR/DIR. (default: ${installdir}/bin)"},
+ {nil, "libdir", "kv", nil , "Set install libraries directory in INSTALLDIR/DIR. (default: ${installdir}/lib)"},
+ {nil, "includedir", "kv", nil , "Set install includes directory in INSTALLDIR/DIR. (default: ${installdir}/include)"},
{'g', "group", "kv", nil , "Uninstall all targets of the given group. It support path pattern matching.",
"e.g.",
" xmake uninstall -g test",
" xmake uninstall -g test_*",
" xmake uninstall --group=benchmark/*" },
- {'p', "prefix", "kv", nil , "Set the prefix directory.",
- "e.g.",
- " $ xmake uninstall --prefix=local",
- "or $ PREFIX=local xmake uninstall" },
{nil, "admin", "k", nil , "Try to request administrator permission to uninstall"},
{ },
{nil, "target", "v", nil , "The target name. It will uninstall all default targets if this parameter is not specified.",
@@ -49,5 +48,3 @@ task("uninstall")
}
}
-
-
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index b3b318e26..3f78174a3 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -1767,7 +1767,11 @@ end
-- get the installed binary directory
function _instance:bindir()
- local bindir = self:extraconf("prefixdir", self:prefixdir(), "bindir")
+ local bindir = baseoption.get("bindir")
+ if bindir then
+ return path.is_absolute(bindir) and path.normalize(bindir) or self:installdir(bindir)
+ end
+ bindir = self:extraconf("prefixdir", self:prefixdir(), "bindir")
if bindir == nil then
bindir = "bin"
end
@@ -1776,7 +1780,11 @@ end
-- get the installed library directory
function _instance:libdir()
- local libdir = self:extraconf("prefixdir", self:prefixdir(), "libdir")
+ local libdir = baseoption.get("libdir")
+ if libdir then
+ return path.is_absolute(libdir) and path.normalize(libdir) or self:installdir(libdir)
+ end
+ libdir = self:extraconf("prefixdir", self:prefixdir(), "libdir")
if libdir == nil then
libdir = "lib"
end
@@ -1785,7 +1793,11 @@ end
-- get the installed include directory
function _instance:includedir()
- local includedir = self:extraconf("prefixdir", self:prefixdir(), "includedir")
+ local includedir = baseoption.get("includedir")
+ if includedir then
+ return path.is_absolute(includedir) and path.normalize(includedir) or self:installdir(includedir)
+ end
+ includedir = self:extraconf("prefixdir", self:prefixdir(), "includedir")
if includedir == nil then
includedir = "include"
end