diff --git a/src/actions/xcode/xcode_common.lua b/src/actions/xcode/xcode_common.lua index ee4cc448..c2d9a898 100644 --- a/src/actions/xcode/xcode_common.lua +++ b/src/actions/xcode/xcode_common.lua @@ -178,7 +178,39 @@ _p('/* End PBXFrameworksBuildPhase section */') _p('') end - + + + function xcode.PBXGroup(tr) + _p('/* Begin PBXGroup section */') + + tree.traverse(tr, { + onnode = function(node) + -- Skip over anything that isn't a proper group + if (node.path and #node.children == 0) or node.kind == "vgroup" then + return + end + + _p(2,'%s /* %s */ = {', node.id, node.name) + _p(3,'isa = PBXGroup;') + _p(3,'children = (') + for _, childnode in ipairs(node.children) do + _p(4,'%s /* %s */,', childnode.id, childnode.name) + end + _p(3,');') + _p(3,'name = %s;', node.name) + if node.path then + _p(3,'path = %s;', node.path) + end + _p(3,'sourceTree = "";') + _p(2,'};') + end + + }, true) + + _p('/* End PBXGroup section */') + _p('') + end + function xcode.Footer() _p(1,'};') diff --git a/src/actions/xcode/xcode_pbxproj.lua b/src/actions/xcode/xcode_pbxproj.lua index 6e1e59be..c3d2bccd 100644 --- a/src/actions/xcode/xcode_pbxproj.lua +++ b/src/actions/xcode/xcode_pbxproj.lua @@ -224,37 +224,6 @@ --------------------------------------------------------------------------- - function xcode.PBXGroup(tr) - _p('/* Begin PBXGroup section */') - - tree.traverse(tr, { - onnode = function(node) - -- Skip over anything that isn't a proper group - if (node.path and #node.children == 0) or node.kind == "vgroup" then - return - end - - _p(2,'%s /* %s */ = {', node.id, node.name) - _p(3,'isa = PBXGroup;') - _p(3,'children = (') - for _, childnode in ipairs(node.children) do - _p(4,'%s /* %s */,', childnode.id, childnode.name) - end - _p(3,');') - _p(3,'name = %s;', node.name) - if node.path then - _p(3,'path = %s;', node.path) - end - _p(3,'sourceTree = "";') - _p(2,'};') - end - - }, true) - - _p('/* End PBXGroup section */') - _p('') - end - function xcode.PBXNativeTarget(tr) _p('/* Begin PBXNativeTarget section */') @@ -489,7 +458,7 @@ xcode.Header(tr) -- done xcode.PBXBuildFile(tr) -- done xcode.PBXFileReference(tr) -- done - xcode.PBXFrameworksBuildPhase(tr) + xcode.PBXFrameworksBuildPhase(tr) -- done xcode.PBXGroup(tr) xcode.PBXNativeTarget(tr) xcode.PBXProject(tr) diff --git a/src/actions/xcode/xcode_project.lua b/src/actions/xcode/xcode_project.lua index 93a6d22d..a9ca9f7c 100644 --- a/src/actions/xcode/xcode_project.lua +++ b/src/actions/xcode/xcode_project.lua @@ -119,5 +119,6 @@ xcode.PBXBuildFile(tr) xcode.PBXFileReference(tr) xcode.PBXFrameworksBuildPhase(tr) + xcode.PBXGroup(tr) xcode.Footer(tr) end diff --git a/tests/actions/test_xcode.lua b/tests/actions/test_xcode.lua index 14cd3eff..d902c770 100644 --- a/tests/actions/test_xcode.lua +++ b/tests/actions/test_xcode.lua @@ -31,186 +31,6 @@ -- PBXGroup tests --------------------------------------------------------------------------- - function T.xcode3.PBXGroup_OnOneProjectNoFiles() - prepare() - xcode.PBXGroup(tr) - test.capture [[ -/* Begin PBXGroup section */ - [MyProject] /* MyProject */ = { - isa = PBXGroup; - children = ( - [Products] /* Products */, - ); - name = MyProject; - sourceTree = ""; - }; - [Products] /* Products */ = { - isa = PBXGroup; - children = ( - [MyProject:product] /* MyProject */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - ]] - end - - - function T.xcode3.PBXGroup_OnMultipleProjectsNoFiles() - test.createproject(sln) - prepare() - xcode.PBXGroup(tr) - test.capture [[ -/* Begin PBXGroup section */ - [MySolution] /* MySolution */ = { - isa = PBXGroup; - children = ( - [MyProject] /* MyProject */, - [MyProject2] /* MyProject2 */, - [Products] /* Products */, - ); - name = MySolution; - sourceTree = ""; - }; - [MyProject] /* MyProject */ = { - isa = PBXGroup; - children = ( - ); - name = MyProject; - sourceTree = ""; - }; - [MyProject2] /* MyProject2 */ = { - isa = PBXGroup; - children = ( - ); - name = MyProject2; - sourceTree = ""; - }; - [Products] /* Products */ = { - isa = PBXGroup; - children = ( - [MyProject:product] /* MyProject */, - [MyProject2:product] /* MyProject2 */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - ]] - end - - - function T.xcode3.PBXGroup_OnSourceFiles() - files { "source.h" } - prepare() - xcode.PBXGroup(tr) - test.capture [[ -/* Begin PBXGroup section */ - [MyProject] /* MyProject */ = { - isa = PBXGroup; - children = ( - [source.h] /* source.h */, - [Products] /* Products */, - ); - name = MyProject; - sourceTree = ""; - }; - [Products] /* Products */ = { - isa = PBXGroup; - children = ( - [MyProject:product] /* MyProject */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - ]] - end - - - function T.xcode3.PBXGroup_OnSourceSubdirs() - files { "include/source.h" } - prepare() - xcode.PBXGroup(tr) - test.capture [[ -/* Begin PBXGroup section */ - [MyProject] /* MyProject */ = { - isa = PBXGroup; - children = ( - [include] /* include */, - [Products] /* Products */, - ); - name = MyProject; - sourceTree = ""; - }; - [include] /* include */ = { - isa = PBXGroup; - children = ( - [source.h] /* source.h */, - ); - name = include; - path = include; - sourceTree = ""; - }; - ]] - end - - - function T.xcode3.PBXGroup_OnResourceFiles() - files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib", "Info.plist" } - prepare() - xcode.PBXGroup(tr) - test.capture [[ -/* Begin PBXGroup section */ - [MyProject] /* MyProject */ = { - isa = PBXGroup; - children = ( - [Info.plist] /* Info.plist */, - [MainMenu.xib] /* MainMenu.xib */, - [Products] /* Products */, - ); - name = MyProject; - sourceTree = ""; - }; - [Products] /* Products */ = { - isa = PBXGroup; - children = ( - [MyProject:product] /* MyProject */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - ]] - end - - - function T.xcode3.PBXGroup_OnFrameworks() - links { "Cocoa.framework" } - prepare() - xcode.PBXGroup(tr) - test.capture [[ -/* Begin PBXGroup section */ - [MyProject] /* MyProject */ = { - isa = PBXGroup; - children = ( - [Frameworks] /* Frameworks */, - [Products] /* Products */, - ); - name = MyProject; - sourceTree = ""; - }; - [Frameworks] /* Frameworks */ = { - isa = PBXGroup; - children = ( - [Cocoa.framework] /* Cocoa.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - ]] - end --------------------------------------------------------------------------- diff --git a/tests/actions/xcode/test_xcode_project.lua b/tests/actions/xcode/test_xcode_project.lua index 6dede1c4..6f42ad82 100644 --- a/tests/actions/xcode/test_xcode_project.lua +++ b/tests/actions/xcode/test_xcode_project.lua @@ -204,3 +204,145 @@ /* End PBXFrameworksBuildPhase section */ ]] end + + +--------------------------------------------------------------------------- +-- PBXGroup tests +--------------------------------------------------------------------------- + + function suite.PBXGroup_OnNoFiles() + prepare() + xcode.PBXGroup(tr) + test.capture [[ +/* Begin PBXGroup section */ + [MyProject] /* MyProject */ = { + isa = PBXGroup; + children = ( + [Products] /* Products */, + ); + name = MyProject; + sourceTree = ""; + }; + [Products] /* Products */ = { + isa = PBXGroup; + children = ( + [MyProject:product] /* MyProject */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + ]] + end + + + function suite.PBXGroup_OnSourceFiles() + files { "source.h" } + prepare() + xcode.PBXGroup(tr) + test.capture [[ +/* Begin PBXGroup section */ + [MyProject] /* MyProject */ = { + isa = PBXGroup; + children = ( + [source.h] /* source.h */, + [Products] /* Products */, + ); + name = MyProject; + sourceTree = ""; + }; + [Products] /* Products */ = { + isa = PBXGroup; + children = ( + [MyProject:product] /* MyProject */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + ]] + end + + + function suite.PBXGroup_OnSourceSubdirs() + files { "include/source.h" } + prepare() + xcode.PBXGroup(tr) + test.capture [[ +/* Begin PBXGroup section */ + [MyProject] /* MyProject */ = { + isa = PBXGroup; + children = ( + [include] /* include */, + [Products] /* Products */, + ); + name = MyProject; + sourceTree = ""; + }; + [include] /* include */ = { + isa = PBXGroup; + children = ( + [source.h] /* source.h */, + ); + name = include; + path = include; + sourceTree = ""; + }; + ]] + end + + + function suite.PBXGroup_OnResourceFiles() + files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib", "Info.plist" } + prepare() + xcode.PBXGroup(tr) + test.capture [[ +/* Begin PBXGroup section */ + [MyProject] /* MyProject */ = { + isa = PBXGroup; + children = ( + [Info.plist] /* Info.plist */, + [MainMenu.xib] /* MainMenu.xib */, + [Products] /* Products */, + ); + name = MyProject; + sourceTree = ""; + }; + [Products] /* Products */ = { + isa = PBXGroup; + children = ( + [MyProject:product] /* MyProject */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + ]] + end + + + function suite.PBXGroup_OnFrameworks() + links { "Cocoa.framework" } + prepare() + xcode.PBXGroup(tr) + test.capture [[ +/* Begin PBXGroup section */ + [MyProject] /* MyProject */ = { + isa = PBXGroup; + children = ( + [Frameworks] /* Frameworks */, + [Products] /* Products */, + ); + name = MyProject; + sourceTree = ""; + }; + [Frameworks] /* Frameworks */ = { + isa = PBXGroup; + children = ( + [Cocoa.framework] /* Cocoa.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + ]] + end