Skip to content

Commit 080c2ae

Browse files
ktososhahmishal
andauthored
Prepare for Linux build and CI (#14)
Co-authored-by: Mishal Shah <mishal_shah@apple.com>
1 parent 14612af commit 080c2ae

File tree

119 files changed

+2709
-2165
lines changed

Some content is hidden

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

119 files changed

+2709
-2165
lines changed

.github/workflows/pull_request.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 Make
35+
run: apt-get -qq update && apt-get -qq install -y make
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+
# - uses: actions/setup-java@v4
40+
# with:
41+
# distribution: 'zulu'
42+
# java-version: '22'
43+
# cache: 'gradle'
44+
- name: Generate sources (make) (Temporary)
45+
# TODO: this should be triggered by the respective builds
46+
run: make jextract-run
47+
- name: Gradle build
48+
run: ./gradlew build --no-daemon
49+
50+
test-swift:
51+
name: Swift tests (swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}} os:${{ matrix.os_version }})
52+
runs-on: ubuntu-latest
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
swift_version: [ 'nightly-main' ]
57+
os_version: [ 'jammy' ]
58+
jdk_vendor: [ 'Corretto' ]
59+
container:
60+
image: ${{ (contains(matrix.swift_version, 'nightly') && 'swiftlang/swift') || 'swift' }}:${{ matrix.swift_version }}-${{ matrix.os_version }}
61+
env:
62+
JAVA_HOME: "/usr/lib/jvm/default-jdk"
63+
steps:
64+
- uses: actions/checkout@v4
65+
- name: Install Make
66+
run: apt-get -qq update && apt-get -qq install -y make
67+
- name: Install JDK
68+
run: "bash -xc 'JDK_VENDOR=${{ matrix.jdk_vendor }} ./docker/install_jdk.sh'"
69+
- name: Generate sources (make) (Temporary)
70+
# TODO: this should be triggered by the respective builds
71+
run: "make jextract-run"
72+
- name: Test Swift
73+
run: "swift test"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ DerivedData/
88
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
99
.netrc
1010
*.class
11+
bin/
1112

1213
# Ignore gradle build artifacts
1314
.gradle

.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: 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-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
//

JavaSwiftKitDemo/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
//

JavaSwiftKitDemo/src/main/java/com/example/swift/HelloSubclass.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +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

1415
package com.example.swift;
16+
1517
import com.example.swift.HelloSwift;
1618

