# HG changeset patch # User Sam # Date 1701797854 -25200 # Node ID 68198310770b1487568806129534b78cc2e46561 # Parent 1727bec9ca2f000aebb437e842bb8e48348526c4 add: function to zip directories, usefull when creating dists diff -r 1727bec9ca2f -r 68198310770b 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}" +