Mercurial > games > semicongine
comparison config.nims @ 438:1ab09f8cc68d
did: refactor and improve packaging API
author | Sam <sam@basx.dev> |
---|---|
date | Wed, 14 Feb 2024 21:58:43 +0700 |
parents | 8e926856a9ce |
children | fe48b091e83f |
comparison
equal
deleted
inserted
replaced
437:e75c6da1d261 | 438:1ab09f8cc68d |
---|---|
6 const DEBUG = "debug" | 6 const DEBUG = "debug" |
7 const RELEASE = "release" | 7 const RELEASE = "release" |
8 const LINUX = "linux" | 8 const LINUX = "linux" |
9 const WINDOWS = "windows" | 9 const WINDOWS = "windows" |
10 | 10 |
11 const BUNDLETYPE* {.strdefine.}: string = "dir" # dir, zip, exe | 11 const PACKAGETYPE* {.strdefine.}: string = "dir" # dir, zip, exe |
12 const RESOURCEROOT* {.strdefine.}: string = "resources" | 12 const RESOURCEROOT* {.strdefine.}: string = "resources" |
13 | 13 |
14 switch("d", "nimPreviewHashRef") | 14 switch("d", "nimPreviewHashRef") |
15 switch("experimental", "strictEffects") | 15 switch("experimental", "strictEffects") |
16 switch("experimental", "strictFuncs") | 16 switch("experimental", "strictFuncs") |
17 switch("nimblePath", "nimbledeps/pkgs2") | 17 switch("nimblePath", "nimbledeps/pkgs2") |
18 | 18 |
19 task build, "build": | 19 task build, "build": |
20 switch("d", "BUNDLETYPE=" & BUNDLETYPE) | 20 switch("d", "PACKAGETYPE=" & PACKAGETYPE) |
21 switch("d", "RESOURCEROOT=" & RESOURCEROOT) | 21 switch("d", "RESOURCEROOT=" & RESOURCEROOT) |
22 var buildType = DEBUG | 22 var buildType = DEBUG |
23 var platformDir = "" | 23 var platformDir = "" |
24 if defined(linux): | 24 if defined(linux): |
25 switch("define", "VK_USE_PLATFORM_XLIB_KHR") | 25 switch("define", "VK_USE_PLATFORM_XLIB_KHR") |
39 rmDir(outdir) | 39 rmDir(outdir) |
40 mkDir(outdir) | 40 mkDir(outdir) |
41 let resourcedir = joinPath(projectDir(), RESOURCEROOT) | 41 let resourcedir = joinPath(projectDir(), RESOURCEROOT) |
42 if dirExists(resourcedir): | 42 if dirExists(resourcedir): |
43 let outdir_resources = joinPath(outdir, RESOURCEROOT) | 43 let outdir_resources = joinPath(outdir, RESOURCEROOT) |
44 if BUNDLETYPE == "dir": | 44 if PACKAGETYPE == "dir": |
45 cpDir(resourcedir, outdir_resources) | 45 cpDir(resourcedir, outdir_resources) |
46 elif BUNDLETYPE == "zip": | 46 elif PACKAGETYPE == "zip": |
47 mkDir(outdir_resources) | 47 mkDir(outdir_resources) |
48 for resource in listDirs(resourcedir): | 48 for resource in listDirs(resourcedir): |
49 let | 49 let |
50 oldcwd = getCurrentDir() | 50 oldcwd = getCurrentDir() |
51 outputfile = joinPath(outdir_resources, resource.splitPath().tail & ".zip") | 51 outputfile = joinPath(outdir_resources, resource.splitPath().tail & ".zip") |
68 if file.endsWith(".nim"): | 68 if file.endsWith(".nim"): |
69 exec(&"nim build -d:release {file}") | 69 exec(&"nim build -d:release {file}") |
70 | 70 |
71 task test_all, "Run all test programs": | 71 task test_all, "Run all test programs": |
72 for file in listFiles("tests"): | 72 for file in listFiles("tests"): |
73 if file.endsWith(".nim"): | 73 if file.endsWith(".nim") and not file.endsWith("test_resources.nim"): |
74 exec(&"nim build --run {file}") | 74 exec(&"nim build --run {file}") |
75 | |
76 exec("nim build -d:BUILD_RESOURCEROOT=tests/resources -d:PACKAGETYPE=dir --run tests/test_resources.nim") | |
77 exec("nim build -d:BUILD_RESOURCEROOT=tests/resources -d:PACKAGETYPE=zip --run tests/test_resources.nim") | |
78 exec("nim build -d:BUILD_RESOURCEROOT=tests/resources -d:PACKAGETYPE=exe --run tests/test_resources.nim") | |
75 | 79 |
76 task clean, "remove all build files": | 80 task clean, "remove all build files": |
77 exec(&"rm -rf {BUILDBASE}") | 81 exec(&"rm -rf {BUILDBASE}") |
78 | 82 |
79 task publish, "publish all build": | 83 task publish, "publish all build": |
123 cpFile "src/vulkan_api/output/api.nim", "src/semicongine/core/api.nim" | 127 cpFile "src/vulkan_api/output/api.nim", "src/semicongine/core/api.nim" |
124 cpDir "src/vulkan_api/output/platform", "src/semicongine/vulkan/platform" | 128 cpDir "src/vulkan_api/output/platform", "src/semicongine/vulkan/platform" |
125 | 129 |
126 if getCommand() in ["c", "compile", "r", "dump", "check", "idetools"]: | 130 if getCommand() in ["c", "compile", "r", "dump", "check", "idetools"]: |
127 if defined(linux): | 131 if defined(linux): |
128 --d:VK_USE_PLATFORM_XLIB_KHR | 132 --d: VK_USE_PLATFORM_XLIB_KHR |
129 if defined(windows): | 133 if defined(windows): |
130 --d:VK_USE_PLATFORM_WIN32_KHR | 134 --d: VK_USE_PLATFORM_WIN32_KHR |