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