summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-02-18 00:47:44 +0800
committerruki <[email protected]>2022-02-18 00:47:44 +0800
commit13941a161ff0461e1a42e0f196ecea0e6e4701fa (patch)
treeb67f09d3b61cd16f609f9354e0042ade61bd12d1
parentcdf8579ede7256d63f6d9c83d77b44cd9547b964 (diff)
fix xrepo install/fetch
-rw-r--r--xmake/modules/private/xrepo/action/fetch.lua37
-rw-r--r--xmake/modules/private/xrepo/action/install.lua35
2 files changed, 45 insertions, 27 deletions
diff --git a/xmake/modules/private/xrepo/action/fetch.lua b/xmake/modules/private/xrepo/action/fetch.lua
index 886e470d9..d3afb5bd4 100644
--- a/xmake/modules/private/xrepo/action/fetch.lua
+++ b/xmake/modules/private/xrepo/action/fetch.lua
@@ -83,31 +83,37 @@ end
-- fetch packages
function _fetch_packages(packages)
- -- enter working project directory
- local workdir = path.join(os.tmpdir(), "xrepo", "working")
- if not os.isdir(workdir) then
- os.mkdir(workdir)
- os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
- else
- os.cd(workdir)
- end
-
- -- is package configuration file? e.g. xrepo fetch xxx.lua
+ -- is package configuration file? e.g. xrepo install xxx.lua
--
-- xxx.lua
-- add_requires("libpng", {system = false})
-- add_requireconfs("libpng.*", {configs = {shared = true}})
local filemode = false
+ local rcfiles = {}
if type(packages) == "string" or #packages == 1 then
local packagefile = table.unwrap(packages)
if type(packagefile) == "string" and packagefile:endswith(".lua") and os.isfile(packagefile) then
- assert(os.isfile("xmake.lua"), "xmake.lua not found!")
- os.cp(packagefile, "xmake.lua")
+ table.insert(rcfiles, path.absolute(packagefile))
filemode = true
end
end
+ -- add includes to rcfiles
+ local includes = option.get("includes")
+ if includes then
+ table.join2(rcfiles, path.splitenv(includes))
+ end
+
+ -- enter working project directory
+ local workdir = path.join(os.tmpdir(), "xrepo", "working")
+ if not os.isdir(workdir) then
+ os.mkdir(workdir)
+ os.cd(workdir)
+ os.vrunv("xmake", {"create", "-P", "."})
+ else
+ os.cd(workdir)
+ end
+
-- do configure first
local config_argv = {"f", "-c"}
if option.get("verbose") then
@@ -137,7 +143,10 @@ function _fetch_packages(packages)
table.insert(config_argv, "-k")
table.insert(config_argv, kind)
end
- local envs = {XMAKE_RCFILES = option.get("includes")}
+ local envs = {}
+ if #rcfiles > 0 then
+ envs.XMAKE_RCFILES = path.joinenv(rcfiles)
+ end
os.vrunv("xmake", config_argv, {envs = envs})
-- do fetch
diff --git a/xmake/modules/private/xrepo/action/install.lua b/xmake/modules/private/xrepo/action/install.lua
index 1daa34e14..0fc4013d1 100644
--- a/xmake/modules/private/xrepo/action/install.lua
+++ b/xmake/modules/private/xrepo/action/install.lua
@@ -98,31 +98,37 @@ end
-- install packages
function _install_packages(packages)
- -- enter working project directory
- local workdir = path.join(os.tmpdir(), "xrepo", "working")
- if not os.isdir(workdir) then
- os.mkdir(workdir)
- os.cd(workdir)
- os.vrunv("xmake", {"create", "-P", "."})
- else
- os.cd(workdir)
- end
-
-- is package configuration file? e.g. xrepo install xxx.lua
--
-- xxx.lua
-- add_requires("libpng", {system = false})
-- add_requireconfs("libpng.*", {configs = {shared = true}})
local filemode = false
+ local rcfiles = {}
if type(packages) == "string" or #packages == 1 then
local packagefile = table.unwrap(packages)
if type(packagefile) == "string" and packagefile:endswith(".lua") and os.isfile(packagefile) then
- assert(os.isfile("xmake.lua"), "xmake.lua not found!")
- os.cp(packagefile, "xmake.lua")
+ table.insert(rcfiles, path.absolute(packagefile))
filemode = true
end
end
+ -- add includes to rcfiles
+ local includes = option.get("includes")
+ if includes then
+ table.join2(rcfiles, path.splitenv(includes))
+ end
+
+ -- enter working project directory
+ local workdir = path.join(os.tmpdir(), "xrepo", "working")
+ if not os.isdir(workdir) then
+ os.mkdir(workdir)
+ os.cd(workdir)
+ os.vrunv("xmake", {"create", "-P", "."})
+ else
+ os.cd(workdir)
+ end
+
-- disable xmake-stats
os.setenv("XMAKE_STATS", "false")
@@ -187,7 +193,10 @@ function _install_packages(packages)
if option.get("target_minver") then
table.insert(config_argv, "--target_minver=" .. option.get("target_minver"))
end
- local envs = {XMAKE_RCFILES = option.get("includes")}
+ local envs = {}
+ if #rcfiles > 0 then
+ envs.XMAKE_RCFILES = path.joinenv(rcfiles)
+ end
os.vrunv("xmake", config_argv, {envs = envs})
-- do install