From 40390a5a18053c0ffc44242986d44e3e6a2cda15 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Fri, 8 Aug 2025 02:42:43 +0300
Subject: [PATCH 21/21] installer_cross: Parametrize create-freeciv-sdl-nsi.sh
 with the gui

See RM #1651

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 .../installer_cross/create-freeciv-sdl-nsi.sh | 36 +++++++++----------
 windows/installer_cross/installer_build.sh    |  2 +-
 .../installer_cross/meson-installer_build.sh  |  3 +-
 3 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/windows/installer_cross/create-freeciv-sdl-nsi.sh b/windows/installer_cross/create-freeciv-sdl-nsi.sh
index e9df763e51..5759582415 100755
--- a/windows/installer_cross/create-freeciv-sdl-nsi.sh
+++ b/windows/installer_cross/create-freeciv-sdl-nsi.sh
@@ -1,9 +1,9 @@
 #!/bin/sh
 
-# ./create-freeciv-sdl-nsi.sh <freeciv files dir> <output dir> <version> <win32|win64|win> [uninstall setup script]
+# ./create-freeciv-sdl-nsi.sh <freeciv files dir> <output dir> <version> <win32|win64|win> <gui id> <gui name> [uninstall setup script]
 
-if test "$5" != "" && ! test -x "$5" ; then
-  echo "$5 not an executable script" >&2
+if test "$7" != "" && ! test -x "$7" ; then
+  echo "$7 not an executable script" >&2
   exit 1
 fi
 
@@ -19,8 +19,8 @@ SetCompressor /SOLID lzma
 
 !define APPNAME "Freeciv"
 !define VERSION $3
-!define GUI_ID sdl2
-!define GUI_NAME SDL2
+!define GUI_ID $5
+!define GUI_NAME $6
 !define WIN_ARCH $4
 !define ARCH_KEY_PART ${ARCH_KEY_PART}
 !define ARCH_INST_PART ${ARCH_INST_PART}
@@ -166,7 +166,7 @@ cat <<EOF
   CreateDirectory "\$SMPROGRAMS\\\$STARTMENU_FOLDER"
   CreateShortCut "\$SMPROGRAMS\\\$STARTMENU_FOLDER\Freeciv Server.lnk" "\$INSTDIR\freeciv-server.cmd" "\$DefaultLanguageCode" "\$INSTDIR\freeciv-server.exe" 0 SW_SHOWMINIMIZED
   CreateShortCut "\$SMPROGRAMS\\\$STARTMENU_FOLDER\Freeciv Modpack Installer.lnk" "\$INSTDIR\freeciv-mp-gtk4.cmd" "\$DefaultLanguageCode" "\$INSTDIR\freeciv-mp-gtk4.exe" 0 SW_SHOWMINIMIZED
-  CreateShortCut "\$SMPROGRAMS\\\$STARTMENU_FOLDER\Freeciv.lnk" "\$INSTDIR\freeciv-sdl2.cmd" "\$DefaultLanguageCode" "\$INSTDIR\freeciv-sdl2.exe" 0 SW_SHOWMINIMIZED
+  CreateShortCut "\$SMPROGRAMS\\\$STARTMENU_FOLDER\Freeciv.lnk" "\$INSTDIR\freeciv-\$GUI_ID.cmd" "\$DefaultLanguageCode" "\$INSTDIR\freeciv-\$GUI_ID.exe" 0 SW_SHOWMINIMIZED
   CreateShortCut "\$SMPROGRAMS\\\$STARTMENU_FOLDER\Documentation.lnk" "\$INSTDIR\doc\freeciv"
   CreateShortCut "\$SMPROGRAMS\\\$STARTMENU_FOLDER\Uninstall.lnk" "\$INSTDIR\uninstall.exe"
   CreateShortCut "\$SMPROGRAMS\\\$STARTMENU_FOLDER\Website.lnk" "\$INSTDIR\Freeciv.url"
@@ -231,19 +231,19 @@ echo "  File /r $1/share/locale/$code/*.*"
 
 # Install special fonts for CJK locales
 if [ "$name" = "zh_CN" ]; then
