changeset 1104:ed79529e70a3

fix: packaging fails if there are no resources, fix: zip-generation
author sam <sam@basx.dev>
date Fri, 12 Apr 2024 19:36:38 +0700
parents b6a00d7171fb
children 4b5891a79f88
files semicongine/build.nim semicongine/resources.nim
diffstat 2 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine/build.nim	Tue Apr 09 23:57:57 2024 +0700
+++ b/semicongine/build.nim	Fri Apr 12 19:36:38 2024 +0700
@@ -21,6 +21,7 @@
 let SQLITELIB = currentSourcePath().parentDir().parentDir().joinPath("libs/sqlite3.dll")
 
 proc semicongine_builddir*(buildname: string, builddir = "./build"): string =
+  assert projectName() != "", "Please specify project file as a commandline argument"
   var platformDir = "unkown"
 
   if defined(linux):
@@ -82,7 +83,7 @@
 proc semicongine_zip*(dir: string) =
   withdir dir.parentDir:
     if defined(linux):
-      exec &"zip -r {dir.lastPathPart} ."
+      exec &"zip -r {dir.lastPathPart} {dir.lastPathPart}"
     elif defined(windows):
       exec &"powershell Compress-Archive * {dir.lastPathPart}"
     else:
--- a/semicongine/resources.nim	Tue Apr 09 23:57:57 2024 +0700
+++ b/semicongine/resources.nim	Fri Apr 12 19:36:38 2024 +0700
@@ -124,13 +124,16 @@
   const BUILD_RESOURCEROOT* {.strdefine.}: string = ""
 
   proc loadResources(): Table[string, Table[string, string]] {.compileTime.} =
-    assert BUILD_RESOURCEROOT != "", "define BUILD_RESOURCEROOT to build for bundle type 'exe'"
-    for kind, packageDir in walkDir(BUILD_RESOURCEROOT):
-      if kind == pcDir:
-        let package = packageDir.splitPath.tail
-        result[package] = Table[string, string]()
-        for resourcefile in walkDirRec(packageDir, relative = true):
-          result[package][resourcefile.replace('\\', '/')] = staticRead(packageDir.joinPath(resourcefile))
+    when BUILD_RESOURCEROOT == "":
+      {.warning: "BUILD_RESOURCEROOT is empty, no resources will be packaged".}
+      return
+    else:
+      for kind, packageDir in walkDir(BUILD_RESOURCEROOT):
+        if kind == pcDir:
+          let package = packageDir.splitPath.tail
+          result[package] = Table[string, string]()
+          for resourcefile in walkDirRec(packageDir, relative = true):
+            result[package][resourcefile.replace('\\', '/')] = staticRead(packageDir.joinPath(resourcefile))
   const bundledResources = loadResources()
 
   proc loadResource_intern(path: string, package: string): Stream =