Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
52 changes: 37 additions & 15 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,47 +176,69 @@ jobs:
- name: Swift Test
run: "swift test"

test-swift-cxx-interop:
name: Test (Swift, C++ Interop) (${{ matrix.os_version }} swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}})
# Test that projects depending on swift-java can build with C++ interoperability enabled.
# This is important because users may enable -cxx-interoperability-mode=default in their
# own projects, and swift-java's public API must be compatible with that mode.
# See: https://github.com/swiftlang/swift-java/issues/391
verify-samples-cxx-interop:
name: Sample ${{ matrix.sample_app }} (C++ Interop) (${{ matrix.os_version }} swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
swift_version: ['6.2', 'nightly']
swift_version: ['6.1.3', '6.2', 'nightly']
os_version: ['jammy']
jdk_vendor: ['corretto']
sample_app: [
'JavaDependencySampleApp',
'JavaKitSampleApp',
'JavaProbablyPrime',
'JavaSieve',
'SwiftAndJavaJarSampleLib',
'SwiftJavaExtractFFMSampleApp',
'SwiftJavaExtractJNISampleApp',
]
container:
image: ${{ (contains(matrix.swift_version, 'nightly') && 'swiftlang/swift') || 'swift' }}:${{ matrix.swift_version }}-${{ matrix.os_version }}
env:
SWIFT_JAVA_VERBOSE: true
CXX_INTEROP: '1'
steps:
- uses: actions/checkout@v4
- name: Prepare CI Environment
uses: ./.github/actions/prepare_env
- name: Swift Build with C++ Interoperability
run: swift build --build-tests --disable-sandbox --disable-experimental-prebuilts -Xswiftc -cxx-interoperability-mode=default
- name: Swift Test with C++ Interoperability
run: swift test --disable-experimental-prebuilts -Xswiftc -cxx-interoperability-mode=default
- name: "Verify sample with C++ Interop: ${{ matrix.sample_app }}"
run: .github/scripts/validate_sample.sh Samples/${{ matrix.sample_app }}

test-swift-cxx-interop-macos:
name: Test (Swift, C++ Interop) (${{ matrix.os_version }} swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}})
verify-samples-cxx-interop-macos:
name: Sample ${{ matrix.sample_app }} (C++ Interop) (${{ matrix.os_version }} swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}})
runs-on: [self-hosted, macos, sequoia, ARM64]
strategy:
fail-fast: false
matrix:
swift_version: ['6.2']
os_version: ['macos']
jdk_vendor: ['corretto']
sample_app: [
'JavaDependencySampleApp',
'JavaKitSampleApp',
'JavaProbablyPrime',
'JavaSieve',
'SwiftAndJavaJarSampleLib',
'SwiftJavaExtractFFMSampleApp',
'SwiftJavaExtractJNISampleApp',
]
env:
SWIFT_JAVA_VERBOSE: true

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We lost the verbose here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ktoso Fixed here 🙏
9cd3191

CXX_INTEROP: '1'
steps:
- uses: actions/checkout@v4
- name: Prepare CI Environment
uses: ./.github/actions/prepare_env
- name: Swift Build with C++ Interoperability
run: swift build --build-tests --disable-sandbox -Xswiftc -cxx-interoperability-mode=default
- name: Swift Test with C++ Interoperability
run: swift test -Xswiftc -cxx-interoperability-mode=default
- name: Install Swiftly
run: ./.github/scripts/install_swiftly.sh
env:
SWIFT_VERSION: "${{ matrix.swift_version }}"
- name: "Verify sample with C++ Interop: ${{ matrix.sample_app }}"
run: .github/scripts/validate_sample.sh Samples/${{ matrix.sample_app }}

build-swift-android:
name: Sample SwiftJavaExtractJNISampleApp (Android) (${{ matrix.os_version }} swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}} android:${{matrix.sdk_triple}})
Expand Down
8 changes: 8 additions & 0 deletions Samples/JavaDependencySampleApp/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ let javaIncludePath = "\(javaHome)/include"
#error("Currently only macOS and Linux platforms are supported, this may change in the future.")
#endif

