Skip to content

Commit 0d9e79d

Browse files
authored
Merge pull request #2724 from abertelrud/eng/SR-12719-5.3
[5.3] SwiftPM 5.2 doesn't notice header file changes during incremental builds
2 parents 2bcd4e5 + 1c9faa7 commit 0d9e79d

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

Fixtures/CFamilyTargets/CLibrarySources/Sources/Foo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "Foo.h"
2+
13
int foo() {
24
int a = 5;
35
int b = a;

Sources/Build/ManifestBuilder.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,8 @@ extension LLBuildManifestBuilder {
441441
description: "Compiling \(target.target.name) \(path.filename)",
442442
inputs: inputs + [.file(path.source)],
443443
outputs: [objectFileNode],
444-
args: args
444+
args: args,
445+
deps: path.deps.pathString
445446
)
446447
}
447448

Tests/BuildTests/IncrementalBuildTests.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ final class IncrementalBuildTests: XCTestCase {
4949
let llbuildManifest = prefix.appending(components: ".build", "debug.yaml")
5050

5151
// Modify the source file in a way that changes its size so that the low-level
52-
// build system can detect the change. The timestamp change might be too less
53-
// for it to detect.
52+
// build system can detect the change (the timestamp change might be too small
53+
// for the granularity of the file system to represent as distinct values).
5454
let sourceFile = prefix.appending(components: "Sources", "Foo.c")
55-
let stream = BufferedOutputByteStream()
56-
stream <<< (try localFileSystem.readFileContents(sourceFile)) <<< "\n"
57-
try localFileSystem.writeFileContents(sourceFile, bytes: stream.bytes)
55+
let sourceStream = BufferedOutputByteStream()
56+
sourceStream <<< (try localFileSystem.readFileContents(sourceFile)) <<< "\n"
57+
try localFileSystem.writeFileContents(sourceFile, bytes: sourceStream.bytes)
5858

5959
// Read the first llbuild manifest.
6060
let llbuildContents1 = try localFileSystem.readFileContents(llbuildManifest)
@@ -76,6 +76,18 @@ final class IncrementalBuildTests: XCTestCase {
7676

7777
XCTAssertEqual(llbuildContents1, llbuildContents2)
7878
XCTAssertEqual(llbuildContents2, llbuildContents3)
79+
80+
// Modify the header file in a way that changes its size so that the low-level
81+
// build system can detect the change (the timestamp change might be too small
82+
// for the granularity of the file system to represent as distinct values).
83+
let headerFile = prefix.appending(components: "Sources", "include", "Foo.h")
84+
let headerStream = BufferedOutputByteStream()
85+
headerStream <<< (try localFileSystem.readFileContents(headerFile)) <<< "\n"
86+
try localFileSystem.writeFileContents(headerFile, bytes: headerStream.bytes)
87+
88+
// Now build again. This should be an incremental build.
89+
let (log4, _) = try executeSwiftBuild(prefix)
90+
XCTAssertTrue(log4.contains("Compiling CLibrarySources Foo.c"))
7991
}
8092
}
8193

0 commit comments

Comments
 (0)