# HG changeset patch # User sam # Date 1712925398 -25200 # Node ID ed79529e70a39bf60760c9e1b2bfd77721c5ffc8 # Parent b6a00d7171fb860c3f8b38328ff096d0bd3f0f2f fix: packaging fails if there are no resources, fix: zip-generation diff -r b6a00d7171fb -r ed79529e70a3 semicongine/build.nim --- 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: diff -r b6a00d7171fb -r ed79529e70a3 semicongine/resources.nim --- 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 =