annotate config.nims @ 661:9995702c34b2

add: few improvments for working with textures
author Sam <sam@basx.dev>
date Sun, 07 May 2023 18:13:39 +0700
parents 53e08e6c5ae6
children 81fab407a479
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
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
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
10
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
11 proc compilerFlags() =
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
12 switch("path", "src")
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
13 switch("mm", "orc")
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
14 switch("experimental", "strictEffects")
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
15 switch("threads", "on")
544
c3c772512e7c add: new vulkan api wrapper, not done yet
Sam <sam@basx.dev>
parents: 543
diff changeset
16 if defined(linux):
c3c772512e7c add: new vulkan api wrapper, not done yet
Sam <sam@basx.dev>
parents: 543
diff changeset
17 switch("define", "VK_USE_PLATFORM_XLIB_KHR")
c3c772512e7c add: new vulkan api wrapper, not done yet
Sam <sam@basx.dev>
parents: 543
diff changeset
18 if defined(windows):
c3c772512e7c add: new vulkan api wrapper, not done yet
Sam <sam@basx.dev>
parents: 543
diff changeset
19 switch("define", "VK_USE_PLATFORM_WIN32_KHR")
c3c772512e7c add: new vulkan api wrapper, not done yet
Sam <sam@basx.dev>
parents: 543
diff changeset
20
479
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
21
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
22 proc compilerFlagsDebug() =
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
23 switch("debugger", "native")
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
24
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
25 proc compilerFlagsRelease() =
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
26 switch("define", "release")
515
2ffabd90c297 fix: use console for debug buids
Sam <sam@basx.dev>
parents: 514
diff changeset
27 switch("app", "gui")
479
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
28
494
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
29 task single_linux_debug, "build linux debug":
482
1670f8e70964 add: clean examples, update build configs
Sam <sam@basx.dev>
parents: 480
diff changeset
30 compilerFlags()
479
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
31 compilerFlagsDebug()
494
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
32 switch("outdir", BUILDBASE / DEBUG / LINUX)
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
33 setCommand "c"
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
34 mkDir(BUILDBASE / DEBUG / LINUX)
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
35
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
36 task single_linux_release, "build linux release":
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
37 compilerFlags()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
38 compilerFlagsRelease()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
39 switch("outdir", BUILDBASE / RELEASE / LINUX)
479
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
40 setCommand "c"
494
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
41 mkDir(BUILDBASE / RELEASE / LINUX)
479
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
42
494
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
43 task single_windows_debug, "build windows debug":
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
44 compilerFlags()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
45 compilerFlagsDebug()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
46 switch("outdir", BUILDBASE & "/" & DEBUG & "/" & WINDOWS)
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
47 setCommand "c"
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
48 mkDir(BUILDBASE & "/" & DEBUG & "/" & WINDOWS)
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
49
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
50 task single_windows_release, "build windows release":
482
1670f8e70964 add: clean examples, update build configs
Sam <sam@basx.dev>
parents: 480
diff changeset
51 compilerFlags()
479
16842d15319a add: basic vertex buffer functionality
Sam <sam@basx.dev>
parents: 474
diff changeset
52 compilerFlagsRelease()
494
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
53 switch("outdir", BUILDBASE & "/" & RELEASE & "/" & WINDOWS)
482
1670f8e70964 add: clean examples, update build configs
Sam <sam@basx.dev>
parents: 480
diff changeset
54 setCommand "c"
494
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
55 mkDir(BUILDBASE & "/" & RELEASE & "/" & WINDOWS)
482
1670f8e70964 add: clean examples, update build configs
Sam <sam@basx.dev>
parents: 480
diff changeset
56
494
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
57 task build_all_linux_debug, "build all examples with linux/debug":
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
58 for file in listFiles("examples"):
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
59 if file.endsWith(".nim"):
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
60 selfExec(&"single_linux_debug {file}")
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
61
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
62 task build_all_linux_release, "build all examples with linux/release":
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
63 for file in listFiles("examples"):
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
64 if file.endsWith(".nim"):
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
65 selfExec(&"single_linux_release {file}")
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
66
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
67 task build_all_windows_debug, "build all examples with windows/debug":
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
68 for file in listFiles("examples"):
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
69 if file.endsWith(".nim"):
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
70 exec(&"nim single_windows_debug --define:mingw {file}")
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 build_all_windows_release, "build all examples with windows/release":
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
73 for file in listFiles("examples"):
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
74 if file.endsWith(".nim"):
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
75 exec(&"nim single_windows_release --define:mingw {file}")
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
76
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
77 task build_all_debug, "build all examples with */debug":
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
78 build_all_linux_debugTask()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
79 build_all_windows_debugTask()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
80
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
81 task build_all_release, "build all examples with */release":
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
82 build_all_linux_releaseTask()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
83 build_all_windows_releaseTask()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
84
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
85 task build_all_linux, "build all examples with linux/*":
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
86 build_all_linux_debugTask()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
87 build_all_linux_releaseTask()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
88
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
89 task build_all_windows, "build all examples with windows/*":
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
90 build_all_windows_debugTask()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
91 build_all_windows_releaseTask()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
92
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
93 task build_all, "build all examples":
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
94 build_all_linuxTask()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
95 build_all_windowsTask()
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
96
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
97 task clean, "remove all build files":
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
98 exec(&"rm -rf {BUILDBASE}")
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
99
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
100 task publish, "publish all build":
514
86629e31543e add: improve build on windows
Sam <sam@basx.dev>
parents: 507
diff changeset
101 for file in listFiles("build/debug/linux"):
86629e31543e add: improve build on windows
Sam <sam@basx.dev>
parents: 507
diff changeset
102 exec(&"scp {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/debug/linux/")
86629e31543e add: improve build on windows
Sam <sam@basx.dev>
parents: 507
diff changeset
103 for file in listFiles("build/release/linux"):
86629e31543e add: improve build on windows
Sam <sam@basx.dev>
parents: 507
diff changeset
104 exec(&"scp {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/release/linux/")
86629e31543e add: improve build on windows
Sam <sam@basx.dev>
parents: 507
diff changeset
105 for file in listFiles("build/debug/windows"):
86629e31543e add: improve build on windows
Sam <sam@basx.dev>
parents: 507
diff changeset
106 exec(&"scp {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/debug/windows/")
86629e31543e add: improve build on windows
Sam <sam@basx.dev>
parents: 507
diff changeset
107 for file in listFiles("build/release/windows"):
86629e31543e add: improve build on windows
Sam <sam@basx.dev>
parents: 507
diff changeset
108 exec(&"scp {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/release/windows/")
86629e31543e add: improve build on windows
Sam <sam@basx.dev>
parents: 507
diff changeset
109
497
797f6f9c9d73 did: migrate rest of make functionality
Sam <sam@basx.dev>
parents: 496
diff changeset
110 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
111 let dirname = "/tmp/glslang_download"
497
797f6f9c9d73 did: migrate rest of make functionality
Sam <sam@basx.dev>
parents: 496
diff changeset
112 exec &"mkdir -p {dirname}"
797f6f9c9d73 did: migrate rest of make functionality
Sam <sam@basx.dev>
parents: 496
diff changeset
113 exec &"cd {dirname} && wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip"
797f6f9c9d73 did: migrate rest of make functionality
Sam <sam@basx.dev>
parents: 496
diff changeset
114 exec &"cd {dirname} && unzip *.zip"
797f6f9c9d73 did: migrate rest of make functionality
Sam <sam@basx.dev>
parents: 496
diff changeset
115 exec &"mv {dirname}/bin/glslangValidator examples/"
797f6f9c9d73 did: migrate rest of make functionality
Sam <sam@basx.dev>
parents: 496
diff changeset
116 exec &"rm -rf {dirname}"
797f6f9c9d73 did: migrate rest of make functionality
Sam <sam@basx.dev>
parents: 496
diff changeset
117
797f6f9c9d73 did: migrate rest of make functionality
Sam <sam@basx.dev>
parents: 496
diff changeset
118 task glslangValidator_exe, "Download glslangValidator.exe (required for windows compilation)":
523
311ee4e58032 fix: some formatting, bug when opening on windows.
Sam <sam@basx.dev>
parents: 516
diff changeset
119 let dirname = "/tmp/glslang_download"
497
797f6f9c9d73 did: migrate rest of make functionality
Sam <sam@basx.dev>
parents: 496
diff changeset
120 exec &"mkdir -p {dirname}"
797f6f9c9d73 did: migrate rest of make functionality
Sam <sam@basx.dev>
parents: 496
diff changeset
121 exec &"cd {dirname} && wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-windows-x64-Release.zip"
797f6f9c9d73 did: migrate rest of make functionality
Sam <sam@basx.dev>
parents: 496
diff changeset
122 exec &"cd {dirname} && unzip *.zip"
797f6f9c9d73 did: migrate rest of make functionality
Sam <sam@basx.dev>
parents: 496
diff changeset
123 exec &"mv {dirname}/bin/glslangValidator.exe examples/"
797f6f9c9d73 did: migrate rest of make functionality
Sam <sam@basx.dev>
parents: 496
diff changeset
124 exec &"rm -rf {dirname}"
494
0c18638c7217 did: refactoring, move more from make to nimscript
Sam <sam@basx.dev>
parents: 485
diff changeset
125
523
311ee4e58032 fix: some formatting, bug when opening on windows.
Sam <sam@basx.dev>
parents: 516
diff changeset
126 task run_all, "Run all binaries":
500
8025ab67d931 fix: hello cube, add: run_all command
Sam <sam@basx.dev>
parents: 499
diff changeset
127 for file in listFiles("build/debug/linux"):
8025ab67d931 fix: hello cube, add: run_all command
Sam <sam@basx.dev>
parents: 499
diff changeset
128 exec file
8025ab67d931 fix: hello cube, add: run_all command
Sam <sam@basx.dev>
parents: 499
diff changeset
129 for file in listFiles("build/release/linux"):
8025ab67d931 fix: hello cube, add: run_all command
Sam <sam@basx.dev>
parents: 499
diff changeset
130 exec file
8025ab67d931 fix: hello cube, add: run_all command
Sam <sam@basx.dev>
parents: 499
diff changeset
131 for file in listFiles("build/debug/windows"):
8025ab67d931 fix: hello cube, add: run_all command
Sam <sam@basx.dev>
parents: 499
diff changeset
132 exec &"wine {file}"
8025ab67d931 fix: hello cube, add: run_all command
Sam <sam@basx.dev>
parents: 499
diff changeset
133 for file in listFiles("build/release/windows"):
8025ab67d931 fix: hello cube, add: run_all command
Sam <sam@basx.dev>
parents: 499
diff changeset
134 exec &"wine {file}"
507
15e78601b390 add: some changes to build on windows host
Sam <sam@basx.dev>
parents: 505
diff changeset
135
539
9400c1cf26a5 add: vulkan api generator, not finished yet
Sam <sam@basx.dev>
parents: 523
diff changeset
136 task get_vulkan_wrapper, "Download vulkan wrapper":
9400c1cf26a5 add: vulkan api generator, not finished yet
Sam <sam@basx.dev>
parents: 523
diff changeset
137 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
138
9400c1cf26a5 add: vulkan api generator, not finished yet
Sam <sam@basx.dev>
parents: 523
diff changeset
139 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
140 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
141 mkDir "src/semicongine/vulkan/"
1822bea7de34 did: complete vulkan api generator pipeline for now
Sam <sam@basx.dev>
parents: 539
diff changeset
142 cpFile "src/vulkan_api/output/api.nim", "src/semicongine/vulkan/api.nim"
1822bea7de34 did: complete vulkan api generator pipeline for now
Sam <sam@basx.dev>
parents: 539
diff changeset
143 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
144
507
15e78601b390 add: some changes to build on windows host
Sam <sam@basx.dev>
parents: 505
diff changeset
145 if getCommand() in ["c", "compile", "r", "dump", "check", "idetools"]:
15e78601b390 add: some changes to build on windows host
Sam <sam@basx.dev>
parents: 505
diff changeset
146 compilerFlags()