annotate semiconginev2/old/build.nim @ 1222:3c3d4d7a8ecd compiletime-tests

did: cleanup config file
author sam <sam@basx.dev>
date Wed, 17 Jul 2024 21:08:15 +0700
parents 56781cc0fc7c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
1 # this should be used with nimscript
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
2
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
3 import std/strformat
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
4 import std/os
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
5 import std/strutils
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
6
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
7 import ./core/audiotypes
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
8 import ./core/constants
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
9
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
10 const BLENDER_CONVERT_SCRIPT = currentSourcePath().parentDir().parentDir().joinPath("tools/blender_gltf_converter.py")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
11 const STEAMCMD_ZIP = currentSourcePath().parentDir().parentDir().joinPath("tools/steamcmd.zip")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
12 const STEAMBUILD_DIR_NAME = "steam"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
13
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
14 var STEAMLIB: string
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
15 if defined(linux):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
16 STEAMLIB = currentSourcePath().parentDir().parentDir().joinPath("libs/libsteam_api.so")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
17 elif defined(windows):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
18 STEAMLIB = currentSourcePath().parentDir().parentDir().joinPath("libs/steam_api.dll")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
19 else:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
20 raise newException(Exception, "Unsupported platform")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
21
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
22 proc semicongine_builddir*(buildname: string, builddir = "./build"): string =
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
23 assert projectName() != "", "Please specify project file as a commandline argument"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
24 var platformDir = "unkown"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
25
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
26 if defined(linux):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
27 platformDir = "linux"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
28 elif defined(windows):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
29 platformDir = "windows"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
30 else:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
31 raise newException(Exception, "Unsupported platform")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
32
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
33 return builddir / buildname / platformDir / projectName()
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
34
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
35 proc semicongine_build_switches*(buildname: string, builddir = "./build") =
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
36 switch("experimental", "strictEffects")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
37 switch("experimental", "strictFuncs")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
38 switch("define", "nimPreviewHashRef")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
39 if defined(linux):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
40 switch("define", "VK_USE_PLATFORM_XLIB_KHR")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
41 elif defined(windows):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
42 switch("define", "VK_USE_PLATFORM_WIN32_KHR")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
43 switch("app", "gui")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
44 else:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
45 raise newException(Exception, "Unsupported platform")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
46
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
47 switch("outdir", semicongine_builddir(buildname, builddir = builddir))
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
48 switch("passL", "-Wl,-rpath,'$ORIGIN'") # adds directory of executable to dynlib search path
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
49
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
50 proc semicongine_pack*(outdir: string, bundleType: string, resourceRoot: string, withSteam: bool) =
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
51 switch("define", "PACKAGETYPE=" & bundleType)
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
52
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
53 assert resourceRoot.dirExists, &"Resource root '{resourceRoot}' does not exists"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
54
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
55 outdir.rmDir()
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
56 outdir.mkDir()
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
57
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
58 echo "BUILD: Packing assets from '" & resourceRoot & "' into directory '" & outdir & "'"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
59 let outdir_resources = joinPath(outdir, RESOURCEROOT)
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
60 if bundleType == "dir":
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
61 cpDir(resourceRoot, outdir_resources)
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
62 elif bundleType == "zip":
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
63 outdir_resources.mkDir()
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
64 for resourceDir in resourceRoot.listDirs():
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
65 let outputfile = joinPath(outdir_resources, resourceDir.splitPath().tail & ".zip")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
66 withdir resourceDir:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
67 if defined(linux):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
68 echo &"zip -r {relativePath(outputfile, resourceDir)} ."
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
69 exec &"zip -r {relativePath(outputfile, resourceDir)} ."
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
70 elif defined(windows):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
71 echo &"powershell Compress-Archive * {relativePath(outputfile, resourceDir)}"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
72 exec &"powershell Compress-Archive * {relativePath(outputfile, resourceDir)}"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
73 else:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
74 raise newException(Exception, "Unsupported platform")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
75 elif bundleType == "exe":
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
76 switch("define", "BUILD_RESOURCEROOT=" & joinPath(getCurrentDir(), resourceRoot)) # required for in-exe packing of resources, must be absolute
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
77 if withSteam:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
78 STEAMLIB.cpFile(outdir.joinPath(STEAMLIB.extractFilename))
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
79
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
80 proc semicongine_zip*(dir: string) =
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
81 withdir dir.parentDir:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
82 let zipFile = dir.lastPathPart & ".zip"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
83 if zipFile.fileExists:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
84 zipFile.rmFile()
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
85 if defined(linux):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
86 exec &"zip -r {dir.lastPathPart} {dir.lastPathPart}"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
87 elif defined(windows):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
88 exec &"powershell Compress-Archive * {dir.lastPathPart}"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
89 else:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
90 raise newException(Exception, "Unsupported platform")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
91
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
92
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
93 # need this because fileNewer from std/os does not work in Nim VM
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
94 proc fileNewerStatic(file1, file2: string): bool =
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
95 assert file1.fileExists
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
96 assert file2.fileExists
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
97 when defined(linux):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
98 let command = "/usr/bin/test " & file1 & " -nt " & file2
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
99 let ex = gorgeEx(command)
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
100 return ex.exitCode == 0
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
101 elif defined(window):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
102 {.error "Resource imports not supported on windows for now".}
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
103
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
104 proc import_meshes*(files: seq[(string, string)]) =
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
105 if files.len == 0:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
106 return
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
107
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
108 var args = @["--background", "--python", BLENDER_CONVERT_SCRIPT, "--"]
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
109 for (input, output) in files:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
110 args.add input
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
111 args.add output
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
112
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
113 exec("blender " & args.join(" "))
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
114
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
115 proc import_audio*(files: seq[(string, string)]) =
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
116 for (input, output) in files:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
117 let command = "ffmpeg " & ["-y", "-i", input, "-ar", $AUDIO_SAMPLE_RATE, output].join(" ")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
118 exec(command)
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
119
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
120 proc semicongine_import_resource_file*(resourceMap: openArray[(string, string)]) =
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
121 when not defined(linux):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
122 {.warning: "Resource files can only be imported on linux, please make sure that the required files are created by runing the build on a linux machine.".}
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
123 return
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
124 var meshfiles: seq[(string, string)]
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
125 var audiofiles: seq[(string, string)]
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
126
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
127 for (target_rel, source_rel) in resourceMap:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
128 let target = thisDir().joinPath(target_rel)
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
129 let source = thisDir().joinPath(source_rel)
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
130 if not source.fileExists:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
131 raise newException(IOError, &"Not found: {source}")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
132 if not target.fileExists or source.fileNewerStatic(target):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
133 echo &"{target} is outdated"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
134 if source.endsWith("blend"):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
135 meshfiles.add (source, target)
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
136 elif source.endsWith("mp3") or source.endsWith("ogg") or source.endsWith("wav"):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
137 audiofiles.add (source, target)
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
138 else:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
139 raise newException(Exception, &"unkown file type: {source}")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
140 target.parentDir().mkDir()
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
141 else:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
142 echo &"{target} is up-to-date"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
143 import_meshes meshfiles
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
144 import_audio audiofiles
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
145
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
146
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
147 # for steam-buildscript docs see https://partner.steamgames.com/doc/sdk/uploading
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
148 proc semicongine_steam_upload*(steamaccount, password, buildscript: string) =
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
149 let steamdir = thisDir().joinPath(STEAMBUILD_DIR_NAME)
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
150 if not dirExists(steamdir):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
151 steamdir.mkDir
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
152 let zipFilename = STEAMCMD_ZIP.extractFilename
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
153 STEAMCMD_ZIP.cpFile(steamdir.joinPath(zipFilename))
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
154 withDir(steamdir):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
155 if defined(linux):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
156 exec &"unzip {zipFilename}"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
157 rmFile zipFilename
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
158 exec "steamcmd/steamcmd.sh +quit" # self-update steamcmd
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
159 elif defined(windows):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
160 exec &"powershell Expand-Archive -LiteralPath {zipFilename} ."
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
161 rmFile zipFilename
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
162 exec "steamcmd/steamcmd.exe +quit" # self-update steamcmd
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
163 else:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
164 raise newException(Exception, "Unsupported platform")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
165
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
166 var steamcmd: string
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
167 if defined(linux):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
168 steamcmd = STEAMBUILD_DIR_NAME.joinPath("steamcmd").joinPath("steamcmd.sh")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
169 elif defined(windows):
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
170 steamcmd = STEAMBUILD_DIR_NAME.joinPath("steamcmd").joinPath("steamcmd.exe")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
171 else:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
172 raise newException(Exception, "Unsupported platform")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
173 let scriptPath = "..".joinPath("..").joinPath(buildscript)
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
174 exec &"./{steamcmd} +login \"{steamaccount}\" \"{password}\" +run_app_build {scriptPath} +quit"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
175
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
176 proc semicongine_sign_executable*(file: string) =
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
177 const SIGNTOOL_EXE = "C:/Program Files (x86)/Windows Kits/10/App Certification Kit/signtool.exe"
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
178 if not SIGNTOOL_EXE.fileExists:
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
179 raise newException(Exception, &"signtool.exe not found at ({SIGNTOOL_EXE}), please install the Windows SDK")
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
180 exec &"\"{SIGNTOOL_EXE}\" sign /a /tr http://timestamp.globalsign.com/tsa/r6advanced1 /fd SHA256 /td SHA256 {file}"