# HG changeset patch # User Sam # Date 1701540162 -25200 # Node ID 31f8ecc6644c7f7960f80496a7d14d95a75b012a # Parent c27281f8e0ce1f8dcfcf1a138b128a6f89a67173 add: util to build projects more streamlined diff -r c27281f8e0ce -r 31f8ecc6644c semicongine/build.nim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/semicongine/build.nim Sun Dec 03 01:02:42 2023 +0700 @@ -0,0 +1,40 @@ +import std/strformat +import std/os + +proc semicongine_build*(buildType: string, bundleType: string, resourceRoot="resources", builddir="./build"): string = + switch("experimental", "strictEffects") + switch("experimental", "strictFuncs") + switch("define", "nimPreviewHashRef") + + + 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" + + var outdir = builddir / buildType / platformDir / projectName() + switch("outdir", outdir) + setCommand "c" + rmDir(outdir) + mkDir(outdir) + let resourcedir = joinPath(projectDir(), resourceRoot) + if os.dirExists(resourcedir): + let outdir_resources = joinPath(outdir, resourceRoot) + if bundleType == "dir": + cpDir(resourcedir, outdir_resources) + 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) + return outdir