Merge pull request #228 from LORgames/ssurtees/multipleWorkspacesFix
Fixed a bug when including (includeexternal) the same project in multiple workspaces
This commit is contained in:
commit
aeca0bb3fd
@ -221,6 +221,20 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Finds the correct premake script filename to be run.
|
||||
--
|
||||
-- @param fname
|
||||
-- The filename of the script to run.
|
||||
-- @return
|
||||
-- The correct location and filename of the script to run.
|
||||
--
|
||||
|
||||
function premake.findProjectScript(fname)
|
||||
return os.locate(fname, fname .. ".lua", path.join(fname, "premake5.lua"), path.join(fname, "premake4.lua"))
|
||||
end
|
||||
|
||||
|
||||
---
|
||||
-- "Immediate If" - returns one of the two values depending on the value
|
||||
-- of the provided condition. Note that both the true and false expressions
|
||||
|
@ -76,12 +76,15 @@
|
||||
---
|
||||
-- Register a general-purpose includeExternal() call which works just like
|
||||
-- include(), but marks any containers created while evaluating the included
|
||||
-- scripts as external.
|
||||
-- scripts as external. It also, loads the file regardless of how many times
|
||||
-- it has been loaded already.
|
||||
---
|
||||
|
||||
function includeexternal(fname)
|
||||
local fullPath = premake.findProjectScript(fname)
|
||||
api._isIncludingExternal = true
|
||||
include(fname)
|
||||
fname = fullPath or fname
|
||||
dofile(fname)
|
||||
api._isIncludingExternal = nil
|
||||
end
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
||||
io._includedFiles = {}
|
||||
|
||||
function include(fname)
|
||||
local fullPath = os.locate(fname, fname .. ".lua", path.join(fname, "premake5.lua"), path.join(fname, "premake4.lua"))
|
||||
local fullPath = premake.findProjectScript(fname)
|
||||
fname = fullPath or fname
|
||||
if not io._includedFiles[fname] then
|
||||
io._includedFiles[fname] = true
|
||||
|
@ -46,3 +46,21 @@
|
||||
include (_TESTS_DIR .. "/../tests/folder/premake5.lua")
|
||||
test.isequal("ok", premake.captured())
|
||||
end
|
||||
|
||||
function suite.includeexternal_runs()
|
||||
includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
test.isequal("ok", premake.captured())
|
||||
end
|
||||
|
||||
function suite.includeexternal_runsAfterInclude()
|
||||
include (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
test.isequal("okok", premake.captured())
|
||||
end
|
||||
|
||||
function suite.includeexternal_runsTwiceAfterInclude()
|
||||
include (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
test.isequal("okokok", premake.captured())
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user