Skip to content

Rework makefile to split JavaKit targets from jextract-swift targets #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

on:
pull_request:
types: [ opened, reopened, synchronize ]

Check failure on line 5 in .github/workflows/pull_request.yml

View workflow job for this annotation

GitHub Actions / soundness / Lint YAML

5:13 [brackets] too many spaces inside brackets

Check failure on line 5 in .github/workflows/pull_request.yml

View workflow job for this annotation

GitHub Actions / soundness / Lint YAML

5:43 [brackets] too many spaces inside brackets

jobs:
soundness:
Expand All @@ -14,7 +14,7 @@
license_header_check_project_name: Swift.org
# 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
# swift-subprocess includes the word "kill" because SIGKILL signal handling so we allow it
unacceptable_language_check_word_list: "blacklist whitelist slave master sane sanity insane insanity killed killing hang hung hanged hanging" #ignore-unacceptable-language

Check warning on line 17 in .github/workflows/pull_request.yml

View workflow job for this annotation

GitHub Actions / soundness / Lint YAML

17:149 [comments] too few spaces before comment

Check warning on line 17 in .github/workflows/pull_request.yml

View workflow job for this annotation

GitHub Actions / soundness / Lint YAML

17:150 [comments] missing starting space in comment

test-java:
name: Java tests (swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}} os:${{ matrix.os_version }})
Expand All @@ -22,9 +22,9 @@
strategy:
fail-fast: true
matrix:
swift_version: [ 'nightly-main' ]

Check failure on line 25 in .github/workflows/pull_request.yml

View workflow job for this annotation

GitHub Actions / soundness / Lint YAML

25:25 [brackets] too many spaces inside brackets

Check failure on line 25 in .github/workflows/pull_request.yml

View workflow job for this annotation

GitHub Actions / soundness / Lint YAML

25:40 [brackets] too many spaces inside brackets
os_version: [ 'jammy' ]

Check failure on line 26 in .github/workflows/pull_request.yml

View workflow job for this annotation

GitHub Actions / soundness / Lint YAML

26:22 [brackets] too many spaces inside brackets

Check failure on line 26 in .github/workflows/pull_request.yml

View workflow job for this annotation

GitHub Actions / soundness / Lint YAML

26:30 [brackets] too many spaces inside brackets
jdk_vendor: [ 'Corretto' ]

Check failure on line 27 in .github/workflows/pull_request.yml

View workflow job for this annotation

GitHub Actions / soundness / Lint YAML

27:22 [brackets] too many spaces inside brackets

Check failure on line 27 in .github/workflows/pull_request.yml

View workflow job for this annotation

GitHub Actions / soundness / Lint YAML

27:33 [brackets] too many spaces inside brackets
container:
image: ${{ (contains(matrix.swift_version, 'nightly') && 'swiftlang/swift') || 'swift' }}:${{ matrix.swift_version }}-${{ matrix.os_version }}
env:
Expand Down Expand Up @@ -68,7 +68,7 @@
strategy:
fail-fast: false
matrix:
swift_version: [ 'nightly-main' ]

Check failure on line 71 in .github/workflows/pull_request.yml

View workflow job for this annotation

GitHub Actions / soundness / Lint YAML

71:25 [brackets] too many spaces inside brackets

Check failure on line 71 in .github/workflows/pull_request.yml

View workflow job for this annotation

GitHub Actions / soundness / Lint YAML

71:40 [brackets] too many spaces inside brackets
os_version: [ 'jammy' ]
jdk_vendor: [ 'Corretto' ]
container:
Expand Down Expand Up @@ -106,6 +106,6 @@
# run the actual build
- name: Generate sources (make) (Temporary)
# TODO: this should be triggered by the respective builds
run: "make jextract-run"
run: "make jextract-generate"
- name: Test Swift
run: "swift test"
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ endif

SAMPLES_DIR := "Samples"

all: generate-all
all:
@echo "Welcome to swift-java! There are several makefile targets to choose from:"
@echo " javakit-run: Run the JavaKit example program that uses Java libraries from Swift."
@echo " javakit-generate: Regenerate the Swift wrapper code for the various JavaKit libraries from Java. This only has to be done when changing the Java2Swift tool."
@echo " jextract-run: Run the Java example code that uses the wrapped Swift library. NOTE: this requires development toolchain described in the README."
@echo " jextract-generate: Generate Java wrapper code for the example Swift library allowing Swift to be called from Java. NOTE: this requires development toolchain described in the README."

