Skip to content

Commit 0b5d0c3

Browse files
committed
Merge branch 'main' into swiftinterface-mangled-names
2 parents 1e60cad + 11ab200 commit 0b5d0c3

File tree

134 files changed

+3145
-781
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+3145
-781
lines changed

.github/workflows/pull_request.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: pull_request
2+
3+
on:
4+
pull_request:
5+
types: [ opened, reopened, synchronize ]
6+
7+
jobs:
8+
soundness:
9+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
10+
with:
11+
api_breakage_check_enabled: false
12+
# FIXME: Something is off with the format task and it gets "stuck", need to investigate
13+
format_check_enabled: false
14+
license_header_check_project_name: Swift.org
15+
# FIXME: we're about to remove _Subprocess immediately anyway, so rather than fixing it one by one remove this adjusted list and use the default again ASAP
16+
# swift-subprocess includes the word "kill" because SIGKILL signal handling so we allow it
17+
unacceptable_language_check_word_list: "blacklist whitelist slave master sane sanity insane insanity killed killing hang hung hanged hanging" #ignore-unacceptable-language
18+
19+
test-java:
20+
name: Java tests (swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}} os:${{ matrix.os_version }})
21+
runs-on: ubuntu-latest
22+
strategy:
23+
fail-fast: true
24+
matrix:
25+
swift_version: [ 'nightly-main' ]
26+
os_version: [ 'jammy' ]
27+
jdk_vendor: [ 'Corretto' ]
28+
container:
29+
image: ${{ (contains(matrix.swift_version, 'nightly') && 'swiftlang/swift') || 'swift' }}:${{ matrix.swift_version }}-${{ matrix.os_version }}
30+
env:
31+
JAVA_HOME: "/usr/lib/jvm/default-jdk"
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Install System Dependencies
35+
run: apt-get -qq update && apt-get -qq install -y make curl wget
36+
- name: Install JDK
37+
run: "bash -xc 'JDK_VENDOR=${{ matrix.jdk_vendor }} ./docker/install_jdk.sh'"
38+
# TODO: not using setup-java since incompatible with the swiftlang/swift base image
39+
- name: Install Untested Nightly Swift
40+
run: "bash -xc './docker/install_untested_nightly_swift.sh'"
41+
# setup caches
42+
- name: Cache local Gradle repository
43+
uses: actions/cache@v4
44+
continue-on-error: true
45+
with:
46+
path: |
47+
/root/.gradle/caches
48+
/root/.gradle/wrapper
49+
key: ${{ runner.os }}-gradle-${{ hashFiles('*/*.gradle*', 'settings.gradle') }}
50+
restore-keys: |
51+
${{ runner.os }}-gradle-
52+
- name: Cache local SwiftPM repository
53+
uses: actions/cache@v4
54+
continue-on-error: true
55+
with:
56+
path: /__w/swift-java/swift-java/.build/checkouts
57+
key: ${{ runner.os }}-swiftpm-cache-${{ hashFiles('Package.swift') }}
58+
restore-keys: |
59+
${{ runner.os }}-swiftpm-cache
60+
${{ runner.os }}-swiftpm-
61+
# run the actual build
62+
- name: Gradle build
63+
run: ./gradlew build --info --no-daemon
64+
65+
test-swift:
66+
name: Swift tests (swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}} os:${{ matrix.os_version }})
67+
runs-on: ubuntu-latest
68+
strategy:
69+
fail-fast: false
70+
matrix:
71+
swift_version: [ 'nightly-main' ]
72+
os_version: [ 'jammy' ]
73+
jdk_vendor: [ 'Corretto' ]
74+
container:
75+
image: ${{ (contains(matrix.swift_version, 'nightly') && 'swiftlang/swift') || 'swift' }}:${{ matrix.swift_version }}-${{ matrix.os_version }}
76+
env:
77+
JAVA_HOME: "/usr/lib/jvm/default-jdk"
78+
steps:
79+
- uses: actions/checkout@v4
80+
- name: Install System Dependencies
81+
run: apt-get -qq update && apt-get -qq install -y make curl wget
82+
- name: Install JDK
83+
run: "bash -xc 'JDK_VENDOR=${{ matrix.jdk_vendor }} ./docker/install_jdk.sh'"
84+
- name: Install Untested Nightly Swift
85+
run: "bash -xc './docker/install_untested_nightly_swift.sh'"
86+
# setup caches
87+
- name: Cache local Gradle repository
88+
uses: actions/cache@v4
89+
continue-on-error: true
90+
with:
91+
path: |
92+
/root/.gradle/caches
93+
/root/.gradle/wrapper
94+
key: ${{ runner.os }}-gradle-${{ hashFiles('*/*.gradle*', 'settings.gradle') }}
95+
restore-keys: |
96+
${{ runner.os }}-gradle-
97+
- name: Cache local SwiftPM repository
98+
uses: actions/cache@v4
99+
continue-on-error: true
100+
with:
101+
path: /__w/swift-java/swift-java/.build/checkouts
102+
key: ${{ runner.os }}-swiftpm-cache-${{ hashFiles('Package.swift') }}
103+
restore-keys: |
104+
${{ runner.os }}-swiftpm-cache
105+
${{ runner.os }}-swiftpm-
106+
# run the actual build
107+
- name: Generate sources (make) (Temporary)
108+
# TODO: this should be triggered by the respective builds
109+
run: "make jextract-run"
110+
- name: Test Swift
111+
run: "swift test"

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ DerivedData/
88
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
99
.netrc
1010
*.class
11+
bin/
12+
BuildLogic/out/
1113

