From 13941a161ff0461e1a42e0f196ecea0e6e4701fa Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 18 Feb 2022 00:47:44 +0800 Subject: fix xrepo install/fetch --- xmake/modules/private/xrepo/action/fetch.lua | 37 ++++++++++++++++---------- xmake/modules/private/xrepo/action/install.lua | 35 +++++++++++++++--------- 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 -- cgit v1.3.1