// Support C++ interoperability mode via CXX_INTEROP environment variable.
// This is used to test that swift-java's public API is compatible with projects
// that enable C++ interoperability mode.
// See: https://github.com/swiftlang/swift-java/issues/391
let cxxInteropEnabled = ProcessInfo.processInfo.environment["CXX_INTEROP"] == "1"

let package = Package(
name: "JavaDependencySampleApp",
platforms: [
Expand Down Expand Up @@ -73,6 +79,7 @@ let package = Package(
swiftSettings: [
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"]),
.swiftLanguageMode(.v5),
.interoperabilityMode(.Cxx, .when(platforms: cxxInteropEnabled ? [.macOS, .linux] : [])),
],
plugins: [
.plugin(name: "SwiftJavaPlugin", package: "swift-java"),
Expand All @@ -92,6 +99,7 @@ let package = Package(
swiftSettings: [
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"]),
.swiftLanguageMode(.v5),
.interoperabilityMode(.Cxx, .when(platforms: cxxInteropEnabled ? [.macOS, .linux] : [])),
],
plugins: [
// .plugin(name: "SwiftJavaBootstrapJavaPlugin", package: "swift-java"),
Expand Down
9 changes: 8 additions & 1 deletion Samples/JavaKitSampleApp/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ let javaIncludePath = "\(javaHome)/include"
let javaPlatformIncludePath = "\(javaIncludePath)/win32)"
#endif

// Support C++ interoperability mode via CXX_INTEROP environment variable.
// This is used to test that swift-java's public API is compatible with projects
// that enable C++ interoperability mode.
// See: https://github.com/swiftlang/swift-java/issues/391
let cxxInteropEnabled = ProcessInfo.processInfo.environment["CXX_INTEROP"] == "1"

let package = Package(
name: "JavaKitSampleApp",
platforms: [
Expand Down Expand Up @@ -70,7 +76,8 @@ let package = Package(
],
swiftSettings: [
.swiftLanguageMode(.v5),
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"])
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"]),
.interoperabilityMode(.Cxx, .when(platforms: cxxInteropEnabled ? [.macOS, .linux] : [])),
],
plugins: [
.plugin(name: "JavaCompilerPlugin", package: "swift-java"),
Expand Down
11 changes: 10 additions & 1 deletion Samples/JavaProbablyPrime/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
import CompilerPluginSupport
import PackageDescription

import class Foundation.ProcessInfo

// Support C++ interoperability mode via CXX_INTEROP environment variable.
// This is used to test that swift-java's public API is compatible with projects
// that enable C++ interoperability mode.
// See: https://github.com/swiftlang/swift-java/issues/391
let cxxInteropEnabled = ProcessInfo.processInfo.environment["CXX_INTEROP"] == "1"

let package = Package(
name: "JavaProbablyPrime",
platforms: [
Expand Down Expand Up @@ -34,7 +42,8 @@ let package = Package(
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
swiftSettings: [
.swiftLanguageMode(.v5)
.swiftLanguageMode(.v5),
.interoperabilityMode(.Cxx, .when(platforms: cxxInteropEnabled ? [.macOS, .linux] : [])),
],
plugins: [
.plugin(name: "SwiftJavaPlugin", package: "swift-java"),
Expand Down
12 changes: 10 additions & 2 deletions Samples/JavaSieve/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ let javaIncludePath = "\(javaHome)/include"
#error("Currently only macOS and Linux platforms are supported, this may change in the future.")
#endif

// Support C++ interoperability mode via CXX_INTEROP environment variable.
// This is used to test that swift-java's public API is compatible with projects
// that enable C++ interoperability mode.
// See: https://github.com/swiftlang/swift-java/issues/391
let cxxInteropEnabled = ProcessInfo.processInfo.environment["CXX_INTEROP"] == "1"

let package = Package(
name: "JavaSieve",
platforms: [
Expand All @@ -59,7 +65,8 @@ let package = Package(
],
exclude: ["swift-java.config"],
swiftSettings: [
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"])
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"]),
.interoperabilityMode(.Cxx, .when(platforms: cxxInteropEnabled ? [.macOS, .linux] : [])),
],
plugins: [
.plugin(name: "SwiftJavaPlugin", package: "swift-java"),
Expand All @@ -77,7 +84,8 @@ let package = Package(
],
exclude: ["swift-java.config"],
swiftSettings: [
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"])
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"]),
.interoperabilityMode(.Cxx, .when(platforms: cxxInteropEnabled ? [.macOS, .linux] : [])),
],
plugins: [
.plugin(name: "SwiftJavaPlugin", package: "swift-java"),
Expand Down
9 changes: 8 additions & 1 deletion Samples/SwiftAndJavaJarSampleLib/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ let javaIncludePath = "\(javaHome)/include"
#error("Currently only macOS and Linux platforms are supported, this may change in the future.")
#endif

// Support C++ interoperability mode via CXX_INTEROP environment variable.
// This is used to test that swift-java's public API is compatible with projects
// that enable C++ interoperability mode.
// See: https://github.com/swiftlang/swift-java/issues/391
let cxxInteropEnabled = ProcessInfo.processInfo.environment["CXX_INTEROP"] == "1"

let package = Package(
name: "SwiftAndJavaJarSampleLib",
platforms: [
Expand Down Expand Up @@ -70,7 +76,8 @@ let package = Package(
],
swiftSettings: [
.swiftLanguageMode(.v5),
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"])
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"]),
.interoperabilityMode(.Cxx, .when(platforms: cxxInteropEnabled ? [.macOS, .linux] : [])),
],
plugins: [
.plugin(name: "JExtractSwiftPlugin", package: "swift-java"),
Expand Down
9 changes: 8 additions & 1 deletion Samples/SwiftJavaExtractFFMSampleApp/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ let javaIncludePath = "\(javaHome)/include"
#error("Currently only macOS and Linux platforms are supported, this may change in the future.")
#endif

// Support C++ interoperability mode via CXX_INTEROP environment variable.
// This is used to test that swift-java's public API is compatible with projects
// that enable C++ interoperability mode.
// See: https://github.com/swiftlang/swift-java/issues/391
let cxxInteropEnabled = ProcessInfo.processInfo.environment["CXX_INTEROP"] == "1"

let package = Package(
name: "SwiftJavaExtractFFMSampleApp",
platforms: [
Expand Down Expand Up @@ -72,7 +78,8 @@ let package = Package(
],
swiftSettings: [
.swiftLanguageMode(.v5),
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"])
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"]),
.interoperabilityMode(.Cxx, .when(platforms: cxxInteropEnabled ? [.macOS, .linux] : [])),
],
plugins: [
.plugin(name: "JExtractSwiftPlugin", package: "swift-java"),
Expand Down
7 changes: 7 additions & 0 deletions Samples/SwiftJavaExtractJNISampleApp/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ let javaIncludePath = "\(javaHome)/include"
#error("Currently only macOS and Linux platforms are supported, this may change in the future.")
#endif

// Support C++ interoperability mode via CXX_INTEROP environment variable.
// This is used to test that swift-java's public API is compatible with projects
// that enable C++ interoperability mode.
// See: https://github.com/swiftlang/swift-java/issues/391
let cxxInteropEnabled = ProcessInfo.processInfo.environment["CXX_INTEROP"] == "1"

let package = Package(
name: "JExtractJNISampleApp",
platforms: [
Expand Down Expand Up @@ -70,6 +76,7 @@ let package = Package(
swiftSettings: [
.swiftLanguageMode(.v5),
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"]),
.interoperabilityMode(.Cxx, .when(platforms: cxxInteropEnabled ? [.macOS, .linux] : [])),
],
plugins: [
.plugin(name: "JExtractSwiftPlugin", package: "swift-java")
Expand Down
Loading