$(BUILD_DIR)/debug/libJavaKit.$(LIB_SUFFIX) $(BUILD_DIR)/debug/Java2Swift:
swift build

run: $(BUILD_DIR)/debug/libJavaKit.$(LIB_SUFFIX) $(BUILD_DIR)/debug/libExampleSwiftLibrary.$(LIB_SUFFIX)
javakit-run: $(BUILD_DIR)/debug/libJavaKit.$(LIB_SUFFIX) $(BUILD_DIR)/debug/libExampleSwiftLibrary.$(LIB_SUFFIX)
./gradlew Samples:JavaKitSampleApp:run

Java2Swift: $(BUILD_DIR)/debug/Java2Swift
Expand All @@ -79,8 +84,8 @@ generate-JavaKitNetwork: Java2Swift generate-JavaKit
mkdir -p Sources/JavaKitNetwork/generated
$(BUILD_DIR)/debug/Java2Swift --module-name JavaKitNetwork --manifests Sources/JavaKit/generated/JavaKit.swift2java -o Sources/JavaKitNetwork/generated java.net.URI java.net.URL java.net.URLClassLoader

generate-all: generate-JavaKit generate-JavaKitReflection generate-JavaKitJar generate-JavaKitNetwork \
jextract-swift
javakit-generate: generate-JavaKit generate-JavaKitReflection generate-JavaKitJar generate-JavaKitNetwork

clean:
rm -rf .build; \
rm -rf Samples/SwiftKitExampleApp/src/generated/java/*
Expand Down Expand Up @@ -112,11 +117,11 @@ jextract-swift: generate-JExtract-interface-files
swift build

generate-JExtract-interface-files: $(BUILD_DIR)/debug/libJavaKit.$(LIB_SUFFIX)
echo "Generate .swiftinterface files..."
@echo "Generate .swiftinterface files..."
@$(call make_swiftinterface, "ExampleSwiftLibrary", "MySwiftLibrary")
@$(call make_swiftinterface, "SwiftKitSwift", "SwiftKit")

jextract-run: jextract-swift generate-JExtract-interface-files
jextract-generate: jextract-swift generate-JExtract-interface-files
swift run jextract-swift \
--package-name com.example.swift.generated \
--swift-module ExampleSwiftLibrary \
Expand All @@ -129,5 +134,5 @@ jextract-run: jextract-swift generate-JExtract-interface-files
$(BUILD_DIR)/jextract/SwiftKitSwift/SwiftKit.swiftinterface


jextract-run-java: jextract-swift generate-JExtract-interface-files
jextract-run: jextract-generate
./gradlew Samples:SwiftKitSampleApp:run
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ This project contains quite a few builds, Swift, Java, and depends on some custo
Easiest way to get going is to:

```bash
make
make javakit-run # Run the JavaKit example of Swift code using Java libraries
make jextract-run # Run the jextract-swift example of Java code using Swift libraries
swift test # test all Swift code, e.g. jextract-swift
./gradlew test # test all Java code, including integration tests that actually use jextract-ed sources
```
Expand Down
2 changes: 1 addition & 1 deletion Samples/SwiftKitSampleApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ task jextract(type: Exec) {

workingDir = rootDir
commandLine "make"
args "jextract-run"
args "jextract-generate"
}

tasks.named("compileGeneratedJava").configure {
Expand Down
4 changes: 2 additions & 2 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ services:

test-java:
<<: *common
command: /bin/bash -xcl "uname -a && swift -version && java -version && make jextract-run && ./gradlew test --debug"
command: /bin/bash -xcl "uname -a && swift -version && java -version && make jextract-generate && ./gradlew test --debug"

test:
<<: *common
command: /bin/bash -xcl "uname -a && swift -version && java -version && make jextract-run && swift $${SWIFT_TEST_VERB-test} $${WARN_AS_ERROR_ARG-} $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-} && ./gradlew test --debug"
command: /bin/bash -xcl "uname -a && swift -version && java -version && make jextract-generate && swift $${SWIFT_TEST_VERB-test} $${WARN_AS_ERROR_ARG-} $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-} && ./gradlew test --debug"

# util

Expand Down