annotate semiconginev2/build.nim @ 1241:a0ed1a918fda

fix: letters sometimes overlapping other letters quad
author sam <sam@basx.dev>
date Mon, 22 Jul 2024 12:51:50 +0700
parents 56781cc0fc7c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
396
c94db8b83040 did: adjust build-variables and config
Sam <sam@basx.dev>
parents: 392
diff changeset
1 # this should be used with nimscript
c94db8b83040 did: adjust build-variables and config
Sam <sam@basx.dev>
parents: 392
diff changeset
2
386
31f8ecc6644c add: util to build projects more streamlined
Sam <sam@basx.dev>
parents:
diff changeset
3 import std/strformat
31f8ecc6644c add: util to build projects more streamlined
Sam <sam@basx.dev>
parents:
diff changeset
4 import std/os
392
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
5 import std/strutils
386
31f8ecc6644c add: util to build projects more streamlined
Sam <sam@basx.dev>
parents:
diff changeset
6
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents: 1156
diff changeset
7 include ./core/globals
388
405bb1fb52b8 add: import-helpers for nimscripts
Sam <sam@basx.dev>
parents: 387
diff changeset
8
930
295cf32f883d and even more cleanup of the repo
sam <sam@basx.dev>
parents: 438
diff changeset
9 const BLENDER_CONVERT_SCRIPT = currentSourcePath().parentDir().parentDir().joinPath("tools/blender_gltf_converter.py")
966
a3428760e483 fix: steamcmd not executable, implement steam-upload
sam <sam@basx.dev>
parents: 964
diff changeset
10 const STEAMCMD_ZIP = currentSourcePath().parentDir().parentDir().joinPath("tools/steamcmd.zip")
973
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
11 const STEAMBUILD_DIR_NAME = "steam"
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
12
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
13 var STEAMLIB: string
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
14 if defined(linux):
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
15 STEAMLIB = currentSourcePath().parentDir().parentDir().joinPath("libs/libsteam_api.so")
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
16 elif defined(windows):
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
17 STEAMLIB = currentSourcePath().parentDir().parentDir().joinPath("libs/steam_api.dll")
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
18 else:
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
19 raise newException(Exception, "Unsupported platform")
392
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
20
437
e75c6da1d261 fix: exe-bundling not working correctly
Sam <sam@basx.dev>
parents: 400
diff changeset
21 proc semicongine_builddir*(buildname: string, builddir = "./build"): string =
995
2a1de6cb5282 fix: packaging fails if there are no resources, fix: zip-generation
sam <sam@basx.dev>
parents: 992
diff changeset
22 assert projectName() != "", "Please specify project file as a commandline argument"
391
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
23 var platformDir = "unkown"
392
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
24
391
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
25 if defined(linux):
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
26 platformDir = "linux"
392
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
27 elif defined(windows):
391
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
28 platformDir = "windows"
975
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
29 else:
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
30 raise newException(Exception, "Unsupported platform")
391
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
31
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
32 return builddir / buildname / platformDir / projectName()
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
33
437
e75c6da1d261 fix: exe-bundling not working correctly
Sam <sam@basx.dev>
parents: 400
diff changeset
34 proc semicongine_build_switches*(buildname: string, builddir = "./build") =
386
31f8ecc6644c add: util to build projects more streamlined
Sam <sam@basx.dev>
parents:
diff changeset
35 switch("experimental", "strictEffects")
31f8ecc6644c add: util to build projects more streamlined
Sam <sam@basx.dev>
parents:
diff changeset
36 switch("experimental", "strictFuncs")
31f8ecc6644c add: util to build projects more streamlined
Sam <sam@basx.dev>
parents:
diff changeset
37 switch("define", "nimPreviewHashRef")
975
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
38 if defined(linux):
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
39 switch("define", "VK_USE_PLATFORM_XLIB_KHR")
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
40 elif defined(windows):
400
7c31e5a780f1 fix: enforce gui-app on windows
sam <sam@basx.dev>
parents: 396
diff changeset
41 switch("define", "VK_USE_PLATFORM_WIN32_KHR")
7c31e5a780f1 fix: enforce gui-app on windows
sam <sam@basx.dev>
parents: 396
diff changeset
42 switch("app", "gui")
975
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
43 else:
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
44 raise newException(Exception, "Unsupported platform")
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
45
437
e75c6da1d261 fix: exe-bundling not working correctly
Sam <sam@basx.dev>
parents: 400
diff changeset
46 switch("outdir", semicongine_builddir(buildname, builddir = builddir))
973
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
47 switch("passL", "-Wl,-rpath,'$ORIGIN'") # adds directory of executable to dynlib search path
386
31f8ecc6644c add: util to build projects more streamlined
Sam <sam@basx.dev>
parents:
diff changeset
48
973
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
49 proc semicongine_pack*(outdir: string, bundleType: string, resourceRoot: string, withSteam: bool) =
438
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 437
diff changeset
50 switch("define", "PACKAGETYPE=" & bundleType)
386
31f8ecc6644c add: util to build projects more streamlined
Sam <sam@basx.dev>
parents:
diff changeset
51
979
6406766a222d fix: tests
sam <sam@basx.dev>
parents: 976
diff changeset
52 assert resourceRoot.dirExists, &"Resource root '{resourceRoot}' does not exists"
6406766a222d fix: tests
sam <sam@basx.dev>
parents: 976
diff changeset
53
966
a3428760e483 fix: steamcmd not executable, implement steam-upload
sam <sam@basx.dev>
parents: 964
diff changeset
54 outdir.rmDir()
a3428760e483 fix: steamcmd not executable, implement steam-upload
sam <sam@basx.dev>
parents: 964
diff changeset
55 outdir.mkDir()
396
c94db8b83040 did: adjust build-variables and config
Sam <sam@basx.dev>
parents: 392
diff changeset
56
c94db8b83040 did: adjust build-variables and config
Sam <sam@basx.dev>
parents: 392
diff changeset
57 echo "BUILD: Packing assets from '" & resourceRoot & "' into directory '" & outdir & "'"
c94db8b83040 did: adjust build-variables and config
Sam <sam@basx.dev>
parents: 392
diff changeset
58 let outdir_resources = joinPath(outdir, RESOURCEROOT)
c94db8b83040 did: adjust build-variables and config
Sam <sam@basx.dev>
parents: 392
diff changeset
59 if bundleType == "dir":
c94db8b83040 did: adjust build-variables and config
Sam <sam@basx.dev>
parents: 392
diff changeset
60 cpDir(resourceRoot, outdir_resources)
c94db8b83040 did: adjust build-variables and config
Sam <sam@basx.dev>
parents: 392
diff changeset
61 elif bundleType == "zip":
966
a3428760e483 fix: steamcmd not executable, implement steam-upload
sam <sam@basx.dev>
parents: 964
diff changeset
62 outdir_resources.mkDir()
979
6406766a222d fix: tests
sam <sam@basx.dev>
parents: 976
diff changeset
63 for resourceDir in resourceRoot.listDirs():
6406766a222d fix: tests
sam <sam@basx.dev>
parents: 976
diff changeset
64 let outputfile = joinPath(outdir_resources, resourceDir.splitPath().tail & ".zip")
6406766a222d fix: tests
sam <sam@basx.dev>
parents: 976
diff changeset
65 withdir resourceDir:
396
c94db8b83040 did: adjust build-variables and config
Sam <sam@basx.dev>
parents: 392
diff changeset
66 if defined(linux):
979
6406766a222d fix: tests
sam <sam@basx.dev>
parents: 976
diff changeset
67 echo &"zip -r {relativePath(outputfile, resourceDir)} ."
6406766a222d fix: tests
sam <sam@basx.dev>
parents: 976
diff changeset
68 exec &"zip -r {relativePath(outputfile, resourceDir)} ."
396
c94db8b83040 did: adjust build-variables and config
Sam <sam@basx.dev>
parents: 392
diff changeset
69 elif defined(windows):
979
6406766a222d fix: tests
sam <sam@basx.dev>
parents: 976
diff changeset
70 echo &"powershell Compress-Archive * {relativePath(outputfile, resourceDir)}"
6406766a222d fix: tests
sam <sam@basx.dev>
parents: 976
diff changeset
71 exec &"powershell Compress-Archive * {relativePath(outputfile, resourceDir)}"
975
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
72 else:
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
73 raise newException(Exception, "Unsupported platform")
437
e75c6da1d261 fix: exe-bundling not working correctly
Sam <sam@basx.dev>
parents: 400
diff changeset
74 elif bundleType == "exe":
e75c6da1d261 fix: exe-bundling not working correctly
Sam <sam@basx.dev>
parents: 400
diff changeset
75 switch("define", "BUILD_RESOURCEROOT=" & joinPath(getCurrentDir(), resourceRoot)) # required for in-exe packing of resources, must be absolute
973
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
76 if withSteam:
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
77 STEAMLIB.cpFile(outdir.joinPath(STEAMLIB.extractFilename))
391
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
78
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
79 proc semicongine_zip*(dir: string) =
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
80 withdir dir.parentDir:
1016
2762e6dd5f90 fix: wrong place
sam <sam@basx.dev>
parents: 1014
diff changeset
81 let zipFile = dir.lastPathPart & ".zip"
2762e6dd5f90 fix: wrong place
sam <sam@basx.dev>
parents: 1014
diff changeset
82 if zipFile.fileExists:
2762e6dd5f90 fix: wrong place
sam <sam@basx.dev>
parents: 1014
diff changeset
83 zipFile.rmFile()
391
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
84 if defined(linux):
995
2a1de6cb5282 fix: packaging fails if there are no resources, fix: zip-generation
sam <sam@basx.dev>
parents: 992
diff changeset
85 exec &"zip -r {dir.lastPathPart} {dir.lastPathPart}"
391
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
86 elif defined(windows):
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
87 exec &"powershell Compress-Archive * {dir.lastPathPart}"
975
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
88 else:
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
89 raise newException(Exception, "Unsupported platform")
391
68198310770b add: function to zip directories, usefull when creating dists
Sam <sam@basx.dev>
parents: 390
diff changeset
90
392
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
91
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
92 # need this because fileNewer from std/os does not work in Nim VM
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
93 proc fileNewerStatic(file1, file2: string): bool =
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
94 assert file1.fileExists
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
95 assert file2.fileExists
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
96 when defined(linux):
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
97 let command = "/usr/bin/test " & file1 & " -nt " & file2
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
98 let ex = gorgeEx(command)
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
99 return ex.exitCode == 0
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
100 elif defined(window):
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
101 {.error "Resource imports not supported on windows for now".}
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
102
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
103 proc import_meshes*(files: seq[(string, string)]) =
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
104 if files.len == 0:
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
105 return
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
106
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
107 var args = @["--background", "--python", BLENDER_CONVERT_SCRIPT, "--"]
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
108 for (input, output) in files:
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
109 args.add input
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
110 args.add output
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
111
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
112 exec("blender " & args.join(" "))
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
113
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
114 proc import_audio*(files: seq[(string, string)]) =
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
115 for (input, output) in files:
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
116 let command = "ffmpeg " & ["-y", "-i", input, "-ar", $AUDIO_SAMPLE_RATE, output].join(" ")
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
117 exec(command)
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
118
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
119 proc semicongine_import_resource_file*(resourceMap: openArray[(string, string)]) =
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
120 when not defined(linux):
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
121 {.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.".}
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
122 return
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
123 var meshfiles: seq[(string, string)]
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
124 var audiofiles: seq[(string, string)]
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
125
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
126 for (target_rel, source_rel) in resourceMap:
967
2f9469f83796 fix: steamcmd and build-script location
sam <sam@basx.dev>
parents: 966
diff changeset
127 let target = thisDir().joinPath(target_rel)
2f9469f83796 fix: steamcmd and build-script location
sam <sam@basx.dev>
parents: 966
diff changeset
128 let source = thisDir().joinPath(source_rel)
392
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
129 if not source.fileExists:
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
130 raise newException(IOError, &"Not found: {source}")
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
131 if not target.fileExists or source.fileNewerStatic(target):
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
132 echo &"{target} is outdated"
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
133 if source.endsWith("blend"):
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
134 meshfiles.add (source, target)
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
135 elif source.endsWith("mp3") or source.endsWith("ogg") or source.endsWith("wav"):
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
136 audiofiles.add (source, target)
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
137 else:
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
138 raise newException(Exception, &"unkown file type: {source}")
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
139 target.parentDir().mkDir()
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
140 else:
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
141 echo &"{target} is up-to-date"
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
142 import_meshes meshfiles
ff751cbe66e3 add: build-time code for resouce importing
Sam <sam@basx.dev>
parents: 391
diff changeset
143 import_audio audiofiles
964
3c17ac18166e add: initial code for automated steam builds
sam <sam@basx.dev>
parents: 930
diff changeset
144
3c17ac18166e add: initial code for automated steam builds
sam <sam@basx.dev>
parents: 930
diff changeset
145
966
a3428760e483 fix: steamcmd not executable, implement steam-upload
sam <sam@basx.dev>
parents: 964
diff changeset
146 # for steam-buildscript docs see https://partner.steamgames.com/doc/sdk/uploading
a3428760e483 fix: steamcmd not executable, implement steam-upload
sam <sam@basx.dev>
parents: 964
diff changeset
147 proc semicongine_steam_upload*(steamaccount, password, buildscript: string) =
973
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
148 let steamdir = thisDir().joinPath(STEAMBUILD_DIR_NAME)
964
3c17ac18166e add: initial code for automated steam builds
sam <sam@basx.dev>
parents: 930
diff changeset
149 if not dirExists(steamdir):
966
a3428760e483 fix: steamcmd not executable, implement steam-upload
sam <sam@basx.dev>
parents: 964
diff changeset
150 steamdir.mkDir
a3428760e483 fix: steamcmd not executable, implement steam-upload
sam <sam@basx.dev>
parents: 964
diff changeset
151 let zipFilename = STEAMCMD_ZIP.extractFilename
a3428760e483 fix: steamcmd not executable, implement steam-upload
sam <sam@basx.dev>
parents: 964
diff changeset
152 STEAMCMD_ZIP.cpFile(steamdir.joinPath(zipFilename))
a3428760e483 fix: steamcmd not executable, implement steam-upload
sam <sam@basx.dev>
parents: 964
diff changeset
153 withDir(steamdir):
975
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
154 if defined(linux):
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
155 exec &"unzip {zipFilename}"
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
156 rmFile zipFilename
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
157 exec "steamcmd/steamcmd.sh +quit" # self-update steamcmd
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
158 elif defined(windows):
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
159 exec &"powershell Expand-Archive -LiteralPath {zipFilename} ."
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
160 rmFile zipFilename
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
161 exec "steamcmd/steamcmd.exe +quit" # self-update steamcmd
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
162 else:
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
163 raise newException(Exception, "Unsupported platform")
966
a3428760e483 fix: steamcmd not executable, implement steam-upload
sam <sam@basx.dev>
parents: 964
diff changeset
164
975
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
165 var steamcmd: string
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
166 if defined(linux):
973
7fb8f62a9ea5 add: api to interact with steam
sam <sam@basx.dev>
parents: 967
diff changeset
167 steamcmd = STEAMBUILD_DIR_NAME.joinPath("steamcmd").joinPath("steamcmd.sh")
975
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
168 elif defined(windows):
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
169 steamcmd = STEAMBUILD_DIR_NAME.joinPath("steamcmd").joinPath("steamcmd.exe")
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
170 else:
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
171 raise newException(Exception, "Unsupported platform")
a8ce28444cf2 add: support steam uploads on windows
sam <sam@basx.dev>
parents: 973
diff changeset
172 let scriptPath = "..".joinPath("..").joinPath(buildscript)
967
2f9469f83796 fix: steamcmd and build-script location
sam <sam@basx.dev>
parents: 966
diff changeset
173 exec &"./{steamcmd} +login \"{steamaccount}\" \"{password}\" +run_app_build {scriptPath} +quit"
1017
1953a7ba4161 add: command to sign executables on windows
sam <sam@basx.dev>
parents: 1016
diff changeset
174
1953a7ba4161 add: command to sign executables on windows
sam <sam@basx.dev>
parents: 1016
diff changeset
175 proc semicongine_sign_executable*(file: string) =
1953a7ba4161 add: command to sign executables on windows
sam <sam@basx.dev>
parents: 1016
diff changeset
176 const SIGNTOOL_EXE = "C:/Program Files (x86)/Windows Kits/10/App Certification Kit/signtool.exe"
1953a7ba4161 add: command to sign executables on windows
sam <sam@basx.dev>
parents: 1016
diff changeset
177 if not SIGNTOOL_EXE.fileExists:
1953a7ba4161 add: command to sign executables on windows
sam <sam@basx.dev>
parents: 1016
diff changeset
178 raise newException(Exception, &"signtool.exe not found at ({SIGNTOOL_EXE}), please install the Windows SDK")
1018
c066b9a63368 fix: wrong string interpolation
sam <sam@basx.dev>
parents: 1017
diff changeset
179 exec &"\"{SIGNTOOL_EXE}\" sign /a /tr http://timestamp.globalsign.com/tsa/r6advanced1 /fd SHA256 /td SHA256 {file}"