-echo "  SetOutPath \$INSTDIR\\data\\themes\\gui-sdl2\\human"
-echo "  File /r $1/data/themes/gui-sdl2/human/COPYING.fireflysung"
-echo "  File /r $1/data/themes/gui-sdl2/human/fireflysung.ttf"
+echo "  SetOutPath \$INSTDIR\\data\\themes\\gui-\$GUI_ID\\human"
+echo "  File /r $1/data/themes/gui-\$GUI_ID/human/COPYING.fireflysung"
+echo "  File /r $1/data/themes/gui-\$GUI_ID/human/fireflysung.ttf"
 fi
 if [ "$name" = "ja" ]; then
-echo "  SetOutPath \$INSTDIR\\data\\themes\\gui-sdl2\\human"
-echo "  File /r $1/data/themes/gui-sdl2/human/COPYING.sazanami"
-echo "  File /r $1/data/themes/gui-sdl2/human/sazanami-gothic.ttf"
+echo "  SetOutPath \$INSTDIR\\data\\themes\\gui-\$GUI_ID\\human"
+echo "  File /r $1/data/themes/gui-\$GUI_ID/human/COPYING.sazanami"
+echo "  File /r $1/data/themes/gui-\$GUI_ID/human/sazanami-gothic.ttf"
 fi
 if [ "$name" = "ko" ]; then
-echo "  SetOutPath \$INSTDIR\\data\\themes\\gui-sdl2\\human"
-echo "  File /r $1/data/themes/gui-sdl2/human/COPYING.UnDotum"
-echo "  File /r $1/data/themes/gui-sdl2/human/UnDotum.ttf"
+echo "  SetOutPath \$INSTDIR\\data\\themes\\gui-\$GUI_ID\\human"
+echo "  File /r $1/data/themes/gui-\$GUI_ID/human/COPYING.UnDotum"
+echo "  File /r $1/data/themes/gui-\$GUI_ID/human/UnDotum.ttf"
 fi
 
 echo "  SetOutPath \$INSTDIR"
@@ -339,7 +339,7 @@ Function HelperScriptFunction
 FunctionEnd
 
 Function RunFreeciv
-  nsExec::Exec '"\$INSTDIR\freeciv-sdl2.cmd" \$DefaultLanguageCode'
+  nsExec::Exec '"\$INSTDIR\freeciv-\$GUI_ID.cmd" \$DefaultLanguageCode'
 FunctionEnd
 
 EOF
@@ -377,8 +377,8 @@ do
 echo "  RMDir \"\$INSTDIR$name\"" | sed 's,/,\\,g'
 done
 
-if test "$5" != "" ; then
-  $5
+if test "$7" != "" ; then
+  $7
 fi
 
 cat <<EOF
diff --git a/windows/installer_cross/installer_build.sh b/windows/installer_cross/installer_build.sh
index db8e7e2e65..1849377fd8 100755
--- a/windows/installer_cross/installer_build.sh
+++ b/windows/installer_cross/installer_build.sh
@@ -294,7 +294,7 @@ else
   if test "$GUI" = "sdl2" ; then
     if ! ./create-freeciv-sdl-nsi.sh \
            "$INSTDIR" "autotools/output" "$VERREV" "$SETUP" \
-           "helpers/uninstaller-helper-gtk3.sh" \
+           "${GUI}" "${GUINAME}" "helpers/uninstaller-helper-gtk3.sh" \
              > "${NSI_DIR}/client-${SETUP}-${VERREV}-${GUI}.nsi"
     then
       exit 1
diff --git a/windows/installer_cross/meson-installer_build.sh b/windows/installer_cross/meson-installer_build.sh
index 9a05036554..201ba1a6ed 100755
--- a/windows/installer_cross/meson-installer_build.sh
+++ b/windows/installer_cross/meson-installer_build.sh
@@ -300,7 +300,8 @@ else
 
   if test "$GUI" = "sdl2" ; then
     if ! ./create-freeciv-sdl-nsi.sh \
-           "$INSTDIR" "meson/output" "$VERREV" "$SETUP" "$UNINSTALLER" \
+           "$INSTDIR" "meson/output" "$VERREV" "$SETUP" \
+           "${GUI}" "${GUINAME}" "$UNINSTALLER" \
              > "$NSI_FILE"
     then
       exit 1
-- 
2.47.2

