Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add include dir from a clang module into the build args in diagnose-api-breaking-changes command. #8209

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Fixtures/Miscellaneous/APIDiff/CIncludePath/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Sample",
products: [
.library(
name: "Sample",
targets: ["Sample"]
),
],
targets: [
.target(
name: "CSample",
sources: ["./vendorsrc/src"],
cSettings: [
.headerSearchPath("./vendorsrc/include"),
]
),
.target(
name: "Sample",
dependencies: ["CSample"]
),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

#include "config.h"
#include "../vendorsrc/include/vendor.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define HAVE_VENDOR_CONFIG
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

#include "config.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "vendor.h"

int vendor__func(int n)
{
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import CSample
1 change: 1 addition & 0 deletions Sources/Build/BuildPlan/BuildPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
if let includeDir = targetDescription.moduleMap?.parentDirectory {
arguments += ["-I", includeDir.pathString]
}
arguments += ["-I", targetDescription.clangTarget.includeDir.pathString]
}
}

Expand Down
10 changes: 10 additions & 0 deletions Tests/CommandsTests/APIDiffTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ final class APIDiffTests: CommandsTestCase {
}
}

func testAPIDiffOfVendoredCDependency() async throws {
try skipIfApiDigesterUnsupportedOrUnset()
try await fixture(name: "Miscellaneous/APIDiff/") { fixturePath in
let packageRoot = fixturePath.appending("CIncludePath")
let (output, _) = try await execute(["diagnose-api-breaking-changes", "main"], packagePath: packageRoot)
yyvch marked this conversation as resolved.
Show resolved Hide resolved

XCTAssertMatch(output, .contains("No breaking changes detected in Sample"))
}
}

func testNoBreakingChanges() async throws {
try skipIfApiDigesterUnsupportedOrUnset()
try await fixture(name: "Miscellaneous/APIDiff/") { fixturePath in
Expand Down