Mercurial > games > semicongine
annotate config.nims @ 53:4c3891eb9ef9
add: improve build on windows
author | Sam <sam@basx.dev> |
---|---|
date | Thu, 19 Jan 2023 22:49:12 +0700 |
parents | 9e81f06a5c57 |
children | a24c6b87ae83 |
rev | line source |
---|---|
33
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
1 import std/strformat |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
2 import std/strutils |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
3 import std/os |
18 | 4 |
33
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
5 const BUILDBASE = "build" |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
6 const DEBUG = "debug" |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
7 const RELEASE = "release" |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
8 const LINUX = "linux" |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
9 const WINDOWS = "windows" |
18 | 10 |
11 proc compilerFlags() = | |
12 switch("path", "src") | |
13 switch("mm", "orc") | |
14 switch("experimental", "strictEffects") | |
15 switch("threads", "on") | |
16 switch("app", "gui") | |
17 | |
18 proc compilerFlagsDebug() = | |
19 switch("debugger", "native") | |
20 switch("checks", "on") | |
21 switch("assertions", "on") | |
22 | |
23 proc compilerFlagsRelease() = | |
24 switch("define", "release") | |
25 switch("checks", "off") | |
26 switch("assertions", "off") | |
27 | |
33
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
28 task single_linux_debug, "build linux debug": |
21
316923e9247c
add: clean examples, update build configs
Sam <sam@basx.dev>
parents:
19
diff
changeset
|
29 compilerFlags() |
18 | 30 compilerFlagsDebug() |
33
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
31 switch("outdir", BUILDBASE / DEBUG / LINUX) |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
32 setCommand "c" |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
33 mkDir(BUILDBASE / DEBUG / LINUX) |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
34 |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
35 task single_linux_release, "build linux release": |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
36 compilerFlags() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
37 compilerFlagsRelease() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
38 switch("outdir", BUILDBASE / RELEASE / LINUX) |
18 | 39 setCommand "c" |
33
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
40 mkDir(BUILDBASE / RELEASE / LINUX) |
18 | 41 |
33
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
42 task single_windows_debug, "build windows debug": |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
43 compilerFlags() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
44 compilerFlagsDebug() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
45 switch("outdir", BUILDBASE & "/" & DEBUG & "/" & WINDOWS) |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
46 setCommand "c" |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
47 mkDir(BUILDBASE & "/" & DEBUG & "/" & WINDOWS) |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
48 |
46
9e81f06a5c57
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
44
diff
changeset
|
49 |
33
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
50 task single_windows_release, "build windows release": |
21
316923e9247c
add: clean examples, update build configs
Sam <sam@basx.dev>
parents:
19
diff
changeset
|
51 compilerFlags() |
18 | 52 compilerFlagsRelease() |
33
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
53 switch("outdir", BUILDBASE & "/" & RELEASE & "/" & WINDOWS) |
21
316923e9247c
add: clean examples, update build configs
Sam <sam@basx.dev>
parents:
19
diff
changeset
|
54 setCommand "c" |
33
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
55 mkDir(BUILDBASE & "/" & RELEASE & "/" & WINDOWS) |
21
316923e9247c
add: clean examples, update build configs
Sam <sam@basx.dev>
parents:
19
diff
changeset
|
56 |
46
9e81f06a5c57
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
44
diff
changeset
|
57 task single_crosscompile_windows_debug, "build crosscompile windows debug": |
9e81f06a5c57
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
44
diff
changeset
|
58 switch("define", "mingw") |
9e81f06a5c57
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
44
diff
changeset
|
59 single_windows_debugTask() |
9e81f06a5c57
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
44
diff
changeset
|
60 |
9e81f06a5c57
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
44
diff
changeset
|
61 task single_crosscompile_windows_release, "build crosscompile windows release": |
9e81f06a5c57
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
44
diff
changeset
|
62 switch("define", "mingw") |
9e81f06a5c57
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
44
diff
changeset
|
63 single_windows_releaseTask() |
9e81f06a5c57
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
44
diff
changeset
|
64 |
33
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
65 task build_all_linux_debug, "build all examples with linux/debug": |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
66 for file in listFiles("examples"): |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
67 if file.endsWith(".nim"): |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
68 selfExec(&"single_linux_debug {file}") |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
69 |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
70 task build_all_linux_release, "build all examples with linux/release": |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
71 for file in listFiles("examples"): |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
72 if file.endsWith(".nim"): |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
73 selfExec(&"single_linux_release {file}") |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
74 |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
75 task build_all_windows_debug, "build all examples with windows/debug": |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
76 for file in listFiles("examples"): |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
77 if file.endsWith(".nim"): |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
78 exec(&"nim single_windows_debug --define:mingw {file}") |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
79 |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
80 task build_all_windows_release, "build all examples with windows/release": |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
81 for file in listFiles("examples"): |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
82 if file.endsWith(".nim"): |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
83 exec(&"nim single_windows_release --define:mingw {file}") |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
84 |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
85 task build_all_debug, "build all examples with */debug": |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
86 build_all_linux_debugTask() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
87 build_all_windows_debugTask() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
88 |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
89 task build_all_release, "build all examples with */release": |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
90 build_all_linux_releaseTask() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
91 build_all_windows_releaseTask() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
92 |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
93 task build_all_linux, "build all examples with linux/*": |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
94 build_all_linux_debugTask() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
95 build_all_linux_releaseTask() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
96 |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
97 task build_all_windows, "build all examples with windows/*": |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
98 build_all_windows_debugTask() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
99 build_all_windows_releaseTask() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
100 |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
101 task build_all, "build all examples": |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
102 build_all_linuxTask() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
103 build_all_windowsTask() |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
104 |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
105 task clean, "remove all build files": |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
106 exec(&"rm -rf {BUILDBASE}") |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
107 |
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
108 task publish, "publish all build": |
44 | 109 exec("rsync -rv build/ basx.dev:/var/www/public.basx.dev/semicongine") |
33
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
110 |
53 | 111 for file in listFiles("build/debug/linux"): |
112 exec(&"scp {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/debug/linux/") | |
113 for file in listFiles("build/release/linux"): | |
114 exec(&"scp {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/release/linux/") | |
115 for file in listFiles("build/debug/windows"): | |
116 exec(&"scp {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/debug/windows/") | |
117 for file in listFiles("build/release/windows"): | |
118 exec(&"scp {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/release/windows/") | |
119 | |
36 | 120 task glslangValidator, "Download glslangValidator (required for linux compilation)": |
121 let dirname="/tmp/glslang_download" | |
122 exec &"mkdir -p {dirname}" | |
123 exec &"cd {dirname} && wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip" | |
124 exec &"cd {dirname} && unzip *.zip" | |
125 exec &"mv {dirname}/bin/glslangValidator examples/" | |
126 exec &"rm -rf {dirname}" | |
127 | |
128 task glslangValidator_exe, "Download glslangValidator.exe (required for windows compilation)": | |
129 let dirname="/tmp/glslang_download" | |
130 exec &"mkdir -p {dirname}" | |
131 exec &"cd {dirname} && wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-windows-x64-Release.zip" | |
132 exec &"cd {dirname} && unzip *.zip" | |
133 exec &"mv {dirname}/bin/glslangValidator.exe examples/" | |
134 exec &"rm -rf {dirname}" | |
33
94c38e4b5782
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
24
diff
changeset
|
135 |
39 | 136 task run_all , "Run all binaries": |
137 for file in listFiles("build/debug/linux"): | |
138 exec file | |
139 for file in listFiles("build/release/linux"): | |
140 exec file | |
141 for file in listFiles("build/debug/windows"): | |
142 exec &"wine {file}" | |
143 for file in listFiles("build/release/windows"): | |
144 exec &"wine {file}" | |
46
9e81f06a5c57
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
44
diff
changeset
|
145 |
9e81f06a5c57
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
44
diff
changeset
|
146 if getCommand() in ["c", "compile", "r", "dump", "check", "idetools"]: |
9e81f06a5c57
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
44
diff
changeset
|
147 compilerFlags() |