1719
public class HelloSubclass extends HelloSwift {

JavaSwiftKitDemo/src/main/java/com/example/swift/HelloSwift.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +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

1415
package com.example.swift;
16+
1517
import com.example.swift.HelloSubclass;
1618

1719
public class HelloSwift {

JavaSwiftKitDemo/src/main/java/org/example/CallMe.java

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
//

JavaSwiftKitDemo/src/main/java/org/example/HelloJava2Swift.java

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
//

JavaSwiftKitDemo/src/main/java/org/example/swift/ManualJavaKitExample.java

Lines changed: 3 additions & 3 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
//
@@ -199,14 +200,13 @@ public static void globalCallJavaCallback(Runnable callMe) {
199200
var mh$ = globalCallJavaCallback.HANDLE;
200201

201202
try {
203+
// signature of 'void run()'
202204
FunctionDescriptor callMe_run_desc = FunctionDescriptor.ofVoid(
203-
// replicate signature of run()
204205
);
205206
MethodHandle callMe_run_handle = MethodHandles.lookup()
206207
.findVirtual(Runnable.class,
207208
"run",
208-
callMe_run_desc.toMethodType()
209-
);
209+
callMe_run_desc.toMethodType());
210210
callMe_run_handle = callMe_run_handle.bindTo(callMe); // set the first parameter to the Runnable as the "this" of the callback pretty much
211211

212212
try (Arena arena = Arena.ofConfined()) {

JavaSwiftKitDemo/src/main/java/org/example/swift/ManualMySwiftClass.java

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
//

JavaSwiftKitDemo/src/main/java/org/example/swift/Manual_MySwiftClass.java

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
//

JavaSwiftKitDemo/src/main/java/org/swift/javakit/ManagedSwiftType.java

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
//

JavaSwiftKitDemo/src/main/java/org/swift/javakit/SwiftKit.java

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
//

JavaSwiftKitDemo/src/main/java/org/swift/swiftkit/SwiftArena.java

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
//

JavaSwiftKitDemo/src/main/java/org/swift/swiftkit/SwiftHeapObject.java

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
//

JavaSwiftKitDemo/src/test/java/org/example/swift/GlobalFunctionsTest.java

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
//

JavaSwiftKitDemo/src/test/java/org/example/swift/JavaKitTest.java

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
//

JavaSwiftKitDemo/src/test/java/org/example/swift/SwiftKitTest.java

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
//

Makefile

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,38 @@
1515
.PHONY: run clean all
1616

1717
ARCH := $(shell arch)
18+
UNAME := $(shell uname)
19+
20+
ifeq ($(UNAME), Linux)
21+
ifeq ($(ARCH), 'i386')
22+
ARCH_SUBDIR := x86_64
23+
else
24+
ARCH_SUBDIR := aarch64
25+
endif
26+
BUILD_DIR := .build/$(ARCH_SUBDIR)-unknown-linux-gnu
27+
LIB_SUFFIX := so
28+
endif
29+
30+
ifeq ($(UNAME), Darwin)
1831
ifeq ($(ARCH), 'i386')
1932
ARCH_SUBDIR := x86_64
2033
else
2134
ARCH_SUBDIR := arm64
2235
endif
36+
BUILD_DIR := .build/$(ARCH_SUBDIR)-apple-macosx
37+
LIB_SUFFIX := dylib
38+
endif
2339

24-
BUILD_DIR=".build/$(ARCH_SUBDIR)-apple-macosx"
2540

2641
all: generate-all
2742

28-
$(BUILD_DIR)/debug/libJavaKit.dylib $(BUILD_DIR)/debug/libJavaKitExample.dylib $(BUILD_DIR)/debug/Java2Swift:
43+
$(BUILD_DIR)/debug/libJavaKit.$(LIB_SUFFIX) $(BUILD_DIR)/debug/libJavaKitExample.$(LIB_SUFFIX) $(BUILD_DIR)/debug/Java2Swift:
2944
swift build
3045

3146
./JavaSwiftKitDemo/build/classes/java/main/com/example/swift/HelloSubclass.class: JavaSwiftKitDemo/src/main/java/com/example/swift
3247
./gradlew build
3348

34-
run: $(BUILD_DIR)/debug/libJavaKit.dylib $(BUILD_DIR)/debug/libJavaKitExample.dylib JavaSwiftKitDemo/src/main/java/com/example/swift
49+
run: $(BUILD_DIR)/debug/libJavaKit.$(LIB_SUFFIX) $(BUILD_DIR)/debug/libJavaKitExample.$(LIB_SUFFIX) JavaSwiftKitDemo/src/main/java/com/example/swift
3550
java -cp JavaSwiftKitDemo/build/classes/java/main -Djava.library.path=$(BUILD_DIR)/debug/ com.example.swift.HelloSwift
3651

3752
Java2Swift: $(BUILD_DIR)/debug/Java2Swift
@@ -82,7 +97,7 @@ endef
8297
jextract-swift: generate-JExtract-interface-files
8398
swift build
8499

85-
generate-JExtract-interface-files: $(BUILD_DIR)/debug/libJavaKit.dylib
100+
generate-JExtract-interface-files: $(BUILD_DIR)/debug/libJavaKit.$(LIB_SUFFIX)
86101
echo "Generate .swiftinterface files..."
87102
@$(call make_swiftinterface, "JavaKitExample", "MySwiftLibrary")
88103
@$(call make_swiftinterface, "JavaKitExample", "SwiftKit")
@@ -92,8 +107,8 @@ jextract-run: jextract-swift generate-JExtract-interface-files
92107
--package-name com.example.swift.generated \
93108
--swift-module JavaKitExample \
94109
--output-directory JavaSwiftKitDemo/src/main/java \
95-
.build/arm64-apple-macosx/jextract/JavaKitExample/MySwiftLibrary.swiftinterface \
96-
.build/arm64-apple-macosx/jextract/JavaKitExample/SwiftKit.swiftinterface
110+
$(BUILD_DIR)/jextract/JavaKitExample/MySwiftLibrary.swiftinterface \
111+
$(BUILD_DIR)/jextract/JavaKitExample/SwiftKit.swiftinterface
97112

98113

99114
jextract-run-java: jextract-swift generate-JExtract-interface-files

0 commit comments

Comments
 (0)