@@ -33,6 +33,10 @@ extension LLBuildManifestBuilder {
33
33
testInputs = [ ]
34
34
}
35
35
36
+ // Create a phony node to represent the entire target.
37
+ let targetName = try buildProduct. product. getLLBuildTargetName ( config: self . buildConfig)
38
+ let output : Node = . virtual( targetName)
39
+
36
40
switch buildProduct. product. type {
37
41
case . library( . static) :
38
42
try self . manifest. addShellCmd (
@@ -49,15 +53,26 @@ extension LLBuildManifestBuilder {
49
53
+ [ buildProduct. linkFileListPath]
50
54
+ testInputs
51
55
56
+ let shouldCodeSign : Bool
57
+ if case . executable = buildProduct. product. type,
58
+ buildParameters. debuggingParameters. shouldEnableDebuggingEntitlement {
59
+ shouldCodeSign = true
60
+ } else {
61
+ shouldCodeSign = false
62
+ }
63
+
64
+ let linkedBinarySuffix = shouldCodeSign ? " -unsigned " : " "
65
+ let linkedBinaryPath = try AbsolutePath ( validating: buildProduct. binaryPath. pathString + linkedBinarySuffix)
66
+
52
67
try self . manifest. addShellCmd (
53
68
name: cmdName,
54
69
description: " Linking \( buildProduct. binaryPath. prettyPath ( ) ) " ,
55
70
inputs: inputs. map ( Node . file) ,
56
- outputs: [ . file( buildProduct . binaryPath ) ] ,
57
- arguments: try buildProduct. linkArguments ( )
71
+ outputs: [ . file( linkedBinaryPath ) ] ,
72
+ arguments: try buildProduct. linkArguments ( outputPathSuffix : linkedBinarySuffix )
58
73
)
59
74
60
- if buildParameters . debuggingParameters . shouldEnableDebuggingEntitlement {
75
+ if shouldCodeSign {
61
76
let basename = try buildProduct. binaryPath. basename
62
77
let plistPath = try buildProduct. binaryPath. parentDirectory
63
78
. appending ( component: " \( basename) -entitlement.plist " )
@@ -67,20 +82,25 @@ extension LLBuildManifestBuilder {
67
82
)
68
83
69
84
let cmdName = try buildProduct. product. getCommandName ( config: self . buildConfig)
85
+ let codeSigningOutput = Node . virtual ( targetName + " -CodeSigning " )
70
86
try self . manifest. addShellCmd (
71
87
name: " \( cmdName) -entitlements " ,
72
88
description: " Applying debug entitlements to \( buildProduct. binaryPath. prettyPath ( ) ) " ,
73
- inputs: [ buildProduct. binaryPath, plistPath] . map ( Node . file) ,
74
- outputs: < #T##[ Node] #> ,
75
- arguments: < #T##[ String] #>
89
+ inputs: [ linkedBinaryPath, plistPath] . map ( Node . file) ,
90
+ outputs: [ codeSigningOutput] ,
91
+ arguments: buildProduct. codeSigningArguments ( plistPath: plistPath, binaryPath: linkedBinaryPath)
92
+ )
93
+
94
+ try self . manifest. addShellCmd (
95
+ name: " \( cmdName) -entitlements " ,
96
+ description: " Applying debug entitlements to \( buildProduct. binaryPath. prettyPath ( ) ) " ,
97
+ inputs: [ . virtual( targetName + " -CodeSigning " ) ] ,
98
+ outputs: [ . file( buildProduct. binaryPath) ] ,
99
+ arguments: [ " mv " , linkedBinaryPath. pathString, buildProduct. binaryPath. pathString]
76
100
)
77
101
}
78
102
}
79
103
80
- // Create a phony node to represent the entire target.
81
- let targetName = try buildProduct. product. getLLBuildTargetName ( config: self . buildConfig)
82
- let output : Node = . virtual( targetName)
83
-
84
104
self . manifest. addNode ( output, toTarget: targetName)
85
105
try self . manifest. addPhonyCmd (
86
106
name: output. name,
0 commit comments