changeset 391:68198310770b

add: function to zip directories, usefull when creating dists
author Sam <sam@basx.dev>
date Wed, 06 Dec 2023 00:37:34 +0700
parents 1727bec9ca2f
children ff751cbe66e3
files semicongine/build.nim
diffstat 1 files changed, 25 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine/build.nim	Wed Dec 06 00:05:55 2023 +0700
+++ b/semicongine/build.nim	Wed Dec 06 00:37:34 2023 +0700
@@ -3,6 +3,17 @@
 
 import ./core/audiotypes
 
+proc semicongine_outdir*(buildname: string, builddir="./build"): string =
+  var platformDir = "unkown"
+  if defined(linux):
+    switch("define", "VK_USE_PLATFORM_XLIB_KHR")
+    platformDir = "linux"
+  if defined(windows):
+    switch("define", "VK_USE_PLATFORM_WIN32_KHR")
+    platformDir = "windows"
+
+  return builddir / buildname / platformDir / projectName()
+
 proc semicongine_build*(buildname: string, bundleType: string, resourceRoot: string, builddir="./build"): string =
   switch("experimental", "strictEffects")
   switch("experimental", "strictFuncs")
@@ -32,13 +43,18 @@
     elif bundleType == "zip":
       mkDir(outdir_resources)
       for resource in listDirs(resourcedir):
-        let
-          oldcwd = getCurrentDir()
-          outputfile = joinPath(outdir_resources, resource.splitPath().tail & ".zip")
-        cd(resource)
-        if defined(linux):
-          exec &"zip -r {outputfile} ."
-        elif defined(windows):
-          exec &"powershell Compress-Archive * {outputfile}"
-        cd(oldcwd)
+        let outputfile = joinPath(outdir_resources, resource.splitPath().tail & ".zip")
+        withdir resource:
+          if defined(linux):
+            exec &"zip -r {outputfile} ."
+          elif defined(windows):
+            exec &"powershell Compress-Archive * {outputfile}"
   return outdir
+
+proc semicongine_zip*(dir: string) =
+  withdir dir.parentDir:
+    if defined(linux):
+      exec &"zip -r {dir.lastPathPart} ."
+    elif defined(windows):
+      exec &"powershell Compress-Archive * {dir.lastPathPart}"
+