Skip to content

Commit

Permalink
Merge pull request #4658 from xmake-io/xmakenv
Browse files Browse the repository at this point in the history
remove PATH in xmake
  • Loading branch information
waruqi committed Jan 26, 2024
2 parents 8aeb3f7 + c4e9dcd commit 445e43b
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 58 deletions.
2 changes: 1 addition & 1 deletion xmake/actions/build/cleaner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions xmake/actions/update/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions xmake/core/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions xmake/modules/package/tools/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"}
Expand All @@ -500,13 +500,13 @@ 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()}
_set_builtin_argv(package, argv)
if opt.target then
table.insert(argv, opt.target)
end
os.vrunv("xmake", argv, {envs = envs})
os.vrunv(os.programfile(), argv, {envs = envs})
end
2 changes: 1 addition & 1 deletion xmake/modules/private/service/remote_build/action.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion xmake/modules/private/utils/completer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion xmake/modules/private/utils/statistics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions xmake/modules/private/xrepo/action/add-repo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions xmake/modules/private/xrepo/action/clean.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions xmake/modules/private/xrepo/action/env.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions xmake/modules/private/xrepo/action/export.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions xmake/modules/private/xrepo/action/fetch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions xmake/modules/private/xrepo/action/import.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions xmake/modules/private/xrepo/action/info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions xmake/modules/private/xrepo/action/install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions xmake/modules/private/xrepo/action/list-repo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions xmake/modules/private/xrepo/action/remove.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions xmake/modules/private/xrepo/action/rm-repo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions xmake/modules/private/xrepo/action/scan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"}
Expand All @@ -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
Expand Down
Loading

0 comments on commit 445e43b

Please sign in to comment.