Added virtual path support to Xcode3
This commit is contained in:
parent
1a074ba81b
commit
112483417b
@ -397,7 +397,7 @@
|
||||
_p(3,'name = Products;')
|
||||
else
|
||||
_p(3,'name = "%s";', node.name)
|
||||
if node.path then
|
||||
if node.path and not node.isvpath then
|
||||
local p = node.path
|
||||
if node.parent.path then
|
||||
p = path.getrelative(node.parent.path, node.path)
|
||||
|
@ -21,8 +21,15 @@
|
||||
local tr = premake.tree.new(prj.name)
|
||||
tr.project = prj
|
||||
|
||||
local isvpath
|
||||
|
||||
local function onadd(node)
|
||||
node.isvpath = isvpath
|
||||
end
|
||||
|
||||
for fcfg in premake.project.eachfile(prj) do
|
||||
local node = premake.tree.add(tr, fcfg.vpath)
|
||||
isvpath = (fcfg.name ~= fcfg.vpath)
|
||||
local node = premake.tree.add(tr, fcfg.vpath, onadd)
|
||||
node.cfg = fcfg
|
||||
end
|
||||
|
||||
|
@ -31,11 +31,14 @@
|
||||
-- The tree to contain the new node.
|
||||
-- @param p
|
||||
-- The path of the new node.
|
||||
-- @param onaddfunc
|
||||
-- A function to call when a new node is added to the tree. Receives the
|
||||
-- new node as an argument.
|
||||
-- @returns
|
||||
-- The new tree node.
|
||||
--
|
||||
|
||||
function premake.tree.add(tr, p)
|
||||
function premake.tree.add(tr, p, onaddfunc)
|
||||
-- Special case "." refers to the current node
|
||||
if p == "." then
|
||||
return tr
|
||||
@ -43,7 +46,7 @@
|
||||
|
||||
-- Look for the immediate parent for this new node, creating it if necessary.
|
||||
-- Recurses to create as much of the tree as necessary.
|
||||
local parentnode = tree.add(tr, path.getdirectory(p))
|
||||
local parentnode = tree.add(tr, path.getdirectory(p), onaddfunc)
|
||||
|
||||
-- Another special case, ".." refers to the parent node and doesn't create anything
|
||||
local childname = path.getname(p)
|
||||
@ -59,6 +62,9 @@
|
||||
if not childnode or childnode.path ~= p then
|
||||
childnode = tree.insert(parentnode, tree.new(childname))
|
||||
childnode.path = p
|
||||
if onaddfunc then
|
||||
onaddfunc(childnode)
|
||||
end
|
||||
end
|
||||
|
||||
return childnode
|
||||
|
@ -81,6 +81,19 @@
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.PBXBuildFile_IgnoresVpaths()
|
||||
files { "source.h", "source.c", "source.cpp", "Info.plist" }
|
||||
vpaths { ["Source Files"] = { "**.c", "**.cpp" } }
|
||||
prepare()
|
||||
xcode.PBXBuildFile(tr)
|
||||
test.capture [[
|
||||
/* Begin PBXBuildFile section */
|
||||
[source.c:build] /* source.c in Sources */ = {isa = PBXBuildFile; fileRef = [source.c] /* source.c */; };
|
||||
[source.cpp:build] /* source.cpp in Sources */ = {isa = PBXBuildFile; fileRef = [source.cpp] /* source.cpp */; };
|
||||
/* End PBXBuildFile section */
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- PBXFileReference tests
|
||||
@ -467,6 +480,34 @@
|
||||
end
|
||||
|
||||
|
||||
function suite.PBXGroup_OnVpaths()
|
||||
files { "include/premake/source.h" }
|
||||
vpaths { ["Headers"] = "**.h" }
|
||||
prepare()
|
||||
xcode.PBXGroup(tr)
|
||||
test.capture [[
|
||||
/* Begin PBXGroup section */
|
||||
[MyProject] /* MyProject */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
[Headers] /* Headers */,
|
||||
[Products] /* Products */,
|
||||
);
|
||||
name = "MyProject";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
[Headers] /* Headers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
[source.h] /* source.h */,
|
||||
);
|
||||
name = "Headers";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- PBXNativeTarget tests
|
||||
---------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user