diff options
| author | ruki <[email protected]> | 2015-05-12 23:02:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-05-12 23:02:30 +0800 |
| commit | 905e90debb2a79993b16d5761c2eced8fdfad4cc (patch) | |
| tree | bc482ff7c9659ee89d0ed20ef7ddb9d403d46f3e /xmake/scripts | |
| parent | 97e6e62e5061f029b1195784671dea9d19211782 (diff) | |
auto-configure plat and arch
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/_xmake_main.lua | 2 | ||||
| -rw-r--r-- | xmake/scripts/action/config.lua | 72 |
2 files changed, 19 insertions, 55 deletions
diff --git a/xmake/scripts/_xmake_main.lua b/xmake/scripts/_xmake_main.lua index 8eec5251f..215db9323 100644 --- a/xmake/scripts/_xmake_main.lua +++ b/xmake/scripts/_xmake_main.lua @@ -23,6 +23,8 @@ -- init namespace: xmake xmake = xmake or {} xmake._ARGV = _ARGV +xmake._PLAT = _PLAT +xmake._ARCH = _ARCH xmake._VERSION = "XMake v1.0.1" xmake._PROGRAM_DIR = _PROGRAM_DIR xmake._SCRIPTS_DIR = _PROGRAM_DIR .. "/scripts/" diff --git a/xmake/scripts/action/config.lua b/xmake/scripts/action/config.lua index af16afad5..b9b33b836 100644 --- a/xmake/scripts/action/config.lua +++ b/xmake/scripts/action/config.lua @@ -58,7 +58,7 @@ function config._save() return true end --- load configs to xmake._OPTIONS from the configure file +-- load configs function config._load() -- the options @@ -121,71 +121,35 @@ function config._load() -- save the default option to the target if not configs[target][k] then - configs[target][k] = v + configs[target][k] = utils.ifelse(v == "auto", config._auto(k), v) end end end end --- save config -function config._save_option(file, option) - - -- check - assert(file and option) +-- auto configs +function config._auto(name) - -- save string - if type(option) == "string" then - file:write(string.format("%q", option)) - -- save boolean - elseif type(option) == "boolean" then - file:write(tostring(option)) - -- save number - elseif type(option) == "number" then - file:write(option) - -- save table - elseif type(option) == "table" then - - -- save head - file:write("{\n") - - -- save body - local i = 0 - for k, v in pairs(option) do - - -- skip --project and --file - if type(k) == "string" and not k:startswith("_") and k ~= "project" and k ~= "file" and k ~= "verbose" then - - -- save separator - file:write(utils.ifelse(i == 0, " ", ", "), k, " = ") - - -- save this key: value - if not config._save_option(file, v) then - return false - end - - -- save newline - file:write("\n") - i = i + 1 - end - end - - -- save tail - file:write("}\n") - else - -- error - utils.error("invalid option type: %s", type(option)) - return false - end + -- get platform + if name == "plat" then + return xmake._PLAT + -- get architecture + elseif name == "arch" then + return xmake._ARCH + end - -- ok - return true + -- unknown + utils.error("unknown config: %s", name) + return "unknown" end -- dump configs function config._dump() -- dump - utils.dump(xmake._CONFIGS, "configs = ") + if xmake._OPTIONS.verbose then + utils.dump(xmake._CONFIGS, "configs = ") + end end @@ -195,8 +159,6 @@ function config.done() -- load configs config._load() - -- TODO - -- dump configs config._dump() |
