summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-02-24 23:57:30 +0800
committerruki <[email protected]>2022-02-24 23:57:30 +0800
commit13f33d137a5a884e077bda3e71b347a74d9023f5 (patch)
tree1d075c4384d205cbc29336be4d47fae97016e762
parent83b50994a3c31b2b65e50a95a00fb7fc5cb22cf7 (diff)
improve xrepo install/fetch
-rw-r--r--xmake/modules/private/xrepo/action/fetch.lua23
-rw-r--r--xmake/modules/private/xrepo/action/install.lua25
2 files changed, 31 insertions, 17 deletions
diff --git a/xmake/modules/private/xrepo/action/fetch.lua b/xmake/modules/private/xrepo/action/fetch.lua
index d3afb5bd4..94a7bb709 100644
--- a/xmake/modules/private/xrepo/action/fetch.lua
+++ b/xmake/modules/private/xrepo/action/fetch.lua
@@ -88,24 +88,27 @@ function _fetch_packages(packages)
-- xxx.lua
-- add_requires("libpng", {system = false})
-- add_requireconfs("libpng.*", {configs = {shared = true}})
- local filemode = false
- local rcfiles = {}
+ local packagefile
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
- table.insert(rcfiles, path.absolute(packagefile))
- filemode = true
+ local filepath = table.unwrap(packages)
+ if type(filepath) == "string" and filepath:endswith(".lua") and os.isfile(filepath) then
+ packagefile = path.absolute(filepath)
end
end
-- add includes to rcfiles
+ local 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")
+ local subdir = "working"
+ if packagefile then
+ subdir = subdir .. "-" .. hash.uuid(packagefile):split('-')[1]
+ end
+ local workdir = path.join(os.tmpdir(), "xrepo", subdir)
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
@@ -113,6 +116,10 @@ function _fetch_packages(packages)
else
os.cd(workdir)
end
+ if packagefile then
+ assert(os.isfile("xmake.lua"), "xmake.lua not found!")
+ os.cp(packagefile, "xmake.lua")
+ end
-- do configure first
local config_argv = {"f", "-c"}
@@ -201,7 +208,7 @@ function _fetch_packages(packages)
local extra_str = string.serialize(extra, {indent = false, strip = true})
table.insert(require_argv, "--extra=" .. extra_str)
end
- if not filemode then
+ if not packagefile then
table.join2(require_argv, packages)
end
os.vexecv("xmake", require_argv, {envs = envs})
diff --git a/xmake/modules/private/xrepo/action/install.lua b/xmake/modules/private/xrepo/action/install.lua
index 34759ca0c..e1849eb3d 100644
--- a/xmake/modules/private/xrepo/action/install.lua
+++ b/xmake/modules/private/xrepo/action/install.lua
@@ -103,24 +103,27 @@ function _install_packages(packages)
-- xxx.lua
-- add_requires("libpng", {system = false})
-- add_requireconfs("libpng.*", {configs = {shared = true}})
- local filemode = false
- local rcfiles = {}
+ local packagefile
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
- table.insert(rcfiles, path.absolute(packagefile))
- filemode = true
+ local filepath = table.unwrap(packages)
+ if type(filepath) == "string" and filepath:endswith(".lua") and os.isfile(filepath) then
+ packagefile = path.absolute(filepath)
end
end
-- add includes to rcfiles
+ local 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")
+ local subdir = "working"
+ if packagefile then
+ subdir = subdir .. "-" .. hash.uuid(packagefile):split('-')[1]
+ end
+ local workdir = path.join(os.tmpdir(), "xrepo", subdir)
if not os.isdir(workdir) then
os.mkdir(workdir)
os.cd(workdir)
@@ -128,6 +131,10 @@ function _install_packages(packages)
else
os.cd(workdir)
end
+ if packagefile then
+ assert(os.isfile("xmake.lua"), "xmake.lua not found!")
+ os.cp(packagefile, "xmake.lua")
+ end
-- disable xmake-stats
os.setenv("XMAKE_STATS", "false")
@@ -197,7 +204,7 @@ function _install_packages(packages)
if #rcfiles > 0 then
envs.XMAKE_RCFILES = path.joinenv(rcfiles)
end
- if filemode then
+ if packagefile then
-- https://github.com/xmake-io/xmake/issues/2084
os.execv("xmake", config_argv, {envs = envs})
else
@@ -254,7 +261,7 @@ function _install_packages(packages)
local extra_str = string.serialize(extra, {indent = false, strip = true})
table.insert(require_argv, "--extra=" .. extra_str)
end
- if not filemode then
+ if not packagefile then
table.join2(require_argv, packages)
end
os.vexecv("xmake", require_argv, {envs = envs})