Remove…() now implicitly creates a new configuration block, so it will be applied in same context as it appears in the script
This commit is contained in:
parent
2d5d3a33da
commit
f349259fa0
@ -11,6 +11,9 @@
|
||||
--
|
||||
-- Here I define all of the getter/setter functions as metadata. The actual
|
||||
-- functions are built programmatically below.
|
||||
--
|
||||
-- Note that these are deprecated in favor of the api.register() calls below,
|
||||
-- and will be going away as soon as I have a chance to port them.
|
||||
--
|
||||
|
||||
premake.fields =
|
||||
@ -193,6 +196,14 @@
|
||||
-- return the current baked value
|
||||
if not value then return end
|
||||
|
||||
-- hack: start a new configuration block if I can, so that the
|
||||
-- remove will be processed in the same context as it appears in
|
||||
-- the script. Can be removed when I rewrite the internals to
|
||||
-- be truly declarative
|
||||
if field.scope == "config" then
|
||||
configuration(api.scope.configuration.terms)
|
||||
end
|
||||
|
||||
local target = api.gettarget(field.scope)
|
||||
|
||||
target.removes = target.removes or {}
|
||||
@ -994,7 +1005,9 @@
|
||||
--
|
||||
|
||||
function premake.remove(fieldname, value)
|
||||
local kind = premake.fields[fieldname].kind
|
||||
local field = premake.fields[fieldname]
|
||||
local kind = field.kind
|
||||
|
||||
function set(value)
|
||||
if kind ~= "list" and not value:startswith("**") then
|
||||
return path.getabsolute(value)
|
||||
@ -1003,7 +1016,11 @@
|
||||
end
|
||||
end
|
||||
|
||||
local cfg = premake.getobject(premake.fields[fieldname].scope)
|
||||
if field.scope == "config" then
|
||||
configuration(api.scope.configuration.terms)
|
||||
end
|
||||
|
||||
local cfg = premake.getobject(field.scope)
|
||||
cfg.removes = cfg.removes or {}
|
||||
cfg.removes[fieldname] = premake.setarray(cfg.removes, fieldname, value, set)
|
||||
end
|
||||
|
@ -475,7 +475,7 @@
|
||||
-- field will be merged.
|
||||
--
|
||||
|
||||
function oven.remove(cfg, removes, filterField)
|
||||
function oven.remove(cfg, removes, filterField)
|
||||
if filterField then
|
||||
oven.removefromfield(cfg[filterField], removes[filterField])
|
||||
else
|
||||
|
@ -410,8 +410,8 @@
|
||||
|
||||
-- find *all* files referenced by the project, regardless of configuration
|
||||
local files = {}
|
||||
for _, block in ipairs(prj.blocks) do
|
||||
for _, file in ipairs(block.files) do
|
||||
for cfg in project.eachconfig(prj) do
|
||||
for _, file in ipairs(cfg.files) do
|
||||
files[file] = file
|
||||
end
|
||||
end
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
function suite.remove_onExactValueMatch()
|
||||
flags { "Symbols", "Optimize", "NoRTTI" }
|
||||
configuration {}
|
||||
removeflags "Optimize"
|
||||
prepare()
|
||||
test.isequal({ "Symbols", "NoRTTI" }, cfg.flags)
|
||||
@ -39,7 +38,6 @@
|
||||
|
||||
function suite.remove_onMultipleValues()
|
||||
flags { "Symbols", "NoExceptions", "Optimize", "NoRTTI" }
|
||||
configuration {}
|
||||
removeflags { "NoExceptions", "NoRTTI" }
|
||||
prepare()
|
||||
test.isequal({ "Symbols", "Optimize" }, cfg.flags)
|
||||
@ -52,7 +50,6 @@
|
||||
|
||||
function suite.remove_onWildcard()
|
||||
defines { "WIN32", "WIN64", "LINUX", "MACOSX" }
|
||||
configuration {}
|
||||
removedefines { "WIN*" }
|
||||
prepare()
|
||||
test.isequal({ "LINUX", "MACOSX" }, cfg.defines)
|
||||
@ -64,7 +61,6 @@
|
||||
|
||||
function suite.remove_onExactValueMatch()
|
||||
flags { "Symbols", "Optimize", "NoRTTI" }
|
||||
configuration {}
|
||||
removeflags "Optimize"
|
||||
prepare()
|
||||
test.isnil(cfg.flags.Optimize)
|
||||
@ -76,12 +72,19 @@
|
||||
|
||||
function suite.remove_onFileField()
|
||||
files { "hello.c", "goodbye.c" }
|
||||
configuration {}
|
||||
removefiles { "goodbye.c" }
|
||||
prepare()
|
||||
test.isequal(path.join(os.getcwd(), "hello.c"), table.concat(cfg.files))
|
||||
test.isequal({ path.join(os.getcwd(), "hello.c") }, cfg.files)
|
||||
end
|
||||
|
||||
function suite.remove_onExcludesWildcard()
|
||||
files { "hello.c", "goodbye.c" }
|
||||
excludes { "goodbye.*" }
|
||||
prepare()
|
||||
test.isequal({ path.join(os.getcwd(), "hello.c") }, cfg.files)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Remove should work on container-level fields too.
|
||||
--
|
||||
|
Reference in New Issue
Block a user