-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
55 lines (49 loc) · 1.47 KB
/
build.sh
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
#!/bin/bash
swt_dir=~/SWT/4.30
# The SWT .jar files for the different operating systems can be downloaded
# from https://download.eclipse.org/eclipse/downloads/index.html.
# They must be stored in the following subdirectories, below $swt_dir:
#
# windows/swt.jar
# macos/swt.jar
# macos-arm/swt.jar
# linux/swt.jar
# linux-arm/swt.jar
# Builds a .jar file that can be executed with "java -jar FILENAME".
# The parameter is one of the subdirectories (see above).
# E.g. "build linux" builds the Linux version.
build() {
# Clean up and create build directories.
local build_dir="build/$1"
rm -r "$build_dir" 2> /dev/null
mkdir -p "$build_dir" || exit 1
local class_dir="$build_dir/classes"
local swt_file="$swt_dir/$1/swt.jar"
# Compile the project's source code.
javac -cp "src:$swt_file" src/GUI.java -d "$class_dir" || exit 1
# Extract required files from the platform's "swt.jar" file.
local libs
if [[ $1 == windows ]]; then libs=*.dll; fi
if [[ $1 == macos* ]]; then libs=*.jnilib; fi
if [[ $1 == linux* ]]; then libs=*.so; fi
unzip "$swt_file" 'org/*' "$libs" -d "$class_dir" || exit 1
# Create the .jar file.
cd "$class_dir" || exit 1
jar -cfe "../pkg_manager_$1.jar" GUI *.class $libs org
cd - > /dev/null
}
case $1 in
all)
build windows
build macos
build macos-arm
build linux
build linux-arm
;;
windows|macos|macos-arm|linux|linux-arm)
build "$1"
;;
*)
echo "Invalid argument: \"$1\"" >&2
;;
esac