mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
Application build scripts
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,6 +4,8 @@ bin/*
|
|||||||
build/*
|
build/*
|
||||||
.gradle/*
|
.gradle/*
|
||||||
TerrarumBuild.jar
|
TerrarumBuild.jar
|
||||||
|
buildapp/out/Terrarum*
|
||||||
|
assets/mods/dwarventech/ModuleComputers.jar
|
||||||
|
|
||||||
# Java native errors
|
# Java native errors
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
|||||||
BIN
buildapp/appimagetool-x86_64.AppImage
Executable file
BIN
buildapp/appimagetool-x86_64.AppImage
Executable file
Binary file not shown.
29
buildapp/build_app_linux_arm.sh
Executable file
29
buildapp/build_app_linux_arm.sh
Executable 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
29
buildapp/build_app_linux_x86.sh
Executable 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
25
buildapp/build_app_mac_arm.sh
Executable 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
25
buildapp/build_app_mac_x86.sh
Executable 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
BIN
buildapp/icns.png
LFS
Normal file
Binary file not shown.
59
buildapp/instructions.md
Normal file
59
buildapp/instructions.md
Normal 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`.
|
||||||
9
buildapp/out/Apps built can be found here
Normal file
9
buildapp/out/Apps built can be found here
Normal 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.
|
||||||
3
buildapp/terrarumlinux_arm/AppRun
Executable file
3
buildapp/terrarumlinux_arm/AppRun
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd "${0%/*}"
|
||||||
|
./runtime-linux-arm/bin/java -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar
|
||||||
6
buildapp/terrarumlinux_arm/Terrarum.desktop
Normal file
6
buildapp/terrarumlinux_arm/Terrarum.desktop
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=Terrarum
|
||||||
|
Exec=AppRun
|
||||||
|
Icon=icns
|
||||||
|
Type=Application
|
||||||
|
Categories=Game;
|
||||||
3
buildapp/terrarumlinux_x86/AppRun
Executable file
3
buildapp/terrarumlinux_x86/AppRun
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd "${0%/*}"
|
||||||
|
./runtime-linux-x86/bin/java -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar
|
||||||
6
buildapp/terrarumlinux_x86/Terrarum.desktop
Normal file
6
buildapp/terrarumlinux_x86/Terrarum.desktop
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=Terrarum
|
||||||
|
Exec=AppRun
|
||||||
|
Icon=icns
|
||||||
|
Type=Application
|
||||||
|
Categories=Game;
|
||||||
8
buildapp/terrarummac_arm/Info.plist
Normal file
8
buildapp/terrarummac_arm/Info.plist
Normal 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>
|
||||||
3
buildapp/terrarummac_arm/Terrarum.sh
Executable file
3
buildapp/terrarummac_arm/Terrarum.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd "${0%/*}"
|
||||||
|
./runtime-arm-x86/bin/java -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar
|
||||||
8
buildapp/terrarummac_x86/Info.plist
Normal file
8
buildapp/terrarummac_x86/Info.plist
Normal 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>
|
||||||
3
buildapp/terrarummac_x86/Terrarum.sh
Executable file
3
buildapp/terrarummac_x86/Terrarum.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd "${0%/*}"
|
||||||
|
./runtime-osx-x86/bin/java -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar
|
||||||
2
buildapp/terrarumwindows_x86/Terrarum.bat
Executable file
2
buildapp/terrarumwindows_x86/Terrarum.bat
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
cd /D "%~dp0"
|
||||||
|
.\runtime-windows-x86\bin\java -Xms1G -Xmx6G -jar .\assets\TerrarumBuild.jar
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
### 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-amd64 --no-header-files --no-man-pages --strip-debug --compress=2
|
|
||||||
|
|
||||||
jlink --module-path ~/Documents/openjdk/jdk-17.0.1-aarch64/jmods:mods --add-modules java.base,java.desktop,java.logging,jdk.unsupported --output ~/Documents/Terrarum/out/runtime-linux-aarch64 --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-amd64 --no-header-files --no-man-pages --strip-debug --compress=2
|
|
||||||
jlink --module-path ~/Documents/openjdk/jdk-17.0.1.jdk-aarch64/Contents/Home/jmods:mods --add-modules java.base,java.desktop,java.logging,jdk.unsupported --output ~/Documents/Terrarum/out/runtime-osx-aarch64 --no-header-files --no-man-pages --strip-debug --compress=2
|
|
||||||
jlink --module-path ~/Documents/openjdk/jdk-17.0.1.jdk-amd64/Contents/Home/jmods:mods --add-modules java.base,java.desktop,java.logging,jdk.unsupported --output ~/Documents/Terrarum/out/runtime-osx-amd64 --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
|
|
||||||
+runtimes
|
|
||||||
`+runtime-linux-aarch64
|
|
||||||
`+runtime-linux-amd64
|
|
||||||
`+runtime-osx-amd64
|
|
||||||
`+runtime-osx-aarch64
|
|
||||||
`+runtime-windows-amd64
|
|
||||||
`TerrarumBuild.jar
|
|
||||||
start_game_linux_aarch64.sh
|
|
||||||
start_game_linux_x86_64.sh
|
|
||||||
start_game_mac_aarch64.sh
|
|
||||||
start_game_mac_x86_64.sh
|
|
||||||
start_game_windows.bat
|
|
||||||
```
|
|
||||||
|
|
||||||
whereas `runtime-*` are runtime directories generated from the commands above, `TerrarumBuild.jar` is the artifact built using the TerrarumBuild.
|
|
||||||
|
|
||||||
`start_game_*` files are on the root directory of the project; you only need to simply copy them over.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
And yes, I'm totally aware that `.sh` file says `x86_64` but the runtimes says `amd64`.
|
|
||||||
26
shit.kts
26
shit.kts
@@ -1,26 +0,0 @@
|
|||||||
val list = intArrayOf(0,2,4,6,9,13,16,54,88)
|
|
||||||
|
|
||||||
val ID = 555
|
|
||||||
|
|
||||||
var low = 0
|
|
||||||
var high = list.size
|
|
||||||
var mid = -1
|
|
||||||
|
|
||||||
while (low < high) {
|
|
||||||
mid = (low + high).ushr(1)
|
|
||||||
|
|
||||||
if (list[mid] > ID)
|
|
||||||
high = mid
|
|
||||||
else
|
|
||||||
low = mid + 1
|
|
||||||
|
|
||||||
low
|
|
||||||
}
|
|
||||||
|
|
||||||
println("$low, $high, $mid")
|
|
||||||
|
|
||||||
val ll = arrayListOf(1,1,1,1,1)
|
|
||||||
ll.add(5, 8)
|
|
||||||
println(ll)
|
|
||||||
|
|
||||||
// take mid value? (except for ID < list[0])
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
cd "${0%/*}"
|
|
||||||
./runtimes/runtime-linux-aarch64/bin/java -Xms1G -Xmx6G -jar ./runtimes/TerrarumBuild.jar
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
cd "${0%/*}"
|
|
||||||
./runtimes/runtime-linux-amd64/bin/java -Xms1G -Xmx6G -jar ./runtimes/TerrarumBuild.jar
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
cd "${0%/*}"
|
|
||||||
./runtimes/runtime-osx-aarch64/bin/java -Xms1G -Xmx6G -jar ./runtimes/TerrarumBuild.jar
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
cd "${0%/*}"
|
|
||||||
./runtimes/runtime-osx-amd64/bin/java -Xms1G -Xmx6G -jar ./runtimes/TerrarumBuild.jar
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
cd /D "%~dp0"
|
|
||||||
runtimes\runtime-windows-amd64\bin\java -Xms1G -Xmx6G -jar .\runtimes\TerrarumBuild.jar
|
|
||||||
Reference in New Issue
Block a user