summaryrefslogtreecommitdiff
path: root/xmake/scripts/base
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-10 11:51:06 +0800
committerruki <[email protected]>2015-06-10 11:51:06 +0800
commit21829afa8efa18ca57e4bd9b322c6be1f84d392d (patch)
treee3af545e1c76f83824fbd63f8f0043363252cd9f /xmake/scripts/base
parent177400e62e74d5ad3539573cfd3143cd19d3d30f (diff)
fix merge option and config for boolean value
Diffstat (limited to 'xmake/scripts/base')
-rw-r--r--xmake/scripts/base/config.lua2
-rw-r--r--xmake/scripts/base/global.lua2
-rw-r--r--xmake/scripts/base/main.lua2
-rw-r--r--xmake/scripts/base/option.lua13
-rw-r--r--xmake/scripts/base/project.lua7
5 files changed, 16 insertions, 10 deletions
diff --git a/xmake/scripts/base/config.lua b/xmake/scripts/base/config.lua
index 62db41dee..6d69de5ff 100644
--- a/xmake/scripts/base/config.lua
+++ b/xmake/scripts/base/config.lua
@@ -304,7 +304,7 @@ function config.load()
if config._need(k) then
-- save the default option to the target
- if not target[k] then
+ if nil == target[k] then
target[k] = v
end
end
diff --git a/xmake/scripts/base/global.lua b/xmake/scripts/base/global.lua
index 7032ba991..32b509d6d 100644
--- a/xmake/scripts/base/global.lua
+++ b/xmake/scripts/base/global.lua
@@ -195,7 +195,7 @@ function global.load()
if global._need(k) then
-- save the default option
- if not configs[k] then
+ if nil == configs[k] then
configs[k] = v
end
end
diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua
index 77db5b2de..a46c3ea81 100644
--- a/xmake/scripts/base/main.lua
+++ b/xmake/scripts/base/main.lua
@@ -163,7 +163,7 @@ function main._prepare_project()
-- merge the default options
for k, v in pairs(options._DEFAULTS) do
- if not options[k] then options[k] = v end
+ if nil == options[k] then options[k] = v end
end
-- load xmake.lua file
diff --git a/xmake/scripts/base/option.lua b/xmake/scripts/base/option.lua
index a6e26907f..8ad3613c2 100644
--- a/xmake/scripts/base/option.lua
+++ b/xmake/scripts/base/option.lua
@@ -221,6 +221,13 @@ function option.init(argv, menu)
return false
end
+ -- value is "true" or "false", translate it
+ if type(value) == "string" then
+ if value == "true" then value = true
+ elseif value == "false" then value = false
+ end
+ end
+
-- save option
xmake._OPTIONS[utils.ifelse(prefix == 1 and opt[2], opt[2], key)] = value
@@ -626,15 +633,15 @@ function option.print_options(options)
end
-- append the option description
- local description = option[5];
+ local description = option[5]
if description then
option_info = option_info .. description
end
-- append the default value
- local default = option[4];
+ local default = option[4]
if default then
- option_info = option_info .. " (default: " .. default .. ")"
+ option_info = option_info .. " (default: " .. tostring(default) .. ")"
end
-- print option info
diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua
index 27041ac81..7b04c7fd0 100644
--- a/xmake/scripts/base/project.lua
+++ b/xmake/scripts/base/project.lua
@@ -341,14 +341,14 @@ function project._make(configs)
-- merge the setted configures
for k, v in pairs(configs._SET) do
- if not target[k] then
+ if nil == target[k] then
target[k] = v
end
end
-- merge the added configures
for k, v in pairs(configs._ADD) do
- if not target[k] then
+ if nil == target[k] then
target[k] = v
else
target[k] = table.join(v, target[k])
@@ -568,8 +568,7 @@ function project.menu()
-- the default
local default = utils.unwrap(opt.default)
- if default then default = "true"
- else default = "auto" end
+ if not default then default = "auto" end
-- append it
table.insert(menu, {nil, name, "kv", default, utils.unwrap(opt.description)})