@@ -226,51 +226,52 @@ public struct LLBuildManifest {
226
226
targets [ target, default: Target ( name: target, nodes: [ ] ) ] . nodes. append ( node)
227
227
}
228
228
229
+ private mutating func addCommand( name: String , tool: ToolProtocol ) {
230
+ assert ( commands [ name] == nil , " already had a command named ' \( name) ' " )
231
+ commands [ name] = Command ( name: name, tool: tool)
232
+ }
233
+
229
234
public mutating func addPhonyCmd(
230
235
name: String ,
231
236
inputs: [ Node ] ,
232
237
outputs: [ Node ]
233
238
) {
234
- assert ( commands [ name] == nil , " already had a command named ' \( name) ' " )
235
239
let tool = PhonyTool ( inputs: inputs, outputs: outputs)
236
- commands [ name ] = Command ( name: name, tool: tool)
240
+ addCommand ( name: name, tool: tool)
237
241
}
238
242
239
243
public mutating func addTestDiscoveryCmd(
240
244
name: String ,
241
245
inputs: [ Node ] ,
242
246
outputs: [ Node ]
243
247
) {
244
- assert ( commands [ name] == nil , " already had a command named ' \( name) ' " )
245
248
let tool = TestDiscoveryTool ( inputs: inputs, outputs: outputs)
246
- commands [ name ] = Command ( name: name, tool: tool)
249
+ addCommand ( name: name, tool: tool)
247
250
}
248
251
249
252
public mutating func addTestEntryPointCmd(
250
253
name: String ,
251
254
inputs: [ Node ] ,
252
255
outputs: [ Node ]
253
256
) {
254
- assert ( commands [ name] == nil , " already had a command named ' \( name) ' " )
255
257
let tool = TestEntryPointTool ( inputs: inputs, outputs: outputs)
256
- commands [ name ] = Command ( name: name, tool: tool)
258
+ addCommand ( name: name, tool: tool)
257
259
}
258
260
259
261
public mutating func addCopyCmd(
260
262
name: String ,
261
263
inputs: [ Node ] ,
262
264
outputs: [ Node ]
263
265
) {
264
- assert ( commands [ name] == nil , " already had a command named ' \( name) ' " )
265
266
let tool = CopyTool ( inputs: inputs, outputs: outputs)
266
- commands [ name ] = Command ( name: name, tool: tool)
267
+ addCommand ( name: name, tool: tool)
267
268
}
268
269
269
270
public mutating func addEntitlementPlistCommand( entitlement: String , outputPath: AbsolutePath ) {
270
271
let inputs = WriteAuxiliary . EntitlementPlist. computeInputs ( entitlement: entitlement)
271
272
let tool = WriteAuxiliaryFile ( inputs: inputs, outputFilePath: outputPath)
272
273
let name = outputPath. pathString
273
- commands [ name ] = Command ( name: name, tool: tool)
274
+ addCommand ( name: name, tool: tool)
274
275
}
275
276
276
277
public mutating func addWriteLinkFileListCommand(
@@ -280,7 +281,7 @@ public struct LLBuildManifest {
280
281
let inputs = WriteAuxiliary . LinkFileList. computeInputs ( objects: objects)
281
282
let tool = WriteAuxiliaryFile ( inputs: inputs, outputFilePath: linkFileListPath)
282
283
let name = linkFileListPath. pathString
283
- commands [ name ] = Command ( name: name, tool: tool)
284
+ addCommand ( name: name, tool: tool)
284
285
}
285
286
286
287
public mutating func addWriteSourcesFileListCommand(
@@ -290,7 +291,7 @@ public struct LLBuildManifest {
290
291
let inputs = WriteAuxiliary . SourcesFileList. computeInputs ( sources: sources)
291
292
let tool = WriteAuxiliaryFile ( inputs: inputs, outputFilePath: sourcesFileListPath)
292
293
let name = sourcesFileListPath. pathString
293
- commands [ name ] = Command ( name: name, tool: tool)
294
+ addCommand ( name: name, tool: tool)
294
295
}
295
296
296
297
public mutating func addSwiftGetVersionCommand(
@@ -300,14 +301,14 @@ public struct LLBuildManifest {
300
301
let inputs = WriteAuxiliary . SwiftGetVersion. computeInputs ( swiftCompilerPath: swiftCompilerPath)
301
302
let tool = WriteAuxiliaryFile ( inputs: inputs, outputFilePath: swiftVersionFilePath, alwaysOutOfDate: true )
302
303
let name = swiftVersionFilePath. pathString
303
- commands [ name ] = Command ( name: name, tool: tool)
304
+ addCommand ( name: name, tool: tool)
304
305
}
305
306
306
307
public mutating func addWriteInfoPlistCommand( principalClass: String , outputPath: AbsolutePath ) {
307
308
let inputs = WriteAuxiliary . XCTestInfoPlist. computeInputs ( principalClass: principalClass)
308
309
let tool = WriteAuxiliaryFile ( inputs: inputs, outputFilePath: outputPath)
309
310
let name = outputPath. pathString
310
- commands [ name ] = Command ( name: name, tool: tool)
311
+ addCommand ( name: name, tool: tool)
311
312
}
312
313
313
314
public mutating func addWriteEmbeddedResourcesCommand(
@@ -317,17 +318,16 @@ public struct LLBuildManifest {
317
318
let inputs = WriteAuxiliary . EmbeddedResources. computeInputs ( resources: resources)
318
319
let tool = WriteAuxiliaryFile ( inputs: inputs, outputFilePath: outputPath)
319
320
let name = outputPath. pathString
320
- commands [ name ] = Command ( name: name, tool: tool)
321
+ addCommand ( name: name, tool: tool)
321
322
}
322
323
323
324
public mutating func addPkgStructureCmd(
324
325
name: String ,
325
326
inputs: [ Node ] ,
326
327
outputs: [ Node ]
327
328
) {
328
- assert ( commands [ name] == nil , " already had a command named ' \( name) ' " )
329
329
let tool = PackageStructureTool ( inputs: inputs, outputs: outputs)
330
- commands [ name ] = Command ( name: name, tool: tool)
330
+ addCommand ( name: name, tool: tool)
331
331
}
332
332
333
333
public mutating func addShellCmd(
@@ -340,7 +340,6 @@ public struct LLBuildManifest {
340
340
workingDirectory: String ? = nil ,
341
341
allowMissingInputs: Bool = false
342
342
) {
343
- assert ( commands [ name] == nil , " already had a command named ' \( name) ' " )
344
343
let tool = ShellTool (
345
344
description: description,
346
345
inputs: inputs,
@@ -350,7 +349,7 @@ public struct LLBuildManifest {
350
349
workingDirectory: workingDirectory,
351
350
allowMissingInputs: allowMissingInputs
352
351
)
353
- commands [ name ] = Command ( name: name, tool: tool)
352
+ addCommand ( name: name, tool: tool)
354
353
}
355
354
356
355
public mutating func addSwiftFrontendCmd(
@@ -362,15 +361,14 @@ public struct LLBuildManifest {
362
361
outputs: [ Node ] ,
363
362
arguments: [ String ]
364
363
) {
365
- assert ( commands [ name] == nil , " already had a command named ' \( name) ' " )
366
364
let tool = SwiftFrontendTool (
367
365
moduleName: moduleName,
368
366
description: description,
369
367
inputs: inputs,
370
368
outputs: outputs,
371
369
arguments: arguments
372
370
)
373
- commands [ name ] = Command ( name: name, tool: tool)
371
+ addCommand ( name: name, tool: tool)
374
372
}
375
373
376
374
public mutating func addClangCmd(
@@ -381,15 +379,14 @@ public struct LLBuildManifest {
381
379
arguments: [ String ] ,
382
380
dependencies: String ? = nil
383
381
) {
384
- assert ( commands [ name] == nil , " already had a command named ' \( name) ' " )
385
382
let tool = ClangTool (
386
383
description: description,
387
384
inputs: inputs,
388
385
outputs: outputs,
389
386
arguments: arguments,
390
387
dependencies: dependencies
391
388
)
392
- commands [ name ] = Command ( name: name, tool: tool)
389
+ addCommand ( name: name, tool: tool)
393
390
}
394
391
395
392
public mutating func addSwiftCmd(
@@ -411,7 +408,6 @@ public struct LLBuildManifest {
411
408
outputFileMapPath: AbsolutePath ,
412
409
prepareForIndexing: Bool
413
410
) {
414
- assert ( commands [ name] == nil , " already had a command named ' \( name) ' " )
415
411
let tool = SwiftCompilerTool (
416
412
inputs: inputs,
417
413
outputs: outputs,
@@ -430,6 +426,6 @@ public struct LLBuildManifest {
430
426
outputFileMapPath: outputFileMapPath,
431
427
prepareForIndexing: prepareForIndexing
432
428
)
433
- commands [ name ] = Command ( name: name, tool: tool)
429
+ addCommand ( name: name, tool: tool)
434
430
}
435
431
}
0 commit comments