Skip to content

Commit f7dc3f5

Browse files
authored
Re-add CXX compat check script (#2919)
Motivation: It's still referenced from CI. Modifications: Re-add script removed in a previous commit. Result: CXX checks on PRs should work again.
1 parent 689e94a commit f7dc3f5

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftNIO open source project
5+
##
6+
## Copyright (c) 2024 Apple Inc. and the SwiftNIO project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
16+
set -euo pipefail
17+
18+
log() { printf -- "** %s\n" "$*" >&2; }
19+
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
20+
fatal() { error "$@"; exit 1; }
21+
22+
log "Checking for Cxx interoperability comaptibility..."
23+
24+
source_dir=$(pwd)
25+
working_dir=$(mktemp -d)
26+
project_name=$(basename "$working_dir")
27+
source_file=Sources/$project_name/$(echo "$project_name" | tr . _).swift
28+
library_products=$( swift package dump-package | jq -r '.products[] | select(.type.library != null) | .name')
29+
package_name=$(swift package dump-package | jq -r '.name')
30+
31+
cd "$working_dir"
32+
swift package init
33+
echo "package.dependencies.append(.package(path: \"$source_dir\"))" >> Package.swift
34+
35+
for product in $library_products; do
36+
echo "package.targets.first!.dependencies.append(.product(name: \"$product\", package: \"$package_name\"))" >> Package.swift
37+
echo "import $product" >> "$source_file"
38+
done
39+
40+
swift build
41+
42+
log "✅ Passed the Cxx interoperability tests."

0 commit comments

Comments
 (0)