Mercurial > games > semicongine
comparison config.nims @ 33:94c38e4b5782
did: refactoring, move more from make to nimscript
author | Sam <sam@basx.dev> |
---|---|
date | Sun, 15 Jan 2023 23:23:54 +0700 |
parents | 71bbe11d8de8 |
children | 7f99b21a8777 |
comparison
equal
deleted
inserted
replaced
32:9edca5dc4e93 | 33:94c38e4b5782 |
---|---|
1 import os | 1 import std/strformat |
2 import std/strutils | |
3 import std/os | |
2 | 4 |
3 const buildbase = "build" | 5 const BUILDBASE = "build" |
6 const DEBUG = "debug" | |
7 const RELEASE = "release" | |
8 const LINUX = "linux" | |
9 const WINDOWS = "windows" | |
4 | 10 |
5 proc compilerFlags() = | 11 proc compilerFlags() = |
6 switch("path", "src") | 12 switch("path", "src") |
7 switch("mm", "orc") | 13 switch("mm", "orc") |
8 switch("experimental", "strictEffects") | 14 switch("experimental", "strictEffects") |
17 proc compilerFlagsRelease() = | 23 proc compilerFlagsRelease() = |
18 switch("define", "release") | 24 switch("define", "release") |
19 switch("checks", "off") | 25 switch("checks", "off") |
20 switch("assertions", "off") | 26 switch("assertions", "off") |
21 | 27 |
22 task build_linux_debug, "build linux debug": | 28 task single_linux_debug, "build linux debug": |
23 compilerFlags() | 29 compilerFlags() |
24 compilerFlagsDebug() | 30 compilerFlagsDebug() |
25 buildbase.joinPath("debug/linux").mkDir() | 31 switch("outdir", BUILDBASE / DEBUG / LINUX) |
26 setCommand "c" | 32 setCommand "c" |
33 mkDir(BUILDBASE / DEBUG / LINUX) | |
27 | 34 |
28 task build_linux_release, "build linux release": | 35 task single_linux_release, "build linux release": |
29 compilerFlags() | 36 compilerFlags() |
30 compilerFlagsRelease() | 37 compilerFlagsRelease() |
31 buildbase.joinPath("release/linux").mkDir() | 38 switch("outdir", BUILDBASE / RELEASE / LINUX) |
32 setCommand "c" | 39 setCommand "c" |
40 mkDir(BUILDBASE / RELEASE / LINUX) | |
33 | 41 |
34 task build_windows_debug, "build windows debug": | 42 task single_windows_debug, "build windows debug": |
35 compilerFlags() | 43 compilerFlags() |
36 compilerFlagsDebug() | 44 compilerFlagsDebug() |
45 # for some the --define:mingw does not work from inside here... | |
46 # so we need to set it when calling the task and use "/" to prevent | |
47 # the use of backslash while crosscompiling | |
37 switch("define", "mingw") | 48 switch("define", "mingw") |
38 buildbase.joinPath("debug/windows").mkDir() | 49 switch("outdir", BUILDBASE & "/" & DEBUG & "/" & WINDOWS) |
39 setCommand "c" | 50 setCommand "c" |
51 mkDir(BUILDBASE & "/" & DEBUG & "/" & WINDOWS) | |
40 | 52 |
41 task build_windows_release, "build windows release": | 53 task single_windows_release, "build windows release": |
42 compilerFlags() | 54 compilerFlags() |
43 compilerFlagsRelease() | 55 compilerFlagsRelease() |
56 switch("outdir", BUILDBASE & "/" & RELEASE & "/" & WINDOWS) | |
44 switch("define", "mingw") | 57 switch("define", "mingw") |
45 buildbase.joinPath("release/windows").mkDir() | |
46 setCommand "c" | 58 setCommand "c" |
59 mkDir(BUILDBASE & "/" & RELEASE & "/" & WINDOWS) | |
47 | 60 |
48 compilerFlags() | 61 task build_all_linux_debug, "build all examples with linux/debug": |
62 for file in listFiles("examples"): | |
63 if file.endsWith(".nim"): | |
64 selfExec(&"single_linux_debug {file}") | |
65 | |
66 task build_all_linux_release, "build all examples with linux/release": | |
67 for file in listFiles("examples"): | |
68 if file.endsWith(".nim"): | |
69 selfExec(&"single_linux_release {file}") | |
70 | |
71 task build_all_windows_debug, "build all examples with windows/debug": | |
72 for file in listFiles("examples"): | |
73 if file.endsWith(".nim"): | |
74 exec(&"nim single_windows_debug --define:mingw {file}") | |
75 | |
76 task build_all_windows_release, "build all examples with windows/release": | |
77 for file in listFiles("examples"): | |
78 if file.endsWith(".nim"): | |
79 exec(&"nim single_windows_release --define:mingw {file}") | |
80 | |
81 task build_all_debug, "build all examples with */debug": | |
82 build_all_linux_debugTask() | |
83 build_all_windows_debugTask() | |
84 | |
85 task build_all_release, "build all examples with */release": | |
86 build_all_linux_releaseTask() | |
87 build_all_windows_releaseTask() | |
88 | |
89 task build_all_linux, "build all examples with linux/*": | |
90 build_all_linux_debugTask() | |
91 build_all_linux_releaseTask() | |
92 | |
93 task build_all_windows, "build all examples with windows/*": | |
94 build_all_windows_debugTask() | |
95 build_all_windows_releaseTask() | |
96 | |
97 task build_all, "build all examples": | |
98 build_all_linuxTask() | |
99 build_all_windowsTask() | |
100 | |
101 task clean, "remove all build files": | |
102 exec(&"rm -rf {BUILDBASE}") | |
103 | |
104 task publish, "publish all build": | |
105 exec("rsync -rv build/ basx.dev:/var/www/public.basx.dev/zamikongine") | |
106 | |
107 | |
108 if getCommand() == "c": | |
109 compilerFlags() |