summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-03 09:29:35 +0800
committerruki <[email protected]>2015-06-03 09:29:35 +0800
commit08bba742c061c93f28c14499fa17af2f1edc2df8 (patch)
tree769eb97f37ada860b6e4c29f6ca247ccf70cbdbc /xmake/scripts
parent03f445c175b2f8e4768bbff28065f935b9fe3201 (diff)
add private configure for preprocessor
Diffstat (limited to 'xmake/scripts')
-rw-r--r--xmake/scripts/base/config.lua8
-rw-r--r--xmake/scripts/base/global.lua4
-rw-r--r--xmake/scripts/base/preprocessor.lua36
-rw-r--r--xmake/scripts/platform/macosx/_macosx.lua1
4 files changed, 41 insertions, 8 deletions
diff --git a/xmake/scripts/base/config.lua b/xmake/scripts/base/config.lua
index 877f7d026..f53338a05 100644
--- a/xmake/scripts/base/config.lua
+++ b/xmake/scripts/base/config.lua
@@ -153,7 +153,7 @@ function config._make()
-- get configs from all targets
for k, v in pairs(configs) do
- if type(k) == "string" and not k:startswith("_") then
+ if type(k) == "string" and not k:find("_%u+") then
current[k] = v
end
end
@@ -242,7 +242,7 @@ function config.savexconf()
assert(configs)
-- open the configure file
- local path = options.project .. "/xmake.xconf"
+ local path = options.project .. "/.xmake.xconf"
local file = io.open(path, "w")
if not file then
-- error
@@ -288,7 +288,7 @@ function config.loadxconf()
end
-- load and execute the xmake.xconf
- local path = options.project .. "/xmake.xconf"
+ local path = options.project .. "/.xmake.xconf"
local newenv = preprocessor.loadfile(path, "config", configures, {"target"})
-- exists local configures?
@@ -370,7 +370,7 @@ function config.dump()
assert(config._CURRENT)
-- dump
- utils.dump(config._CURRENT)
+ utils.dump(config._CURRENT, "__%w*")
end
diff --git a/xmake/scripts/base/global.lua b/xmake/scripts/base/global.lua
index 095d49adb..64836bd2c 100644
--- a/xmake/scripts/base/global.lua
+++ b/xmake/scripts/base/global.lua
@@ -120,7 +120,7 @@ function global._make()
-- make current global configure
for k, v in pairs(configs) do
- if type(k) == "string" and not k:startswith("_") then
+ if type(k) == "string" and not k:find("_%u+") then
current[k] = v
end
end
@@ -269,7 +269,7 @@ function global.dump()
assert(global._CURRENT)
-- dump
- utils.dump(global._CURRENT)
+ utils.dump(global._CURRENT, "__%w*")
end
diff --git a/xmake/scripts/base/preprocessor.lua b/xmake/scripts/base/preprocessor.lua
index 235ae8011..10a64593b 100644
--- a/xmake/scripts/base/preprocessor.lua
+++ b/xmake/scripts/base/preprocessor.lua
@@ -79,7 +79,7 @@ function preprocessor._register(env, names, filter)
local _current = env._current
assert(_current)
- -- init ldflags
+ -- init the configure entry
_current[name] = _current[name] or {}
-- get arguments
@@ -109,7 +109,39 @@ function preprocessor._init(root, configures, scopes, filter, import)
-- enter new environment
local newenv = {}
local oldenv = getfenv()
- setmetatable(newenv, {__index = _G})
+ setmetatable(newenv, { __index = function(tbl, key)
+ -- private configure entry? we can get it directly and need not register it
+ if key and type(key) == "string" and key:startswith("__") then
+
+ return function(...)
+
+ -- check
+ local _current = newenv._current
+ assert(_current)
+
+ -- init the configure entry
+ _current[key] = _current[key] or {}
+
+ -- get arguments
+ local arg = arg or {...}
+ if table.getn(arg) == 0 then
+ -- no argument
+ _current[key] = nil
+ elseif table.getn(arg) == 1 then
+ -- save only one argument
+ _current[key] = preprocessor._filter(newenv, arg[1], filter)
+ else
+ -- save all arguments
+ for i, v in ipairs(arg) do
+ _current[key][i] = preprocessor._filter(newenv, v, filter)
+ end
+ end
+ end
+ end
+
+ -- get it from the global table
+ return rawget(_G, key)
+ end})
setfenv(1, newenv)
-- register all configures
diff --git a/xmake/scripts/platform/macosx/_macosx.lua b/xmake/scripts/platform/macosx/_macosx.lua
index 6ab67da0f..8ff4d31cc 100644
--- a/xmake/scripts/platform/macosx/_macosx.lua
+++ b/xmake/scripts/platform/macosx/_macosx.lua
@@ -59,6 +59,7 @@ function _macosx.make(configs)
-- init xcode sdk directory
configs.xcode_sdkdir = config.get("xcode_dir") .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. config.get("xcode_sdkver") .. ".sdk"
+
end
-- get the option menu for action: xmake config or global