Merge branch 'master' into master
This commit is contained in:
commit
26558d1597
@ -1,6 +1,7 @@
|
||||
require ("gmake2")
|
||||
|
||||
return {
|
||||
"test_gmake2_buildcmds.lua",
|
||||
"test_gmake2_clang.lua",
|
||||
"test_gmake2_file_rules.lua",
|
||||
"test_gmake2_flags.lua",
|
||||
|
57
modules/gmake2/tests/test_gmake2_buildcmds.lua
Normal file
57
modules/gmake2/tests/test_gmake2_buildcmds.lua
Normal file
@ -0,0 +1,57 @@
|
||||
|
||||
|
||||
|
||||
local suite = test.declare("gmake2_buildcommands")
|
||||
local gmake2 = premake.modules.gmake2
|
||||
|
||||
premake.api.register {
|
||||
name = 'test_libdir', -- this controls the targetdir for StaticLib projects.
|
||||
scope = 'config',
|
||||
kind = 'path',
|
||||
tokens = true,
|
||||
pathVars = true,
|
||||
}
|
||||
|
||||
local wks, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
wks = workspace("MyWorkspace")
|
||||
test_libdir (path.join(_MAIN_SCRIPT_DIR, 'lib'))
|
||||
configurations { "Debug", "Release" }
|
||||
prj = test.createProject(wks)
|
||||
end
|
||||
|
||||
|
||||
local function prepare()
|
||||
wks = test.getWorkspace(wks)
|
||||
prj = test.getproject(wks, 1)
|
||||
cfg = test.getconfig(prj, "Debug")
|
||||
|
||||
local toolset = gmake2.getToolSet(cfg)
|
||||
gmake2.postBuildCmds(cfg, toolset)
|
||||
end
|
||||
|
||||
|
||||
function suite.postbuildcommands()
|
||||
targetname "blink"
|
||||
kind "StaticLib"
|
||||
language "C++"
|
||||
|
||||
postbuildcommands
|
||||
{
|
||||
"mkdir %{cfg.test_libdir}/www",
|
||||
"mkdir %{cfg.test_libdir}/www"
|
||||
}
|
||||
|
||||
prepare()
|
||||
|
||||
test.capture [[
|
||||
define POSTBUILDCMDS
|
||||
@echo Running postbuild commands
|
||||
mkdir lib/www
|
||||
mkdir lib/www
|
||||
endef
|
||||
]]
|
||||
end
|
||||
|
||||
|
@ -31,24 +31,21 @@
|
||||
--
|
||||
|
||||
function detoken.expand(value, environ, field, basedir)
|
||||
field = field or {}
|
||||
|
||||
-- fetch the path variable from the action, if needed
|
||||
local varMap = {}
|
||||
if field.pathVars then
|
||||
local action = p.action.current()
|
||||
if action then
|
||||
varMap = action.pathVars or {}
|
||||
function expandtoken(token, e, f)
|
||||
-- fetch the path variable from the action, if needed
|
||||
local varMap = {}
|
||||
if f.pathVars then
|
||||
local action = p.action.current()
|
||||
if action then
|
||||
varMap = action.pathVars or {}
|
||||
end
|
||||
end
|
||||
end
|
||||
-- fetch the pathVars from the enviroment.
|
||||
local envMap = e.pathVars or {}
|
||||
|
||||
-- fetch the pathVars from the enviroment.
|
||||
local envMap = environ.pathVars or {}
|
||||
-- enable access to the global environment
|
||||
setmetatable(e, {__index = _G})
|
||||
|
||||
-- enable access to the global environment
|
||||
setmetatable(environ, {__index = _G})
|
||||
|
||||
function expandtoken(token, e)
|
||||
local isAbs = false
|
||||
local err
|
||||
local result
|
||||
@ -111,7 +108,7 @@
|
||||
result = path.resolvedeferredjoin(result)
|
||||
end
|
||||
isAbs = path.isabsolute(result)
|
||||
if isAbs and not field.paths and basedir and not dontMakeRelative then
|
||||
if isAbs and not f.paths and basedir and not dontMakeRelative then
|
||||
result = path.getrelative(basedir, result)
|
||||
end
|
||||
end
|
||||
@ -132,14 +129,13 @@
|
||||
-- result, which should always be the last absolute path specified:
|
||||
-- "/home/user/myprj/obj/Debug"
|
||||
|
||||
if result ~= nil and isAbs and field.paths then
|
||||
if result ~= nil and isAbs and f.paths then
|
||||
result = "\0" .. result
|
||||
end
|
||||
|
||||
return result, err
|
||||
end
|
||||
|
||||
function expandvalue(value, e)
|
||||
function expandvalue(value, e, f)
|
||||
if type(value) ~= "string" then
|
||||
return value
|
||||
end
|
||||
@ -147,7 +143,7 @@
|
||||
local count
|
||||
repeat
|
||||
value, count = value:gsub("%%{(.-)}", function(token)
|
||||
local result, err = expandtoken(token:gsub("\\", "\\\\"), e)
|
||||
local result, err = expandtoken(token:gsub("\\", "\\\\"), e, f)
|
||||
if err then
|
||||
error(err .. " in token: " .. token, 0)
|
||||
end
|
||||
@ -159,7 +155,7 @@
|
||||
until count == 0
|
||||
|
||||
-- if a path, look for a split out embedded absolute paths
|
||||
if field.paths then
|
||||
if f.paths then
|
||||
local i, j
|
||||
repeat
|
||||
i, j = value:find("\0")
|
||||
@ -168,29 +164,35 @@
|
||||
end
|
||||
until not i
|
||||
end
|
||||
|
||||
return value
|
||||
end
|
||||
|
||||
function recurse(value, e)
|
||||
local expand_cache = {}
|
||||
|
||||
function recurse(value, e, f)
|
||||
if type(value) == "table" then
|
||||
local res_table = {}
|
||||
|
||||
for k, v in pairs(value) do
|
||||
if tonumber(k) ~= nil then
|
||||
res_table[k] = recurse(v, e)
|
||||
res_table[k] = recurse(v, e, f)
|
||||
else
|
||||
local nk = recurse(k, e);
|
||||
res_table[nk] = recurse(v, e)
|
||||
local nk = recurse(k, e, f)
|
||||
res_table[nk] = recurse(v, e, f)
|
||||
end
|
||||
end
|
||||
|
||||
return res_table
|
||||
else
|
||||
return expandvalue(value, e)
|
||||
local res = expand_cache[value]
|
||||
if res == nil then
|
||||
res = expandvalue(value, e, f)
|
||||
expand_cache[value] = res
|
||||
end
|
||||
return res
|
||||
end
|
||||
end
|
||||
|
||||
return recurse(value, environ)
|
||||
return recurse(value, environ, field or {})
|
||||
end
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
local cset, parentset
|
||||
|
||||
function suite.setup()
|
||||
local wks = test.createWorkspace()
|
||||
parentset = configset.new()
|
||||
cset = configset.new(parentset)
|
||||
end
|
||||
|
Reference in New Issue
Block a user