Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Perkins <starkos@industriousone.com>2011-08-16 00:00:20 +0400
committerJason Perkins <starkos@industriousone.com>2011-08-16 00:00:20 +0400
commit112483417bfdf95a3d59db42b3c8f1296332dccd (patch)
treef602e0b92a44ceb2cfb6b4c4e4f371fd44c7bbf9
parent1a074ba81bdcedf53eb41246cd7b2e323af76a6d (diff)
Added virtual path support to Xcode3
-rw-r--r--src/actions/xcode/xcode_common.lua2
-rw-r--r--src/base/project.lua9
-rw-r--r--src/base/tree.lua10
-rw-r--r--tests/actions/xcode/test_xcode_project.lua41
4 files changed, 58 insertions, 4 deletions
diff --git a/src/actions/xcode/xcode_common.lua b/src/actions/xcode/xcode_common.lua
index 6f430dc..bda20e4 100644
--- a/src/actions/xcode/xcode_common.lua
+++ b/src/actions/xcode/xcode_common.lua
@@ -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)
diff --git a/src/base/project.lua b/src/base/project.lua
index 8e89168..1f40cde 100644
--- a/src/base/project.lua
+++ b/src/base/project.lua
@@ -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
diff --git a/src/base/tree.lua b/src/base/tree.lua
index 2d61001..527aa4c 100644
--- a/src/base/tree.lua
+++ b/src/base/tree.lua
@@ -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
diff --git a/tests/actions/xcode/test_xcode_project.lua b/tests/actions/xcode/test_xcode_project.lua
index 8437ee0..642e68e 100644
--- a/tests/actions/xcode/test_xcode_project.lua
+++ b/tests/actions/xcode/test_xcode_project.lua
@@ -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
---------------------------------------------------------------------------