1214
# Ignore gradle build artifacts
1315
.gradle
1416
**/build/
17+
lib/
18+
19+
# Ignore package resolved
20+
Package.resolved
1521

1622
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
1723
!gradle-wrapper.jar
@@ -23,4 +29,4 @@ DerivedData/
2329
.gradletasknamecache
2430

2531
# Ignore generated sources
26-
JavaSwiftKitDemo/src/main/java/com/example/swift/generated/*
32+
**/generated/

.licenseignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.gitignore
2+
.licenseignore
3+
.swiftformatignore
4+
.spi.yml
5+
.swift-format
6+
.github/*
7+
*.md
8+
CONTRIBUTORS.txt
9+
LICENSE.txt
10+
NOTICE.txt
11+
Package.swift
12+
Package.resolved
13+
README.md
14+
SECURITY.md
15+
scripts/unacceptable-language.txt
16+
docker/*
17+
**/*.docc/*
18+
**/.gitignore
19+
**/Package.swift
20+
**/Package.resolved
21+
**/*.md
22+
**/openapi.yml
23+
**/petstore.yaml
24+
**/openapi-generator-config.yaml
25+
**/openapi-generator-config.yml
26+
**/docker-compose.yaml
27+
**/docker/*
28+
**/.dockerignore
29+
JavaSwiftKitDemo/src/main/java/com/example/swift/generated/*
30+
Makefile
31+
**/Makefile
32+
**/*.html
33+
**/CMakeLists.txt
34+
**/*.jar
35+
gradle/wrapper/gradle-wrapper.properties
36+
gradlew
37+
gradlew.bat
38+
**/*.swift2java
39+
Sources/JavaKit/generated/*
40+
Sources/JavaKitJar/generated/*
41+
Sources/JavaKitNetwork/generated/*
42+
Sources/JavaKitReflection/generated/*
43+
Sources/_Subprocess/*
44+
Sources/_Subprocess/**/*
45+
Sources/_SubprocessCShims/*
46+
Sources/_SubprocessCShims/**/*

BuildLogic/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
910
//
1011
// SPDX-License-Identifier: Apache-2.0
1112
//

BuildLogic/settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
910
//
1011
// SPDX-License-Identifier: Apache-2.0
1112
//

BuildLogic/src/main/kotlin/build-logic.java-application-conventions.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
910
//
1011
// SPDX-License-Identifier: Apache-2.0
1112
//

BuildLogic/src/main/kotlin/build-logic.java-common-conventions.gradle.kts

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
910
//
1011
// SPDX-License-Identifier: Apache-2.0
1112
//
1213
//===----------------------------------------------------------------------===//
1314

15+
import java.util.*
16+
1417
plugins {
1518
java
1619
}
@@ -39,16 +42,44 @@ tasks.withType(JavaCompile::class).forEach {
3942
it.options.compilerArgs.add("-Xlint:preview")
4043
}
4144

45+
46+
// FIXME: cannot share definition with 'buildSrc' so we duplicated the impl here
47+
fun javaLibraryPaths(): List<String> {
48+
val osName = System.getProperty("os.name")
49+
val osArch = System.getProperty("os.arch")
50+
val isLinux = osName.lowercase(Locale.getDefault()).contains("linux")
51+
52+
return listOf(
53+
if (isLinux) {
54+
if (osArch.equals("x86_64") || osArch.equals("amd64")) {
55+
"$rootDir/.build/x86_64-unknown-linux-gnu/debug/"
56+
} else {
57+
"$rootDir/.build/$osArch-unknown-linux-gnu/debug/"
58+
}
59+
} else {
60+
if (osArch.equals("aarch64")) {
61+
"$rootDir/.build/arm64-apple-macosx/debug/"
62+
} else {
63+
"$rootDir/.build/$osArch-apple-macosx/debug/"
64+
}
65+
},
66+
if (isLinux) {
67+
"/usr/lib/swift/linux"
68+
} else {
69+
// assume macOS
70+
"/usr/lib/swift/"
71+
}
72+
)
73+
}
74+
75+
4276
// Configure paths for native (Swift) libraries
4377
tasks.test {
4478
jvmArgs(
4579
"--enable-native-access=ALL-UNNAMED",
4680

4781
// Include the library paths where our dylibs are that we want to load and call
48-
"-Djava.library.path=" + listOf(
49-
"""$rootDir/.build/arm64-apple-macosx/debug/""",
50-
"/usr/lib/swift/"
51-
).joinToString(File.pathSeparator)
82+
"-Djava.library.path=" + javaLibraryPaths().joinToString(File.pathSeparator)
5283
)
5384
}
5485

@@ -59,14 +90,15 @@ tasks.withType<Test> {
5990
}
6091

6192

62-
val buildSwiftJExtract = tasks.register<Exec>("buildSwiftJExtract") {
63-
description = "Builds Swift targets, including jextract-swift"
64-
65-
workingDir("..")
66-
commandLine("make")
67-
}
68-
69-
tasks.build {
70-
dependsOn(buildSwiftJExtract)
71-
}
93+
// TODO: This is a crude workaround, we'll remove 'make' soon and properly track build dependencies
94+
// val buildSwiftJExtract = tasks.register<Exec>("buildMake") {
95+
// description = "Triggers 'make' build"
96+
//
97+
// workingDir(rootDir)
98+
// commandLine("make")
99+
// }
100+
//
101+
// tasks.build {
102+
// dependsOn(buildSwiftJExtract)
103+
// }
72104

BuildLogic/src/main/kotlin/build-logic.java-library-conventions.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
910
//
1011
// SPDX-License-Identifier: Apache-2.0
1112
//

0 commit comments

Comments
 (0)