Skip to content

Commit

Permalink
Add Cxx interop swift settings to CI (#2999)
Browse files Browse the repository at this point in the history
### 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 <[email protected]>
  • Loading branch information
rnro and glbrntt authored Nov 25, 2024
1 parent 0ee1657 commit 1f1e787
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripts/check-cxx-interop-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -39,4 +45,4 @@ done

swift build

log "✅ Passed the Cxx interoperability tests."
log "✅ Passed the Cxx interoperability tests."

0 comments on commit 1f1e787

Please sign in to comment.