diff options
| author | ruki <[email protected]> | 2018-04-14 00:54:38 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-04-13 23:27:52 +0800 |
| commit | 7467328ac81ac59a95125420b4dbca1bc3abc5f3 (patch) | |
| tree | 3f5bdaa14fdb149f27489be4493e7a0d35fdf8a1 /xmake/core/project/config.lua | |
| parent | 9e80cf8b5075b5eb4af1a2a0b652b486ddfe2da9 (diff) | |
add is_mode is_plat and is_arch builtin apis
Diffstat (limited to 'xmake/core/project/config.lua')
| -rw-r--r-- | xmake/core/project/config.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index 598212b03..e04fad967 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -237,6 +237,51 @@ function config.clear() config._CONFIGS = nil end +-- the current mode is belong to the given modes? +function config.is_mode(...) + + -- get the current mode + local mode = config.get("mode") + if not mode then return false end + + -- exists this mode? + for _, m in ipairs(table.join(...)) do + if m and type(m) == "string" and m == mode then + return true + end + end +end + +-- the current platform is belong to the given platforms? +function config.is_plat(...) + + -- get the current platform + local plat = config.get("plat") + if not plat then return false end + + -- exists this platform? and escape '-' + for _, p in ipairs(table.join(...)) do + if p and type(p) == "string" and plat:find("^" .. p:gsub("%-", "%%-") .. "$") then + return true + end + end +end + +-- the current platform is belong to the given architectures? +function config.is_arch(...) + + -- get the current architecture + local arch = config.get("arch") + if not arch then return false end + + -- exists this architecture? and escape '-' + for _, a in ipairs(table.join(...)) do + if a and type(a) == "string" and arch:find("^" .. a:gsub("%-", "%%-") .. "$") then + return true + end + end +end + -- dump the configure function config.dump() |
