Mercurial > games > semicongine
diff config.nims @ 494:0c18638c7217
did: refactoring, move more from make to nimscript
author | Sam <sam@basx.dev> |
---|---|
date | Sun, 15 Jan 2023 23:23:54 +0700 |
parents | b4a972bd37d5 |
children | 7f99b21a8777 |
line wrap: on
line diff
--- a/config.nims Sat Jan 14 23:34:50 2023 +0700 +++ b/config.nims Sun Jan 15 23:23:54 2023 +0700 @@ -1,6 +1,12 @@ -import os +import std/strformat +import std/strutils +import std/os -const buildbase = "build" +const BUILDBASE = "build" +const DEBUG = "debug" +const RELEASE = "release" +const LINUX = "linux" +const WINDOWS = "windows" proc compilerFlags() = switch("path", "src") @@ -19,30 +25,85 @@ switch("checks", "off") switch("assertions", "off") -task build_linux_debug, "build linux debug": +task single_linux_debug, "build linux debug": compilerFlags() compilerFlagsDebug() - buildbase.joinPath("debug/linux").mkDir() + switch("outdir", BUILDBASE / DEBUG / LINUX) + setCommand "c" + mkDir(BUILDBASE / DEBUG / LINUX) + +task single_linux_release, "build linux release": + compilerFlags() + compilerFlagsRelease() + switch("outdir", BUILDBASE / RELEASE / LINUX) setCommand "c" + mkDir(BUILDBASE / RELEASE / LINUX) -task build_linux_release, "build linux release": +task single_windows_debug, "build windows debug": + compilerFlags() + compilerFlagsDebug() + # for some the --define:mingw does not work from inside here... + # so we need to set it when calling the task and use "/" to prevent + # the use of backslash while crosscompiling + switch("define", "mingw") + switch("outdir", BUILDBASE & "/" & DEBUG & "/" & WINDOWS) + setCommand "c" + mkDir(BUILDBASE & "/" & DEBUG & "/" & WINDOWS) + +task single_windows_release, "build windows release": compilerFlags() compilerFlagsRelease() - buildbase.joinPath("release/linux").mkDir() - setCommand "c" - -task build_windows_debug, "build windows debug": - compilerFlags() - compilerFlagsDebug() + switch("outdir", BUILDBASE & "/" & RELEASE & "/" & WINDOWS) switch("define", "mingw") - buildbase.joinPath("debug/windows").mkDir() setCommand "c" + mkDir(BUILDBASE & "/" & RELEASE & "/" & WINDOWS) -task build_windows_release, "build windows release": +task build_all_linux_debug, "build all examples with linux/debug": + for file in listFiles("examples"): + if file.endsWith(".nim"): + selfExec(&"single_linux_debug {file}") + +task build_all_linux_release, "build all examples with linux/release": + for file in listFiles("examples"): + if file.endsWith(".nim"): + selfExec(&"single_linux_release {file}") + +task build_all_windows_debug, "build all examples with windows/debug": + for file in listFiles("examples"): + if file.endsWith(".nim"): + exec(&"nim single_windows_debug --define:mingw {file}") + +task build_all_windows_release, "build all examples with windows/release": + for file in listFiles("examples"): + if file.endsWith(".nim"): + exec(&"nim single_windows_release --define:mingw {file}") + +task build_all_debug, "build all examples with */debug": + build_all_linux_debugTask() + build_all_windows_debugTask() + +task build_all_release, "build all examples with */release": + build_all_linux_releaseTask() + build_all_windows_releaseTask() + +task build_all_linux, "build all examples with linux/*": + build_all_linux_debugTask() + build_all_linux_releaseTask() + +task build_all_windows, "build all examples with windows/*": + build_all_windows_debugTask() + build_all_windows_releaseTask() + +task build_all, "build all examples": + build_all_linuxTask() + build_all_windowsTask() + +task clean, "remove all build files": + exec(&"rm -rf {BUILDBASE}") + +task publish, "publish all build": + exec("rsync -rv build/ basx.dev:/var/www/public.basx.dev/zamikongine") + + +if getCommand() == "c": compilerFlags() - compilerFlagsRelease() - switch("define", "mingw") - buildbase.joinPath("release/windows").mkDir() - setCommand "c" - -compilerFlags()