Application build scripts

This commit is contained in:
minjaesong
2022-02-23 11:52:34 +09:00
parent cba25ef428
commit 841a77403b
25 changed files with 223 additions and 82 deletions

Binary file not shown.

29
buildapp/build_app_linux_arm.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
cd "${0%/*}"
APPIMAGETOOL="appimagetool-x86_64.AppImage"
SRCFILES="terrarumlinux_arm"
DESTDIR="TerrarumLinux.arm"
RUNTIME="runtime-linux-arm"
# Cleanup
rm -rf $DESTDIR || true
mkdir $DESTDIR
# Prepare an application
cp icns.png $DESTDIR/icns.png
cp $SRCFILES/Terrarum.desktop $DESTDIR/
cp $SRCFILES/AppRun $DESTDIR/AppRun
chmod +x $DESTDIR/AppRun
# Copy over a Java runtime
cp -r "../out/$RUNTIME" $DESTDIR/
# Copy over all the assets and a jarfile
cp -r "../assets" $DESTDIR/
cp -r "../out/TerrarumBuild.jar" $DESTDIR/assets/
# Pack everything to AppImage
"./$APPIMAGETOOL" $DESTDIR "out/$DESTDIR.AppImage" || { echo 'Building AppImage failed' >&2; exit 1; }
chmod +x "out/$DESTDIR.AppImage"
rm -rf $DESTDIR || true
echo "Build successful: $DESTDIR"

29
buildapp/build_app_linux_x86.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
cd "${0%/*}"
APPIMAGETOOL="appimagetool-x86_64.AppImage"
SRCFILES="terrarumlinux_x86"
DESTDIR="TerrarumLinux.x86"
RUNTIME="runtime-linux-x86"
# Cleanup
rm -rf $DESTDIR || true
mkdir $DESTDIR
# Prepare an application
cp icns.png $DESTDIR/icns.png
cp $SRCFILES/Terrarum.desktop $DESTDIR/
cp $SRCFILES/AppRun $DESTDIR/AppRun
chmod +x $DESTDIR/AppRun
# Copy over a Java runtime
cp -r "../out/$RUNTIME" $DESTDIR/
# Copy over all the assets and a jarfile
cp -r "../assets" $DESTDIR/
cp -r "../out/TerrarumBuild.jar" $DESTDIR/assets/
# Pack everything to AppImage
"./$APPIMAGETOOL" $DESTDIR "out/$DESTDIR.AppImage" || { echo 'Building AppImage failed' >&2; exit 1; }
chmod +x "out/$DESTDIR.AppImage"
rm -rf $DESTDIR || true
echo "Build successful: $DESTDIR"

25
buildapp/build_app_mac_arm.sh Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
cd "${0%/*}"
SRCFILES="terrarummac_arm"
DESTDIR="out/TerrarumMac.arm.app"
RUNTIME="runtime-osx-arm"
# Cleanup
rm -rf $DESTDIR || true
mkdir $DESTDIR
mkdir $DESTDIR/Contents
mkdir $DESTDIR/Contents/MacOS
# Prepare an application
cp icns.png $DESTDIR/.icns
cp $SRCFILES/Info.plist $DESTDIR/Contents/
cp $SRCFILES/Terrarum.sh $DESTDIR/Contents/MacOS/
chmod +x $DESTDIR/Contents/MacOS/Terrarum.sh
# Copy over a Java runtime
cp -r "../out/$RUNTIME" $DESTDIR/Contents/MacOS/
# Copy over all the assets and a jarfile
cp -r "../assets" $DESTDIR/Contents/MacOS/
cp -r "../out/TerrarumBuild.jar" $DESTDIR/Contents/MacOS/assets/
echo "Build successful: $DESTDIR"

25
buildapp/build_app_mac_x86.sh Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
cd "${0%/*}"
SRCFILES="terrarummac_x86"
DESTDIR="out/TerrarumMac.x86.app"
RUNTIME="runtime-osx-x86"
# Cleanup
rm -rf $DESTDIR || true
mkdir $DESTDIR
mkdir $DESTDIR/Contents
mkdir $DESTDIR/Contents/MacOS
# Prepare an application
cp icns.png $DESTDIR/.icns
cp $SRCFILES/Info.plist $DESTDIR/Contents/
cp $SRCFILES/Terrarum.sh $DESTDIR/Contents/MacOS/
chmod +x $DESTDIR/Contents/MacOS/Terrarum.sh
# Copy over a Java runtime
cp -r "../out/$RUNTIME" $DESTDIR/Contents/MacOS/
# Copy over all the assets and a jarfile
cp -r "../assets" $DESTDIR/Contents/MacOS/
cp -r "../out/TerrarumBuild.jar" $DESTDIR/Contents/MacOS/assets/
echo "Build successful: $DESTDIR"

BIN
buildapp/icns.png LFS Normal file

Binary file not shown.

59
buildapp/instructions.md Normal file
View File

