Baking changes to support tokens in object directories
This commit is contained in:
parent
7675e057d2
commit
aded68ba8a
@ -50,7 +50,7 @@
|
||||
--
|
||||
|
||||
function solution.bakeall()
|
||||
result = {}
|
||||
local result = {}
|
||||
for i, sln in ipairs(solution.list) do
|
||||
result[i] = solution.bake(sln)
|
||||
end
|
||||
@ -138,7 +138,10 @@
|
||||
local configs = {}
|
||||
|
||||
for prj in premake.solution.eachproject_ng(sln) do
|
||||
for cfg in project.eachconfig(prj, "objdir") do
|
||||
for cfg in project.eachconfig(prj) do
|
||||
-- expand any tokens contained in the field
|
||||
oven.expandtokens(cfg, "config", nil, "objdir")
|
||||
|
||||
-- get the dirs for this config, and remember the association
|
||||
local dirs = getobjdirs(cfg)
|
||||
configs[cfg] = dirs
|
||||
|
@ -119,7 +119,7 @@
|
||||
-- Scan an object for expandable tokens, and expand them, in place.
|
||||
--
|
||||
|
||||
function oven.expandtokens(cfg, scope, filecfg)
|
||||
function oven.expandtokens(cfg, scope, filecfg, fieldname)
|
||||
-- build a context for the tokens to use
|
||||
local context = {
|
||||
sln = cfg.solution,
|
||||
@ -140,12 +140,18 @@
|
||||
end
|
||||
|
||||
local target = filecfg or cfg
|
||||
for key, value in pairs(target) do
|
||||
-- to avoid unexpected errors or recursions, I only process
|
||||
-- Premake's own API fields, and only those marked for it
|
||||
local field = premake.fields[key]
|
||||
if field ~= nil and field.tokens and field.scope == scope then
|
||||
expand(target, key)
|
||||
if fieldname then
|
||||
if target[fieldname] then
|
||||
expand(target, fieldname)
|
||||
end
|
||||
else
|
||||
for key, value in pairs(target) do
|
||||
-- to avoid unexpected errors or recursions, I only process
|
||||
-- Premake's own API fields, and only those marked for it
|
||||
local field = premake.fields[key]
|
||||
if field ~= nil and field.tokens and field.scope == scope then
|
||||
expand(target, key)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -200,17 +200,11 @@
|
||||
--
|
||||
-- @param prj
|
||||
-- The project object to query.
|
||||
-- @param field
|
||||
-- An optional field name. If specified, only that field will be
|
||||
-- included in the resulting configuration object.
|
||||
-- @param filename
|
||||
-- An optional file name. If specified, only configuration blocks
|
||||
-- with a keyword matching the filename will be considered.
|
||||
-- @return
|
||||
-- An iterator function returning configuration objects.
|
||||
--
|
||||
|
||||
function project.eachconfig(prj, field, filename)
|
||||
function project.eachconfig(prj)
|
||||
-- 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
|
||||
|
@ -119,3 +119,13 @@
|
||||
prepare()
|
||||
test.isequal("a", cfg.testapi)
|
||||
end
|
||||
|
||||
--
|
||||
-- Make sure I can use tokens in the objects directory, which can also be a token itself.
|
||||
--
|
||||
|
||||
function suite.canUseTokensInObjDir()
|
||||
objdir "tmp/%{prj.name}_%{cfg.buildcfg}"
|
||||
prepare()
|
||||
test.isequal("tmp/MyProject_Debug", cfg.objdir)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user