summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-03-15 00:44:44 +0800
committerruki <[email protected]>2022-03-15 00:44:44 +0800
commitbc501387029826a8dbcb6a5b7776fd8f17e37d2f (patch)
tree0e7e7e6d6b01d476a33783cb1865e5d42b607a2f
parent1ae43ee981c8dc36735b7810b6ba14e1e49b3dae (diff)
improve xrepo export
-rw-r--r--xmake/modules/private/xrepo/action/export.lua36
1 files changed, 29 insertions, 7 deletions
diff --git a/xmake/modules/private/xrepo/action/export.lua b/xmake/modules/private/xrepo/action/export.lua
index e6c4b3ffc..bb33429e1 100644
--- a/xmake/modules/private/xrepo/action/export.lua
+++ b/xmake/modules/private/xrepo/action/export.lua
@@ -72,9 +72,25 @@ end
-- export packages
function _export_packages(packages)
+ -- is package configuration file? e.g. xrepo export xxx.lua
+ --
+ -- xxx.lua
+ -- add_requires("libpng", {system = false})
+ -- add_requireconfs("libpng.*", {configs = {shared = true}})
+ local packagefile
+ if type(packages) == "string" or #packages == 1 then
+ local filepath = table.unwrap(packages)
+ if type(filepath) == "string" and filepath:endswith(".lua") and os.isfile(filepath) then
+ packagefile = path.absolute(filepath)
+ end
+ end
+
-- enter working project directory
- local oldir = os.curdir()
- 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)
@@ -82,9 +98,13 @@ function _export_packages(packages)
else
os.cd(workdir)
end
+ if packagefile then
+ assert(os.isfile("xmake.lua"), "xmake.lua not found!")
+ io.writefile("xmake.lua", ('includes("%s")\ntarget("test", {kind = "phony"})'):format((packagefile:gsub("\\", "/"))))
+ end
-- do configure first
- local config_argv = {"f", "-c"}
+ local config_argv = {"f", "-c", "--require=n"}
if option.get("verbose") then
table.insert(config_argv, "-v")
end
@@ -150,11 +170,13 @@ function _export_packages(packages)
raise(errors)
end
end
- if extra then
- local extra_str = string.serialize(extra, {indent = false, strip = true})
- table.insert(require_argv, "--extra=" .. extra_str)
+ if not packagefile then
+ if extra then
+ local extra_str = string.serialize(extra, {indent = false, strip = true})
+ table.insert(require_argv, "--extra=" .. extra_str)
+ end
+ table.join2(require_argv, packages)
end
- table.join2(require_argv, packages)
os.vexecv("xmake", require_argv)
end