changeset 975:a8ce28444cf2

add: support steam uploads on windows
author sam <sam@basx.dev>
date Thu, 04 Apr 2024 22:08:25 +0700
parents 2a5e7b54736e
children 68663ee3b068
files semicongine.nimble semicongine/build.nim tools/steamcmd.zip
diffstat 3 files changed, 35 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine.nimble	Thu Apr 04 20:59:19 2024 +0700
+++ b/semicongine.nimble	Thu Apr 04 22:08:25 2024 +0700
@@ -9,6 +9,11 @@
 installDirs = @["semicongine"]
 
 # Dependencies
+# On linux/debian also run the following to get everything working
+# sudo dpkg --add-architecture i386
+# sudo apt-get update
+# sudo apt-get install zip unzip libstdc++6:i386 libc6:i386
+
 
 requires "nim >= 2.0"
 requires "winim"
--- a/semicongine/build.nim	Thu Apr 04 20:59:19 2024 +0700
+++ b/semicongine/build.nim	Thu Apr 04 22:08:25 2024 +0700
@@ -26,6 +26,8 @@
     platformDir = "linux"
   elif defined(windows):
     platformDir = "windows"
+  else:
+    raise newException(Exception, "Unsupported platform")
 
   return builddir / buildname / platformDir / projectName()
 
@@ -33,10 +35,14 @@
   switch("experimental", "strictEffects")
   switch("experimental", "strictFuncs")
   switch("define", "nimPreviewHashRef")
-  if defined(linux): switch("define", "VK_USE_PLATFORM_XLIB_KHR")
-  if defined(windows):
+  if defined(linux):
+    switch("define", "VK_USE_PLATFORM_XLIB_KHR")
+  elif defined(windows):
     switch("define", "VK_USE_PLATFORM_WIN32_KHR")
     switch("app", "gui")
+  else:
+    raise newException(Exception, "Unsupported platform")
+
   switch("outdir", semicongine_builddir(buildname, builddir = builddir))
   switch("passL", "-Wl,-rpath,'$ORIGIN'") # adds directory of executable to dynlib search path
 
@@ -59,6 +65,8 @@
           exec &"zip -r {outputfile} ."
         elif defined(windows):
           exec &"powershell Compress-Archive * {outputfile}"
+        else:
+          raise newException(Exception, "Unsupported platform")
   elif bundleType == "exe":
     switch("define", "BUILD_RESOURCEROOT=" & joinPath(getCurrentDir(), resourceRoot)) # required for in-exe packing of resources, must be absolute
   if withSteam:
@@ -70,6 +78,8 @@
       exec &"zip -r {dir.lastPathPart} ."
     elif defined(windows):
       exec &"powershell Compress-Archive * {dir.lastPathPart}"
+    else:
+      raise newException(Exception, "Unsupported platform")
 
 
 # need this because fileNewer from std/os does not work in Nim VM
@@ -131,17 +141,30 @@
   if not defined(linux):
     echo "steam uploads must be done on linux for now"
     return
+
   let steamdir = thisDir().joinPath(STEAMBUILD_DIR_NAME)
   if not dirExists(steamdir):
     steamdir.mkDir
     let zipFilename = STEAMCMD_ZIP.extractFilename
     STEAMCMD_ZIP.cpFile(steamdir.joinPath(zipFilename))
     withDir(steamdir):
-      exec &"unzip {zipFilename}"
-      rmFile zipFilename
-      exec "steamcmd/steamcmd.sh +quit" # self-update steamcmd
+      if defined(linux):
+        exec &"unzip {zipFilename}"
+        rmFile zipFilename
+        exec "steamcmd/steamcmd.sh +quit" # self-update steamcmd
+      elif defined(windows):
+        exec &"powershell Expand-Archive -LiteralPath {zipFilename} ."
+        rmFile zipFilename
+        exec "steamcmd/steamcmd.exe +quit" # self-update steamcmd
+      else:
+        raise newException(Exception, "Unsupported platform")
 
-  let
+  var steamcmd: string
+  if defined(linux):
     steamcmd = STEAMBUILD_DIR_NAME.joinPath("steamcmd").joinPath("steamcmd.sh")
-    scriptPath = "..".joinPath("..").joinPath(buildscript)
+  elif defined(windows):
+    steamcmd = STEAMBUILD_DIR_NAME.joinPath("steamcmd").joinPath("steamcmd.exe")
+  else:
+    raise newException(Exception, "Unsupported platform")
+  let scriptPath = "..".joinPath("..").joinPath(buildscript)
   exec &"./{steamcmd} +login \"{steamaccount}\" \"{password}\" +run_app_build {scriptPath} +quit"
Binary file tools/steamcmd.zip has changed