Mercurial > games > semicongine
annotate semicongine/core/buildconfig.nim @ 397:ce66095e19e3
fix: bad way to do build config
author | Sam <sam@basx.dev> |
---|---|
date | Tue, 26 Dec 2023 21:12:14 +0700 |
parents | c94db8b83040 |
children | 7c31e5a780f1 |
rev | line source |
---|---|
194
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
1 import std/strutils |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
2 import std/logging |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
3 import std/os |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
4 |
397 | 5 import ./constants |
194
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
6 |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
7 # checks required build options: |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
8 static: |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
9 assert compileOption("threads"), ENGINENAME & " requires --threads=on" |
366
857cd931d24b
add: function-based animations, preparing-refactring for better material system, hashable dynamic arrays
Sam <sam@basx.dev>
parents:
316
diff
changeset
|
10 assert defined(nimPreviewHashRef), ENGINENAME & " requires -d:nimPreviewHashRef" |
194
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
11 |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
12 if defined(release): |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
13 assert compileOption("app", "gui"), ENGINENAME & " requires --app=gui for release builds" |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
14 |
366
857cd931d24b
add: function-based animations, preparing-refactring for better material system, hashable dynamic arrays
Sam <sam@basx.dev>
parents:
316
diff
changeset
|
15 |
194
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
16 if defined(linux): |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
17 assert defined(VK_USE_PLATFORM_XLIB_KHR), ENGINENAME & " requires --d:VK_USE_PLATFORM_XLIB_KHR for linux builds" |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
18 elif defined(windows): |
214 | 19 assert defined(VK_USE_PLATFORM_WIN32_KHR), ENGINENAME & " requires --d:VK_USE_PLATFORM_WIN32_KHR for windows builds" |
194
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
20 else: |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
21 assert false, "trying to build on unsupported platform" |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
22 |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
23 # build configuration |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
24 # ===================== |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
25 |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
26 # compile-time defines, usefull for build-dependent settings |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
27 # can be overriden with compiler flags, e.g. -d:Foo=42 -d:Bar=false |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
28 # pramas: {.intdefine.} {.strdefine.} {.booldefine.} |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
29 |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
30 # root of where settings files will be searched |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
31 # must be relative (to the directory of the binary) |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
32 const DEBUG* = not defined(release) |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
33 const CONFIGROOT* {.strdefine.}: string = "." |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
34 assert not isAbsolute(CONFIGROOT) |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
35 |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
36 const CONFIGEXTENSION* {.strdefine.}: string = "ini" |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
37 |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
38 # by default enable hot-reload of runtime-configuration only in debug builds |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
39 const CONFIGHOTRELOAD* {.booldefine.}: bool = DEBUG |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
40 |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
41 # milliseconds to wait between checks for settings hotreload |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
42 const CONFIGHOTRELOADINTERVAL* {.intdefine.}: int = 1000 |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
43 |
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
44 # log level |
315
4921ec86dcb4
did: preparations to refactor material system, still tons to do
Sam <sam@basx.dev>
parents:
299
diff
changeset
|
45 const LOGLEVEL {.strdefine.}: string = (when DEBUG: "lvlWarn" else: "lvlWarn") |
194
93f661a20f74
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
diff
changeset
|
46 const ENGINE_LOGLEVEL* = parseEnum[Level](LOGLEVEL) |
196 | 47 |
270
563ca4a82931
did: overhaul some of the mesh-data uploading and transformation handling, added: text/font rendering
Sam <sam@basx.dev>
parents:
214
diff
changeset
|
48 # resource bundleing settings, need to be configured per project |
563ca4a82931
did: overhaul some of the mesh-data uploading and transformation handling, added: text/font rendering
Sam <sam@basx.dev>
parents:
214
diff
changeset
|
49 const BUNDLETYPE* {.strdefine.}: string = "" # dir, zip, exe |
563ca4a82931
did: overhaul some of the mesh-data uploading and transformation handling, added: text/font rendering
Sam <sam@basx.dev>
parents:
214
diff
changeset
|
50 static: |
563ca4a82931
did: overhaul some of the mesh-data uploading and transformation handling, added: text/font rendering
Sam <sam@basx.dev>
parents:
214
diff
changeset
|
51 assert BUNDLETYPE in ["dir", "zip", "exe"], ENGINENAME & " requires one of -d:BUNDLETYPE=dir -d:BUNDLETYPE=zip -d:BUNDLETYPE=exe" |