summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-02-20 21:30:26 +0800
committerruki <[email protected]>2022-02-20 21:30:26 +0800
commitfb0bc7afac5aec7f3f42c0ad72abbe6b7cc6ac6f (patch)
treeb5902db1e7e9c3240c79090fe21f56370c39d8e3
parent1adac6da5c51607e020c8ea26c96e77cca88a909 (diff)
add builtin xrepo/envs
-rw-r--r--xmake/modules/private/xrepo/action/env.lua30
-rw-r--r--xmake/scripts/xrepo/envs/llvm-mingw.lua1
-rw-r--r--xmake/scripts/xrepo/envs/llvm.lua1
-rw-r--r--xmake/scripts/xrepo/envs/mingw-w64.lua1
-rw-r--r--xmake/scripts/xrepo/envs/msvc.lua3
-rw-r--r--xmake/scripts/xrepo/envs/python2.lua1
-rw-r--r--xmake/scripts/xrepo/envs/python3.lua1
7 files changed, 32 insertions, 6 deletions
diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua
index d2c04a9fe..264ab74c1 100644
--- a/xmake/modules/private/xrepo/action/env.lua
+++ b/xmake/modules/private/xrepo/action/env.lua
@@ -198,13 +198,20 @@ function _get_envsdir()
return path.join(global.directory(), "envs")
end
+-- get builtin environment directory
+function _get_envsdir_builtin()
+ return path.join(os.programdir(), "scripts", "xrepo", "envs")
+end
+
-- get bound environment or packages
function _get_boundenv(opt)
local bind = (opt and opt.bind) or option.get("bind")
if bind then
- local envfile = path.join(_get_envsdir(), bind .. ".lua")
- if envfile and os.isfile(envfile) then
- return envfile
+ for _, envsdir in ipairs({_get_envsdir(), _get_envsdir_builtin()}) do
+ local envfile = path.join(envsdir, bind .. ".lua")
+ if envfile and os.isfile(envfile) then
+ return envfile
+ end
end
end
return bind
@@ -431,9 +438,13 @@ function main()
if option.get("list") then
local envname = option.get("program")
if envname then
- local envfile = path.join(_get_envsdir(), envname .. ".lua")
- print("%s:", envfile)
- io.cat(envfile)
+ for _, envsdir in ipairs({_get_envsdir(), _get_envsdir_builtin()}) do
+ local envfile = path.join(envsdir, envname .. ".lua")
+ if os.isfile(envfile) then
+ print("%s:", envfile)
+ io.cat(envfile)
+ end
+ end
else
print("%s:", _get_envsdir())
local count = 0
@@ -442,6 +453,13 @@ function main()
print(" - %s", envname)
count = count + 1
end
+ print("%s (builtin):", _get_envsdir_builtin())
+ local count = 0
+ for _, envfile in ipairs(os.files(path.join(_get_envsdir_builtin(), "*.lua"))) do
+ local envname = path.basename(envfile)
+ print(" - %s", envname)
+ count = count + 1
+ end
print("envs(%d) found!", count)
end
elseif option.get("add") then
diff --git a/xmake/scripts/xrepo/envs/llvm-mingw.lua b/xmake/scripts/xrepo/envs/llvm-mingw.lua
new file mode 100644
index 000000000..6ee80a382
--- /dev/null
+++ b/xmake/scripts/xrepo/envs/llvm-mingw.lua
@@ -0,0 +1 @@
+add_requires("llvm-mingw")
diff --git a/xmake/scripts/xrepo/envs/llvm.lua b/xmake/scripts/xrepo/envs/llvm.lua
new file mode 100644
index 000000000..73201e4d9
--- /dev/null
+++ b/xmake/scripts/xrepo/envs/llvm.lua
@@ -0,0 +1 @@
+add_requires("llvm")
diff --git a/xmake/scripts/xrepo/envs/mingw-w64.lua b/xmake/scripts/xrepo/envs/mingw-w64.lua
new file mode 100644
index 000000000..6ee80a382
--- /dev/null
+++ b/xmake/scripts/xrepo/envs/mingw-w64.lua
@@ -0,0 +1 @@
+add_requires("llvm-mingw")
diff --git a/xmake/scripts/xrepo/envs/msvc.lua b/xmake/scripts/xrepo/envs/msvc.lua
new file mode 100644
index 000000000..f3f893841
--- /dev/null
+++ b/xmake/scripts/xrepo/envs/msvc.lua
@@ -0,0 +1,3 @@
+if is_host("windows") then
+ set_toolchains("msvc")
+end
diff --git a/xmake/scripts/xrepo/envs/python2.lua b/xmake/scripts/xrepo/envs/python2.lua
new file mode 100644
index 000000000..d338ef356
--- /dev/null
+++ b/xmake/scripts/xrepo/envs/python2.lua
@@ -0,0 +1 @@
+add_requires("python 2.x")
diff --git a/xmake/scripts/xrepo/envs/python3.lua b/xmake/scripts/xrepo/envs/python3.lua
new file mode 100644
index 000000000..63cc2e643
--- /dev/null
+++ b/xmake/scripts/xrepo/envs/python3.lua
@@ -0,0 +1 @@
+add_requires("python 3.x")