forked from swiftlang/swift-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci-validate.sh
More file actions
executable file
·68 lines (57 loc) · 2.57 KB
/
ci-validate.sh
File metadata and controls
executable file
·68 lines (57 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
set -e
set -x
./gradlew jar
SWIFT_VERSION="$(swift -version | awk '/Swift version/ { print $3 }')"
# This is how env variables are set by setup-java
if [ "$(uname -m)" = 'arm64' ]; then
ARCH=ARM64
JAVAC="${JAVA_HOME_25_ARM64}/bin/javac"
JAVA="${JAVA_HOME_25_ARM64}/bin/java"
else
ARCH=X64
JAVAC="${JAVA_HOME_25_X64}/bin/javac"
JAVA="${JAVA_HOME_25_X64}/bin/java"
fi
if [ -n "$JAVA_HOME_25_$ARCH" ]; then
export JAVA_HOME="$JAVA_HOME_25_$ARCH"
elif [ "$(uname -s)" = 'Linux' ]
then
export PATH="${PATH}:/usr/lib/jvm/jdk-25/bin" # we need to make sure to use the latest JDK to actually compile/run the executable
fi
# check if we can compile a plain Example file that uses the generated Java bindings that should be in the generated jar
# The classpath MUST end with a * if it contains jar files, and must not if it directly contains class files.
SWIFTKIT_CORE_CLASSPATH="$(pwd)/../../SwiftKitCore/build/libs/*"
SWIFTKIT_FFM_CLASSPATH="$(pwd)/../../SwiftKitFFM/build/libs/*"
MYLIB_CLASSPATH="$(pwd)/build/libs/*"
CLASSPATH="$(pwd)/:${SWIFTKIT_FFM_CLASSPATH}:${SWIFTKIT_CORE_CLASSPATH}:${MYLIB_CLASSPATH}"
echo "CLASSPATH = ${CLASSPATH}"
$JAVAC -cp "${CLASSPATH}" Example.java
# FIXME: move all this into Gradle or SwiftPM and make it easier to get the right classpath for running
if [ "$(uname -s)" = 'Linux' ]
then
SWIFT_LIB_PATHS=/usr/lib/swift/linux
SWIFT_LIB_PATHS="${SWIFT_LIB_PATHS}:$(find . | grep libMySwiftLibrary.so$ | sort | head -n1 | xargs dirname)"
# if we are on linux, find the Swiftly or System-wide installed libraries dir
SWIFT_CORE_LIB=$(find "$HOME"/.local -name "libswiftCore.so" 2>/dev/null | grep "$SWIFT_VERSION" | head -n1)
if [ -n "$SWIFT_CORE_LIB" ]; then
SWIFT_LIB_PATHS="${SWIFT_LIB_PATHS}:$(dirname "$SWIFT_CORE_LIB")"
ls "$SWIFT_LIB_PATHS"
else
# maybe there is one installed system-wide in /usr/lib?
SWIFT_CORE_LIB2=$(find /usr/lib -name "libswiftCore.so" 2>/dev/null | grep "$SWIFT_VERSION" | head -n1)
if [ -n "$SWIFT_CORE_LIB2" ]; then
SWIFT_LIB_PATHS="${SWIFT_LIB_PATHS}:$(dirname "$SWIFT_CORE_LIB2")"
fi
fi
elif [ "$(uname -s)" = 'Darwin' ]
then
SWIFT_LIB_PATHS=$(find "$(swiftly use --print-location)" | grep dylib$ | grep libswiftCore | grep macos | head -n1 | xargs dirname)
SWIFT_LIB_PATHS="${SWIFT_LIB_PATHS}:$(pwd)/$(find . | grep libMySwiftLibrary.dylib$ | sort | head -n1 | xargs dirname)"
fi
echo "SWIFT_LIB_PATHS = ${SWIFT_LIB_PATHS}"
# Can we run the example?
${JAVA} --enable-native-access=ALL-UNNAMED \
-Djava.library.path="${SWIFT_LIB_PATHS}" \
-cp "${CLASSPATH}" \
Example