Ported resource handling in build files

This commit is contained in:
starkos 2009-11-05 21:09:48 +00:00
parent 505efec180
commit 5f48d7414e
4 changed files with 41 additions and 20 deletions

View File

@ -589,8 +589,8 @@
function premake.xcode.pbxproj(sln)
tr = xcode.buildtree(sln)
xcode.Header(tr)
xcode.PBXBuildFile(tr)
xcode.Header(tr) -- done
xcode.PBXBuildFile(tr) -- done
xcode.PBXFileReference(tr)
xcode.PBXFrameworksBuildPhase(tr)
xcode.PBXGroup(tr)
@ -601,5 +601,5 @@
xcode.PBXVariantGroup(tr)
xcode.XCBuildConfiguration(tr)
xcode.XCBuildConfigurationList(tr)
xcode.Footer(tr)
xcode.Footer(tr) -- done
end

View File

@ -20,6 +20,32 @@
function xcode.buildprjtree(prj)
local tr = premake.project.buildsourcetree(prj)
-- convert localized resources from their filesystem layout (English.lproj/MainMenu.xib)
-- to Xcode's display layout (MainMenu.xib/English).
tree.traverse(tr, {
onbranch = function(node)
if path.getextension(node.name) == ".lproj" then
local lang = path.getbasename(node.name) -- "English", "French", etc.
-- create a new language group for each file it contains
for _, filenode in ipairs(node.children) do
local grpnode = node.parent.children[filenode.name]
if not grpnode then
grpnode = tree.insert(node.parent, tree.new(filenode.name))
grpnode.kind = "vgroup"
end
-- convert the file node to a language node and add to the group
filenode.name = path.getbasename(lang)
tree.insert(grpnode, filenode)
end
-- remove this directory from the tree
tree.remove(node)
end
end
})
-- Final setup
tree.traverse(tr, {
onnode = function(node)

View File

@ -27,23 +27,6 @@
end
---------------------------------------------------------------------------
-- PBXBuildFile tests
---------------------------------------------------------------------------
function T.xcode3.PBXBuildFile_ListsResourceFilesOnlyOnceWithGroupID()
files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib" }
prepare()
xcode.PBXBuildFile(tr)
test.capture [[
/* Begin PBXBuildFile section */
[MainMenu.xib:build] /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = [MainMenu.xib] /* MainMenu.xib */; };
/* End PBXBuildFile section */
]]
end
---------------------------------------------------------------------------
-- PBXFileReference tests
---------------------------------------------------------------------------

View File

@ -44,3 +44,15 @@
/* End PBXBuildFile section */
]]
end
function suite.PBXBuildFile_ListsResourceFilesOnlyOnceWithGroupID()
files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib" }
prepare()
xcode.PBXBuildFile(tr)
test.capture [[
/* Begin PBXBuildFile section */
[MainMenu.xib:build] /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = [MainMenu.xib] /* MainMenu.xib */; };
/* End PBXBuildFile section */
]]
end