From 1f1e787f0bfa9f5e4f5b54176f9f879ce44b638c Mon Sep 17 00:00:00 2001 From: Rick Newton-Rogers Date: Mon, 25 Nov 2024 16:21:41 +0000 Subject: [PATCH] Add Cxx interop swift settings to CI (#2999) ### Motivation: At the moment the Cxx interoperability CI workflow doesn't actually test Cxx interoperability. ### Modifications: The script now looks for the precise way that the `Package.swift` currently formats the target entry and appends a `swiftSettings` entry to it. This approach is pretty brittle but has the advantage that it's the same on Linux and Darwin. If this formatting changes too often then we could give up on this and assume the availability of gnu-sed instead (and make sure it's present on our CI containers). ### Result: All Cxx interoperability checks will check what they are named for. --------- Co-authored-by: George Barnett --- scripts/check-cxx-interop-compatibility.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/check-cxx-interop-compatibility.sh b/scripts/check-cxx-interop-compatibility.sh index f393eb4c78..5ad33a609c 100755 --- a/scripts/check-cxx-interop-compatibility.sh +++ b/scripts/check-cxx-interop-compatibility.sh @@ -19,7 +19,7 @@ log() { printf -- "** %s\n" "$*" >&2; } error() { printf -- "** ERROR: %s\n" "$*" >&2; } fatal() { error "$@"; exit 1; } -log "Checking for Cxx interoperability comaptibility..." +log "Checking for Cxx interoperability compatibility..." source_dir=$(pwd) working_dir=$(mktemp -d) @@ -30,6 +30,12 @@ package_name=$(swift package dump-package | jq -r '.name') cd "$working_dir" swift package init + +{ + echo "let swiftSettings: [SwiftSetting] = [.interoperabilityMode(.Cxx)]" + echo "for target in package.targets { target.swiftSettings = swiftSettings }" +} >> Package.swift + echo "package.dependencies.append(.package(path: \"$source_dir\"))" >> Package.swift for product in $library_products; do @@ -39,4 +45,4 @@ done swift build -log "✅ Passed the Cxx interoperability tests." \ No newline at end of file +log "✅ Passed the Cxx interoperability tests."