comparison config.nims @ 1059:9c364af8d3f0

did: tons of small improvments, on the way to make GPU sync (more) correct I guess
author sam <sam@basx.dev>
date Sun, 31 Mar 2024 22:11:50 +0700
parents 1ab09f8cc68d
children 6406766a222d
comparison
equal deleted inserted replaced
1058:7a0d5fc00f4f 1059:9c364af8d3f0
1 import std/strformat 1 import std/strformat
2 import std/strutils 2 import std/strutils
3 import std/os 3 import std/os
4 4
5 const BUILDBASE = "build" 5 import semicongine/build
6 const DEBUG = "debug"
7 const RELEASE = "release"
8 const LINUX = "linux"
9 const WINDOWS = "windows"
10 6
11 const PACKAGETYPE* {.strdefine.}: string = "dir" # dir, zip, exe 7 # TODO: totally update this file!!
12 const RESOURCEROOT* {.strdefine.}: string = "resources"
13 8
14 switch("d", "nimPreviewHashRef")
15 switch("experimental", "strictEffects")
16 switch("experimental", "strictFuncs")
17 switch("nimblePath", "nimbledeps/pkgs2") 9 switch("nimblePath", "nimbledeps/pkgs2")
18 10
19 task build, "build": 11 task build_dev, "build dev":
20 switch("d", "PACKAGETYPE=" & PACKAGETYPE) 12 semicongine_build_switches(buildname = "dev")
21 switch("d", "RESOURCEROOT=" & RESOURCEROOT) 13 setCommand "c"
22 var buildType = DEBUG 14 let outdir = semicongine_builddir(buildname = "dev")
23 var platformDir = "" 15 semicongine_pack(outdir, bundleType = "exe", resourceRoot = "resources")
24 if defined(linux):
25 switch("define", "VK_USE_PLATFORM_XLIB_KHR")
26 platformDir = LINUX
27 if defined(windows):
28 switch("define", "VK_USE_PLATFORM_WIN32_KHR")
29 platformDir = WINDOWS
30 if defined(release):
31 switch("app", "gui")
32 buildType = RELEASE
33 else:
34 switch("debugger", "native")
35 16
36 var outdir = getCurrentDir() / BUILDBASE / buildType / platformDir / projectName() 17 task build_release, "build release":
37 switch("outdir", outdir) 18 switch "define", "release"
19 switch "app", "gui"
20 semicongine_build_switches(buildname = "release")
38 setCommand "c" 21 setCommand "c"
39 rmDir(outdir) 22 let outdir = semicongine_builddir(buildname = "release")
40 mkDir(outdir) 23 semicongine_pack(outdir, bundleType = "exe", resourceRoot = "resources")
41 let resourcedir = joinPath(projectDir(), RESOURCEROOT) 24
42 if dirExists(resourcedir):
43 let outdir_resources = joinPath(outdir, RESOURCEROOT)
44 if PACKAGETYPE == "dir":
45 cpDir(resourcedir, outdir_resources)
46 elif PACKAGETYPE == "zip":
47 mkDir(outdir_resources)
48 for resource in listDirs(resourcedir):
49 let
50 oldcwd = getCurrentDir()
51 outputfile = joinPath(outdir_resources, resource.splitPath().tail & ".zip")
52 inputfile = resource.splitPath().tail
53 cd(resource)
54 if defined(linux):
55 exec &"zip -r {outputfile} ."
56 elif defined(windows):
57 # TODO: test this
58 exec &"powershell Compress-Archive * {outputfile}"
59 cd(oldcwd)
60 25
61 task build_all_debug, "build all examples for debug": 26 task build_all_debug, "build all examples for debug":
62 for file in listFiles("examples"): 27 for file in listFiles("examples"):
63 if file.endsWith(".nim"): 28 if file.endsWith(".nim"):
64 exec(&"nim build {file}") 29 exec(&"nim build {file}")
74 exec(&"nim build --run {file}") 39 exec(&"nim build --run {file}")
75 40
76 exec("nim build -d:BUILD_RESOURCEROOT=tests/resources -d:PACKAGETYPE=dir --run tests/test_resources.nim") 41 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") 42 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") 43 exec("nim build -d:BUILD_RESOURCEROOT=tests/resources -d:PACKAGETYPE=exe --run tests/test_resources.nim")
79
80 task clean, "remove all build files":
81 exec(&"rm -rf {BUILDBASE}")
82 44
83 task publish, "publish all build": 45 task publish, "publish all build":
84 for file in listDirs("build/debug/linux"): 46 for file in listDirs("build/debug/linux"):
85 exec(&"scp -r {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/debug/linux/") 47 exec(&"scp -r {file} sam@mail.basx.dev:/var/www/public.basx.dev/semicongine/debug/linux/")
86 for file in listDirs("build/release/linux"): 48 for file in listDirs("build/release/linux"):