summaryrefslogtreecommitdiff
path: root/xmake/core/project/config.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-07-19 21:12:51 +0800
committerruki <[email protected]>2017-07-19 21:12:51 +0800
commit1ea7269e5078041df9c170b020953273ea176675 (patch)
treecade92c9dd13d9bc69f62007d5f41f717c4124ff /xmake/core/project/config.lua
parent2b52ec7d069e2a5b297b52f6696f70f3d53ff385 (diff)
fix config and add readonly mode
Diffstat (limited to 'xmake/core/project/config.lua')
-rw-r--r--xmake/core/project/config.lua33
1 files changed, 22 insertions, 11 deletions
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
index 643665173..1fa1ac856 100644
--- a/xmake/core/project/config.lua
+++ b/xmake/core/project/config.lua
@@ -67,31 +67,42 @@ end
-- get the current given configure
function config.get(name)
- -- get configs
- local configs = config._CONFIGS or {}
-
-- get it
- local value = configs[name]
- if type(value) == "string" and value == "auto" then
- value = nil
+ local value = nil
+ if config._CONFIGS then
+ value = config._CONFIGS[name]
+ if type(value) == "string" and value == "auto" then
+ value = nil
+ end
end
-- get it
return value
end
+-- this config name is readonly?
+function config.readonly(name)
+ return config._MODES and config._MODES["__readonly_" .. name]
+end
+
-- set the given configure to the current
-function config.set(name, value)
+function config.set(name, value, readonly)
-- check
assert(name)
- -- get configs
- local configs = config._CONFIGS or {}
- config._CONFIGS = configs
+ -- check readonly
+ assert(not config.readonly(name), "cannot set readonly config: " .. name)
-- set it
- configs[name] = value
+ config._CONFIGS = config._CONFIGS or {}
+ config._CONFIGS[name] = value
+
+ -- mark as readonly
+ if readonly then
+ config._MODES = config._MODES or {}
+ config._MODES["__readonly_" .. name] = true
+ end
end
-- get all options