Mercurial > games > semicongine
annotate config.nims @ 700:abc0d97392cb
did: nicer test example, scene switching still problematic
author | Sam <sam@basx.dev> |
---|---|
date | Sat, 20 May 2023 23:21:03 +0700 |
parents | 275ac4cdf7e0 |
children | 952428f04ffc |
rev | line source |
---|---|
494
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
1 import std/strformat |
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
2 import std/strutils |
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
3 import std/os |
479 | 4 |
494
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
5 const BUILDBASE = "build" |
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
6 const DEBUG = "debug" |
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
7 const RELEASE = "release" |
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
8 const LINUX = "linux" |
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
9 const WINDOWS = "windows" |
479 | 10 |
674
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
11 const BUNDLETYPE* {.strdefine.}: string = "dir" # dir, zip, exe |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
12 const RESOURCEROOT* {.strdefine.}: string = "resources" |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
13 |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
14 task build, "build": |
479 | 15 switch("path", "src") |
16 switch("mm", "orc") | |
17 switch("experimental", "strictEffects") | |
18 switch("threads", "on") | |
696
275ac4cdf7e0
did: replace zippy with "standard" nim zip, compiled from source, fix some errors
Sam <sam@basx.dev>
parents:
675
diff
changeset
|
19 switch("d", "useLibzipSrc") |
674
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
20 var buildType = DEBUG |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
21 var platformDir = "" |
544
c3c772512e7c
add: new vulkan api wrapper, not done yet
Sam <sam@basx.dev>
parents:
543
diff
changeset
|
22 if defined(linux): |
c3c772512e7c
add: new vulkan api wrapper, not done yet
Sam <sam@basx.dev>
parents:
543
diff
changeset
|
23 switch("define", "VK_USE_PLATFORM_XLIB_KHR") |
674
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
24 platformDir = LINUX |
544
c3c772512e7c
add: new vulkan api wrapper, not done yet
Sam <sam@basx.dev>
parents:
543
diff
changeset
|
25 if defined(windows): |
c3c772512e7c
add: new vulkan api wrapper, not done yet
Sam <sam@basx.dev>
parents:
543
diff
changeset
|
26 switch("define", "VK_USE_PLATFORM_WIN32_KHR") |
674
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
27 platformDir = WINDOWS |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
28 if defined(release): |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
29 switch("app", "gui") |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
30 buildType = RELEASE |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
31 else: |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
32 switch("debugger", "native") |
494
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
33 |
674
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
34 var outdir = getCurrentDir() / BUILDBASE / buildType / platformDir / projectName() |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
35 switch("outdir", outdir) |
479 | 36 setCommand "c" |
674
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
37 rmDir(outdir) |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
38 mkDir(outdir) |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
39 let resourcedir = joinPath(projectDir(), RESOURCEROOT) |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
40 if existsDir(resourcedir): |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
41 let outdir_resources = joinPath(outdir, RESOURCEROOT) |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
42 if BUNDLETYPE == "dir": |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
43 cpDir(resourcedir, outdir_resources) |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
44 elif BUNDLETYPE == "zip": |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
45 mkDir(outdir_resources) |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
46 for resource in listDirs(resourcedir): |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
47 let |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
48 oldcwd = getCurrentDir() |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
49 outputfile = joinPath(outdir_resources, resource.splitPath().tail & ".zip") |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
50 inputfile = resource.splitPath().tail |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
51 cd(resource) |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
52 if defined(linux): |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
53 exec &"zip -r {outputfile} ." |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
54 elif defined(windows): |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
55 # TODO: test this |
675 | 56 exec &"powershell Compress-Archive * {outputfile}" |
674
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
57 cd(oldcwd) |
479 | 58 |
674
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
59 task build_all_debug, "build all examples for debug": |
494
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
60 for file in listFiles("examples"): |
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
61 if file.endsWith(".nim"): |
674
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
62 exec(&"nim build {file}") |
494
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
63 |
674
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
64 task build_all_release, "build all examples for release": |
494
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
65 for file in listFiles("examples"): |
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
66 if file.endsWith(".nim"): |
674
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
67 exec(&"nim build -d:release {file}") |
494
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
68 |
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
69 task clean, "remove all build files": |
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
70 exec(&"rm -rf {BUILDBASE}") |
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
71 |
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
72 task publish, "publish all build": |
514 | 73 for file in listFiles("build/debug/linux"): |
74 exec(&"scp {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/debug/linux/") | |
75 for file in listFiles("build/release/linux"): | |
76 exec(&"scp {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/release/linux/") | |
77 for file in listFiles("build/debug/windows"): | |
78 exec(&"scp {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/debug/windows/") | |
79 for file in listFiles("build/release/windows"): | |
80 exec(&"scp {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/release/windows/") | |
81 | |
497 | 82 task glslangValidator, "Download glslangValidator (required for linux compilation)": |
523
311ee4e58032
fix: some formatting, bug when opening on windows.
Sam <sam@basx.dev>
parents:
516
diff
changeset
|
83 let dirname = "/tmp/glslang_download" |
497 | 84 exec &"mkdir -p {dirname}" |
85 exec &"cd {dirname} && wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip" | |
86 exec &"cd {dirname} && unzip *.zip" | |
87 exec &"mv {dirname}/bin/glslangValidator examples/" | |
88 exec &"rm -rf {dirname}" | |
89 | |
90 task glslangValidator_exe, "Download glslangValidator.exe (required for windows compilation)": | |
674
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
91 # TODO: make this work on windows |
523
311ee4e58032
fix: some formatting, bug when opening on windows.
Sam <sam@basx.dev>
parents:
516
diff
changeset
|
92 let dirname = "/tmp/glslang_download" |
497 | 93 exec &"mkdir -p {dirname}" |
94 exec &"cd {dirname} && wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-windows-x64-Release.zip" | |
95 exec &"cd {dirname} && unzip *.zip" | |
96 exec &"mv {dirname}/bin/glslangValidator.exe examples/" | |
97 exec &"rm -rf {dirname}" | |
494
0c18638c7217
did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents:
485
diff
changeset
|
98 |
523
311ee4e58032
fix: some formatting, bug when opening on windows.
Sam <sam@basx.dev>
parents:
516
diff
changeset
|
99 task run_all, "Run all binaries": |
500 | 100 for file in listFiles("build/debug/linux"): |
101 exec file | |
102 for file in listFiles("build/release/linux"): | |
103 exec file | |
104 for file in listFiles("build/debug/windows"): | |
105 exec &"wine {file}" | |
106 for file in listFiles("build/release/windows"): | |
107 exec &"wine {file}" | |
507
15e78601b390
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
505
diff
changeset
|
108 |
539
9400c1cf26a5
add: vulkan api generator, not finished yet
Sam <sam@basx.dev>
parents:
523
diff
changeset
|
109 task get_vulkan_wrapper, "Download vulkan wrapper": |
9400c1cf26a5
add: vulkan api generator, not finished yet
Sam <sam@basx.dev>
parents:
523
diff
changeset
|
110 exec &"curl https://raw.githubusercontent.com/nimgl/nimgl/master/src/nimgl/vulkan.nim > src/semicongine/vulkan/c_api.nim" |
9400c1cf26a5
add: vulkan api generator, not finished yet
Sam <sam@basx.dev>
parents:
523
diff
changeset
|
111 |
9400c1cf26a5
add: vulkan api generator, not finished yet
Sam <sam@basx.dev>
parents:
523
diff
changeset
|
112 task generate_vulkan_api, "Generate Vulkan API": |
655
53e08e6c5ae6
did: a bit of cleanup with the config, also add some documentation
Sam <sam@basx.dev>
parents:
544
diff
changeset
|
113 selfExec &"c -d:ssl --run src/vulkan_api/vulkan_api_generator.nim" |
543
1822bea7de34
did: complete vulkan api generator pipeline for now
Sam <sam@basx.dev>
parents:
539
diff
changeset
|
114 mkDir "src/semicongine/vulkan/" |
668
a02d503ffa53
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
655
diff
changeset
|
115 mkDir "src/semicongine/core/" |
a02d503ffa53
add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
655
diff
changeset
|
116 cpFile "src/vulkan_api/output/api.nim", "src/semicongine/core/api.nim" |
543
1822bea7de34
did: complete vulkan api generator pipeline for now
Sam <sam@basx.dev>
parents:
539
diff
changeset
|
117 cpDir "src/vulkan_api/output/platform", "src/semicongine/vulkan/platform" |
539
9400c1cf26a5
add: vulkan api generator, not finished yet
Sam <sam@basx.dev>
parents:
523
diff
changeset
|
118 |
507
15e78601b390
add: some changes to build on windows host
Sam <sam@basx.dev>
parents:
505
diff
changeset
|
119 if getCommand() in ["c", "compile", "r", "dump", "check", "idetools"]: |
674
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
120 --path:src |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
121 --mm:orc |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
122 --threads:on |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
123 if defined(linux): |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
124 --d:VK_USE_PLATFORM_XLIB_KHR |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
125 if defined(windows): |
496b328faa43
add: resource packaging and loading for different resource types, simplify build commands, update readme
Sam <sam@basx.dev>
parents:
668
diff
changeset
|
126 --d:VK_USE_PLATFORM_WIN32_KHR |