712.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # HG changeset patch
  2. # User Ben Henning
  3. # Date 1376509869 25200
  4. # Wed Aug 14 12:51:09 2013 -0700
  5. # Node ID e8558df4fbdb173a2b9ed0d354d6c3e76b376698
  6. # Parent a5f8b4f709722222e02fa481873d76ad25255e09
  7. Fixed a bug in Xcode project generation wherein pre/prelink/post-build commands
  8. would not be properly executed if the premake script only had the commands
  9. in configuration blocks, rather than in the project block. According to the
  10. website, these commands can exist in both blocks and the Xcode script does
  11. properly generate the commands, it just doesn't add a single line which allows
  12. Xcode to execute the commands at the correct stage. This patch fixes those
  13. issues.
  14. diff --git a/src/actions/xcode/xcode_common.lua b/src/actions/xcode/xcode_common.lua
  15. --- a/src/actions/xcode/xcode_common.lua
  16. +++ b/src/actions/xcode/xcode_common.lua
  17. @@ -432,20 +432,37 @@
  18. for _, node in ipairs(tr.products.children) do
  19. local name = tr.project.name
  20. + -- This function checks whether there are build commands of a specific
  21. + -- type to be executed; they will be generated correctly, but the project
  22. + -- commands will not contain any per-configuration commands, so the logic
  23. + -- has to be extended a bit to account for that.
  24. + local function hasBuildCommands(which)
  25. + -- standard check...this is what existed before
  26. + if #tr.project[which] > 0 then
  27. + return true
  28. + end
  29. + -- what if there are no project-level commands? check configs...
  30. + for _, cfg in ipairs(tr.configs) do
  31. + if #cfg[which] > 0 then
  32. + return true
  33. + end
  34. + end
  35. + end
  36. +
  37. _p(2,'%s /* %s */ = {', node.targetid, name)
  38. _p(3,'isa = PBXNativeTarget;')
  39. _p(3,'buildConfigurationList = %s /* Build configuration list for PBXNativeTarget "%s" */;', node.cfgsection, name)
  40. _p(3,'buildPhases = (')
  41. - if #tr.project.prebuildcommands > 0 then
  42. + if hasBuildCommands('prebuildcommands') then
  43. _p(4,'9607AE1010C857E500CD1376 /* Prebuild */,')
  44. end
  45. _p(4,'%s /* Resources */,', node.resstageid)
  46. _p(4,'%s /* Sources */,', node.sourcesid)
  47. - if #tr.project.prelinkcommands > 0 then
  48. + if hasBuildCommands('prelinkcommands') then
  49. _p(4,'9607AE3510C85E7E00CD1376 /* Prelink */,')
  50. end
  51. _p(4,'%s /* Frameworks */,', node.fxstageid)
  52. - if #tr.project.postbuildcommands > 0 then
  53. + if hasBuildCommands('postbuildcommands') then
  54. _p(4,'9607AE3710C85E8F00CD1376 /* Postbuild */,')
  55. end
  56. _p(3,');')