Skip to content

Commit c28aeff

Browse files
authored
Adding --verbose to swift build triggers a full rebuild instead of incremental (#8717)
Normalize any build parameters whose modifications do not need to cause a recompilation. For instance, building with or without `--verbose` should not cause a full rebuild. Issue: #8690
1 parent 542279e commit c28aeff

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Sources/Build/LLBuildCommands.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ final class PackageStructureCommand: CustomLLBuildCommand {
407407
let encoder = JSONEncoder.makeWithDefaults()
408408
// Include build parameters and process env in the signature.
409409
var hash = Data()
410-
hash += try! encoder.encode(self.context.productsBuildParameters)
411-
hash += try! encoder.encode(self.context.toolsBuildParameters)
410+
hash += try! encoder.encode(normalizeBuildParameters(self.context.productsBuildParameters))
411+
hash += try! encoder.encode(normalizeBuildParameters(self.context.toolsBuildParameters))
412412
hash += try! encoder.encode(Environment.current)
413413
return [UInt8](hash)
414414
}
@@ -421,6 +421,20 @@ final class PackageStructureCommand: CustomLLBuildCommand {
421421
await self.context.packageStructureDelegate.packageStructureChanged()
422422
}
423423
}
424+
425+
/// Normalize any build parameters whose modifications do not need to cause a recompilation.
426+
/// For instance, building with or without `--verbose` should not cause a full rebuild.
427+
private func normalizeBuildParameters(
428+
_ buildParameters: BuildParameters
429+
) -> BuildParameters {
430+
var buildParameters = buildParameters
431+
buildParameters.outputParameters = BuildParameters.Output(
432+
isColorized: false,
433+
isVerbose: false
434+
)
435+
buildParameters.workers = 1
436+
return buildParameters
437+
}
424438
}
425439

426440
final class CopyCommand: CustomLLBuildCommand {

0 commit comments

Comments
 (0)