From 2bbf92d056eb3c0df299120653812c2f36ca8606 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 27 Aug 2023 21:01:13 +0900 Subject: [PATCH] build script update --- buildapp/build_app_linux_arm.sh | 6 +- buildapp/build_app_linux_x86.sh | 6 +- buildapp/build_app_mac_arm.sh | 13 ++-- buildapp/build_app_mac_x86.sh | 13 ++-- buildapp/build_app_windows_x86.sh | 17 ++++-- buildapp/icns.ico | Bin 0 -> 2576 bytes buildapp/terrarumlinux_arm/Terrarum.desktop | 6 -- buildapp/terrarumlinux_x86/Terrarum.desktop | 6 -- buildapp/terrarumwindows_x86/terrarum.rc | 1 + src/net/torvald/terrarum/Prebuild.kt | 64 +++++++++++++++++++- 10 files changed, 91 insertions(+), 41 deletions(-) create mode 100644 buildapp/icns.ico delete mode 100644 buildapp/terrarumlinux_arm/Terrarum.desktop delete mode 100644 buildapp/terrarumlinux_x86/Terrarum.desktop create mode 100644 buildapp/terrarumwindows_x86/terrarum.rc 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 0000000000000000000000000000000000000000..aa36fc989297a2107e4aee292557f87d4acb42fa GIT binary patch literal 2576 zcmZQzU<5)CU}TVB_{GVW22Kc%2a!GLknY^AJE2Z9jQcUbnww zW@yOwXJBxcz`)R;0Q8_E&;v~@3=AwlA94sWFbJqHFerG?PQk93b__ExAxG^UZT8KVqD8G#a6x_=C-GW`{nQc=j*Ba_y5nw-%tJ& zS;b$w$oyzfICF2#ZL69?r4{v89@p8|I^D{=z0BX^GcY#k9izx0d*SRC#shPv=SH{t z@8EmiUv=mGa{n1-zkb%U-~S&NN86Nz><+A{8=UltZ`_Sj|Nj5)>+L6hK0SZ&Yi0lM zzh5{nyY2t4e|wwXyK2UP$rdojzexMVpke(cZ~f%o-^&+&KK=T()vo$m+io&XOZ~nXaBLxIVZl~u^Cw2 zT-1L6EN}j>R}OG!X3Vu~*amjw|1baUKKb+M@FyYBSC$-tv_2b?6XWX-&tN;21BZI+#flgun8JDapwwRd1 R!vku3dAj + + +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