summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-10-29 00:45:53 +0800
committerruki <[email protected]>2021-10-29 00:45:53 +0800
commit9eedba8ac9cd4832e20343a0eda720b9c1ceb5a9 (patch)
treece172eaa9a79a168c4f35468dea3bf6231f2e700
parentb8baa986376112e67221fa8b982d2b3197e1d919 (diff)
add xmake.branch
-rw-r--r--xmake/core/base/xmake.lua7
-rw-r--r--xmake/core/sandbox/modules/xmake.lua1
2 files changed, 7 insertions, 1 deletions
diff --git a/xmake/core/base/xmake.lua b/xmake/core/base/xmake.lua
index 239540a5a..837742af2 100644
--- a/xmake/core/base/xmake.lua
+++ b/xmake/core/base/xmake.lua
@@ -29,7 +29,7 @@ function xmake.name()
return xmake._NAME or "xmake"
end
--- get xmake version
+-- get xmake version, e.g. v2.5.8+dev.d4cff6e11
function xmake.version()
if xmake._VERSION_CACHE == nil then
xmake._VERSION_CACHE = semver.new(xmake._VERSION) or false
@@ -37,6 +37,11 @@ function xmake.version()
return xmake._VERSION_CACHE or nil
end
+-- get the git branch of xmake version, e.g. build: {"dev", "d4cff6e11"}
+function xmake.branch()
+ return xmake.version():build()[1]
+end
+
-- get the program directory
function xmake.programdir()
return xmake._PROGRAM_DIR
diff --git a/xmake/core/sandbox/modules/xmake.lua b/xmake/core/sandbox/modules/xmake.lua
index fcc6437e1..70e5f5e36 100644
--- a/xmake/core/sandbox/modules/xmake.lua
+++ b/xmake/core/sandbox/modules/xmake.lua
@@ -26,6 +26,7 @@ local sandbox_xmake = sandbox_xmake or {}
-- inherit some builtin interfaces
sandbox_xmake.version = xmake.version
+sandbox_xmake.branch = xmake.branch
sandbox_xmake.programdir = xmake.programdir
sandbox_xmake.programfile = xmake.programfile
sandbox_xmake.luajit = xmake.luajit