forked from SwiftJava/SwiftJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenswift.sh
More file actions
executable file
·25 lines (18 loc) · 930 Bytes
/
genswift.sh
File metadata and controls
executable file
·25 lines (18 loc) · 930 Bytes
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
#!/bin/bash
#
# Interface to the Swift code generator Java code
#
# FILTER is the package names/classes to generate code for
# TARGET_JAR is the jar containing these classes
# PACKAGE_ORDER allows you to specify the order of frameworks
#
# In order to generate code with argument names captured you
# need to compile with the new-to-Java8 option -parameters.
#
export JAVA_HOME="${JAVA_HOME?-Please export JAVA_HOME}"
FILTER="${1:-java/lang|java/util|java/sql|java/awt|javax/swing}"
FILTER="$(echo "$FILTER" | sed 's@[._]@/@g' | sed 's@\$@\\$@g')"
TARGET_JAR="${2:-$JAVA_HOME/jre/lib/rt.jar}"
PACKAGE_ORDER=${3:-java/lang|java/util|java/sql|java/awt|javax/swing}
cd "$(dirname "$0")/src" && mkdir -p ../bin && "$JAVA_HOME/bin/javac" -d ../bin genswift.java && cd .. &&
"$JAVA_HOME/bin/jar" tf "$TARGET_JAR" | egrep "^($FILTER)" | sed "s@\\.class\$@@" | "$JAVA_HOME/bin/java" -cp "$TARGET_JAR:bin" genswift "$PACKAGE_ORDER"