diff --git a/buildapp/build_app_linux_arm.sh b/buildapp/build_app_linux_arm.sh
index e7b8b175a..745456d80 100755
--- a/buildapp/build_app_linux_arm.sh
+++ b/buildapp/build_app_linux_arm.sh
@@ -6,6 +6,8 @@ APPIMAGETOOL="appimagetool-x86_64.AppImage"
SRCFILES="terrarumlinux_arm"
DESTDIR="TerrarumLinux.arm"
RUNTIME="runtime-linux-arm"
+DESKTOPFILE="../out/build_autogen_linux.desktop"
+JARNAME="TerrarumBuild.jar"
if [ ! -d "../assets_release" ]; then
echo "'assets_release' does not exist; prepare the assets for the release and put them into the assets_release directory, exiting now." >&2
@@ -18,7 +20,7 @@ mkdir $DESTDIR
# Prepare an application
cp icns.png $DESTDIR/icns.png
-cp $SRCFILES/Terrarum.desktop $DESTDIR/
+cp $DESKTOPFILE $DESTDIR/
cp $SRCFILES/AppRun $DESTDIR/AppRun
chmod +x $DESTDIR/AppRun
@@ -30,7 +32,7 @@ mv $DESTDIR/out/$RUNTIME/bin/java $DESTDIR/out/$RUNTIME/bin/Terrarum
# Copy over all the assets and a jarfile
cp -r "../assets_release" $DESTDIR/
mv $DESTDIR/assets_release $DESTDIR/assets
-cp "../out/TerrarumBuild.jar" $DESTDIR/out/
+cp "../out/$JARNAME" $DESTDIR/out/
# Pack everything to AppImage
ARCH=arm_aarch64 "./$APPIMAGETOOL" $DESTDIR "out/$DESTDIR.AppImage" || { echo 'Building AppImage failed' >&2; exit 1; }
diff --git a/buildapp/build_app_linux_x86.sh b/buildapp/build_app_linux_x86.sh
index f56ade280..5ab227042 100755
--- a/buildapp/build_app_linux_x86.sh
+++ b/buildapp/build_app_linux_x86.sh
@@ -6,6 +6,8 @@ APPIMAGETOOL="appimagetool-x86_64.AppImage"
SRCFILES="terrarumlinux_x86"
DESTDIR="TerrarumLinux.x86"
RUNTIME="runtime-linux-x86"
+DESKTOPFILE="../out/build_autogen_linux.desktop"
+JARNAME="TerrarumBuild.jar"
if [ ! -d "../assets_release" ]; then
echo "'assets_release' does not exist; prepare the assets for the release and put them into the assets_release directory, exiting now." >&2
@@ -18,7 +20,7 @@ mkdir $DESTDIR
# Prepare an application
cp icns.png $DESTDIR/icns.png
-cp $SRCFILES/Terrarum.desktop $DESTDIR/
+cp $DESKTOPFILE $DESTDIR/
cp $SRCFILES/AppRun $DESTDIR/AppRun
chmod +x $DESTDIR/AppRun
@@ -30,7 +32,7 @@ mv $DESTDIR/out/$RUNTIME/bin/java $DESTDIR/out/$RUNTIME/bin/Terrarum
# Copy over all the assets and a jarfile
cp -r "../assets_release" $DESTDIR/
mv $DESTDIR/assets_release $DESTDIR/assets
-cp "../out/TerrarumBuild.jar" $DESTDIR/out/
+cp "../out/$JARNAME" $DESTDIR/out/
# Pack everything to AppImage
"./$APPIMAGETOOL" $DESTDIR "out/$DESTDIR.AppImage" || { echo 'Building AppImage failed' >&2; exit 1; }
diff --git a/buildapp/build_app_mac_arm.sh b/buildapp/build_app_mac_arm.sh
index b37a8fdbc..06b91e05a 100755
--- a/buildapp/build_app_mac_arm.sh
+++ b/buildapp/build_app_mac_arm.sh
@@ -6,7 +6,8 @@ SRCFILES="terrarummac_arm"
APPDIR="./TerrarumMac.arm.app"
DESTDIR="out/$APPDIR"
RUNTIME="runtime-osx-arm"
-VERSIONNUMFILE="../out/build_version_string.autogen"
+PLISTFILE="../out/build_autogen_macos_Info.plist"
+JARNAME="TerrarumBuild.jar"
if [ ! -d "../assets_release" ]; then
echo "'assets_release' does not exist; prepare the assets for the release and put them into the assets_release directory, exiting now." >&2
@@ -24,12 +25,7 @@ mkdir $DESTDIR/Contents/Resources
cp AppIcon.icns $DESTDIR/Contents/Resources/AppIcon.icns
cp $SRCFILES/Terrarum.sh $DESTDIR/Contents/MacOS/
chmod +x $DESTDIR/Contents/MacOS/Terrarum.sh
-
-# Prepare an plist
-cp $SRCFILES/Info.plist $DESTDIR/Contents/
-printf "\nCFBundleVersion" >> $DESTDIR/Contents/Info.plist
-cat $VERSIONNUMFILE >> $DESTDIR/Contents/Info.plist
-printf "\n" >> $DESTDIR/Contents/Info.plist
+cp $PLISTFILE $DESTDIR/Contents/Info.plist
# Copy over a Java runtime
mkdir $DESTDIR/Contents/MacOS/out
@@ -39,8 +35,9 @@ mv $DESTDIR/Contents/MacOS/out/$RUNTIME/bin/java $DESTDIR/Contents/MacOS/out/$RU
# Copy over all the assets and a jarfile
cp -r "../assets_release" $DESTDIR/Contents/MacOS/
mv $DESTDIR/Contents/MacOS/assets_release $DESTDIR/Contents/MacOS/assets
-cp "../out/TerrarumBuild.jar" $DESTDIR/Contents/MacOS/out/
+cp "../out/$JARNAME" $DESTDIR/Contents/MacOS/out/
+# zip everything
cd "out"
rm $APPDIR.zip
7z a -tzip $APPDIR.zip $APPDIR
diff --git a/buildapp/build_app_mac_x86.sh b/buildapp/build_app_mac_x86.sh
index 24d698e90..a0b867b24 100755
--- a/buildapp/build_app_mac_x86.sh
+++ b/buildapp/build_app_mac_x86.sh
@@ -6,7 +6,8 @@ SRCFILES="terrarummac_x86"
APPDIR="./TerrarumMac.x86.app"
DESTDIR="out/$APPDIR"
RUNTIME="runtime-osx-x86"
-VERSIONNUMFILE="../out/build_version_string.autogen"
+PLISTFILE="../out/build_autogen_macos_Info.plist"
+JARNAME="TerrarumBuild.jar"
if [ ! -d "../assets_release" ]; then
echo "'assets_release' does not exist; prepare the assets for the release and put them into the assets_release directory, exiting now." >&2
@@ -24,12 +25,7 @@ mkdir $DESTDIR/Contents/Resources
cp AppIcon.icns $DESTDIR/Contents/Resources/AppIcon.icns
cp $SRCFILES/Terrarum.sh $DESTDIR/Contents/MacOS/
chmod +x $DESTDIR/Contents/MacOS/Terrarum.sh
-
-# Prepare an plist
-cp $SRCFILES/Info.plist $DESTDIR/Contents/
-printf "\nCFBundleVersion" >> $DESTDIR/Contents/Info.plist
-cat $VERSIONNUMFILE >> $DESTDIR/Contents/Info.plist
-printf "\n" >> $DESTDIR/Contents/Info.plist
+cp $PLISTFILE $DESTDIR/Contents/Info.plist
# Copy over a Java runtime
mkdir $DESTDIR/Contents/MacOS/out
@@ -39,8 +35,9 @@ mv $DESTDIR/Contents/MacOS/out/$RUNTIME/bin/java $DESTDIR/Contents/MacOS/out/$RU
# Copy over all the assets and a jarfile
cp -r "../assets_release" $DESTDIR/Contents/MacOS/
mv $DESTDIR/Contents/MacOS/assets_release $DESTDIR/Contents/MacOS/assets
-cp "../out/TerrarumBuild.jar" $DESTDIR/Contents/MacOS/out/
+cp "../out/$JARNAME" $DESTDIR/Contents/MacOS/out/
+# zip everything
cd "out"
rm $APPDIR.zip
7z a -tzip $APPDIR.zip $APPDIR
diff --git a/buildapp/build_app_windows_x86.sh b/buildapp/build_app_windows_x86.sh
index 5f247fb14..b2196808b 100755
--- a/buildapp/build_app_windows_x86.sh
+++ b/buildapp/build_app_windows_x86.sh
@@ -5,6 +5,8 @@ cd "${0%/*}"
SRCFILES="terrarumwindows_x86"
DESTDIR="TerrarumWindows.x86"
RUNTIME="runtime-windows-x86"
+RCFILE="../out/build_autogen_windows.rc"
+JARNAME="TerrarumBuild.jar"
if [ ! -d "../assets_release" ]; then
echo "'assets_release' does not exist; prepare the assets for the release and put them into the assets_release directory, exiting now." >&2
@@ -21,8 +23,11 @@ then
echo 'Mingw32 not found; please install mingw64-cross-gcc (or similar) to your system' >&2; exit 1;
fi
-x86_64-w64-mingw32-gcc -Os -s -o $DESTDIR/Terrarum.exe $SRCFILES/Terrarum.c || { echo 'Building EXE failed' >&2; exit 1; }
-# TODO add icon to the exe (use x86_64-w64-mingw32-windres?)
+# Compile .rc
+x86_64-w64-mingw32-windres $RCFILE -O coff -o $RCFILE.res
+
+# compile exe
+x86_64-w64-mingw32-gcc -Os -s -o $DESTDIR/Terrarum.exe $SRCFILES/Terrarum.c $RCFILE.res || { echo 'Building EXE failed' >&2; exit 1; }
# Copy over a Java runtime
mkdir $DESTDIR/out
@@ -32,10 +37,10 @@ mv $DESTDIR/out/$RUNTIME/bin/java.exe $DESTDIR/out/$RUNTIME/bin/Terrarum.exe
# Copy over all the assets and a jarfile
cp -r "../assets_release" $DESTDIR/
mv $DESTDIR/assets_release $DESTDIR/assets
-cp "../out/TerrarumBuild.jar" $DESTDIR/out/
+cp "../out/$JARNAME" $DESTDIR/out/
-# Temporary solution: zip everything
-rm "out/TerrarumWindows.x86.zip"
-zip -r -9 -l "out/TerrarumWindows.x86.zip" $DESTDIR
+# zip everything
+rm "out/$DESTDIR.zip"
+zip -r -9 -l "out/$DESTDIR.zip" $DESTDIR
rm -rf $DESTDIR || true
echo "Build successful: $DESTDIR"
diff --git a/buildapp/icns.ico b/buildapp/icns.ico
new file mode 100644
index 000000000..aa36fc989
Binary files /dev/null and b/buildapp/icns.ico differ
diff --git a/buildapp/terrarumlinux_arm/Terrarum.desktop b/buildapp/terrarumlinux_arm/Terrarum.desktop
deleted file mode 100644
index abf3a6cd6..000000000
--- a/buildapp/terrarumlinux_arm/Terrarum.desktop
+++ /dev/null
@@ -1,6 +0,0 @@
-[Desktop Entry]
-Name=Terrarum
-Exec=AppRun
-Icon=icns
-Type=Application
-Categories=Game;
\ No newline at end of file
diff --git a/buildapp/terrarumlinux_x86/Terrarum.desktop b/buildapp/terrarumlinux_x86/Terrarum.desktop
deleted file mode 100644
index abf3a6cd6..000000000
--- a/buildapp/terrarumlinux_x86/Terrarum.desktop
+++ /dev/null
@@ -1,6 +0,0 @@
-[Desktop Entry]
-Name=Terrarum
-Exec=AppRun
-Icon=icns
-Type=Application
-Categories=Game;
\ No newline at end of file
diff --git a/buildapp/terrarumwindows_x86/terrarum.rc b/buildapp/terrarumwindows_x86/terrarum.rc
new file mode 100644
index 000000000..f85ae6a98
--- /dev/null
+++ b/buildapp/terrarumwindows_x86/terrarum.rc
@@ -0,0 +1 @@
+1 ICON "icns.ico"
diff --git a/src/net/torvald/terrarum/Prebuild.kt b/src/net/torvald/terrarum/Prebuild.kt
index 2f2d28bcd..d9ddda083 100644
--- a/src/net/torvald/terrarum/Prebuild.kt
+++ b/src/net/torvald/terrarum/Prebuild.kt
@@ -6,9 +6,67 @@ import java.io.File
* Created by minjaesong on 2023-08-25.
*/
-fun main() {
- val s = App.getVERSION_STRING()
- val f = File("./out/build_version_string.autogen")
+private fun writeWindowsRC(major: Int, minor: Int, patch: Int) {
+ val s = """1 ICON "icns.ico"
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION $major,$minor,$patch,0
+ PRODUCTVERSION $major,$minor,$patch,0
+{
+ BLOCK "StringFileInfo"
+ {
+ BLOCK "040904b0"
+ {
+ VALUE "FileDescription", "${TerrarumAppConfiguration.GAME_NAME}\0"
+ VALUE "FileVersion", "${App.getVERSION_STRING()}\0"
+ VALUE "LegalCopyright", "${TerrarumAppConfiguration.COPYRIGHT_DATE_NAME}\0"
+ VALUE "OriginalFilename", "${TerrarumAppConfiguration.GAME_NAME}.exe\0"
+ VALUE "ProductName", "${TerrarumAppConfiguration.GAME_NAME}\0"
+ VALUE "ProductVersion", "${App.getVERSION_STRING()}\0"
+ }
+ }
+ BLOCK "VarFileInfo"
+ {
+ VALUE "Translation", 0x409, 1200
+ }
+}"""
+ val f = File("./out/build_autogen_windows.rc")
f.delete()
f.writeText(s)
+}
+
+private fun writeOSXPlist(major: Int, minor: Int, patch: Int) {
+ val s = """
+
+
+CFBundleExecutable${TerrarumAppConfiguration.GAME_NAME}.sh
+CFBundleDisplayName${TerrarumAppConfiguration.GAME_NAME}
+CFBundleName${TerrarumAppConfiguration.GAME_NAME}
+CFBundleIconFileAppIcon.icns
+CFBundleVersion${App.getVERSION_STRING()}
+"""
+ val f = File("./out/build_autogen_macos_Info.plist")
+ f.delete()
+ f.writeText(s)
+}
+
+private fun writeLinuxDesktop(major: Int, minor: Int, patch: Int) {
+ val s = """[Desktop Entry]
+Name=${TerrarumAppConfiguration.GAME_NAME}
+Exec=AppRun
+Icon=icns
+Type=Application
+Categories=Game;"""
+ val f = File("./out/build_autogen_linux.desktop")
+ f.delete()
+ f.writeText(s)
+}
+
+fun main() {
+ val major = (App.VERSION_RAW ushr 48).toInt()
+ val minor = ((App.VERSION_RAW and 0xffff000000L) ushr 24).toInt()
+ val patch = (App.VERSION_RAW and 0xffffffL).toInt()
+
+ writeLinuxDesktop(major, minor, patch)
+ writeOSXPlist(major, minor, patch)
+ writeWindowsRC(major, minor, patch)
}
\ No newline at end of file