Provide a way to 'tag' systems, and filter on those tags.
This commit is contained in:
parent
34aaff9c66
commit
70e00883f8
@ -668,3 +668,22 @@
|
|||||||
end
|
end
|
||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Get a set of tags for different 'platforms'
|
||||||
|
--
|
||||||
|
|
||||||
|
function os.getSystemTags(name)
|
||||||
|
local tags =
|
||||||
|
{
|
||||||
|
["aix"] = { "aix", "posix" },
|
||||||
|
["bsd"] = { "bsd", "posix" },
|
||||||
|
["haiku"] = { "haiku", "posix" },
|
||||||
|
["linux"] = { "linux", "posix" },
|
||||||
|
["macosx"] = { "macosx", "darwin", "posix" },
|
||||||
|
["solaris"] = { "solaris", "posix" },
|
||||||
|
["windows"] = { "windows", "win32" },
|
||||||
|
}
|
||||||
|
return tags[name] or name
|
||||||
|
end
|
||||||
|
@ -64,7 +64,7 @@
|
|||||||
context.addFilter(self, "action", _ACTION)
|
context.addFilter(self, "action", _ACTION)
|
||||||
|
|
||||||
self.system = self.system or p.action.current().targetos or os.target()
|
self.system = self.system or p.action.current().targetos or os.target()
|
||||||
context.addFilter(self, "system", self.system)
|
context.addFilter(self, "system", os.getSystemTags(self.system))
|
||||||
|
|
||||||
-- Add command line options to the filtering options
|
-- Add command line options to the filtering options
|
||||||
local options = {}
|
local options = {}
|
||||||
@ -205,7 +205,7 @@
|
|||||||
-- values that might already in the context to override my defaults.
|
-- values that might already in the context to override my defaults.
|
||||||
|
|
||||||
self.system = self.system or p.action.current().targetos or os.target()
|
self.system = self.system or p.action.current().targetos or os.target()
|
||||||
context.addFilter(self, "system", self.system)
|
context.addFilter(self, "system", os.getSystemTags(self.system))
|
||||||
context.addFilter(self, "architecture", self.architecture)
|
context.addFilter(self, "architecture", self.architecture)
|
||||||
|
|
||||||
-- The kind is a configuration level value, but if it has been set at the
|
-- The kind is a configuration level value, but if it has been set at the
|
||||||
@ -580,7 +580,7 @@
|
|||||||
|
|
||||||
-- allow the project script to override the default system
|
-- allow the project script to override the default system
|
||||||
ctx.system = ctx.system or system
|
ctx.system = ctx.system or system
|
||||||
context.addFilter(ctx, "system", ctx.system)
|
context.addFilter(ctx, "system", os.getSystemTags(ctx.system))
|
||||||
|
|
||||||
-- allow the project script to override the default architecture
|
-- allow the project script to override the default architecture
|
||||||
ctx.architecture = ctx.architecture or architecture
|
ctx.architecture = ctx.architecture or architecture
|
||||||
|
@ -107,3 +107,27 @@
|
|||||||
prepare()
|
prepare()
|
||||||
test.isequal({}, cfg.defines)
|
test.isequal({}, cfg.defines)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Test filtering on system.
|
||||||
|
--
|
||||||
|
|
||||||
|
function suite.onFilterLinuxIsPosix()
|
||||||
|
system "linux"
|
||||||
|
filter { "system:posix" }
|
||||||
|
defines { "POSIX" }
|
||||||
|
filter { "system:not posix" }
|
||||||
|
defines { "NOTPOSIX" }
|
||||||
|
prepare()
|
||||||
|
test.isequal({ "POSIX" }, cfg.defines)
|
||||||
|
end
|
||||||
|
|
||||||
|
function suite.onFilterWindowsIsNotPosix()
|
||||||
|
system "windows"
|
||||||
|
filter { "system:posix" }
|
||||||
|
defines { "POSIX" }
|
||||||
|
filter { "system:not posix" }
|
||||||
|
defines { "NOTPOSIX" }
|
||||||
|
prepare()
|
||||||
|
test.isequal({ "NOTPOSIX" }, cfg.defines)
|
||||||
|
end
|
||||||
|
Reference in New Issue
Block a user