Skip to content

Commit 8469311

Browse files
yyvchjakepetroules
authored andcommitted
Add include dir from a clang module into the build args.
Each clang module has public `include` dir. When building current module then it typically works as-is, but when a module has non-standard source location, then explicit include of `include` is necessary.
1 parent 083840e commit 8469311

File tree

8 files changed

+51
-0
lines changed

8 files changed

+51
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// swift-tools-version: 6.0
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "Sample",
8+
products: [
9+
.library(
10+
name: "Sample",
11+
targets: ["Sample"]
12+
),
13+
],
14+
targets: [
15+
.target(
16+
name: "CSample",
17+
sources: ["./vendorsrc/src"],
18+
cSettings: [
19+
.headerSearchPath("./vendorsrc/include"),
20+
]
21+
),
22+
.target(
23+
name: "Sample",
24+
dependencies: ["CSample"]
25+
),
26+
]
27+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
#include "config.h"
3+
#include "../vendorsrc/include/vendor.h"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define HAVE_VENDOR_CONFIG
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
#include "config.h"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "vendor.h"
2+
3+
int vendor__func(int n)
4+
{
5+
return 0;
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import CSample

Sources/Build/BuildPlan/BuildPlan.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
593593
if let includeDir = targetDescription.moduleMap?.parentDirectory {
594594
arguments += ["-I", includeDir.pathString]
595595
}
596+
arguments += ["-I", targetDescription.clangTarget.includeDir.pathString]
596597
}
597598
}
598599

Tests/CommandsTests/APIDiffTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,16 @@ final class APIDiffTests: CommandsTestCase {
263263
}
264264
}
265265

266+
func testAPIDiffOfVendoredCDependency() async throws {
267+
try skipIfApiDigesterUnsupportedOrUnset()
268+
try await fixture(name: "Miscellaneous/APIDiff/") { fixturePath in
269+
let packageRoot = fixturePath.appending("CIncludePath")
270+
let (output, _) = try await execute(["diagnose-api-breaking-changes", "main"], packagePath: packageRoot)
271+
272+
XCTAssertMatch(output, .contains("No breaking changes detected in Sample"))
273+
}
274+
}
275+
266276
func testNoBreakingChanges() async throws {
267277
try skipIfApiDigesterUnsupportedOrUnset()
268278
try await fixture(name: "Miscellaneous/APIDiff/") { fixturePath in

0 commit comments

Comments
 (0)