Merged pull request #26: added dependson command to allow dependency without linking
This commit is contained in:
commit
82633e66ce
121
src/base/api.lua
121
src/base/api.lua
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
premake.fields = {}
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- A place to store the current active objects in each project scope.
|
||||
@ -40,7 +40,7 @@
|
||||
if not name then
|
||||
error("missing name", 2)
|
||||
end
|
||||
|
||||
|
||||
if _G[name] then
|
||||
error("name in use", 2)
|
||||
end
|
||||
@ -49,22 +49,22 @@
|
||||
if not api.getsetter(field) then
|
||||
error("invalid kind '" .. kind .. "'", 2)
|
||||
end
|
||||
|
||||
|
||||
-- add this new field to my master list
|
||||
premake.fields[field.name] = field
|
||||
|
||||
|
||||
-- add create a setter function for it
|
||||
_G[name] = function(value)
|
||||
return api.callback(field, value)
|
||||
end
|
||||
|
||||
|
||||
-- list values also get a removal function
|
||||
if api.islistfield(field) and not api.iskeyedfield(field) then
|
||||
_G["remove" .. name] = function(value)
|
||||
return api.remove(field, value)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- if the field needs special handling, tell the config
|
||||
-- set system about it
|
||||
configset.registerfield(field.name, {
|
||||
@ -85,7 +85,7 @@
|
||||
else
|
||||
target = api.scope.configuration or api.scope.root
|
||||
end
|
||||
|
||||
|
||||
return target
|
||||
end
|
||||
|
||||
@ -97,20 +97,20 @@
|
||||
|
||||
function api.callback(field, value)
|
||||
local target = api.gettarget(field.scope)
|
||||
|
||||
|
||||
if not value then
|
||||
return target.configset[field.name]
|
||||
end
|
||||
|
||||
local status, result = pcall(function ()
|
||||
local status, result = pcall(function ()
|
||||
if api.iskeyedfield(field) then
|
||||
api.setkeyvalue(target, field, value)
|
||||
api.setkeyvalue(target, field, value)
|
||||
else
|
||||
local setter = api.getsetter(field, true)
|
||||
setter(target, field.name, field, value)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
if not status then
|
||||
if type(result) == "table" then
|
||||
result = result.msg
|
||||
@ -137,7 +137,7 @@
|
||||
local remover = api["remove" .. kind] or table.insert
|
||||
|
||||
local removes = {}
|
||||
|
||||
|
||||
function recurse(value)
|
||||
if type(value) == "table" then
|
||||
for _, v in ipairs(value) do
|
||||
@ -149,7 +149,7 @@
|
||||
end
|
||||
|
||||
recurse(value)
|
||||
|
||||
|
||||
local target = api.gettarget(field.scope)
|
||||
configset.removevalues(target.configset, field.name, removes)
|
||||
end
|
||||
@ -176,8 +176,8 @@
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if field.allowed then
|
||||
if type(field.allowed) == "function" then
|
||||
return field.allowed(value)
|
||||
@ -219,7 +219,7 @@
|
||||
function api.iskeyedfield(field)
|
||||
return field.kind:startswith("key-")
|
||||
end
|
||||
|
||||
|
||||
function api.islistfield(field)
|
||||
return field.kind:endswith("-list")
|
||||
end
|
||||
@ -268,14 +268,14 @@
|
||||
function api.setarray(target, name, field, value)
|
||||
-- if the target is the project, configset will be set and I can push
|
||||
-- the value there. Otherwise I was called to store into some other kind
|
||||
-- of object (i.e. an array or list)
|
||||
-- of object (i.e. an array or list)
|
||||
target = target.configset or target
|
||||
|
||||
|
||||
-- put simple values in an array
|
||||
if type(value) ~= "table" then
|
||||
value = { value }
|
||||
end
|
||||
|
||||
|
||||
-- store it, overwriting any existing value
|
||||
target[name] = value
|
||||
end
|
||||
@ -309,11 +309,11 @@
|
||||
target[name] = path.getabsolute(value)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function api.removefile(target, value)
|
||||
table.insert(target, path.getabsolute(value))
|
||||
end
|
||||
|
||||
|
||||
api.removedirectory = api.removefile
|
||||
|
||||
|
||||
@ -326,14 +326,14 @@
|
||||
if type(values) ~= "table" then
|
||||
error({ msg="value must be a table of key-value pairs" })
|
||||
end
|
||||
|
||||
|
||||
local newval = {}
|
||||
|
||||
|
||||
local setter = api.getsetter(field, true)
|
||||
for key, value in pairs(values) do
|
||||
setter(newval, key, field, value)
|
||||
end
|
||||
|
||||
|
||||
configset.addvalue(target.configset, field.name, newval)
|
||||
end
|
||||
|
||||
@ -405,9 +405,9 @@
|
||||
|
||||
-- if the target is the project, configset will be set and I can push
|
||||
-- the value there. Otherwise I was called to store into some other kind
|
||||
-- of object (i.e. an array or list)
|
||||
-- of object (i.e. an array or list)
|
||||
target = target.configset or target
|
||||
|
||||
|
||||
target[name] = value
|
||||
end
|
||||
|
||||
@ -437,7 +437,7 @@
|
||||
name = "buildaction",
|
||||
scope = "config",
|
||||
kind = "string",
|
||||
allowed = {
|
||||
allowed = {
|
||||
"Compile",
|
||||
"Copy",
|
||||
"Embed",
|
||||
@ -470,7 +470,7 @@
|
||||
scope = "project",
|
||||
kind = "string-list",
|
||||
}
|
||||
|
||||
|
||||
api.register {
|
||||
name = "debugargs",
|
||||
scope = "config",
|
||||
@ -491,7 +491,7 @@
|
||||
kind = "path",
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
|
||||
api.register {
|
||||
name = "debugenvs",
|
||||
scope = "config",
|
||||
@ -507,14 +507,21 @@
|
||||
"c7",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
api.register {
|
||||
name = "defines",
|
||||
scope = "config",
|
||||
kind = "string-list",
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
|
||||
api.register {
|
||||
name = "dependson",
|
||||
scope = "config",
|
||||
kind = "string-list",
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "deploymentoptions",
|
||||
scope = "config",
|
||||
@ -613,22 +620,22 @@
|
||||
name = "imageoptions",
|
||||
scope = "config",
|
||||
kind = "string-list",
|
||||
tokens = true,
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
|
||||
api.register {
|
||||
name = "imagepath",
|
||||
scope = "config",
|
||||
kind = "path",
|
||||
tokens = true,
|
||||
}
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "implibdir",
|
||||
scope = "config",
|
||||
kind = "path",
|
||||
tokens = true,
|
||||
}
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "implibextension",
|
||||
@ -701,7 +708,7 @@
|
||||
kind = "string-list",
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
|
||||
api.register {
|
||||
name = "links",
|
||||
scope = "config",
|
||||
@ -728,7 +735,7 @@
|
||||
scope = "config",
|
||||
kind = "string-list",
|
||||
tokens = true,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
api.register {
|
||||
@ -757,7 +764,7 @@
|
||||
scope = "config",
|
||||
kind = "path",
|
||||
tokens = true,
|
||||
}
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "platforms",
|
||||
@ -829,7 +836,7 @@
|
||||
scope = "config",
|
||||
kind = "path",
|
||||
tokens = true,
|
||||
}
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "targetextension",
|
||||
@ -917,13 +924,13 @@
|
||||
|
||||
function premake.getobject(t)
|
||||
local container
|
||||
|
||||
|
||||
if (t == "container" or t == "solution") then
|
||||
container = premake.CurrentContainer
|
||||
else
|
||||
container = premake.CurrentConfiguration
|
||||
end
|
||||
|
||||
|
||||
if t == "solution" then
|
||||
if type(container) == "project" then
|
||||
container = container.solution
|
||||
@ -932,7 +939,7 @@
|
||||
container = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local msg
|
||||
if (not container) then
|
||||
if (t == "container") then
|
||||
@ -943,7 +950,7 @@
|
||||
msg = "no active solution, project, or configuration"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return container, msg
|
||||
end
|
||||
|
||||
@ -963,15 +970,15 @@
|
||||
if (not container) then
|
||||
error(err, 2)
|
||||
end
|
||||
|
||||
|
||||
local cfg = { }
|
||||
cfg.terms = table.flatten({terms})
|
||||
cfg.basedir = os.getcwd()
|
||||
cfg.configset = container.configset
|
||||
|
||||
|
||||
table.insert(container.blocks, cfg)
|
||||
premake.CurrentConfiguration = cfg
|
||||
|
||||
|
||||
-- create a keyword list using just the indexed keyword items. This is a little
|
||||
-- confusing: "terms" are what the user specifies in the script, "keywords" are
|
||||
-- the Lua patterns that result. I'll refactor to better names.
|
||||
@ -1024,7 +1031,7 @@
|
||||
|
||||
sln.projects[name] = prj
|
||||
end
|
||||
|
||||
|
||||
prj.script = _SCRIPT
|
||||
prj.usage = isUsage;
|
||||
prj.group = api.scope.group or ""
|
||||
@ -1040,31 +1047,31 @@
|
||||
if(premake.CurrentContainer.usage) then return nil end
|
||||
return premake.CurrentContainer
|
||||
end
|
||||
|
||||
|
||||
-- identify the parent solution
|
||||
local sln
|
||||
if (type(premake.CurrentContainer) == "project") then
|
||||
sln = premake.CurrentContainer.solution
|
||||
else
|
||||
sln = premake.CurrentContainer
|
||||
end
|
||||
end
|
||||
if (type(sln) ~= "solution") then
|
||||
error("no active solution", 2)
|
||||
end
|
||||
|
||||
|
||||
-- if this is a new project, or the old project is a usage project, create it
|
||||
if((not sln.projects[name]) or sln.projects[name].usage) then
|
||||
premake.CurrentContainer = createproject(name, sln)
|
||||
else
|
||||
premake.CurrentContainer = sln.projects[name];
|
||||
end
|
||||
|
||||
|
||||
-- add an empty, global configuration to the project
|
||||
configuration {}
|
||||
|
||||
|
||||
-- this is the new place for storing scoped objects
|
||||
api.scope.project = premake.CurrentContainer
|
||||
|
||||
|
||||
return premake.CurrentContainer
|
||||
end
|
||||
|
||||
@ -1081,7 +1088,7 @@
|
||||
return premake.CurrentContainer
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
premake.CurrentContainer = premake.solution.get(name)
|
||||
if (not premake.CurrentContainer) then
|
||||
local sln = premake.solution.new(name)
|
||||
@ -1090,12 +1097,12 @@
|
||||
|
||||
-- add an empty, global configuration
|
||||
configuration {}
|
||||
|
||||
|
||||
-- this is the new place for storing scoped objects
|
||||
api.scope.solution = premake.CurrentContainer
|
||||
api.scope.project = nil
|
||||
api.scope.group = nil
|
||||
|
||||
|
||||
return premake.CurrentContainer
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
--
|
||||
|
||||
premake.project = { }
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Create a tree from a project's list of files, representing the filesystem hierarchy.
|
||||
@ -22,11 +22,11 @@
|
||||
tr.project = prj
|
||||
|
||||
local isvpath
|
||||
|
||||
|
||||
local function onadd(node)
|
||||
node.isvpath = isvpath
|
||||
end
|
||||
|
||||
|
||||
for fcfg in premake.project.eachfile(prj) do
|
||||
isvpath = (fcfg.name ~= fcfg.vpath)
|
||||
local node = premake.tree.add(tr, fcfg.vpath, onadd)
|
||||
@ -47,10 +47,10 @@
|
||||
function premake.eachconfig(prj, platform)
|
||||
-- I probably have the project root config, rather than the actual project
|
||||
if prj.project then prj = prj.project end
|
||||
|
||||
|
||||
local cfgs = prj.solution.configurations
|
||||
local i = 0
|
||||
|
||||
|
||||
return function ()
|
||||
i = i + 1
|
||||
if i <= #cfgs then
|
||||
@ -58,7 +58,7 @@
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
@ -105,8 +105,8 @@
|
||||
return value
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Given a map of supported platform identifiers, filters the solution's list
|
||||
@ -130,17 +130,17 @@
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if #result == 0 and default then
|
||||
table.insert(result, default)
|
||||
end
|
||||
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
|
||||
--
|
||||
-- Locate a project by name; case insensitive.
|
||||
--
|
||||
|
||||
@ -153,8 +153,8 @@
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Locate a file in a project with a given extension; used to locate "special"
|
||||
@ -219,12 +219,12 @@
|
||||
return iif(useshortname, name:lower(), name)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Returns a list of sibling projects on which the specified project depends.
|
||||
-- This is used to list dependencies within a solution or workspace. Must
|
||||
-- Returns a list of sibling projects on which the specified project depends.
|
||||
-- This is used to list dependencies within a solution or workspace. Must
|
||||
-- consider all configurations because Visual Studio does not support per-config
|
||||
-- project dependencies.
|
||||
--
|
||||
@ -237,15 +237,22 @@
|
||||
function premake.getdependencies(prj)
|
||||
-- make sure I've got the project and not root config
|
||||
prj = prj.project or prj
|
||||
|
||||
|
||||
local function add_to_project_list(depproj, results)
|
||||
local dep = premake.findproject(depproj)
|
||||
if dep and not table.contains(results, dep) then
|
||||
table.insert(results, dep)
|
||||
end
|
||||
end
|
||||
|
||||
local results = { }
|
||||
for _, cfg in pairs(prj.__configs) do
|
||||
for _, link in ipairs(cfg.links) do
|
||||
local dep = premake.findproject(link)
|
||||
if dep and not table.contains(results, dep) then
|
||||
table.insert(results, dep)
|
||||
end
|
||||
add_to_project_list(link, results)
|
||||
end
|
||||
for _, depproj in ipairs(cfg.dependson) do
|
||||
add_to_project_list(depproj, results)
|
||||
end
|
||||
end
|
||||
|
||||
return results
|
||||
@ -271,9 +278,9 @@
|
||||
fname = path.join(premake5.project.getlocation(prj), fname)
|
||||
return path.getrelative(os.getcwd(), fname)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Returns a list of link targets. Kind may be one of:
|
||||
-- siblings - linkable sibling projects
|
||||
@ -287,21 +294,21 @@
|
||||
-- directory - just the directory, no name
|
||||
-- fullpath - full path with decorated name
|
||||
-- object - return the project object of the dependency
|
||||
--
|
||||
|
||||
--
|
||||
|
||||
function premake.getlinks(cfg, kind, part)
|
||||
-- if I'm building a list of link directories, include libdirs
|
||||
local result = iif (part == "directory" and kind == "all", cfg.libdirs, {})
|
||||
|
||||
-- am I getting links for a configuration or a project?
|
||||
local cfgname = iif(cfg.name == cfg.project.name, "", cfg.name)
|
||||
|
||||
|
||||
-- how should files be named?
|
||||
local pathstyle = premake.getpathstyle(cfg)
|
||||
local namestyle = premake.getnamestyle(cfg)
|
||||
|
||||
|
||||
local function canlink(source, target)
|
||||
if (target.kind ~= "SharedLib" and target.kind ~= "StaticLib") then
|
||||
if (target.kind ~= "SharedLib" and target.kind ~= "StaticLib") then
|
||||
return false
|
||||
end
|
||||
if premake.iscppproject(source) then
|
||||
@ -310,14 +317,14 @@
|
||||
return premake.isdotnetproject(target)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
for _, link in ipairs(cfg.links) do
|
||||
local item
|
||||
|
||||
|
||||
-- is this a sibling project?
|
||||
local prj = premake.findproject(link)
|
||||
if prj and kind ~= "system" then
|
||||
|
||||
|
||||
local prjcfg = premake.getconfig(prj, cfgname, cfg.platform)
|
||||
if kind == "dependencies" or canlink(cfg, prjcfg) then
|
||||
if (part == "directory") then
|
||||
@ -332,7 +339,7 @@
|
||||
end
|
||||
|
||||
elseif not prj and (kind == "system" or kind == "all") then
|
||||
|
||||
|
||||
if (part == "directory") then
|
||||
local dir = path.getdirectory(link)
|
||||
if (dir ~= ".") then
|
||||
@ -365,12 +372,12 @@
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Gets the name style for a configuration, indicating what kind of prefix,
|
||||
-- extensions, etc. should be used in target file names.
|
||||
@ -384,7 +391,7 @@
|
||||
function premake.getnamestyle(cfg)
|
||||
return premake.platforms[cfg.platform].namestyle or premake.gettool(cfg).namestyle or "posix"
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
@ -404,7 +411,7 @@
|
||||
return "posix"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Assembles a target for a particular tool/system/configuration.
|
||||
@ -434,18 +441,18 @@
|
||||
--
|
||||
|
||||
function premake.gettarget(cfg, direction, pathstyle, namestyle, system)
|
||||
if system == "bsd" or system == "solaris" then
|
||||
system = "linux"
|
||||
if system == "bsd" or system == "solaris" then
|
||||
system = "linux"
|
||||
end
|
||||
|
||||
-- Fix things up based on the current system
|
||||
local kind = cfg.kind
|
||||
if premake.iscppproject(cfg) then
|
||||
-- On Windows, shared libraries link against a static import library
|
||||
if (namestyle == "windows" or system == "windows")
|
||||
and kind == "SharedLib" and direction == "link"
|
||||
and not cfg.flags.NoImportLib
|
||||
then
|
||||
if (namestyle == "windows" or system == "windows")
|
||||
and kind == "SharedLib" and direction == "link"
|
||||
and not cfg.flags.NoImportLib
|
||||
then
|
||||
kind = "StaticLib"
|
||||
end
|
||||
|
||||
@ -492,11 +499,11 @@
|
||||
ext = ".a"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
prefix = cfg[field.."prefix"] or cfg.targetprefix or prefix
|
||||
suffix = cfg[field.."suffix"] or cfg.targetsuffix or suffix
|
||||
ext = cfg[field.."extension"] or cfg.targetextension or ext
|
||||
|
||||
|
||||
-- build the results object
|
||||
local result = { }
|
||||
result.basename = name .. suffix
|
||||
@ -506,12 +513,12 @@
|
||||
result.suffix = suffix
|
||||
result.fullpath = path.join(result.directory, result.name)
|
||||
result.bundlepath = bundlepath or result.fullpath
|
||||
|
||||
|
||||
if pathstyle == "windows" then
|
||||
result.directory = path.translate(result.directory, "\\")
|
||||
result.fullpath = path.translate(result.fullpath, "\\")
|
||||
end
|
||||
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
@ -535,8 +542,8 @@
|
||||
return premake.dotnet
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Given a source file path, return a corresponding virtual path based on
|
||||
@ -546,24 +553,24 @@
|
||||
|
||||
function premake.project.getvpath(prj, filename)
|
||||
prj = prj.project
|
||||
|
||||
|
||||
-- if there is no match, return the input filename
|
||||
local vpath = filename
|
||||
|
||||
for replacement,patterns in pairs(prj.vpaths or {}) do
|
||||
for _,pattern in ipairs(patterns) do
|
||||
pattern = premake5.project.getrelative(prj, pattern)
|
||||
|
||||
|
||||
-- does the filename match this vpath pattern?
|
||||
local i = vpath:find(path.wildcards(pattern))
|
||||
if i == 1 then
|
||||
if i == 1 then
|
||||
-- yes; trim the leading portion of the path
|
||||
i = pattern:find("*", 1, true) or (pattern:len() + 1)
|
||||
local leaf = vpath:sub(i)
|
||||
if leaf:startswith("/") then
|
||||
leaf = leaf:sub(2)
|
||||
end
|
||||
|
||||
|
||||
-- check for (and remove) stars in the replacement pattern.
|
||||
-- If there are none, then trim all path info from the leaf
|
||||
-- and use just the filename in the replacement (stars should
|
||||
@ -575,12 +582,12 @@
|
||||
leaf = path.getname(leaf)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
vpath = path.join(stem, leaf)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- remove any dot ("./", "../") patterns from the start of the path
|
||||
local changed
|
||||
repeat
|
||||
@ -593,12 +600,12 @@
|
||||
changed = false
|
||||
end
|
||||
until not changed
|
||||
|
||||
|
||||
return vpath
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
--
|
||||
-- Returns true if the solution contains at least one C/C++ project.
|
||||
--
|
||||
|
||||
@ -610,9 +617,9 @@
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
|
||||
--
|
||||
-- Returns true if the solution contains at least one .NET project.
|
||||
--
|
||||
|
||||
|
@ -70,7 +70,7 @@
|
||||
local ctx = context.new(prj.configset, environ)
|
||||
context.addterms(ctx, _ACTION)
|
||||
context.addterms(ctx, prj.language)
|
||||
|
||||
|
||||
-- allow script to override system and architecture
|
||||
ctx.system = ctx.system or premake.action.current().os or os.get()
|
||||
context.addterms(ctx, ctx.system)
|
||||
@ -91,9 +91,9 @@
|
||||
|
||||
-- apply any mappings to the project's list of configurations and platforms
|
||||
ctx._cfglist = project.bakeconfiglist(ctx, cfgs)
|
||||
|
||||
|
||||
-- TODO: OLD, REMOVE: build an old-style configuration to wrap context, for now
|
||||
|
||||
|
||||
-- TODO: OLD, REMOVE: build an old-style configuration to wrap context, for now
|
||||
local result = oven.merge(oven.merge({}, sln), prj)
|
||||
result.solution = sln
|
||||
result.blocks = prj.blocks
|
||||
@ -101,15 +101,15 @@
|
||||
|
||||
-- prevent any default system setting from influencing configurations
|
||||
result.system = nil
|
||||
|
||||
|
||||
-- TODO: HACK, TRANSITIONAL, REMOVE: pass requests for missing values
|
||||
-- through to the config context. Eventually all values will be in the
|
||||
|
||||
-- TODO: HACK, TRANSITIONAL, REMOVE: pass requests for missing values
|
||||
-- through to the config context. Eventually all values will be in the
|
||||
-- context and the cfg wrapper can be done away with
|
||||
setmetatable(prj, nil)
|
||||
|
||||
result.context = ctx
|
||||
prj.context = ctx
|
||||
prj.context = ctx
|
||||
setmetatable(result, {
|
||||
__index = function(prj, key)
|
||||
return prj.context[key]
|
||||
@ -124,14 +124,14 @@
|
||||
local buildcfg = pairing[1]
|
||||
local platform = pairing[2]
|
||||
local cfg = project.bakeconfig(result, buildcfg, platform)
|
||||
|
||||
|
||||
-- make sure this config is supported by the action; skip if not
|
||||
if premake.action.supportsconfig(cfg) then
|
||||
configs[(buildcfg or "*") .. (platform or "")] = cfg
|
||||
end
|
||||
end
|
||||
result.configs = configs
|
||||
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
@ -215,7 +215,7 @@
|
||||
--
|
||||
|
||||
function project.bakeconfig(prj, buildcfg, platform)
|
||||
-- set the default system and architecture values; for backward
|
||||
-- set the default system and architecture values; for backward
|
||||
-- compatibility, use platform if it would be a valid value
|
||||
local system = premake.action.current().os or os.get()
|
||||
local architecture = nil
|
||||
@ -266,8 +266,8 @@
|
||||
ctx.action = _ACTION
|
||||
ctx.language = prj.language
|
||||
|
||||
|
||||
-- TODO: OLD, REMOVE: build an old-style configuration to wrap context, for now
|
||||
|
||||
-- TODO: OLD, REMOVE: build an old-style configuration to wrap context, for now
|
||||
local filter = {
|
||||
["buildcfg"] = buildcfg,
|
||||
["platform"] = platform,
|
||||
@ -275,7 +275,7 @@
|
||||
["system"] = ctx.system,
|
||||
["architecture"] = ctx.architecture,
|
||||
}
|
||||
|
||||
|
||||
local cfg = oven.bake(prj, prj.solution, filter)
|
||||
cfg.solution = prj.solution
|
||||
cfg.project = prj
|
||||
@ -300,8 +300,8 @@
|
||||
environ.cfg = proxy
|
||||
|
||||
|
||||
-- TODO: HACK, TRANSITIONAL, REMOVE: pass requests for missing values
|
||||
-- through to the config context. Eventually all values will be in the
|
||||
-- TODO: HACK, TRANSITIONAL, REMOVE: pass requests for missing values
|
||||
-- through to the config context. Eventually all values will be in the
|
||||
-- context and the cfg wrapper can be done away with
|
||||
setmetatable(cfg, {
|
||||
__index = function(cfg, key)
|
||||
@ -312,7 +312,7 @@
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
|
||||
-- fill in any calculated values
|
||||
premake5.config.bake(cfg)
|
||||
|
||||
@ -321,6 +321,10 @@
|
||||
|
||||
|
||||
--
|
||||
|
||||
|
||||
|
||||
|
||||
-- Returns an iterator function for the configuration objects contained by
|
||||
-- the project. Each configuration corresponds to a build configuration/
|
||||
-- platform pair (i.e. "Debug|x32") as specified in the solution.
|
||||
@ -340,7 +344,7 @@
|
||||
|
||||
local configs = prj._cfglist
|
||||
local count = #configs
|
||||
|
||||
|
||||
local i = 0
|
||||
return function ()
|
||||
i = i + 1
|
||||
@ -351,7 +355,7 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
--
|
||||
-- Locate a project by name; case insensitive.
|
||||
--
|
||||
-- @param name
|
||||
@ -372,7 +376,7 @@
|
||||
|
||||
|
||||
--
|
||||
-- Retrieve the project's configuration information for a particular build
|
||||
-- Retrieve the project's configuration information for a particular build
|
||||
-- configuration/platform pair.
|
||||
--
|
||||
-- @param prj
|
||||
@ -384,35 +388,35 @@
|
||||
-- @return
|
||||
-- A configuration object.
|
||||
--
|
||||
|
||||
|
||||
function project.getconfig(prj, buildcfg, platform)
|
||||
-- to make testing a little easier, allow this function to
|
||||
-- accept an unbaked project, and fix it on the fly
|
||||
if not prj.baked then
|
||||
prj = project.bake(prj, prj.solution)
|
||||
end
|
||||
|
||||
|
||||
-- if no build configuration is specified, return the "root" project
|
||||
-- configurations, which includes all configuration values that
|
||||
-- weren't set with a specific configuration filter
|
||||
if not buildcfg then
|
||||
return prj
|
||||
end
|
||||
|
||||
|
||||
-- apply any configuration mappings
|
||||
local pairing = project.mapconfig(prj, buildcfg, platform)
|
||||
buildcfg = pairing[1]
|
||||
platform = pairing[2]
|
||||
|
||||
-- look up and return the associated config
|
||||
-- look up and return the associated config
|
||||
local key = (buildcfg or "*") .. (platform or "")
|
||||
return prj.configs[key]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Returns a list of sibling projects on which the specified project depends.
|
||||
-- This is used to list dependencies within a solution or workspace. Must
|
||||
-- Returns a list of sibling projects on which the specified project depends.
|
||||
-- This is used to list dependencies within a solution or workspace. Must
|
||||
-- consider all configurations because Visual Studio does not support per-config
|
||||
-- project dependencies.
|
||||
--
|
||||
@ -425,12 +429,19 @@
|
||||
function project.getdependencies(prj)
|
||||
if not prj.dependencies then
|
||||
local result = {}
|
||||
for cfg in project.eachconfig(prj) do
|
||||
for _, link in ipairs(cfg.links) do
|
||||
local dep = premake.solution.findproject(cfg.solution, link)
|
||||
local function add_to_project_list(cfg, depproj, result)
|
||||
local dep = premake.solution.findproject(cfg.solution, depproj)
|
||||
if dep and not table.contains(result, dep) then
|
||||
table.insert(result, dep)
|
||||
end
|
||||
end
|
||||
|
||||
for cfg in project.eachconfig(prj) do
|
||||
for _, link in ipairs(cfg.links) do
|
||||
add_to_project_list(cfg, link, result)
|
||||
end
|
||||
for _, depproj in ipairs(cfg.dependson) do
|
||||
add_to_project_list(cfg, depproj, result)
|
||||
end
|
||||
end
|
||||
prj.dependencies = result
|
||||
@ -466,7 +477,7 @@
|
||||
fcfg.name = path.getname(filename)
|
||||
fcfg.basename = path.getbasename(filename)
|
||||
fcfg.path = fcfg.relpath
|
||||
|
||||
|
||||
return fcfg
|
||||
end
|
||||
|
||||
@ -501,26 +512,26 @@
|
||||
function project.getfileobject(prj, filename)
|
||||
-- make sure I have the project, and not it's root configuration
|
||||
prj = prj.project or prj
|
||||
|
||||
|
||||
-- create a list of objects if necessary
|
||||
prj.fileobjects = prj.fileobjects or {}
|
||||
|
||||
-- look for the corresponding object file
|
||||
-- look for the corresponding object file
|
||||
local basename = path.getbasename(filename)
|
||||
local uniqued = basename
|
||||
local i = 0
|
||||
|
||||
|
||||
while prj.fileobjects[uniqued] do
|
||||
-- found a match?
|
||||
if prj.fileobjects[uniqued] == filename then
|
||||
return uniqued
|
||||
end
|
||||
|
||||
|
||||
-- check a different name
|
||||
i = i + 1
|
||||
uniqued = basename .. i
|
||||
end
|
||||
|
||||
|
||||
-- no match, create a new one
|
||||
prj.fileobjects[uniqued] = filename
|
||||
return uniqued
|
||||
@ -564,7 +575,7 @@
|
||||
end
|
||||
if not location then
|
||||
location = prj.basedir
|
||||
end
|
||||
end
|
||||
if relativeto then
|
||||
location = path.getrelative(relativeto, location)
|
||||
end
|
||||
@ -618,7 +629,7 @@
|
||||
function project.getsourcetree(prj)
|
||||
-- make sure I have the project, and not it's root configuration
|
||||
prj = prj.project or prj
|
||||
|
||||
|
||||
-- check for a previously cached tree
|
||||
if prj.sourcetree then
|
||||
return prj.sourcetree
|
||||
@ -634,10 +645,10 @@
|
||||
|
||||
-- create a file config lookup cache
|
||||
prj.fileconfigs = {}
|
||||
|
||||
|
||||
-- create a tree from the file list
|
||||
local tr = premake.tree.new(prj.name)
|
||||
|
||||
|
||||
for file in pairs(files) do
|
||||
local fcfg = project.getfileconfig(prj, file)
|
||||
|
||||
@ -646,23 +657,23 @@
|
||||
-- virtual paths are used when adding nodes.
|
||||
local node = premake.tree.add(tr, fcfg.vpath, function(node)
|
||||
-- ...but when a real file system path is used, store it so that
|
||||
-- an association can be made in the IDE
|
||||
-- an association can be made in the IDE
|
||||
if fcfg.vpath == fcfg.relpath then
|
||||
node.realpath = node.path
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
-- Store full file configuration in file (leaf) nodes
|
||||
for key, value in pairs(fcfg) do
|
||||
node[key] = value
|
||||
end
|
||||
|
||||
|
||||
prj.fileconfigs[node.abspath] = node
|
||||
end
|
||||
|
||||
premake.tree.trimroot(tr)
|
||||
premake.tree.sort(tr)
|
||||
|
||||
|
||||
-- cache result and return
|
||||
prj.sourcetree = tr
|
||||
return tr
|
||||
@ -678,7 +689,7 @@
|
||||
function project.getvpath(prj, filename)
|
||||
-- if there is no match, return the input filename
|
||||
local vpath = filename
|
||||
|
||||
|
||||
for replacement,patterns in pairs(prj.vpaths or {}) do
|
||||
for _,pattern in ipairs(patterns) do
|
||||
|
||||
@ -710,12 +721,12 @@
|
||||
else
|
||||
leaf = path.getname(leaf)
|
||||
end
|
||||
|
||||
|
||||
vpath = path.join(stem, leaf)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return vpath
|
||||
end
|
||||
|
||||
@ -765,7 +776,7 @@
|
||||
|
||||
function project.mapconfig(prj, buildcfg, platform)
|
||||
local pairing = { buildcfg, platform }
|
||||
|
||||
|
||||
local testpattern = function(pattern, pairing, i)
|
||||
local j = 1
|
||||
while i <= #pairing and j <= #pattern do
|
||||
@ -777,12 +788,12 @@
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
for pattern, replacements in pairs(prj.configmap or {}) do
|
||||
if type(pattern) ~= "table" then
|
||||
pattern = { pattern }
|
||||
end
|
||||
|
||||
|
||||
-- does this pattern match any part of the pair? If so,
|
||||
-- replace it with the corresponding values
|
||||
for i = 1, #pairing do
|
||||
@ -795,7 +806,7 @@
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return pairing
|
||||
end
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
--
|
||||
|
||||
local sln, prj
|
||||
|
||||
|
||||
function suite.setup()
|
||||
_ACTION = "vs2008"
|
||||
sln = test.createsolution()
|
||||
@ -42,7 +42,7 @@
|
||||
|
||||
|
||||
--
|
||||
-- If a sibling project is listed in links(), an item group should
|
||||
-- If a sibling project is listed in links()/dependson(), an item group should
|
||||
-- be written with a reference to that sibling project.
|
||||
--
|
||||
|
||||
@ -59,8 +59,22 @@
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.projectReferenceAdded_onSiblingProjectDependson()
|
||||
dependson { "MyProject" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="MyProject.vcproj">
|
||||
<Project>{00112233-4455-6677-8888-99AABBCCDDEE}</Project>
|
||||
<Name>MyProject</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Project references should always be specified relative to the
|
||||
-- Project references should always be specified relative to the
|
||||
-- project doing the referencing.
|
||||
--
|
||||
|
||||
@ -79,4 +93,4 @@
|
||||
</ItemGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
|
@ -10,25 +10,31 @@
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local sln, prj1, prj2
|
||||
|
||||
|
||||
function suite.setup()
|
||||
_ACTION = "vs2005"
|
||||
sln, prj1 = test.createsolution()
|
||||
uuid "AE61726D-187C-E440-BD07-2556188A6565"
|
||||
prj2 = test.createproject(sln)
|
||||
uuid "2151E83B-997F-4A9D-955D-380157E88C31"
|
||||
prj3 = test.createproject(sln)
|
||||
uuid "CAA68162-8B96-11E1-8D5E-5885BBE59B18"
|
||||
links "MyProject"
|
||||
dependson "MyProject2"
|
||||
end
|
||||
|
||||
|
||||
local function prepare(language)
|
||||
prj1.language = language
|
||||
prj2.language = language
|
||||
prj2 = premake.solution.getproject_ng(sln, 2)
|
||||
sln2005.projectdependencies_ng(prj2)
|
||||
prj3.language = language
|
||||
prj3 = premake.solution.getproject_ng(sln, 3)
|
||||
sln2005.projectdependencies_ng(prj3)
|
||||
end
|
||||
|
||||
|
||||
@ -40,6 +46,7 @@
|
||||
test.capture [[
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{AE61726D-187C-E440-BD07-2556188A6565} = {AE61726D-187C-E440-BD07-2556188A6565}
|
||||
{2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31}
|
||||
EndProjectSection
|
||||
]]
|
||||
end
|
||||
@ -54,6 +61,7 @@
|
||||
test.capture [[
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{AE61726D-187C-E440-BD07-2556188A6565} = {AE61726D-187C-E440-BD07-2556188A6565}
|
||||
{2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31}
|
||||
EndProjectSection
|
||||
]]
|
||||
end
|
||||
@ -70,6 +78,7 @@
|
||||
test.capture [[
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{AE61726D-187C-E440-BD07-2556188A6565} = {AE61726D-187C-E440-BD07-2556188A6565}
|
||||
{2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31}
|
||||
EndProjectSection
|
||||
]]
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user