summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-01-26 23:15:10 +0800
committerGitHub <[email protected]>2024-01-26 23:15:10 +0800
commit445e43b40846b29b9abb1293b32b27b7104f54fa (patch)
treed8385c41e4225216ceb165badb0b9d49409bcfd8
parent8aeb3f7b343981756cdb8b468238776be7285f20 (diff)
parentc4e9dcda21240b9683273a771d4c79446d706d91 (diff)
Merge pull request #4658 from xmake-io/xmakenv
remove PATH in xmake
-rw-r--r--xmake/actions/build/cleaner.lua2
-rw-r--r--xmake/actions/update/main.lua4
-rw-r--r--xmake/core/main.lua8
-rw-r--r--xmake/modules/package/tools/xmake.lua8
-rw-r--r--xmake/modules/private/service/remote_build/action.lua2
-rw-r--r--xmake/modules/private/utils/completer.lua2
-rw-r--r--xmake/modules/private/utils/statistics.lua2
-rw-r--r--xmake/modules/private/xrepo/action/add-repo.lua4
-rw-r--r--xmake/modules/private/xrepo/action/clean.lua6
-rw-r--r--xmake/modules/private/xrepo/action/env.lua4
-rw-r--r--xmake/modules/private/xrepo/action/export.lua6
-rw-r--r--xmake/modules/private/xrepo/action/fetch.lua6
-rw-r--r--xmake/modules/private/xrepo/action/import.lua6
-rw-r--r--xmake/modules/private/xrepo/action/info.lua6
-rw-r--r--xmake/modules/private/xrepo/action/install.lua6
-rw-r--r--xmake/modules/private/xrepo/action/list-repo.lua4
-rw-r--r--xmake/modules/private/xrepo/action/remove.lua6
-rw-r--r--xmake/modules/private/xrepo/action/rm-repo.lua8
-rw-r--r--xmake/modules/private/xrepo/action/scan.lua6
-rw-r--r--xmake/modules/private/xrepo/action/search.lua6
-rw-r--r--xmake/modules/private/xrepo/action/update-repo.lua4
-rw-r--r--xmake/modules/privilege/sudo.lua2
22 files changed, 50 insertions, 58 deletions
diff --git a/xmake/actions/build/cleaner.lua b/xmake/actions/build/cleaner.lua
index 7c1eaed4b..552cde987 100644
--- a/xmake/actions/build/cleaner.lua
+++ b/xmake/actions/build/cleaner.lua
@@ -54,7 +54,7 @@ function cleanup()
try
{
function ()
- process.openv("xmake", argv, {stdout = path.join(os.tmpdir(), "cleaner.log"), detach = true}):close()
+ process.openv(os.programfile(), argv, {stdout = path.join(os.tmpdir(), "cleaner.log"), detach = true}):close()
end
}
end
diff --git a/xmake/actions/update/main.lua b/xmake/actions/update/main.lua
index 463815132..43ef974a5 100644
--- a/xmake/actions/update/main.lua
+++ b/xmake/actions/update/main.lua
@@ -149,10 +149,10 @@ function _uninstall()
end
else
if os.programdir():startswith("/usr/") then
- _sudo_v("xmake", {"lua", "rm", os.programdir()})
+ _sudo_v(os.programfile(), {"lua", "rm", os.programdir()})
for _, f in ipairs({"/usr/local/bin/xmake", "/usr/local/bin/xrepo", "/usr/bin/xmake", "/usr/bin/xrepo"}) do
if os.isfile(f) then
- _sudo_v("xmake", {"lua", "rm", f})
+ _sudo_v(os.programfile(), {"lua", "rm", f})
end
end
else
diff --git a/xmake/core/main.lua b/xmake/core/main.lua
index e813c849a..478f0181f 100644
--- a/xmake/core/main.lua
+++ b/xmake/core/main.lua
@@ -202,14 +202,6 @@ function main._init()
xmake._PROJECT_DIR = path.join(os.tmpdir(), "local")
xmake._PROJECT_FILE = path.join(xmake._PROJECT_DIR, xmake._NAME .. ".lua")
end
-
- -- add the directory of the program file (xmake) to $PATH environment
- local programfile = os.programfile()
- if programfile and os.isfile(programfile) then
- os.addenv("PATH", path.directory(programfile))
- else
- os.addenv("PATH", os.programdir())
- end
return true
end
diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua
index 27c0bd872..0a7dd231a 100644
--- a/xmake/modules/package/tools/xmake.lua
+++ b/xmake/modules/package/tools/xmake.lua
@@ -467,7 +467,7 @@ function install(package, configs, opt)
local repo_argv = {"repo"}
_set_builtin_argv(package, repo_argv)
table.join2(repo_argv, {"--add", repo:name(), repo:directory()})
- os.vrunv("xmake", repo_argv, {envs = envs})
+ os.vrunv(os.programfile(), repo_argv, {envs = envs})
end
-- pass configurations
@@ -488,7 +488,7 @@ function install(package, configs, opt)
end
-- do configure
- os.vrunv("xmake", argv, {envs = envs})
+ os.vrunv(os.programfile(), argv, {envs = envs})
-- do build
argv = {"build"}
@@ -500,7 +500,7 @@ function install(package, configs, opt)
if njob then
table.insert(argv, "--jobs=" .. njob)
end
- os.vrunv("xmake", argv, {envs = envs})
+ os.vrunv(os.programfile(), argv, {envs = envs})
-- do install
argv = {"install", "-y", "--nopkgs", "-o", package:installdir()}
@@ -508,5 +508,5 @@ function install(package, configs, opt)
if opt.target then
table.insert(argv, opt.target)
end
- os.vrunv("xmake", argv, {envs = envs})
+ os.vrunv(os.programfile(), argv, {envs = envs})
end
diff --git a/xmake/modules/private/service/remote_build/action.lua b/xmake/modules/private/service/remote_build/action.lua
index fcf3fff89..f3a919f14 100644
--- a/xmake/modules/private/service/remote_build/action.lua
+++ b/xmake/modules/private/service/remote_build/action.lua
@@ -29,5 +29,5 @@ end
function main()
config.load()
- remote_build_client.singleton():runcmd("xmake", xmake.argv())
+ remote_build_client.singleton():runcmd(os.programfile(), xmake.argv())
end
diff --git a/xmake/modules/private/utils/completer.lua b/xmake/modules/private/utils/completer.lua
index 3dc014227..f205ba865 100644
--- a/xmake/modules/private/utils/completer.lua
+++ b/xmake/modules/private/utils/completer.lua
@@ -272,7 +272,7 @@ function completer:_complete_option(options, segs, completing)
if current_options.project then
table.insert(args, 2, "--project=" .. current_options.project)
end
- os.execv("xmake", args)
+ os.execv(os.programfile(), args)
return true
end
diff --git a/xmake/modules/private/utils/statistics.lua b/xmake/modules/private/utils/statistics.lua
index 615cfce79..6ebe20c13 100644
--- a/xmake/modules/private/utils/statistics.lua
+++ b/xmake/modules/private/utils/statistics.lua
@@ -86,7 +86,7 @@ function post()
try
{
function ()
- process.openv("xmake", argv, {stdout = path.join(os.tmpdir(), projectname .. ".stats.log"), detach = true}):close()
+ process.openv(os.programfile(), argv, {stdout = path.join(os.tmpdir(), projectname .. ".stats.log"), detach = true}):close()
end
}
diff --git a/xmake/modules/private/xrepo/action/add-repo.lua b/xmake/modules/private/xrepo/action/add-repo.lua
index d2aef26e6..ecbd50aa3 100644
--- a/xmake/modules/private/xrepo/action/add-repo.lua
+++ b/xmake/modules/private/xrepo/action/add-repo.lua
@@ -59,7 +59,7 @@ function _add_repository(name, url, branch)
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -77,7 +77,7 @@ function _add_repository(name, url, branch)
if branch then
table.insert(repo_argv, branch)
end
- os.vexecv("xmake", repo_argv)
+ os.vexecv(os.programfile(), repo_argv)
end
-- main entry
diff --git a/xmake/modules/private/xrepo/action/clean.lua b/xmake/modules/private/xrepo/action/clean.lua
index 25e44db39..9336455df 100644
--- a/xmake/modules/private/xrepo/action/clean.lua
+++ b/xmake/modules/private/xrepo/action/clean.lua
@@ -62,7 +62,7 @@ function _clean_packages(packages)
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -72,7 +72,7 @@ function _clean_packages(packages)
if option.get("diagnosis") then
table.insert(config_argv, "-vD")
end
- os.vrunv("xmake", config_argv)
+ os.vrunv(os.programfile(), config_argv)
-- do clean
local require_argv = {"require", "--clean"}
@@ -91,7 +91,7 @@ function _clean_packages(packages)
if packages then
table.join2(require_argv, packages)
end
- os.vexecv("xmake", require_argv)
+ os.vexecv(os.programfile(), require_argv)
end
-- main entry
diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua
index b2e421f24..21b77211e 100644
--- a/xmake/modules/private/xrepo/action/env.lua
+++ b/xmake/modules/private/xrepo/action/env.lua
@@ -102,11 +102,11 @@ function _enter_project()
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
os.rm("*")
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
end
project.chdir(workdir)
end
diff --git a/xmake/modules/private/xrepo/action/export.lua b/xmake/modules/private/xrepo/action/export.lua
index 4c718bcb0..e5a0fc786 100644
--- a/xmake/modules/private/xrepo/action/export.lua
+++ b/xmake/modules/private/xrepo/action/export.lua
@@ -104,7 +104,7 @@ function _export_packages(packages)
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -143,7 +143,7 @@ function _export_packages(packages)
if #rcfiles > 0 then
envs.XMAKE_RCFILES = path.joinenv(rcfiles)
end
- os.vrunv("xmake", config_argv, {envs = envs})
+ os.vrunv(os.programfile(), config_argv, {envs = envs})
-- do export
local require_argv = {"require", "--export"}
@@ -191,7 +191,7 @@ function _export_packages(packages)
end
table.join2(require_argv, packages)
end
- os.vexecv("xmake", require_argv, {envs = envs})
+ os.vexecv(os.programfile(), require_argv, {envs = envs})
end
-- export packages in current project
diff --git a/xmake/modules/private/xrepo/action/fetch.lua b/xmake/modules/private/xrepo/action/fetch.lua
index 4455d21e7..06178d02b 100644
--- a/xmake/modules/private/xrepo/action/fetch.lua
+++ b/xmake/modules/private/xrepo/action/fetch.lua
@@ -113,7 +113,7 @@ function _fetch_packages(packages)
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -152,7 +152,7 @@ function _fetch_packages(packages)
if #rcfiles > 0 then
envs.XMAKE_RCFILES = path.joinenv(rcfiles)
end
- os.vrunv("xmake", config_argv, {envs = envs})
+ os.vrunv(os.programfile(), config_argv, {envs = envs})
-- do fetch
local require_argv = {"require", "--fetch"}
@@ -210,7 +210,7 @@ function _fetch_packages(packages)
end
table.join2(require_argv, packages)
end
- os.vexecv("xmake", require_argv, {envs = envs})
+ os.vexecv(os.programfile(), require_argv, {envs = envs})
end
-- main entry
diff --git a/xmake/modules/private/xrepo/action/import.lua b/xmake/modules/private/xrepo/action/import.lua
index 7ad0a1759..701478846 100644
--- a/xmake/modules/private/xrepo/action/import.lua
+++ b/xmake/modules/private/xrepo/action/import.lua
@@ -77,7 +77,7 @@ function _import_packages(packages)
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -105,7 +105,7 @@ function _import_packages(packages)
table.insert(config_argv, "-k")
table.insert(config_argv, kind)
end
- os.vrunv("xmake", config_argv)
+ os.vrunv(os.programfile(), config_argv)
-- do import
local require_argv = {"require", "--import"}
@@ -148,7 +148,7 @@ function _import_packages(packages)
table.insert(require_argv, "--extra=" .. extra_str)
end
table.join2(require_argv, packages)
- os.vexecv("xmake", require_argv)
+ os.vexecv(os.programfile(), require_argv)
end
-- import packages in current project
diff --git a/xmake/modules/private/xrepo/action/info.lua b/xmake/modules/private/xrepo/action/info.lua
index e89ac80af..39afea846 100644
--- a/xmake/modules/private/xrepo/action/info.lua
+++ b/xmake/modules/private/xrepo/action/info.lua
@@ -70,7 +70,7 @@ function _info_packages(packages)
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -98,7 +98,7 @@ function _info_packages(packages)
table.insert(config_argv, "-k")
table.insert(config_argv, kind)
end
- os.vrunv("xmake", config_argv)
+ os.vrunv(os.programfile(), config_argv)
-- show info
local require_argv = {"require", "--info"}
@@ -131,7 +131,7 @@ function _info_packages(packages)
table.insert(require_argv, "--extra=" .. extra_str)
end
table.join2(require_argv, packages)
- os.vexecv("xmake", require_argv)
+ os.vexecv(os.programfile(), require_argv)
end
-- main entry
diff --git a/xmake/modules/private/xrepo/action/install.lua b/xmake/modules/private/xrepo/action/install.lua
index 81420f51f..0c65773b0 100644
--- a/xmake/modules/private/xrepo/action/install.lua
+++ b/xmake/modules/private/xrepo/action/install.lua
@@ -143,7 +143,7 @@ function _install_packages(packages)
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -235,7 +235,7 @@ function _install_packages(packages)
if #rcfiles > 0 then
envs.XMAKE_RCFILES = path.joinenv(rcfiles)
end
- os.vrunv("xmake", config_argv, {envs = envs})
+ os.vrunv(os.programfile(), config_argv, {envs = envs})
-- do install
local require_argv = {"require"}
@@ -297,7 +297,7 @@ function _install_packages(packages)
end
table.join2(require_argv, packages)
end
- os.vexecv("xmake", require_argv, {envs = envs})
+ os.vexecv(os.programfile(), require_argv, {envs = envs})
end
-- main entry
diff --git a/xmake/modules/private/xrepo/action/list-repo.lua b/xmake/modules/private/xrepo/action/list-repo.lua
index 15861cad8..e9054beb7 100644
--- a/xmake/modules/private/xrepo/action/list-repo.lua
+++ b/xmake/modules/private/xrepo/action/list-repo.lua
@@ -54,7 +54,7 @@ function list_repository()
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -67,7 +67,7 @@ function list_repository()
if option.get("diagnosis") then
table.insert(repo_argv, "-D")
end
- os.vexecv("xmake", repo_argv)
+ os.vexecv(os.programfile(), repo_argv)
end
-- main entry
diff --git a/xmake/modules/private/xrepo/action/remove.lua b/xmake/modules/private/xrepo/action/remove.lua
index 38be707fb..71b52f79f 100644
--- a/xmake/modules/private/xrepo/action/remove.lua
+++ b/xmake/modules/private/xrepo/action/remove.lua
@@ -106,7 +106,7 @@ function _remove_packages(packages)
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -145,7 +145,7 @@ function _remove_packages(packages)
if #rcfiles > 0 then
envs.XMAKE_RCFILES = path.joinenv(rcfiles)
end
- os.vrunv("xmake", config_argv, {envs = envs})
+ os.vrunv(os.programfile(), config_argv, {envs = envs})
-- do remove
local require_argv = {"require", "--uninstall"}
@@ -184,7 +184,7 @@ function _remove_packages(packages)
end
table.join2(require_argv, packages)
end
- os.vexecv("xmake", require_argv)
+ os.vexecv(os.programfile(), require_argv)
end
-- main entry
diff --git a/xmake/modules/private/xrepo/action/rm-repo.lua b/xmake/modules/private/xrepo/action/rm-repo.lua
index 14040b7e5..2f5fd7ded 100644
--- a/xmake/modules/private/xrepo/action/rm-repo.lua
+++ b/xmake/modules/private/xrepo/action/rm-repo.lua
@@ -58,7 +58,7 @@ function remove_repository(name)
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -72,7 +72,7 @@ function remove_repository(name)
table.insert(repo_argv, "-D")
end
table.insert(repo_argv, name)
- os.vexecv("xmake", repo_argv)
+ os.vexecv(os.programfile(), repo_argv)
end
-- clear repository
@@ -83,7 +83,7 @@ function clear_repository()
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -96,7 +96,7 @@ function clear_repository()
if option.get("diagnosis") then
table.insert(repo_argv, "-D")
end
- os.vexecv("xmake", repo_argv)
+ os.vexecv(os.programfile(), repo_argv)
end
-- main entry
diff --git a/xmake/modules/private/xrepo/action/scan.lua b/xmake/modules/private/xrepo/action/scan.lua
index a156d6c65..b5d55a9b6 100644
--- a/xmake/modules/private/xrepo/action/scan.lua
+++ b/xmake/modules/private/xrepo/action/scan.lua
@@ -61,7 +61,7 @@ function _scan_packages(packages)
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -71,7 +71,7 @@ function _scan_packages(packages)
if option.get("diagnosis") then
table.insert(config_argv, "-vD")
end
- os.vrunv("xmake", config_argv)
+ os.vrunv(os.programfile(), config_argv)
-- do scan
local require_argv = {"require", "--scan"}
@@ -87,7 +87,7 @@ function _scan_packages(packages)
if packages then
table.join2(require_argv, packages)
end
- os.vexecv("xmake", require_argv)
+ os.vexecv(os.programfile(), require_argv)
end
-- main entry
diff --git a/xmake/modules/private/xrepo/action/search.lua b/xmake/modules/private/xrepo/action/search.lua
index e30cbe01a..a40adf620 100644
--- a/xmake/modules/private/xrepo/action/search.lua
+++ b/xmake/modules/private/xrepo/action/search.lua
@@ -60,7 +60,7 @@ function _search_packages(packages)
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -70,7 +70,7 @@ function _search_packages(packages)
if option.get("diagnosis") then
table.insert(config_argv, "-vD")
end
- os.vrunv("xmake", config_argv)
+ os.vrunv(os.programfile(), config_argv)
-- do search
local require_argv = {"require", "--search"}
@@ -81,7 +81,7 @@ function _search_packages(packages)
table.insert(require_argv, "-D")
end
table.join2(require_argv, packages)
- os.vexecv("xmake", require_argv)
+ os.vexecv(os.programfile(), require_argv)
end
-- main entry
diff --git a/xmake/modules/private/xrepo/action/update-repo.lua b/xmake/modules/private/xrepo/action/update-repo.lua
index b79e13b4d..8746a91be 100644
--- a/xmake/modules/private/xrepo/action/update-repo.lua
+++ b/xmake/modules/private/xrepo/action/update-repo.lua
@@ -54,7 +54,7 @@ function update_repository()
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
+ os.vrunv(os.programfile(), {"create", "-P", "."})
else
os.cd(workdir)
end
@@ -67,7 +67,7 @@ function update_repository()
if option.get("diagnosis") then
table.insert(repo_argv, "-D")
end
- os.vexecv("xmake", repo_argv)
+ os.vexecv(os.programfile(), repo_argv)
end
-- main entry
diff --git a/xmake/modules/privilege/sudo.lua b/xmake/modules/privilege/sudo.lua
index d1fd93b76..ac872ac67 100644
--- a/xmake/modules/privilege/sudo.lua
+++ b/xmake/modules/privilege/sudo.lua
@@ -85,7 +85,7 @@ function _lua(runner, luafile, luaargv)
end
-- run it with administrator permission
- _sudov(runner, "xmake", table.join(argv, luafile, luaargv))
+ _sudov(runner, os.programfile(), table.join(argv, luafile, luaargv))
end
-- has sudo?