summaryrefslogtreecommitdiff
path: root/xmake/scripts/base
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-25 11:41:38 +0800
committerruki <[email protected]>2015-06-25 11:41:38 +0800
commit5b6c2e819db721baa24d42ad33924431a28cd7e6 (patch)
tree1d2c4089f16b6d768f43cddd973ed2d3b7b1adb1 /xmake/scripts/base
parent40aeeb7d3f1f2fdc4b2a18fd6654301f4a757394 (diff)
rebuild all archs for package and fix find option bug
Diffstat (limited to 'xmake/scripts/base')
-rw-r--r--xmake/scripts/base/option.lua84
1 files changed, 17 insertions, 67 deletions
diff --git a/xmake/scripts/base/option.lua b/xmake/scripts/base/option.lua
index 36963476b..1c8c35573 100644
--- a/xmake/scripts/base/option.lua
+++ b/xmake/scripts/base/option.lua
@@ -355,79 +355,29 @@ end
function option.find(argv, name, shortname)
-- check
- assert(argv and name)
+ assert(argv and (name or shortname))
- -- parse _ARGV to _OPTIONS
- local _iter, _s, _k = ipairs(argv)
- while true do
+ -- find it
+ local nextvalue = false
+ for _, arg in ipairs(argv) do
- -- the idx and arg
- local idx, arg = _iter(_s, _k)
+ -- get this value
+ if nextvalue then return arg end
- -- end?
- _k = idx
- if idx == nil then break end
-
- -- parse key and value
- local key, value
- local i = arg:find("=", 1, true)
-
- -- key=value?
- if i then
- key = arg:sub(1, i - 1)
- value = arg:sub(i + 1)
- -- only key?
- else
- key = arg
- value = true
- end
-
- -- --key?
- local prefix = 0
- if key:startswith("--") then
- key = key:sub(3)
- prefix = 2
- -- -k?
- elseif key:startswith("-") then
- key = key:sub(2)
- prefix = 1
- end
+ -- --name=value?
+ if name and arg:startswith("--" .. name) then
+
+ -- get value
+ local i = arg:find("=", 1, true)
+ if i then return arg:sub(i + 1) end
- -- check key
- if prefix and #key == 0 then
- -- failed
- return
+ -- -shortname value?
+ elseif shortname and arg:startswith("-" .. shortname) then
+
+ -- get value
+ nextvalue = true
end
- -- --key=value or -k value or -k?
- if prefix ~= 0 then
-
- -- -k value? continue to get the value
- if prefix == 1 then
-
- -- get the next idx and arg
- idx, arg = _iter(_s, _k)
-
- -- exists value?
- _k = idx
- if idx == nil or arg:startswith("-") then
- -- failed
- return
- end
-
- -- get value
- value = arg
- end
-
- -- ok?
- if key == name or (shortname and key == shortname) then
- return value
- end
-
- -- action? skip it
- elseif idx == 1 then
- -- value?
- else return end
end
end