Merge with Premake-dev tip
This commit is contained in:
commit
1773146d4d
@ -106,6 +106,7 @@
|
||||
* Fix linking to external libraries outside of project folder
|
||||
* Improve processing of ld.so.conf (Cameron Hart)
|
||||
* Patch 154: Fix .def file support for VS2010 (Riccardo Ghetta)
|
||||
* Patch 159: Validate all values passed to options (Moi_ioM)
|
||||
|
||||
|
||||
-------
|
||||
|
@ -1,25 +1,25 @@
|
||||
--
|
||||
-- option.lua
|
||||
-- Work with the list of registered options.
|
||||
-- Copyright (c) 2002-2009 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2002-2013 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
premake.option = { }
|
||||
premake.option = {}
|
||||
|
||||
|
||||
--
|
||||
-- The list of registered options.
|
||||
--
|
||||
|
||||
premake.option.list = { }
|
||||
|
||||
premake.option.list = {}
|
||||
|
||||
|
||||
--
|
||||
-- Register a new option.
|
||||
--
|
||||
-- @param opt
|
||||
-- The new option object.
|
||||
--
|
||||
--
|
||||
|
||||
function premake.option.add(opt)
|
||||
-- some sanity checking
|
||||
@ -29,11 +29,11 @@
|
||||
missing = field
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if (missing) then
|
||||
error("option needs a " .. missing, 3)
|
||||
end
|
||||
|
||||
|
||||
-- add it to the master list
|
||||
premake.option.list[opt.trigger] = opt
|
||||
end
|
||||
@ -64,7 +64,7 @@
|
||||
table.insert(keys, option.trigger)
|
||||
end
|
||||
table.sort(keys)
|
||||
|
||||
|
||||
local i = 0
|
||||
return function()
|
||||
i = i + 1
|
||||
@ -89,18 +89,24 @@
|
||||
if (not opt) then
|
||||
return false, "invalid option '" .. key .. "'"
|
||||
end
|
||||
|
||||
|
||||
-- does it need a value?
|
||||
if (opt.value and value == "") then
|
||||
return false, "no value specified for option '" .. key .. "'"
|
||||
end
|
||||
|
||||
|
||||
-- is the value allowed?
|
||||
if (opt.allowed) then
|
||||
if opt.allowed then
|
||||
local found = false
|
||||
for _, match in ipairs(opt.allowed) do
|
||||
if (match[1] == value) then return true end
|
||||
if match[1] == value then
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not found then
|
||||
return false, string.format("invalid value '%s' for option '%s'", value, key)
|
||||
end
|
||||
return false, "invalid value '" .. value .. "' for option '" .. key .. "'"
|
||||
end
|
||||
end
|
||||
return true
|
||||
|
Loading…
Reference in New Issue
Block a user