Skip to content

Commit 8c2f391

Browse files
committed
wip: bringing validation of sample to linux
1 parent 6399519 commit 8c2f391

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

Samples/SwiftAndJavaJarSampleLib/build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,14 @@ def swiftProductsWithJExtractPlugin() {
7878
}
7979
}
8080

81+
def swiftCheckValid = tasks.register("swift-check-valid", Exec) {
82+
commandLine "swift"
83+
args("-version")
84+
}
85+
8186
def jextract = tasks.register("jextract", Exec) {
8287
description = "Generate Java wrappers for swift target"
88+
dependsOn swiftCheckValid
8389
// dependsOn compileSwiftJExtractPlugin
8490

8591
// only because we depend on "live developing" the plugin while using this project to test it
@@ -90,7 +96,8 @@ def jextract = tasks.register("jextract", Exec) {
9096
inputs.file(new File(projectDir, "Package.swift"))
9197

9298
// monitor all targets/products which depend on the JExtract plugin
93-
swiftProductsWithJExtractPlugin().each {
99+
// swiftProductsWithJExtractPlugin().each {
100+
["MySwiftLibrary"].each {
94101
logger.info("[swift-java:jextract (Gradle)] Swift input target: ${it}")
95102
inputs.dir(new File(layout.projectDirectory.asFile, "Sources/${it}".toString()))
96103
}

Samples/SwiftAndJavaJarSampleLib/ci-validate.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@ set -x
88
# check if we can compile a plain Example file that uses the generated Java bindings that should be in the generated jar
99
javac -cp bin/default/build/libs/*jar Example.java
1010

11-
# Can we run the example?
12-
# - find libswiftCore.dylib
13-
SWIFT_DYLIB_PATHS=$(find "$(swiftly use --print-location)" | grep dylib$ | grep libswiftCore | grep macos | xargs dirname)
14-
# - find our library dylib
15-
SWIFT_DYLIB_PATHS="${SWIFT_DYLIB_PATHS}:$(find . | grep libMySwiftLibrary.dylib$ | sort | head -n1 | xargs dirname)"
16-
java -Djava.library.path="${SWIFT_DYLIB_PATHS}" -cp ".:bin/default/build/libs/*jar:../../SwiftKit/build/libs/*jar" Example
11+
12+
if [ "$(uname -s)" = 'Linux' ]
13+
then
14+
exit 1 # not implemented yet
15+
elif [ "$(uname -s)" = 'Darwin' ]
16+
then
17+
# Can we run the example?
18+
# - find libswiftCore.dylib
19+
SWIFT_DYLIB_PATHS=$(find "$(swiftly use --print-location)" | grep dylib$ | grep libswiftCore | grep macos | xargs dirname)
20+
# - find our library dylib
21+
SWIFT_DYLIB_PATHS="${SWIFT_DYLIB_PATHS}:$(find . | grep libMySwiftLibrary.dylib$ | sort | head -n1 | xargs dirname)"
22+
java -Djava.library.path="${SWIFT_DYLIB_PATHS}" -cp ".:bin/default/build/libs/*jar:../../SwiftKit/build/libs/*jar" Example
23+
fi

Samples/SwiftKitSampleApp/build.gradle

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,19 @@ repositories {
3030

3131
java {
3232
toolchain {
33-
languageVersion.set(JavaLanguageVersion.of(22))
33+
languageVersion.set(JavaLanguageVersion.of(23))
3434
}
3535
}
3636

37+
def swiftCheckValid = tasks.register("swift-check-valid", Exec) {
38+
commandLine "swift"
39+
args("-version")
40+
}
41+
3742
def jextract = tasks.register("jextract", Exec) {
3843
description = "Builds swift sources, including swift-java source generation"
39-
dependsOn compileSwiftJExtractPlugin
44+
dependsOn swiftCheckValid
45+
// dependsOn compileSwiftJExtractPlugin
4046

4147
// only because we depend on "live developing" the plugin while using this project to test it
4248
inputs.file(new File(rootDir, "Package.swift"))

0 commit comments

Comments
 (0)