# HG changeset patch # User Sam # Date 1701797854 -25200 # Node ID 5951a2e31d8646b9737bd8198d7c214d030f57e6 # Parent 8f0c82acb9221b174fb00001de4a151646be7041 add: function to zip directories, usefull when creating dists diff -r 8f0c82acb922 -r 5951a2e31d86 semicongine/build.nim --- 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}" +