diff options
| author | ruki <[email protected]> | 2015-05-13 09:40:49 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-05-13 09:40:49 +0800 |
| commit | ba92342286d9fabb29c97acac4c5deed0906a25b (patch) | |
| tree | c651ec1678d84498dfd6d3dbd6ba585bd4abbdde /xmake/scripts | |
| parent | 905e90debb2a79993b16d5761c2eced8fdfad4cc (diff) | |
add host option
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/_xmake_main.lua | 2 | ||||
| -rw-r--r-- | xmake/scripts/action/config.lua | 27 | ||||
| -rw-r--r-- | xmake/scripts/base/main.lua | 1 | ||||
| -rw-r--r-- | xmake/scripts/base/option.lua | 6 |
4 files changed, 23 insertions, 13 deletions
diff --git a/xmake/scripts/_xmake_main.lua b/xmake/scripts/_xmake_main.lua index 215db9323..41977a6b3 100644 --- a/xmake/scripts/_xmake_main.lua +++ b/xmake/scripts/_xmake_main.lua @@ -23,7 +23,7 @@ -- init namespace: xmake xmake = xmake or {} xmake._ARGV = _ARGV -xmake._PLAT = _PLAT +xmake._HOST = _HOST xmake._ARCH = _ARCH xmake._VERSION = "XMake v1.0.1" xmake._PROGRAM_DIR = _PROGRAM_DIR diff --git a/xmake/scripts/action/config.lua b/xmake/scripts/action/config.lua index b9b33b836..030c1f9fa 100644 --- a/xmake/scripts/action/config.lua +++ b/xmake/scripts/action/config.lua @@ -35,7 +35,7 @@ function config._save() assert(options) -- open the configure file - local path = options.project .. "/.config.lua" + local path = options.project .. "/xmake.conf" local file = io.open(path, "w") if not file then -- error @@ -70,7 +70,7 @@ function config._load() assert(target) -- open the configure file - local path = options.project .. "/.config.lua" + local path = options.project .. "/xmake.conf" local file = loadfile(path) if file then -- execute it @@ -85,6 +85,14 @@ function config._load() -- check assert(cfg and type(cfg) == "table") + -- clear configs if the host environment has been changed + if cfg[target] and cfg[target].host ~= xmake._HOST then + cfg = {} + end + if cfg.all and cfg.all.host ~= xmake._HOST then + cfg = {} + end + -- merges configs to xmake._CONFIGS xmake._CONFIGS = cfg end @@ -121,7 +129,11 @@ function config._load() -- save the default option to the target if not configs[target][k] then - configs[target][k] = utils.ifelse(v == "auto", config._auto(k), v) + if v == "auto" then + configs[target][k] = config._auto(k) + else + configs[target][k] = v + end end end end @@ -129,10 +141,10 @@ end -- auto configs function config._auto(name) - - -- get platform - if name == "plat" then - return xmake._PLAT + + -- get platform or host + if name == "plat" or name == "host" then + return xmake._HOST -- get architecture elseif name == "arch" then return xmake._ARCH @@ -168,6 +180,7 @@ function config.done() end -- ok + print("configure ok!") return true end diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua index d4ae4f3d7..77af72118 100644 --- a/xmake/scripts/base/main.lua +++ b/xmake/scripts/base/main.lua @@ -144,6 +144,7 @@ local menu = , " - debug" , " - release" , " - profile" } + , {'-', "host", "kv", "auto", "The current host environment." } , {} , {'o', "output", "kv", "build", "Set the build directory" } diff --git a/xmake/scripts/base/option.lua b/xmake/scripts/base/option.lua index 3aaa788cd..60b769dd8 100644 --- a/xmake/scripts/base/option.lua +++ b/xmake/scripts/base/option.lua @@ -250,11 +250,6 @@ function option.init(argv, menu) end end - -- dump options --- for a, b in pairs(xmake._OPTIONS) do --- print(a, b) --- end - -- ok return true end @@ -265,6 +260,7 @@ function option.print_menu(action) -- no action? print main menu if not action then option.print_main() + return end -- the menu |