@@ -0,0 +1,59 @@
### Preparation
Download and unzip the JDK for the appropriate operation systems first! JDKs can be downloaded on https://jdk.java.net/archive/.
Then, on the terminal, run following commands:
jlink --add-modules java.base,java.desktop,java.logging,jdk.unsupported --output ~/Documents/Terrarum/out/runtime-linux-x86 --no-header-files --no-man-pages --strip-debug --compress=2
jlink --module-path ~/Documents/openjdk/jdk-17.0.1-arm/jmods:mods --add-modules java.base,java.desktop,java.logging,jdk.unsupported --output ~/Documents/Terrarum/out/runtime-linux-arm --no-header-files --no-man-pages --strip-debug --compress=2
jlink --module-path ~/Documents/openjdk/jdk-17.0.1-windows/jmods:mods --add-modules java.base,java.desktop,java.logging,jdk.unsupported --output ~/Documents/Terrarum/out/runtime-windows-x86 --no-header-files --no-man-pages --strip-debug --compress=2
jlink --module-path ~/Documents/openjdk/jdk-17.0.1.jdk-arm/Contents/Home/jmods:mods --add-modules java.base,java.desktop,java.logging,jdk.unsupported --output ~/Documents/Terrarum/out/runtime-osx-arm --no-header-files --no-man-pages --strip-debug --compress=2
jlink --module-path ~/Documents/openjdk/jdk-17.0.1.jdk-x86/Contents/Home/jmods:mods --add-modules java.base,java.desktop,java.logging,jdk.unsupported --output ~/Documents/Terrarum/out/runtime-osx-x86 --no-header-files --no-man-pages --strip-debug --compress=2
This process assumes that the game does NOT use the Java 9+ modules and every single required libraries are fat-jar'd (their contents extracted right into the Jar)
### Packaging
Create an output directory; its contents shall be:
```
+assets
`(regular "assets")
`TerrarumBuild.jar
Terrarum.arm.app /* uses start_game_mac_aarch64.sh and contains runtime-osx-arm */
Terrarum.x86.app /* uses start_game_mac_x86_64.sh and contains runtime-osx-x86 */
Terrarum.arm.AppImage /* uses start_game_linux_aarch64.sh and contains runtime-linux-arm */
Terrarum.x86.AppImage /* uses start_game_linux_x86_64.sh and contains runtime-linux-x86 */
Terrarum.exe /* uses start_game_windows.bat and contains runtime-windows-x86 */
```
#### Packaging Script
Before running the packaging script make sure:
1. All five runtimes must exist on `<project dir>/out/runtime-<linux|osx|windows>-<arm|x86>` directory
2. The build scripts are on a subdirectory of the project directory
#### OSX .app Packaging
```
Terrarum.*.app
+.icns /* 512x512 PNG */
+Contents
`Info.plist
+MacOS
`start_game_mac_*.sh * permission: +x */
```
`assets/TerrarumBuild.jar` is the artifact built using the TerrarumBuild.
`start_game_*` files are on the root directory of the project; use them to build executable apps.
Hide the `.jar` within the subdirectory; users will think this file is the main executable and will try to execute it using whatever JVM they may (or may not) have.
### Notes to Terrarum Programmers
By self-containing everything in one file, it is not possible to modify the base game easily. Modloading scheme must be extended to load from mutable directory such as `%APPDATA%/Terrarum/mods`.

View File

@@ -0,0 +1,9 @@
You should be able to find following files here:
TerrarumMac.x86.app (a directory)
TerrarumMac.arm.app (a directory)
TerrarumLinux.x86.AppImage (an ELF executable)
TerrarumLinux.arm.AppImage (an ELF executable)
TerrarumWindows.x86.exe (a Windows executable)
NOTE: Mac apps won't run unless you disable the Gatekeeper by running `sudo spctl --master-disable` on Terminal (to be honest, doing so also opens a gaping hole called "security hazard"); signing a code requires both Apple Developer Connection (costs 99 USD/year) and a working Mac (cost a fortune) of which I'm not willing to shell out. So, if you're one of those unlucky Mac user try this game on your own risk, or get a Windows machine.

View File

@@ -0,0 +1,3 @@
#!/bin/bash
cd "${0%/*}"
./runtime-linux-arm/bin/java -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar

View File

@@ -0,0 +1,6 @@
[Desktop Entry]
Name=Terrarum
Exec=AppRun
Icon=icns
Type=Application
Categories=Game;

View File

@@ -0,0 +1,3 @@
#!/bin/bash
cd "${0%/*}"
./runtime-linux-x86/bin/java -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar

View File

@@ -0,0 +1,6 @@
[Desktop Entry]
Name=Terrarum
Exec=AppRun
Icon=icns
Type=Application
Categories=Game;

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>Terrarum.sh</string>
</dict>
</plist>

View File

@@ -0,0 +1,3 @@
#!/bin/bash
cd "${0%/*}"
./runtime-arm-x86/bin/java -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>Terrarum.sh</string>
</dict>
</plist>

View File

@@ -0,0 +1,3 @@
#!/bin/bash
cd "${0%/*}"
./runtime-osx-x86/bin/java -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar

View File

@@ -0,0 +1,2 @@
cd /D "%~dp0"
.\runtime-windows-x86\bin\java -Xms1G -Xmx6G -jar .\assets\TerrarumBuild.jar