Added new filter() to replace configuration(), with required field prefixes
- use like: filter { "configurations:Debug" } - supported prefixes: action, architecture, configurations, files, kind, language, options, platforms, system - defaults to "configurations" if no prefix is specified
This commit is contained in:
parent
a672ec416a
commit
f4e55da621
@ -3,7 +3,7 @@
|
||||
--
|
||||
-- Prepares the runtime environment for the add-ons and user project scripts.
|
||||
--
|
||||
-- Copyright (c) 2012-2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local api = premake.api
|
||||
@ -876,45 +876,45 @@
|
||||
|
||||
-- Use Posix-style target naming by default, since it is the most common.
|
||||
|
||||
configuration { "SharedLib" }
|
||||
filter { "kind:SharedLib" }
|
||||
targetprefix "lib"
|
||||
targetextension ".so"
|
||||
|
||||
configuration { "StaticLib" }
|
||||
filter { "kind:StaticLib" }
|
||||
targetprefix "lib"
|
||||
targetextension ".a"
|
||||
|
||||
-- Add variations for other Posix-like systems.
|
||||
|
||||
configuration { "MacOSX", "SharedLib" }
|
||||
filter { "system:MacOSX", "kind:SharedLib" }
|
||||
targetextension ".dylib"
|
||||
|
||||
-- Windows and friends.
|
||||
|
||||
configuration { "Windows or C#", "ConsoleApp or WindowedApp" }
|
||||
filter { "system:Windows or language:C#", "kind:ConsoleApp or WindowedApp" }
|
||||
targetextension ".exe"
|
||||
|
||||
configuration { "Xbox360", "ConsoleApp or WindowedApp" }
|
||||
filter { "system:Xbox360", "kind:ConsoleApp or WindowedApp" }
|
||||
targetextension ".exe"
|
||||
|
||||
configuration { "Windows or Xbox360", "SharedLib" }
|
||||
filter { "system:Windows or Xbox360", "kind:SharedLib" }
|
||||
targetprefix ""
|
||||
targetextension ".dll"
|
||||
implibextension ".lib"
|
||||
|
||||
configuration { "Windows or Xbox360", "StaticLib" }
|
||||
filter { "system:Windows or Xbox360", "kind:StaticLib" }
|
||||
targetprefix ""
|
||||
targetextension ".lib"
|
||||
|
||||
configuration { "C#", "SharedLib" }
|
||||
filter { "language:C#", "kind:SharedLib" }
|
||||
targetprefix ""
|
||||
targetextension ".dll"
|
||||
implibextension ".dll"
|
||||
|
||||
-- PS3 configurations
|
||||
|
||||
configuration { "PS3" }
|
||||
filter { "system:PS3" }
|
||||
toolset "snc"
|
||||
|
||||
configuration { "PS3", "ConsoleApp" }
|
||||
filter { "system:PS3", "kind:ConsoleApp" }
|
||||
targetextension ".elf"
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- _premake_main.lua
|
||||
-- Script-side entry point for the main program logic.
|
||||
-- Copyright (c) 2002-2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2002-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local shorthelp = "Type 'premake5 --help' for help"
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
-- Clear out any configuration scoping left over from initialization
|
||||
|
||||
configuration {}
|
||||
filter {}
|
||||
|
||||
-- Seed the random number generator so actions don't have to do it themselves
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
-- configuration scoping gets cleared before continuing
|
||||
|
||||
dofileopt(_OPTIONS["systemscript"] or { "premake5-system.lua", "premake-system.lua" })
|
||||
configuration {}
|
||||
filter {}
|
||||
|
||||
-- The "next-gen" actions have now replaced their deprecated counterparts.
|
||||
-- Provide a warning for a little while before I remove them entirely.
|
||||
|
@ -758,9 +758,10 @@
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Start a new block of configuration settings.
|
||||
--
|
||||
---
|
||||
-- Start a new block of configuration settings, using the old, "open"
|
||||
-- style of matching without field prefixes.
|
||||
---
|
||||
|
||||
function configuration(terms)
|
||||
local target = api.gettarget()
|
||||
@ -768,14 +769,32 @@
|
||||
if terms == "*" then terms = nil end
|
||||
configset.addblock(target, {terms}, os.getcwd())
|
||||
end
|
||||
|
||||
return target
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
|
||||
---
|
||||
-- Start a new block of configuration settings, using the new prefixed
|
||||
-- style of pattern matching.
|
||||
---
|
||||
|
||||
function filter(terms)
|
||||
local target = api.gettarget()
|
||||
if terms then
|
||||
if terms == "*" then terms = nil end
|
||||
local ok, err = configset.addFilter(target, {terms}, os.getcwd())
|
||||
if not ok then
|
||||
error(err, 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Begin a new solution group, which will contain any subsequent projects.
|
||||
--
|
||||
---
|
||||
|
||||
function group(name)
|
||||
if name == "*" then name = nil end
|
||||
|
@ -38,6 +38,7 @@
|
||||
end
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Retrieve a value from the configuration set.
|
||||
--
|
||||
@ -58,9 +59,7 @@
|
||||
---
|
||||
|
||||
function configset.fetch(cset, field, context)
|
||||
if not context then
|
||||
context = cset.current._criteria.terms
|
||||
end
|
||||
context = context or {}
|
||||
|
||||
if premake.field.merges(field) then
|
||||
return configset._fetchMerged(cset, field, context)
|
||||
@ -83,7 +82,7 @@
|
||||
|
||||
-- If the filter contains a file path, make it relative to
|
||||
-- this block's basedir
|
||||
if value and abspath and block._basedir ~= basedir and not cset.compiled then
|
||||
if value and abspath and not cset.compiled and block._basedir ~= basedir then
|
||||
basedir = block._basedir
|
||||
filter.files = path.getrelative(basedir, abspath)
|
||||
end
|
||||
@ -189,7 +188,7 @@
|
||||
__index = function(tbl, key)
|
||||
local f = premake.field.get(key)
|
||||
if f then
|
||||
return configset.fetch(cset, f, cset.current._criteria.terms)
|
||||
return configset.fetch(cset, f)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
@ -199,9 +198,11 @@
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Create a new block of configuration field-value pairs, with the provided
|
||||
-- set of context terms to control their application.
|
||||
---
|
||||
-- Create a new block of configuration field-value pairs, using a set of
|
||||
-- old-style, non-prefixed context terms to control their application. This
|
||||
-- approach will eventually be phased out in favor of prefixed filters;
|
||||
-- see addFilter() below.
|
||||
--
|
||||
-- @param cset
|
||||
-- The configuration set to hold the new block.
|
||||
@ -213,21 +214,48 @@
|
||||
-- relative to this basis before pattern testing.
|
||||
-- @return
|
||||
-- The new configuration data block.
|
||||
--
|
||||
---
|
||||
|
||||
function configset.addblock(cset, terms, basedir)
|
||||
configset.addFilter(cset, terms, basedir, true)
|
||||
return cset.current
|
||||
end
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Create a new block of configuration field-value pairs, using a set
|
||||
-- of new-style, prefixed context terms to control their application.
|
||||
--
|
||||
-- @param cset
|
||||
-- The configuration set to hold the new block.
|
||||
-- @param terms
|
||||
-- A set of terms used to control the application of the values
|
||||
-- contained in the block.
|
||||
-- @param basedir
|
||||
-- An optional base directory. If set, filename filter tests will be
|
||||
-- made relative to this base before pattern testing.
|
||||
-- @param unprefixed
|
||||
-- If true, uses the old, unprefixed style for filter terms. This will
|
||||
-- eventually be phased out in favor of prefixed filters.
|
||||
---
|
||||
|
||||
function configset.addFilter(cset, terms, basedir, unprefixed)
|
||||
local crit, err = criteria.new(terms, unprefixed)
|
||||
if not crit then
|
||||
return nil, err
|
||||
end
|
||||
|
||||
local block = {}
|
||||
block._criteria = crit
|
||||
|
||||
if basedir then
|
||||
block._basedir = basedir:lower()
|
||||
end
|
||||
|
||||
-- attach a criteria object to the block to control its application
|
||||
block._criteria = criteria.new(terms)
|
||||
|
||||
table.insert(cset.blocks, block)
|
||||
cset.current = block
|
||||
return block
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@ -287,8 +315,11 @@
|
||||
function configset.remove(cset, field, values)
|
||||
-- removes are always processed first; starting a new block here
|
||||
-- ensures that they will be processed in the proper order
|
||||
local current = cset.current
|
||||
configset.addblock(cset, current._criteria.terms, current._basedir)
|
||||
local block = {}
|
||||
block._basedir = cset.current._basedir
|
||||
block._criteria = cset.current._criteria
|
||||
table.insert(cset.blocks, block)
|
||||
cset.current = block
|
||||
|
||||
-- This needs work; right now it is hardcoded to only work for lists.
|
||||
-- To support removing from keyed collections, I first need to figure
|
||||
|
@ -13,49 +13,103 @@
|
||||
|
||||
|
||||
--
|
||||
-- These prefixes correspond to the context information built by the oven
|
||||
-- during baking. In theory, any field could be used as a filter, but right
|
||||
-- now only these are set.
|
||||
--
|
||||
|
||||
criteria.validPrefixes = {
|
||||
_ACTION = true,
|
||||
action = true,
|
||||
architecture = true,
|
||||
configurations = true,
|
||||
files = true,
|
||||
kind = true,
|
||||
language = true,
|
||||
_OPTIONS = true,
|
||||
options = true,
|
||||
platforms = true,
|
||||
system = true,
|
||||
}
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Create a new criteria object.
|
||||
--
|
||||
-- @param terms
|
||||
-- A list of criteria terms.
|
||||
-- @param unprefixed
|
||||
-- If true, use the old style, unprefixed filter terms. This will
|
||||
-- eventually be phased out in favor of prefixed terms only.
|
||||
-- @return
|
||||
-- A new criteria object.
|
||||
--
|
||||
---
|
||||
|
||||
function criteria.new(terms)
|
||||
function criteria.new(terms, unprefixed)
|
||||
terms = table.flatten(terms)
|
||||
|
||||
-- Preprocess the terms list for performance in matches() later.
|
||||
-- Wildcards are replaced with Lua patterns. Terms with "or" and
|
||||
-- "not" modifiers are split into arrays of parts to test.
|
||||
-- Prefixes are split out and stored under a quick lookup key.
|
||||
-- Preprocess the list of terms for better performance in matches().
|
||||
-- Each term is replaced with a pattern, with an implied AND between
|
||||
-- them. Each pattern contains one or more words, with an implied OR
|
||||
-- between them. A word maybe be flagged as negated, or as a wildcard
|
||||
-- pattern, and may have a field prefix associated with it.
|
||||
|
||||
local patterns = {}
|
||||
|
||||
for i, term in ipairs(terms) do
|
||||
term = term:lower()
|
||||
terms[i] = term
|
||||
|
||||
local pattern = {}
|
||||
local prefix = iif(unprefixed, nil, "configurations")
|
||||
|
||||
local n = term:find(":", 1, true)
|
||||
if n then
|
||||
pattern.prefix = term:sub(1, n - 1)
|
||||
term = term:sub(n + 1)
|
||||
end
|
||||
|
||||
local parts = term:explode(" or ")
|
||||
for i, part in ipairs(parts) do
|
||||
local item = path.wildcards(part)
|
||||
if (item ~= part) then
|
||||
item = "%%" .. item
|
||||
local words = term:explode(" or ")
|
||||
for _, word in ipairs(words) do
|
||||
word, prefix = criteria._word(word, prefix)
|
||||
if prefix and not criteria.validPrefixes[prefix] then
|
||||
return nil, string.format("Invalid field prefix '%s'", prefix)
|
||||
end
|
||||
table.insert(pattern, item)
|
||||
table.insert(pattern, word)
|
||||
end
|
||||
|
||||
table.insert(patterns, pattern)
|
||||
end
|
||||
|
||||
-- The matching logic is written in C now for performance; compile
|
||||
-- this collection of patterns to C data structures to make that
|
||||
-- code easier to read and maintain.
|
||||
|
||||
local crit = {}
|
||||
crit.terms = terms
|
||||
crit.patterns = patterns
|
||||
crit.data = criteria._compile(patterns)
|
||||
return crit
|
||||
end
|
||||
|
||||
|
||||
|
||||
function criteria._word(word, prefix)
|
||||
local wildcard
|
||||
local assertion = true
|
||||
|
||||
-- Trim off all "not" and field prefixes and check for wildcards
|
||||
while (true) do
|
||||
if word:startswith("not ") then
|
||||
assertion = not assertion
|
||||
word = word:sub(5)
|
||||
else
|
||||
local i = word:find(":", 1, true)
|
||||
if prefix and i then
|
||||
prefix = word:sub(1, i - 1)
|
||||
word = word:sub(i + 1)
|
||||
else
|
||||
wildcard = (word:find("*", 1, true) ~= nil)
|
||||
if wildcard then
|
||||
word = path.wildcards(word)
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return { word, prefix, assertion, wildcard }, prefix
|
||||
end
|
||||
|
@ -352,16 +352,25 @@
|
||||
--
|
||||
|
||||
function oven.bakeConfigMap(ctx, cset, cfgs)
|
||||
|
||||
-- build a query filter that will match any configuration name,
|
||||
-- within the existing constraints of the project
|
||||
|
||||
local terms = table.arraycopy(ctx.terms)
|
||||
local configurations = {}
|
||||
local platforms = {}
|
||||
|
||||
for _, cfg in ipairs(cfgs) do
|
||||
if cfg[1] then table.insert(terms, cfg[1]:lower()) end
|
||||
if cfg[2] then table.insert(terms, cfg[2]:lower()) end
|
||||
if cfg[1] then
|
||||
table.insert(configurations, cfg[1]:lower())
|
||||
end
|
||||
if cfg[2] then
|
||||
table.insert(platforms, cfg[2]:lower())
|
||||
end
|
||||
end
|
||||
|
||||
local terms = table.deepcopy(ctx.terms)
|
||||
terms.configurations = configurations
|
||||
terms.platforms = platforms
|
||||
|
||||
-- assemble all matching configmaps, and then merge their keys
|
||||
-- into the project's configmap
|
||||
|
||||
|
@ -1,24 +1,147 @@
|
||||
/**
|
||||
* \file criteria_matches.c
|
||||
* \brief Determine if this criteria is met by the provided filter terms.
|
||||
* \author Copyright (c) 2002-2013 Jason Perkins and the Premake project
|
||||
* \author Copyright (c) 2002-2014 Jason Perkins and the Premake project
|
||||
*/
|
||||
|
||||
#include "premake.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static int match(lua_State* L, const char* value, const char* pattern, int wildcard)
|
||||
{
|
||||
/*
|
||||
if wildcard then
|
||||
return value:match(pattern) == value
|
||||
else
|
||||
return value == pattern
|
||||
end
|
||||
*/
|
||||
struct Word {
|
||||
const char* word;
|
||||
const char* prefix;
|
||||
int matchesFiles;
|
||||
int assertion;
|
||||
int wildcard;
|
||||
};
|
||||
|
||||
if (wildcard) {
|
||||
struct Pattern {
|
||||
int matchesFiles;
|
||||
int n;
|
||||
struct Word* word;
|
||||
};
|
||||
|
||||
struct Patterns {
|
||||
int prefixed;
|
||||
int filePatterns;
|
||||
int n;
|
||||
struct Pattern* pattern;
|
||||
};
|
||||
|
||||
|
||||
static int criteria_compilePattern(lua_State* L, struct Pattern* pattern);
|
||||
|
||||
|
||||
int criteria_compile(lua_State* L)
|
||||
{
|
||||
struct Patterns* patterns;
|
||||
int i, n;
|
||||
|
||||
/* create a Patterns object and userdata; holds a list of Pattern items */
|
||||
patterns = (struct Patterns*)lua_newuserdata(L, sizeof(struct Patterns));
|
||||
patterns->prefixed = 0;
|
||||
patterns->filePatterns = 0;
|
||||
|
||||
if (luaL_newmetatable(L, "premake.criteria")) {
|
||||
lua_pushstring(L, "__gc");
|
||||
lua_pushcfunction(L, criteria_delete);
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
/* create array to hold the incoming list of patterns */
|
||||
n = lua_objlen(L, 1);
|
||||
patterns->n = n;
|
||||
patterns->pattern = (struct Pattern*)malloc(sizeof(struct Pattern) * n);
|
||||
|
||||
/* create a new pattern object for each incoming pattern */
|
||||
for (i = 0; i < n; ++i) {
|
||||
struct Pattern* pattern = &patterns->pattern[i];
|
||||
|
||||
lua_rawgeti(L, 1, i + 1);
|
||||
criteria_compilePattern(L, pattern);
|
||||
lua_pop(L, 1);
|
||||
|
||||
if (pattern->n > 0 && pattern->word[0].prefix != NULL) {
|
||||
patterns->prefixed = 1;
|
||||
}
|
||||
|
||||
if (pattern->matchesFiles) {
|
||||
++patterns->filePatterns;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int criteria_compilePattern(lua_State* L, struct Pattern* pattern)
|
||||
{
|
||||
int i, n;
|
||||
|
||||
/* create array to hold the incoming list of words */
|
||||
n = lua_objlen(L, -1);
|
||||
pattern->n = n;
|
||||
pattern->word = (struct Word*)malloc(sizeof(struct Word) * n);
|
||||
pattern->matchesFiles = 0;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
struct Word* word = &pattern->word[i];
|
||||
word->matchesFiles = 0;
|
||||
|
||||
lua_rawgeti(L, -1, i + 1);
|
||||
|
||||
lua_rawgeti(L, -1, 1);
|
||||
word->word = lua_tostring(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_rawgeti(L, -1, 2);
|
||||
word->prefix = lua_tostring(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_rawgeti(L, -1, 3);
|
||||
word->assertion = lua_toboolean(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_rawgeti(L, -1, 4);
|
||||
word->wildcard = lua_toboolean(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
if (word->prefix && strcmp(word->prefix, "files") == 0) {
|
||||
word->matchesFiles = 1;
|
||||
pattern->matchesFiles = 1;
|
||||
}
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int criteria_delete(lua_State* L)
|
||||
{
|
||||
int i, n;
|
||||
struct Patterns* patterns = (struct Patterns*)lua_touserdata(L, 1);
|
||||
|
||||
n = patterns->n;
|
||||
for (i = 0; i < n; ++i) {
|
||||
free(patterns->pattern[i].word);
|
||||
}
|
||||
free(patterns->pattern);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int match(lua_State* L, const char* value, struct Word* word)
|
||||
{
|
||||
if (word->wildcard) {
|
||||
/* use string.match() to compare */
|
||||
const char* result;
|
||||
int matched = 0;
|
||||
|
||||
@ -26,7 +149,7 @@ static int match(lua_State* L, const char* value, const char* pattern, int wildc
|
||||
|
||||
lua_pushvalue(L, 4);
|
||||
lua_pushstring(L, value);
|
||||
lua_pushstring(L, pattern);
|
||||
lua_pushstring(L, word->word);
|
||||
lua_call(L, 2, 1);
|
||||
|
||||
if (lua_isstring(L, -1)) {
|
||||
@ -38,40 +161,27 @@ static int match(lua_State* L, const char* value, const char* pattern, int wildc
|
||||
return matched;
|
||||
}
|
||||
else {
|
||||
return (strcmp(value, pattern) == 0);
|
||||
return (strcmp(value, word->word) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Compares the value on the top of the stack to the provided
|
||||
* part, which is a Lua pattern string.
|
||||
* Compares the value on the top of the stack to the specified word.
|
||||
*/
|
||||
static int testValue(lua_State* L, const char* part, const int wildcard)
|
||||
|
||||
static int testValue(lua_State* L, struct Word* word)
|
||||
{
|
||||
const char* value;
|
||||
size_t i, n;
|
||||
int result;
|
||||
|
||||
/*
|
||||
if type(value) == "table" then
|
||||
for i = 1, #value do
|
||||
if testValue(value[i], part) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
else
|
||||
if value and value:match(part) == value then
|
||||
return true;
|
||||
end
|
||||
end
|
||||
*/
|
||||
|
||||
if (lua_istable(L, -1)) {
|
||||
n = lua_objlen(L, -1);
|
||||
for (i = 1; i <= n; ++i) {
|
||||
lua_rawgeti(L, -1, i);
|
||||
result = testValue(L, part, wildcard);
|
||||
result = testValue(L, word);
|
||||
lua_pop(L, 1);
|
||||
if (result) {
|
||||
return 1;
|
||||
@ -81,169 +191,58 @@ static int testValue(lua_State* L, const char* part, const int wildcard)
|
||||
}
|
||||
|
||||
value = lua_tostring(L, -1);
|
||||
if (value && match(L, value, part, wildcard)) {
|
||||
return 1;
|
||||
if (value) {
|
||||
return match(L, value, word);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The context is a set of key-value pairs, something like:
|
||||
* {
|
||||
* action = "vs2010",
|
||||
* configurations = "Debug",
|
||||
* system = "windows",
|
||||
* files = "/absolute/path/to/hello.cpp",
|
||||
* -- and so on...
|
||||
* }
|
||||
*/
|
||||
static int testContext(lua_State* L, const char* prefix, const char* part,
|
||||
const int assertion, const int wildcard,
|
||||
const char* filename, int* fileMatched)
|
||||
|
||||
static int testWithPrefix(lua_State* L, struct Word* word, const char* filename, int* fileMatched)
|
||||
{
|
||||
/*
|
||||
if prefix then
|
||||
local isFiles = (prefix == "files")
|
||||
if isFiles and not filename then
|
||||
return false
|
||||
end
|
||||
local result = testValue(context[prefix], part, wildcard)
|
||||
if isFiles and result == assertion then
|
||||
filematched = true
|
||||
end
|
||||
if result then
|
||||
return assertion
|
||||
end
|
||||
else
|
||||
if filename and assertion and filename:match(part) == filename then
|
||||
filematched = true
|
||||
return assertion
|
||||
end
|
||||
|
||||
for prefix, value in pairs(context) do
|
||||
if testValue(value, part, wildcard) then
|
||||
return assertion
|
||||
end
|
||||
end
|
||||
end
|
||||
*/
|
||||
|
||||
int result;
|
||||
if (prefix) {
|
||||
int isFiles = (strcmp(prefix, "files") == 0);
|
||||
if (isFiles && filename == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
lua_getfield(L, 2, prefix);
|
||||
result = testValue(L, part, wildcard);
|
||||
lua_pop(L, 1);
|
||||
if (isFiles && result == assertion) {
|
||||
(*fileMatched) = 1;
|
||||
}
|
||||
if (result) {
|
||||
return assertion;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (filename && assertion && match(L, filename, part, wildcard)) {
|
||||
(*fileMatched) = 1;
|
||||
return assertion;
|
||||
}
|
||||
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, 2)) {
|
||||
if (testValue(L, part, wildcard)) {
|
||||
lua_pop(L, 2);
|
||||
return assertion;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
if (word->matchesFiles && !filename) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (!assertion);
|
||||
lua_pushstring(L, word->prefix);
|
||||
lua_rawget(L, 2);
|
||||
result = testValue(L, word);
|
||||
lua_pop(L, 1);
|
||||
|
||||
if (word->matchesFiles && result == word->assertion) {
|
||||
(*fileMatched) = 1;
|
||||
}
|
||||
|
||||
if (result) {
|
||||
return word->assertion;
|
||||
}
|
||||
|
||||
return (!word->assertion);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Patterns are represented as an array of string values.
|
||||
* "windows" = { "windows" }
|
||||
* "not windows" = { "not", "windows" }
|
||||
* "windows or linux" = { "windows", "linux" }
|
||||
*
|
||||
* If the patterns is targeted at a specific prefix, that is stored
|
||||
* as a keyed value.
|
||||
*
|
||||
* "files:**.c" = { prefix="files", "**.c" }
|
||||
*/
|
||||
static int testPattern(lua_State* L, const char* filename, int* fileMatched)
|
||||
static int testNoPrefix(lua_State* L, struct Word* word, const char* filename, int* fileMatched)
|
||||
{
|
||||
const char* prefix;
|
||||
const char* part;
|
||||
size_t i, n;
|
||||
int result = 0;
|
||||
if (filename && word->assertion && match(L, filename, word)) {
|
||||
(*fileMatched) = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* prefix = pattern.prefix */
|
||||
lua_getfield(L, -1, "prefix");
|
||||
prefix = lua_tostring(L, -1);
|
||||
|
||||
/*
|
||||
for i = 1, #pattern do
|
||||
local assertion = true
|
||||
local wildcard = false
|
||||
|
||||
part = pattern[i]
|
||||
|
||||
if part:startswith("%%") then
|
||||
part = part:sub(3)
|
||||
wildcard = true
|
||||
end
|
||||
|
||||
if part:startswith("not ") then
|
||||
part = part:sub(5)
|
||||
assertion = false
|
||||
end
|
||||
|
||||
if testContext(pattern.prefix, part, assertion) then
|
||||
result = true
|
||||
break
|
||||
end
|
||||
end
|
||||
*/
|
||||
|
||||
n = lua_objlen(L, -2);
|
||||
for (i = 1; i <= n; ++i) {
|
||||
int assertion = 1;
|
||||
int wildcard = 0;
|
||||
|
||||
lua_rawgeti(L, -2, i);
|
||||
|
||||
part = lua_tostring(L, -1);
|
||||
|
||||
if (part[0] == '%' && part[1] == '%') {
|
||||
part += 2;
|
||||
wildcard = 1;
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, 2)) {
|
||||
if (testValue(L, word)) {
|
||||
lua_pop(L, 2);
|
||||
return word->assertion;
|
||||
}
|
||||
|
||||
if (strncmp(part, "not ", 4) == 0) {
|
||||
part += 4;
|
||||
assertion = 0;
|
||||
}
|
||||
|
||||
if (testContext(L, prefix, part, assertion, wildcard, filename, fileMatched)) {
|
||||
lua_pop(L, 1);
|
||||
result = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
lua_pop(L, 1);
|
||||
return result;
|
||||
return (!word->assertion);
|
||||
}
|
||||
|
||||
|
||||
@ -253,57 +252,59 @@ int criteria_matches(lua_State* L)
|
||||
/* stack [1] = criteria */
|
||||
/* stack [2] = context */
|
||||
|
||||
struct Patterns* patterns;
|
||||
const char* filename;
|
||||
int fileMatched;
|
||||
int top = lua_gettop(L);
|
||||
int i, j, fileMatched;
|
||||
int matched = 1;
|
||||
|
||||
/*
|
||||
Cache string.match for a quicker lookup in match() above
|
||||
stack[3] = string
|
||||
stack[4] = string.match
|
||||
*/
|
||||
/* filename = context.files */
|
||||
lua_pushstring(L, "files");
|
||||
lua_rawget(L, 2);
|
||||
filename = lua_tostring(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
/* fetch the patterns to be tested */
|
||||
lua_pushstring(L, "data");
|
||||
lua_rawget(L, 1);
|
||||
patterns = (struct Patterns*)lua_touserdata(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
/* if a file is being matched, the pattern must be able to match it */
|
||||
if (patterns->prefixed && filename != NULL && patterns->filePatterns == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Cache string.match on the stack (at index 4) to save time in matches() later */
|
||||
|
||||
lua_getglobal(L, "string");
|
||||
lua_getfield(L, -1, "match");
|
||||
|
||||
/* filename = context.files */
|
||||
|
||||
lua_getfield(L, 2, "files");
|
||||
filename = lua_tostring(L, -1);
|
||||
/* if there is no file to consider, consider it matched */
|
||||
fileMatched = (filename == NULL);
|
||||
|
||||
/*
|
||||
for i, pattern in pairs(criteria.patterns) do
|
||||
if not testPattern(pattern) then
|
||||
matched = false
|
||||
break
|
||||
end
|
||||
end
|
||||
*/
|
||||
/* all patterns must match to pass */
|
||||
for (i = 0; matched && i < patterns->n; ++i) {
|
||||
struct Pattern* pattern = &patterns->pattern[i];
|
||||
|
||||
lua_getfield(L, 1, "patterns");
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, -2)) {
|
||||
if (!testPattern(L, filename, &fileMatched)) {
|
||||
matched = 0;
|
||||
break;
|
||||
/* only one word needs to match for the pattern to pass */
|
||||
matched = 0;
|
||||
|
||||
for (j = 0; !matched && j < pattern->n; ++j) {
|
||||
struct Word* word = &pattern->word[j];
|
||||
if (word->prefix) {
|
||||
matched = testWithPrefix(L, word, filename, &fileMatched);
|
||||
}
|
||||
else {
|
||||
matched = testNoPrefix(L, word, filename, &fileMatched);
|
||||
}
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
if matched and filename and not filematched then
|
||||
matched = false
|
||||
end
|
||||
return matched
|
||||
*/
|
||||
|
||||
if (filename != NULL && !fileMatched) {
|
||||
/* if a file name was provided in the context, it must be matched */
|
||||
if (filename && !fileMatched) {
|
||||
matched = 0;
|
||||
}
|
||||
|
||||
lua_settop(L, top);
|
||||
lua_pushboolean(L, matched);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* \file premake.c
|
||||
* \brief Program entry point.
|
||||
* \author Copyright (c) 2002-2013 Jason Perkins and the Premake project
|
||||
* \author Copyright (c) 2002-2014 Jason Perkins and the Premake project
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -36,6 +36,8 @@ extern const char* builtin_scripts[];
|
||||
|
||||
/* Built-in functions */
|
||||
static const luaL_Reg criteria_functions[] = {
|
||||
{ "_compile", criteria_compile },
|
||||
{ "_delete", criteria_delete },
|
||||
{ "matches", criteria_matches },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* \file premake.h
|
||||
* \brief Program-wide constants and definitions.
|
||||
* \author Copyright (c) 2002-2013 Jason Perkins and the Premake project
|
||||
* \author Copyright (c) 2002-2014 Jason Perkins and the Premake project
|
||||
*/
|
||||
|
||||
#define lua_c
|
||||
@ -62,6 +62,8 @@ void do_translate(char* value, const char sep);
|
||||
|
||||
|
||||
/* Built-in functions */
|
||||
int criteria_compile(lua_State* L);
|
||||
int criteria_delete(lua_State* L);
|
||||
int criteria_matches(lua_State* L);
|
||||
int path_getabsolute(lua_State* L);
|
||||
int path_getrelative(lua_State* L);
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/actions/make/cpp/test_file_rules.lua
|
||||
-- Validate the makefile source building rules.
|
||||
-- Copyright (c) 2009-2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("make_cpp_file_rules")
|
||||
@ -69,7 +69,7 @@ $(OBJDIR)/test.o: src/test.cpp
|
||||
|
||||
function suite.customBuildRule()
|
||||
files { "hello.x" }
|
||||
configuration "**.x"
|
||||
filter "files:**.x"
|
||||
buildmessage "Compiling %{file.name}"
|
||||
buildcommands {
|
||||
'cxc -c "%{file.path}" -o "%{cfg.objdir}/%{file.basename}.xo"',
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/actions/make/cpp/test_objects.lua
|
||||
-- Validate the list of objects for a makefile.
|
||||
-- Copyright (c) 2009-2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("make_cpp_objects")
|
||||
@ -61,9 +61,9 @@ OBJECTS := \
|
||||
--
|
||||
|
||||
function suite.configFilesAreConditioned()
|
||||
configuration "Debug"
|
||||
filter "Debug"
|
||||
files { "src/hello_debug.cpp" }
|
||||
configuration "Release"
|
||||
filter "Release"
|
||||
files { "src/hello_release.cpp" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -110,7 +110,7 @@ OBJECTS := \
|
||||
|
||||
function suite.customBuildRule()
|
||||
files { "hello.x" }
|
||||
configuration "**.x"
|
||||
filter "files:**.x"
|
||||
buildmessage "Compiling %{file.name}"
|
||||
buildcommands {
|
||||
'cxc -c "%{file.path}" -o "%{cfg.objdir}/%{file.basename}.xo"',
|
||||
@ -139,7 +139,7 @@ endif
|
||||
|
||||
function suite.excludedFromBuild_onExcludedFile()
|
||||
files { "hello.cpp" }
|
||||
configuration "Debug"
|
||||
filter "Debug"
|
||||
removefiles { "hello.cpp" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -158,7 +158,7 @@ endif
|
||||
|
||||
function suite.excludedFromBuild_onExcludeFlag()
|
||||
files { "hello.cpp" }
|
||||
configuration { "Debug", "hello.cpp" }
|
||||
filter { "Debug", "files:hello.cpp" }
|
||||
flags { "ExcludeFromBuild" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/actions/make/cs/test_embed_files.lua
|
||||
-- Tests embedded file listings for C# Makefiles.
|
||||
-- Copyright (c) 2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2013-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("make_cs_embed_files")
|
||||
@ -63,7 +63,7 @@ EMBEDFILES += \
|
||||
|
||||
function suite.doesIncludeCompileBuildAction()
|
||||
files { "Hello.txt" }
|
||||
configuration "*.txt"
|
||||
filter "files:*.txt"
|
||||
buildaction "Embed"
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/actions/make/cs/test_sources.lua
|
||||
-- Tests source file listings for C# Makefiles.
|
||||
-- Copyright (c) 2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2013-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("make_cs_sources")
|
||||
@ -78,7 +78,7 @@ SOURCES += \
|
||||
|
||||
function suite.doesIncludeCompileBuildAction()
|
||||
files { "Hello.txt" }
|
||||
configuration "*.txt"
|
||||
filter "files:*.txt"
|
||||
buildaction "Compile"
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
@ -1,11 +1,10 @@
|
||||
--
|
||||
-- tests/actions/vstudio/cs2005/test_files.lua
|
||||
-- Validate generation of <Files/> block in Visual Studio 2005 .csproj
|
||||
-- Copyright (c) 2009-2012 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.vstudio_cs2005_files = { }
|
||||
local suite = T.vstudio_cs2005_files
|
||||
local suite = test.declare("vstudio_cs2005_files")
|
||||
local cs2005 = premake.vstudio.cs2005
|
||||
|
||||
|
||||
@ -107,7 +106,7 @@
|
||||
|
||||
function suite.copyAction()
|
||||
files { "Hello.txt" }
|
||||
configuration "**.txt"
|
||||
filter "files:**.txt"
|
||||
buildaction "Copy"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -119,7 +118,7 @@
|
||||
|
||||
function suite.componentAction()
|
||||
files { "Hello.cs" }
|
||||
configuration "Hello.cs"
|
||||
filter "files:Hello.cs"
|
||||
buildaction "Component"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -131,7 +130,7 @@
|
||||
|
||||
function suite.embeddedResourceAction()
|
||||
files { "Hello.ico" }
|
||||
configuration "*.ico"
|
||||
filter "files:*.ico"
|
||||
buildaction "Embed"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -141,7 +140,7 @@
|
||||
|
||||
function suite.formAction()
|
||||
files { "HelloForm.cs" }
|
||||
configuration "HelloForm.cs"
|
||||
filter "files:HelloForm.cs"
|
||||
buildaction "Form"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -153,7 +152,7 @@
|
||||
|
||||
function suite.userControlAction()
|
||||
files { "Hello.cs" }
|
||||
configuration "Hello.cs"
|
||||
filter "files:Hello.cs"
|
||||
buildaction "UserControl"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -165,7 +164,7 @@
|
||||
|
||||
function suite.resourceAction()
|
||||
files { "Hello.ico" }
|
||||
configuration "*.ico"
|
||||
filter "files:*.ico"
|
||||
buildaction "Resource"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -201,7 +200,7 @@
|
||||
|
||||
function suite.usesLinkInFolder_onExternalContent()
|
||||
files { "../Resources/Hello.txt" }
|
||||
configuration "**.txt"
|
||||
filter "files:**.txt"
|
||||
buildaction "Copy"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -289,7 +288,7 @@
|
||||
|
||||
function suite.xamlApp_onBuildAction()
|
||||
files { "MyApp.xaml", "MyApp.xaml.cs" }
|
||||
configuration "MyApp.xaml"
|
||||
filter "files:MyApp.xaml"
|
||||
buildaction "Application"
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
@ -1,11 +1,10 @@
|
||||
--
|
||||
-- tests/actions/vstudio/sln2005/test_platforms.lua
|
||||
-- Test the Visual Studio 2005-2010 platform mapping blocks.
|
||||
-- Copyright (c) 2009-2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.vstudio_sln2005_platforms = { }
|
||||
local suite = T.vstudio_sln2005_platforms
|
||||
local suite = test.declare("vstudio_sln2005_platforms")
|
||||
local sln2005 = premake.vstudio.sln2005
|
||||
|
||||
|
||||
@ -360,9 +359,9 @@
|
||||
|
||||
function suite.onSingleCpp_withPlatforms_withArchs()
|
||||
platforms { "DLL32", "DLL64" }
|
||||
configuration "DLL32"
|
||||
filter "platforms:DLL32"
|
||||
architecture "x32"
|
||||
configuration "DLL64"
|
||||
filter "platforms:DLL64"
|
||||
architecture "x64"
|
||||
|
||||
project "MyProject"
|
||||
@ -389,9 +388,9 @@
|
||||
|
||||
function suite.onSingleCs_withPlatforms_withArchs()
|
||||
platforms { "DLL32", "DLL64" }
|
||||
configuration "DLL32"
|
||||
filter "platforms:DLL32"
|
||||
architecture "x32"
|
||||
configuration "DLL64"
|
||||
filter "platforms:DLL64"
|
||||
architecture "x64"
|
||||
|
||||
project "MyProject"
|
||||
@ -419,9 +418,9 @@
|
||||
|
||||
function suite.onMixedLanguage_withPlatforms_withArchs()
|
||||
platforms { "DLL32", "DLL64" }
|
||||
configuration "DLL32"
|
||||
filter "platforms:DLL32"
|
||||
architecture "x32"
|
||||
configuration "DLL64"
|
||||
filter "platforms:DLL64"
|
||||
architecture "x64"
|
||||
|
||||
project "MyProject1"
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc200x/test_files.lua
|
||||
-- Validate generation of <files/> block in Visual Studio 200x projects.
|
||||
-- Copyright (c) 2009-2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("vstudio_vs200x_files")
|
||||
@ -209,7 +209,7 @@
|
||||
|
||||
function suite.excludedFromBuild_onExcludedFile()
|
||||
files { "hello.cpp" }
|
||||
configuration "Debug"
|
||||
filter "Debug"
|
||||
removefiles { "hello.cpp" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -231,7 +231,7 @@
|
||||
|
||||
function suite.excludedFromBuild_onExcludeFlag()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
filter "files:hello.cpp"
|
||||
flags { "ExcludeFromBuild" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -261,10 +261,10 @@
|
||||
|
||||
function suite.excludedFromBuild_onCustomBuildRule_excludedFile()
|
||||
files { "hello.cg" }
|
||||
configuration "**.cg"
|
||||
filter "files:**.cg"
|
||||
buildcommands { "cgc $(InputFile)" }
|
||||
buildoutputs { "$(InputName).obj" }
|
||||
configuration "Debug"
|
||||
filter "Debug"
|
||||
removefiles { "hello.cg" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -288,7 +288,7 @@
|
||||
|
||||
function suite.excludedFromBuild_onCustomBuildRule_excludeFlag()
|
||||
files { "hello.cg" }
|
||||
configuration "**.cg"
|
||||
filter "files:**.cg"
|
||||
buildcommands { "cgc $(InputFile)" }
|
||||
buildoutputs { "$(InputName).obj" }
|
||||
flags { "ExcludeFromBuild" }
|
||||
@ -322,7 +322,7 @@
|
||||
|
||||
function suite.customBuildTool_onBuildRule()
|
||||
files { "hello.x" }
|
||||
configuration "**.x"
|
||||
filter "files:**.x"
|
||||
buildmessage "Compiling $(InputFile)"
|
||||
buildcommands {
|
||||
'cxc -c "$(InputFile)" -o "$(IntDir)/$(InputName).xo"',
|
||||
@ -350,7 +350,7 @@
|
||||
function suite.customBuildTool_onBuildRuleWithTokens()
|
||||
files { "hello.x" }
|
||||
objdir "../tmp/%{cfg.name}"
|
||||
configuration "**.x"
|
||||
filter "files:**.x"
|
||||
buildmessage "Compiling $(InputFile)"
|
||||
buildcommands {
|
||||
'cxc -c %{file.relpath} -o %{cfg.objdir}/%{file.basename}.xo',
|
||||
@ -424,7 +424,7 @@
|
||||
|
||||
function suite.forcedIncludeFiles()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
filter "files:**.cpp"
|
||||
forceincludes { "../include/force1.h", "../include/force2.h" }
|
||||
|
||||
prepare()
|
||||
@ -449,7 +449,7 @@
|
||||
|
||||
function suite.additionalOptions()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
filter "files:**.cpp"
|
||||
buildoptions { "/Xc" }
|
||||
|
||||
prepare()
|
||||
@ -474,7 +474,7 @@
|
||||
|
||||
function suite.onOptimize()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
filter "files:**.cpp"
|
||||
optimize "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -494,7 +494,7 @@
|
||||
|
||||
function suite.onOptimizeSize()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
filter "files:**.cpp"
|
||||
optimize "Size"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -513,7 +513,7 @@
|
||||
|
||||
function suite.onOptimizeSpeed()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
filter "files:**.cpp"
|
||||
optimize "Speed"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -532,7 +532,7 @@
|
||||
|
||||
function suite.onOptimizeFull()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
filter "files:**.cpp"
|
||||
optimize "Full"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -551,7 +551,7 @@
|
||||
|
||||
function suite.onOptimizeOff()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
filter "files:**.cpp"
|
||||
optimize "Off"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -570,7 +570,7 @@
|
||||
|
||||
function suite.onOptimizeDebug()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
filter "files:**.cpp"
|
||||
optimize "Debug"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -595,7 +595,7 @@
|
||||
|
||||
function suite.defines()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
filter "files:hello.cpp"
|
||||
defines { "HELLO" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc200x/test_project.lua
|
||||
-- Validate generation of the opening <VisualStudioProject> element.
|
||||
-- Copyright (c) 2011-2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2011-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("vstudio_vs200x_project")
|
||||
@ -114,9 +114,9 @@
|
||||
--
|
||||
|
||||
function suite.includeKeyword_onMixedConfigs()
|
||||
configuration "Debug"
|
||||
filter "Debug"
|
||||
system "Windows"
|
||||
configuration "Release"
|
||||
filter "Release"
|
||||
system "PS3"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -134,7 +134,7 @@
|
||||
|
||||
|
||||
--
|
||||
-- Makefile projects set new keyword. It should also drop the root
|
||||
-- Makefile projects set new keyword. It should also drop the root
|
||||
-- namespace, but I need to figure out a better way to test for
|
||||
-- empty configurations in the project first.
|
||||
--
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc2010/test_files.lua
|
||||
-- Validate generation of files block in Visual Studio 2010 C/C++ projects.
|
||||
-- Copyright (c) 2011-2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2011-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("vstudio_vs2010_files")
|
||||
@ -71,7 +71,7 @@
|
||||
|
||||
function suite.customBuild_onBuildRule()
|
||||
files { "hello.cg" }
|
||||
configuration "**.cg"
|
||||
filter "files:**.cg"
|
||||
buildcommands { "cgc $(InputFile)" }
|
||||
buildoutputs { "$(InputName).obj" }
|
||||
prepare()
|
||||
@ -91,7 +91,7 @@
|
||||
|
||||
function suite.customBuild_onBuildRuleWithMessage()
|
||||
files { "hello.cg" }
|
||||
configuration "**.cg"
|
||||
filter "files:**.cg"
|
||||
buildmessage "Compiling shader $(InputFile)"
|
||||
buildcommands { "cgc $(InputFile)" }
|
||||
buildoutputs { "$(InputName).obj" }
|
||||
@ -138,7 +138,7 @@
|
||||
|
||||
function suite.excludedFromBuild_onExcludedFile()
|
||||
files { "hello.cpp" }
|
||||
configuration "Debug"
|
||||
filter "Debug"
|
||||
removefiles { "hello.cpp" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -152,7 +152,7 @@
|
||||
|
||||
function suite.excludedFromBuild_onExcludeFlag()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
filter "files:hello.cpp"
|
||||
flags { "ExcludeFromBuild" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -167,7 +167,7 @@
|
||||
|
||||
function suite.excludedFromBuild_onResourceFile_excludedFile()
|
||||
files { "hello.rc" }
|
||||
configuration "Debug"
|
||||
filter "Debug"
|
||||
removefiles { "hello.rc" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -181,7 +181,7 @@
|
||||
|
||||
function suite.excludedFromBuild_onResourceFile_excludeFlag()
|
||||
files { "hello.rc" }
|
||||
configuration "hello.rc"
|
||||
filter "files:hello.rc"
|
||||
flags { "ExcludeFromBuild" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -197,7 +197,7 @@
|
||||
function suite.excludedFromBuild_onResourceFile_excludeFlag_nonWindows()
|
||||
files { "hello.rc" }
|
||||
system "PS3"
|
||||
configuration "hello.rc"
|
||||
filter "files:hello.rc"
|
||||
flags { "ExcludeFromBuild" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -209,10 +209,10 @@
|
||||
|
||||
function suite.excludedFromBuild_onCustomBuildRule_excludedFile()
|
||||
files { "hello.cg" }
|
||||
configuration "**.cg"
|
||||
filter "files:**.cg"
|
||||
buildcommands { "cgc $(InputFile)" }
|
||||
buildoutputs { "$(InputName).obj" }
|
||||
configuration "Debug"
|
||||
filter "Debug"
|
||||
removefiles { "hello.cg" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -228,7 +228,7 @@
|
||||
|
||||
function suite.excludedFromBuild_onCustomBuildRule_excludeFlag()
|
||||
files { "hello.cg" }
|
||||
configuration "**.cg"
|
||||
filter "files:**.cg"
|
||||
buildcommands { "cgc $(InputFile)" }
|
||||
buildoutputs { "$(InputName).obj" }
|
||||
flags { "ExcludeFromBuild" }
|
||||
@ -250,10 +250,10 @@
|
||||
|
||||
function suite.excludedFromBuild_onCustomBuildRule_withNoCommands()
|
||||
files { "hello.cg" }
|
||||
configuration { "**.cg", "Debug" }
|
||||
filter { "files:**.cg", "Debug" }
|
||||
buildcommands { "cgc $(InputFile)" }
|
||||
buildoutputs { "$(InputName).obj" }
|
||||
configuration { "**.cg" }
|
||||
filter { "files:**.cg" }
|
||||
flags { "ExcludeFromBuild" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -295,7 +295,7 @@
|
||||
|
||||
function suite.forcedIncludeFiles()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
filter "files:**.cpp"
|
||||
forceincludes { "../include/force1.h", "../include/force2.h" }
|
||||
|
||||
prepare()
|
||||
@ -316,7 +316,7 @@
|
||||
|
||||
function suite.additionalOptions()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
filter "files:**.cpp"
|
||||
buildoptions { "/Xc" }
|
||||
|
||||
prepare()
|
||||
@ -337,7 +337,7 @@
|
||||
|
||||
function suite.onOptimize()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
filter "files:hello.cpp"
|
||||
optimize "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -350,7 +350,7 @@
|
||||
|
||||
function suite.onOptimizeSize()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
filter "files:hello.cpp"
|
||||
optimize "Size"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -362,7 +362,7 @@
|
||||
|
||||
function suite.onOptimizeSpeed()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
filter "files:hello.cpp"
|
||||
optimize "Speed"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -374,7 +374,7 @@
|
||||
|
||||
function suite.onOptimizeFull()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
filter "files:hello.cpp"
|
||||
optimize "Full"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -386,7 +386,7 @@
|
||||
|
||||
function suite.onOptimizeOff()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
filter "files:hello.cpp"
|
||||
optimize "Off"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -398,7 +398,7 @@
|
||||
|
||||
function suite.onOptimizeDebug()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
filter "files:hello.cpp"
|
||||
optimize "Debug"
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -415,7 +415,7 @@
|
||||
|
||||
function suite.excludedFromPCH()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
filter "files:**.cpp"
|
||||
flags { "NoPCH" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -436,7 +436,7 @@
|
||||
|
||||
function suite.perFileDefines()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
filter "files:**.cpp"
|
||||
defines { "IS_CPP" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
@ -478,7 +478,7 @@
|
||||
|
||||
function suite.perFileVectorExtensions()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
filter "files:**.cpp"
|
||||
vectorextensions "sse2"
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
@ -1,11 +1,10 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc2010/test_filters.lua
|
||||
-- Validate generation of file filter blocks in Visual Studio 2010 C/C++ projects.
|
||||
-- Copyright (c) 2011-2012 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2011-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.vs2010_filters = { }
|
||||
local suite = T.vs2010_filters
|
||||
local suite = test.declare("vs2010_filters")
|
||||
local vc2010 = premake.vstudio.vc2010
|
||||
|
||||
|
||||
@ -67,7 +66,7 @@
|
||||
|
||||
function suite.itemGroup_onBuildRule()
|
||||
files { "hello.c", "hello.h", "hello.rc", "hello.cg" }
|
||||
configuration "**.cg"
|
||||
filter "files:**.cg"
|
||||
buildcommands { "cgc $(InputFile)" }
|
||||
buildoutputs { "$(InputName).obj" }
|
||||
prepare("CustomBuild")
|
||||
@ -80,7 +79,7 @@
|
||||
|
||||
function suite.itemGroup_onSingleConfigBuildRule()
|
||||
files { "hello.c", "hello.h", "hello.rc", "hello.cg" }
|
||||
configuration { "Release", "**.cg" }
|
||||
filter { "Release", "files:**.cg" }
|
||||
buildcommands { "cgc $(InputFile)" }
|
||||
buildoutputs { "$(InputName).obj" }
|
||||
prepare("CustomBuild")
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc2010/test_globals.lua
|
||||
-- Validate generation of the Globals property group.
|
||||
-- Copyright (c) 2011-2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2011-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("vstudio_vs2010_globals")
|
||||
@ -98,9 +98,9 @@
|
||||
--
|
||||
|
||||
function suite.includeKeyword_onMixedConfigs()
|
||||
configuration "Debug"
|
||||
filter "Debug"
|
||||
system "Windows"
|
||||
configuration "Release"
|
||||
filter "Release"
|
||||
system "PS3"
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
@ -1,11 +1,10 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc2010/test_project_configs.lua
|
||||
-- Test the Visual Studio 2010 project configurations item group.
|
||||
-- Copyright (c) 2009-2012 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.vstudio_vc2010_project_configs = { }
|
||||
local suite = T.vstudio_vc2010_project_configs
|
||||
local suite = test.declare("vstudio_vc2010_project_configs")
|
||||
local vc2010 = premake.vstudio.vc2010
|
||||
|
||||
|
||||
@ -55,9 +54,9 @@
|
||||
|
||||
function suite.allArchitecturesListed_onMultipleArchitectures()
|
||||
platforms { "32b", "64b" }
|
||||
configuration "32b"
|
||||
filter "platforms:32b"
|
||||
architecture "x32"
|
||||
configuration "64b"
|
||||
filter "platforms:64b"
|
||||
architecture "x64"
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/api/test_containers.lua
|
||||
-- Tests the API's solution() and project() container definitions.
|
||||
-- Copyright (c) 2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2013-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("api_containers")
|
||||
@ -76,7 +76,7 @@
|
||||
function suite.solution_onStar()
|
||||
project("MyProject")
|
||||
group("MyGroup")
|
||||
configuration("Debug")
|
||||
filter("Debug")
|
||||
solution "*"
|
||||
test.isnil(api.scope.solution)
|
||||
test.isnil(api.scope.project)
|
||||
@ -86,7 +86,7 @@
|
||||
function suite.project_onStar()
|
||||
project("MyProject")
|
||||
group("MyGroup")
|
||||
configuration("Debug")
|
||||
filter("Debug")
|
||||
project "*"
|
||||
test.issame(sln, api.scope.solution)
|
||||
test.isnil(api.scope.project)
|
||||
|
@ -22,6 +22,7 @@
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Make sure that new() returns a valid object.
|
||||
--
|
||||
@ -31,14 +32,20 @@
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Check the default values for different field types.
|
||||
--
|
||||
|
||||
function suite.defaultValue_onString()
|
||||
test.isnil(configset.fetch(cset, field.get("targetextension"), {}))
|
||||
test.isnil(configset.fetch(cset, field.get("targetextension")))
|
||||
end
|
||||
|
||||
function suite.defaultValue_onList()
|
||||
test.isequal({}, configset.fetch(cset, field.get("defines")))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Make sure that I can roundtrip a value stored into the
|
||||
@ -52,6 +59,7 @@
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Make sure that I can roundtrip a value stored into a block
|
||||
-- with a simple matching term.
|
||||
|
@ -16,23 +16,13 @@
|
||||
local crit
|
||||
|
||||
|
||||
--
|
||||
-- Make sure that new() returns a valid object.
|
||||
--
|
||||
|
||||
function suite.new_returnsValidObject()
|
||||
crit = criteria.new {}
|
||||
test.isequal("table", type(crit))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- A criteria with no terms should satisfy any context.
|
||||
--
|
||||
|
||||
function suite.matches_onEmptyCriteria()
|
||||
function suite.matches_alwaysTrue_onNoFilterTerms()
|
||||
crit = criteria.new {}
|
||||
test.istrue(criteria.matches(crit, { "apple", "orange" }))
|
||||
test.istrue(criteria.matches(crit, { configurations="Debug", system="Windows" }))
|
||||
end
|
||||
|
||||
|
||||
@ -40,9 +30,9 @@
|
||||
-- Should not match if any term is missing in the context.
|
||||
--
|
||||
|
||||
function suite.fails_onMissingContext()
|
||||
crit = criteria.new { "orange", "pear" }
|
||||
test.isfalse(criteria.matches(crit, { "apple", "orange" }))
|
||||
function suite.matches_fails_onMissingContext()
|
||||
crit = criteria.new { "system:Windows", "architecture:x32" }
|
||||
test.isfalse(criteria.matches(crit, { configurations="Debug", system="Windows" }))
|
||||
end
|
||||
|
||||
|
||||
@ -50,9 +40,9 @@
|
||||
-- Context terms must match the entire criteria term.
|
||||
--
|
||||
|
||||
function suite.fails_onIncompleteMatch()
|
||||
crit = criteria.new { "ps3" }
|
||||
test.isfalse(criteria.matches(crit, { "ps3 ppu sn" }))
|
||||
function suite.matches_fails_onIncompleteTermMatch()
|
||||
crit = criteria.new { "platforms:ps3" }
|
||||
test.isfalse(criteria.matches(crit, { platforms="ps3 ppu sn" }))
|
||||
end
|
||||
|
||||
|
||||
@ -60,9 +50,9 @@
|
||||
-- Wildcard matches should work.
|
||||
--
|
||||
|
||||
function suite.passes_onPatternMatch()
|
||||
crit = criteria.new { "vs*" }
|
||||
test.istrue(criteria.matches(crit, { "vs2005" }))
|
||||
function suite.matches_passes_onPatternMatch()
|
||||
crit = criteria.new { "action:vs*" }
|
||||
test.istrue(criteria.matches(crit, { action="vs2005" }))
|
||||
end
|
||||
|
||||
|
||||
@ -70,14 +60,29 @@
|
||||
-- The "not" modifier should fail the test if the term is matched.
|
||||
--
|
||||
|
||||
function suite.fails_onNotMatch()
|
||||
crit = criteria.new { "not windows" }
|
||||
test.isfalse(criteria.matches(crit, { "windows" }))
|
||||
function suite.matches_fails_onMatchWithNotModifier_afterPrefix()
|
||||
crit = criteria.new { "system:not windows" }
|
||||
test.isfalse(criteria.matches(crit, { system="windows" }))
|
||||
end
|
||||
|
||||
function suite.passes_onNotUnmatched()
|
||||
crit = criteria.new { "not windows" }
|
||||
test.istrue(criteria.matches(crit, { "linux" }))
|
||||
function suite.matches_fails_onMatchWithNotModifier_beforePrefix()
|
||||
crit = criteria.new { "not system:windows" }
|
||||
test.isfalse(criteria.matches(crit, { system="windows" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_onMissWithNotModifier_afterPrefix()
|
||||
crit = criteria.new { "system:not windows" }
|
||||
test.istrue(criteria.matches(crit, { system="linux" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_onMissWithNotModifier_beforePrefix()
|
||||
crit = criteria.new { "not system:windows" }
|
||||
test.istrue(criteria.matches(crit, { system="linux" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_onMissWithNotModifier_noPrefix()
|
||||
crit = criteria.new { "not debug" }
|
||||
test.istrue(criteria.matches(crit, { configurations="release" }))
|
||||
end
|
||||
|
||||
|
||||
@ -85,24 +90,44 @@
|
||||
-- The "or" modifier should pass if either term is present.
|
||||
--
|
||||
|
||||
function suite.passes_onFirstOrTermMatched()
|
||||
crit = criteria.new { "windows or linux" }
|
||||
test.istrue(criteria.matches(crit, { "windows" }))
|
||||
function suite.matches_passes_onFirstOrTermMatched()
|
||||
crit = criteria.new { "system:windows or linux" }
|
||||
test.istrue(criteria.matches(crit, { system="windows" }))
|
||||
end
|
||||
|
||||
function suite.passes_onSecondOrTermMatched()
|
||||
crit = criteria.new { "windows or linux" }
|
||||
test.istrue(criteria.matches(crit, { "linux" }))
|
||||
function suite.matches_passes_onSecondOrTermMatched()
|
||||
crit = criteria.new { "system:windows or linux" }
|
||||
test.istrue(criteria.matches(crit, { system="linux" }))
|
||||
end
|
||||
|
||||
function suite.passes_onThirdOrTermMatched()
|
||||
crit = criteria.new { "windows or linux or vs2005" }
|
||||
test.istrue(criteria.matches(crit, { "vs2005" }))
|
||||
function suite.matches_passes_onThirdOrTermMatched()
|
||||
crit = criteria.new { "system:windows or linux or vs2005" }
|
||||
test.istrue(criteria.matches(crit, { system="vs2005" }))
|
||||
end
|
||||
|
||||
function suite.fails_onNoOrTermMatched()
|
||||
crit = criteria.new { "windows or linux" }
|
||||
test.isfalse(criteria.matches(crit, { "vs2005" }))
|
||||
function suite.matches_fails_onNoOrTermMatched()
|
||||
crit = criteria.new { "system:windows or linux" }
|
||||
test.isfalse(criteria.matches(crit, { system="vs2005" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_onMixedPrefixes_firstTermMatched_projectContext()
|
||||
crit = criteria.new { "system:windows or files:core*" }
|
||||
test.istrue(criteria.matches(crit, { system="windows" }))
|
||||
end
|
||||
|
||||
function suite.matches_fails_onMixedPrefixes_firstTermMatched_fileContext()
|
||||
crit = criteria.new { "system:windows or files:core*" }
|
||||
test.isfalse(criteria.matches(crit, { system="windows", files="hello.cpp" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_onMixedPrefixes_secondTermMatched()
|
||||
crit = criteria.new { "system:windows or files:core*" }
|
||||
test.istrue(criteria.matches(crit, { system="linux", files="coregraphics.cpp" }))
|
||||
end
|
||||
|
||||
function suite.matches_fails_onMixedPrefixes_noTermMatched()
|
||||
crit = criteria.new { "system:windows or files:core*" }
|
||||
test.isfalse(criteria.matches(crit, { system="linux", files="hello.cpp" }))
|
||||
end
|
||||
|
||||
|
||||
@ -110,14 +135,14 @@
|
||||
-- The "not" modifier should fail on any match with an "or" modifier.
|
||||
--
|
||||
|
||||
function suite.passes_onNotOrMatchesFirst()
|
||||
crit = criteria.new { "not windows or linux" }
|
||||
test.isfalse(criteria.matches(crit, { "windows" }))
|
||||
function suite.matches_passes_onNotOrMatchesFirst()
|
||||
crit = criteria.new { "system:not windows or linux" }
|
||||
test.isfalse(criteria.matches(crit, { system="windows" }))
|
||||
end
|
||||
|
||||
function suite.passes_onNotOrMatchesSecond()
|
||||
crit = criteria.new { "windows or not linux" }
|
||||
test.isfalse(criteria.matches(crit, { "linux" }))
|
||||
function suite.matches_passes_onNotOrMatchesSecond()
|
||||
crit = criteria.new { "system:windows or not linux" }
|
||||
test.isfalse(criteria.matches(crit, { system="linux" }))
|
||||
end
|
||||
|
||||
|
||||
@ -125,102 +150,161 @@
|
||||
-- The "not" modifier should succeed with "or" if there are no matches.
|
||||
--
|
||||
|
||||
function suite.passes_onNoNotMatch()
|
||||
crit = criteria.new { "not windows or linux" }
|
||||
test.istrue(criteria.matches(crit, { "macosx" }))
|
||||
function suite.matches_passes_onNoNotMatch()
|
||||
crit = criteria.new { "system:not windows or linux" }
|
||||
test.istrue(criteria.matches(crit, { system="macosx" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a filename is provided, it must be matched by at least one pattern.
|
||||
-- If the context specifies a filename, the filter must match it explicitly.
|
||||
--
|
||||
|
||||
function suite.passes_onFilenameAndMatchingPattern()
|
||||
crit = criteria.new { "**.c", "windows" }
|
||||
test.istrue(criteria.matches(crit, { system = "windows", files = "hello.c" }))
|
||||
function suite.matches_passes_onFilenameAndMatchingPattern()
|
||||
crit = criteria.new { "files:**.c", "system:windows" }
|
||||
test.istrue(criteria.matches(crit, { system="windows", files="hello.c" }))
|
||||
end
|
||||
|
||||
function suite.fails_onFilenameAndNoMatchingPattern()
|
||||
crit = criteria.new { "windows" }
|
||||
test.isfalse(criteria.matches(crit, { "windows", files = "hello.c" }))
|
||||
function suite.matches_fails_onFilenameAndNoMatchingPattern()
|
||||
crit = criteria.new { "system:windows" }
|
||||
test.isfalse(criteria.matches(crit, { system="windows", files="hello.c" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- "Not" modifiers should not match filenames.
|
||||
-- "Not" modifiers can also be used on filenames.
|
||||
--
|
||||
|
||||
function suite.fails_onFilenameAndNotModifier()
|
||||
crit = criteria.new { "not linux" }
|
||||
test.isfalse(criteria.matches(crit, { "windows", files = "hello.c" }))
|
||||
function suite.matches_passes_onFilenameMissAndNotModifier()
|
||||
crit = criteria.new { "files:not **.c", "system:windows" }
|
||||
test.istrue(criteria.matches(crit, { system="windows", files="hello.h" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- "Open" or non-prefixed terms can match against any scope.
|
||||
--
|
||||
|
||||
function suite.openTerm_matchesAnyKeyedScope()
|
||||
crit = criteria.new { "debug" }
|
||||
test.istrue(criteria.matches(crit, { configuration="debug" }))
|
||||
function suite.matches_fails_onFilenameHitAndNotModifier()
|
||||
crit = criteria.new { "files:not **.c", "system:windows" }
|
||||
test.isfalse(criteria.matches(crit, { system="windows", files="hello.c" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Prefixed terms should only matching against context that
|
||||
-- uses a matching key.
|
||||
--
|
||||
|
||||
function suite.prefixedTermMatches_onKeyMatch()
|
||||
crit = criteria.new { "configurations:debug" }
|
||||
test.istrue(criteria.matches(crit, { configurations="debug" }))
|
||||
end
|
||||
|
||||
function suite.prefixedTermFails_onNoKeyMatch()
|
||||
crit = criteria.new { "configurations:debug" }
|
||||
test.isfalse(criteria.matches(crit, { configurations="release", platforms="debug" }))
|
||||
end
|
||||
|
||||
function suite.prefixTermFails_onFilenameMatch()
|
||||
crit = criteria.new { "configurations:hello**" }
|
||||
test.isfalse(criteria.matches(crit, { files = "hello.cpp" }))
|
||||
end
|
||||
|
||||
--
|
||||
-- If context provides a list of values, match against them.
|
||||
--
|
||||
|
||||
function suite.termMatchesList_onNoPrefix()
|
||||
crit = criteria.new { "debug" }
|
||||
test.istrue(criteria.matches(crit, { options={ "debug", "logging" }}))
|
||||
end
|
||||
|
||||
function suite.termMatchesList_onPrefix()
|
||||
function suite.matches_passes_termMatchesList()
|
||||
crit = criteria.new { "options:debug" }
|
||||
test.istrue(criteria.matches(crit, { options={ "debug", "logging" }}))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check handling of the files: prefix.
|
||||
-- If no prefix is specified, default to "configurations".
|
||||
--
|
||||
|
||||
function suite.matchesFilePrefix_onPositiveMatch()
|
||||
crit = criteria.new { "files:**.cpp" }
|
||||
test.istrue(criteria.matches(crit, { files = "hello.cpp" }))
|
||||
function suite.matches_usesDefaultPrefix_onSingleTerm()
|
||||
crit = criteria.new { "debug" }
|
||||
test.istrue(criteria.matches(crit, { configurations="debug" }))
|
||||
end
|
||||
|
||||
function suite.matchesFilePrefix_onNotModifier()
|
||||
crit = criteria.new { "files:not **.h" }
|
||||
test.istrue(criteria.matches(crit, { files = "hello.cpp" }))
|
||||
|
||||
|
||||
--
|
||||
-- These tests use the older, unprefixed style of filter terms. This
|
||||
-- approach will get phased out eventually, but are still included here
|
||||
-- for backward compatibility testing.
|
||||
--
|
||||
|
||||
function suite.matches_onEmptyCriteria_Unprefixed()
|
||||
crit = criteria.new({}, true)
|
||||
test.istrue(criteria.matches(crit, { "apple", "orange" }))
|
||||
end
|
||||
|
||||
function suite.filesTermFails_onNoValue()
|
||||
crit = criteria.new { "files:Debug**" }
|
||||
test.isfalse(criteria.matches(crit, { configurations = "Debug32" }))
|
||||
function suite.fails_onMissingContext_Unprefixed()
|
||||
crit = criteria.new({ "orange", "pear" }, true)
|
||||
test.isfalse(criteria.matches(crit, { "apple", "orange" }))
|
||||
end
|
||||
|
||||
function suite.filesTermFails_onNotModifierAndNoMatch()
|
||||
crit = criteria.new { "files:not Debug**" }
|
||||
test.isfalse(criteria.matches(crit, { configurations = "Debug32" }))
|
||||
function suite.fails_onIncompleteMatch_Unprefixed()
|
||||
crit = criteria.new({ "ps3" }, true)
|
||||
test.isfalse(criteria.matches(crit, { "ps3 ppu sn" }))
|
||||
end
|
||||
|
||||
function suite.passes_onPatternMatch_Unprefixed()
|
||||
crit = criteria.new({ "vs*" }, true)
|
||||
test.istrue(criteria.matches(crit, { "vs2005" }))
|
||||
end
|
||||
|
||||
function suite.fails_onNotMatch_Unprefixed()
|
||||
crit = criteria.new({ "not windows" }, true)
|
||||
test.isfalse(criteria.matches(crit, { "windows" }))
|
||||
end
|
||||
|
||||
function suite.passes_onNotUnmatched_Unprefixed()
|
||||
crit = criteria.new({ "not windows" }, true)
|
||||
test.istrue(criteria.matches(crit, { "linux" }))
|
||||
end
|
||||
|
||||
function suite.passes_onFirstOrTermMatched_Unprefixed()
|
||||
crit = criteria.new({ "windows or linux" }, true)
|
||||
test.istrue(criteria.matches(crit, { "windows" }))
|
||||
end
|
||||
|
||||
function suite.passes_onSecondOrTermMatched_Unprefixed()
|
||||
crit = criteria.new({ "windows or linux" }, true)
|
||||
test.istrue(criteria.matches(crit, { "linux" }))
|
||||
end
|
||||
|
||||
function suite.passes_onThirdOrTermMatched_Unprefixed()
|
||||
crit = criteria.new({ "windows or linux or vs2005" }, true)
|
||||
test.istrue(criteria.matches(crit, { "vs2005" }))
|
||||
end
|
||||
|
||||
function suite.fails_onNoOrTermMatched_Unprefixed()
|
||||
crit = criteria.new({ "windows or linux" }, true)
|
||||
test.isfalse(criteria.matches(crit, { "vs2005" }))
|
||||
end
|
||||
|
||||
function suite.passes_onNotOrMatchesFirst_Unprefixed()
|
||||
crit = criteria.new({ "not windows or linux" }, true)
|
||||
test.isfalse(criteria.matches(crit, { "windows" }))
|
||||
end
|
||||
|
||||
function suite.passes_onNotOrMatchesSecond_Unprefixed()
|
||||
crit = criteria.new({ "windows or not linux" }, true)
|
||||
test.isfalse(criteria.matches(crit, { "linux" }))
|
||||
end
|
||||
|
||||
function suite.passes_onNoNotMatch_Unprefixed()
|
||||
crit = criteria.new({ "not windows or linux" }, true)
|
||||
test.istrue(criteria.matches(crit, { "macosx" }))
|
||||
end
|
||||
|
||||
function suite.passes_onFilenameAndMatchingPattern_Unprefixed()
|
||||
crit = criteria.new({ "**.c", "windows" }, true)
|
||||
test.istrue(criteria.matches(crit, { system="windows", files="hello.c" }))
|
||||
end
|
||||
|
||||
function suite.fails_onFilenameAndNoMatchingPattern_Unprefixed()
|
||||
crit = criteria.new({ "windows" }, true)
|
||||
test.isfalse(criteria.matches(crit, { system="windows", files="hello.c" }))
|
||||
end
|
||||
|
||||
function suite.fails_onFilenameAndNotModifier_Unprefixed()
|
||||
crit = criteria.new({ "not linux" }, true)
|
||||
test.isfalse(criteria.matches(crit, { system="windows", files="hello.c" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_termMatchesList_Unprefixed()
|
||||
crit = criteria.new({ "debug" }, true)
|
||||
test.istrue(criteria.matches(crit, { options={ "debug", "logging" }}))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should return nil and an error message on an invalid prefix.
|
||||
--
|
||||
|
||||
function suite.returnsNilAndError_onInvalidPrefix()
|
||||
crit, err = criteria.new { "gibble:Debug" }
|
||||
test.isnil(crit)
|
||||
test.isnotnil(err)
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/base/test_validation.lua
|
||||
-- Verify the project information sanity checking.
|
||||
-- Copyright (c) 2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2013-20124 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("premake_validation")
|
||||
@ -100,7 +100,7 @@
|
||||
project "MyProject"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
configuration "Debug"
|
||||
filter "Debug"
|
||||
startproject "MyProject"
|
||||
premake.validate()
|
||||
test.stderr("'startproject' on config")
|
||||
@ -123,7 +123,7 @@
|
||||
project "MyProject"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
configuration "Debug"
|
||||
filter "Debug"
|
||||
location "MyProject"
|
||||
premake.validate()
|
||||
test.stderr("'location' on config")
|
||||
@ -135,7 +135,7 @@
|
||||
project "MyProject"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
configuration "Debug"
|
||||
filter "Debug"
|
||||
vpaths { ["Headers"] = "**.h" }
|
||||
premake.validate()
|
||||
test.stderr("'vpaths' on config")
|
||||
@ -147,7 +147,7 @@
|
||||
project "MyProject"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
configuration "Debug"
|
||||
filter "Debug"
|
||||
configurations "Deployment"
|
||||
premake.validate()
|
||||
test.stderr("'configurations' on config")
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/oven/test_filtering.lua
|
||||
-- Test the project object configuration accessor.
|
||||
-- Copyright (c) 2011-2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2011-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("oven_filtering")
|
||||
@ -30,7 +30,7 @@
|
||||
|
||||
function suite.onAction()
|
||||
_ACTION = "vs2012"
|
||||
configuration { "vs2012" }
|
||||
filter { "action:vs2012" }
|
||||
defines { "USE_VS2012" }
|
||||
prepare()
|
||||
test.isequal({ "USE_VS2012" }, prj.defines)
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
function suite.onActionMismatch()
|
||||
_ACTION = "vs2010"
|
||||
configuration { "vs2012" }
|
||||
filter { "action:vs2012" }
|
||||
defines { "USE_VS2012" }
|
||||
prepare()
|
||||
test.isequal({}, prj.defines)
|
||||
@ -51,14 +51,14 @@
|
||||
|
||||
function suite.onOptionNoValue()
|
||||
_OPTIONS["release"] = ""
|
||||
configuration { "release" }
|
||||
filter { "options:release" }
|
||||
defines { "USE_RELEASE" }
|
||||
prepare()
|
||||
test.isequal({ "USE_RELEASE" }, prj.defines)
|
||||
end
|
||||
|
||||
function suite.onOptionNoValueUnset()
|
||||
configuration { "release" }
|
||||
filter { "options:release" }
|
||||
defines { "USE_RELEASE" }
|
||||
prepare()
|
||||
test.isequal({ }, prj.defines)
|
||||
@ -66,7 +66,7 @@
|
||||
|
||||
function suite.onOptionWithValue()
|
||||
_OPTIONS["renderer"] = "opengl"
|
||||
configuration { "renderer=opengl" }
|
||||
filter { "options:renderer=opengl" }
|
||||
defines { "USE_OPENGL" }
|
||||
prepare()
|
||||
test.isequal({ "USE_OPENGL" }, prj.defines)
|
||||
@ -74,14 +74,14 @@
|
||||
|
||||
function suite.onOptionWithValueMismatch()
|
||||
_OPTIONS["renderer"] = "direct3d"
|
||||
configuration { "renderer=opengl" }
|
||||
filter { "options:renderer=opengl" }
|
||||
defines { "USE_OPENGL" }
|
||||
prepare()
|
||||
test.isequal({ }, prj.defines)
|
||||
end
|
||||
|
||||
function suite.onOptionWithValueUnset()
|
||||
configuration { "renderer=opengl" }
|
||||
filter { "options:renderer=opengl" }
|
||||
defines { "USE_OPENGL" }
|
||||
prepare()
|
||||
test.isequal({ }, prj.defines)
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/project/test_config_maps.lua
|
||||
-- Test mapping from solution to project configurations.
|
||||
-- Copyright (c) 2012-2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("project_config_maps")
|
||||
@ -154,7 +154,7 @@
|
||||
function suite.canBubbleUp_onConfiguration()
|
||||
platforms { "XCUA", "XCUB" }
|
||||
|
||||
configuration { "CCU" }
|
||||
filter { "platforms:CCU" }
|
||||
configmap { XCUA = "CCU", XCUB = "CCU" }
|
||||
|
||||
project "MyProject"
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/project/test_getconfig.lua
|
||||
-- Test the project object configuration accessor.
|
||||
-- Copyright (c) 2011-2013 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2011-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("project_getconfig")
|
||||
@ -31,7 +31,7 @@
|
||||
function suite.usesCurrentOS_onNoSystemSpecified()
|
||||
_OS = "linux"
|
||||
project ("MyProject")
|
||||
configuration { "linux" }
|
||||
filter { "system:linux" }
|
||||
defines { "correct" }
|
||||
prepare()
|
||||
test.isequal("correct", cfg.defines[1])
|
||||
@ -48,7 +48,7 @@
|
||||
_OS = "linux"
|
||||
_ACTION = "vs2005"
|
||||
project ("MyProject")
|
||||
configuration { "windows" }
|
||||
filter { "system:windows" }
|
||||
defines { "correct" }
|
||||
prepare()
|
||||
test.isequal("correct", cfg.defines[1])
|
||||
@ -65,7 +65,7 @@
|
||||
_ACTION = "vs2005"
|
||||
project ("MyProject")
|
||||
system "macosx"
|
||||
configuration { "macosx" }
|
||||
filter { "system:macosx" }
|
||||
defines { "correct" }
|
||||
prepare()
|
||||
test.isequal("correct", cfg.defines[1])
|
||||
@ -79,7 +79,7 @@
|
||||
function suite.appliesActionToFilters()
|
||||
_ACTION = "vs2005"
|
||||
project ("MyProject")
|
||||
configuration { "vs2005" }
|
||||
filter { "action:vs2005" }
|
||||
defines { "correct" }
|
||||
prepare()
|
||||
test.isequal("correct", cfg.defines[1])
|
||||
|
Reference in New Issue
Block a user