-
Notifications
You must be signed in to change notification settings - Fork 145
/
SCsub
108 lines (86 loc) · 3.59 KB
/
SCsub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env python
import gdre_icon_builder
import shutil
from subprocess import Popen, PIPE
Import("env")
Import("env_modules")
mmp3thirdparty_dir = "#thirdparty/minimp3/"
liboggthirdparty_dir = "#thirdparty/libogg/"
webpthirdparty_dir = "#thirdparty/libwebp/"
env_gdsdecomp = env_modules.Clone()
env_gdsdecomp.Append(CPPPATH=["."])
env_gdsdecomp.Append(CPPPATH=["#thirdparty/thorsvg/"])
env_gdsdecomp["BUILDERS"]["MakeGDREIconsBuilder"] = Builder(
action=env_gdsdecomp.Run(gdre_icon_builder.make_gdre_icons_action),
suffix=".h",
src_suffix=".svg",
)
icon_sources = Glob("icons/*.svg")
env_gdsdecomp.Alias(
"gdre_icons",
[env_gdsdecomp.MakeGDREIconsBuilder("editor/gdre_icons.gen.h", icon_sources)],
)
def doproc(cmd):
# ensure that it doesn't print stderr to the terminal if print_err is False
process = Popen(cmd, stdout=PIPE, stderr=PIPE)
(output, err) = process.communicate()
if not err:
return output.decode("utf-8").strip()
else:
return None
def write_version_header():
git = shutil.which("git")
version_info = "unknown"
is_tag = False
if git == None:
print("GDRE WARNING: cannot find git on path, unknown version will be saved in gdre_version.gen.h")
else:
# git describe --abbrev=6
version_info = doproc([git, "describe", "--tags", "--abbrev=6"])
if version_info is None:
print("GDRE WARNING: git failed to run, unknown version will be saved in gdre_version.gen.h")
version_info = "unknown"
else:
# git describe --exact-match --tags HEAD
res = doproc([git, "describe", "--exact-match", "--tags", "HEAD"])
if not res:
is_tag = False
splits = version_info.split("-")
build_info = splits[-1]
build_num = splits[-2]
# everything but the last two elements
new_version_info = "-".join(splits[:-2])
splits = new_version_info.split(".")
splits[2] = str(int(splits[2]) + 1)
new_version_info = ".".join(splits)
new_version_info += "-dev." if "-" not in new_version_info else "+dev."
version_info = new_version_info + build_num + "+" + build_info
else:
is_tag = True
version_info = res
f = open("editor/gdre_version.gen.h", "w")
# check if we're not on a tag
process = Popen([git, "status", "--porcelain"], stdout=PIPE)
# define GDRE_VERSION "dev-poc (for Godot 4.0)"
f.write('#define GDRE_VERSION "')
f.write(version_info)
f.write('"\n')
f.close()
write_version_header()
if env["builtin_libogg"]:
env_gdsdecomp.Prepend(CPPPATH=[liboggthirdparty_dir])
if env["builtin_libvorbis"]:
env_gdsdecomp.Prepend(CPPPATH=["#thirdparty/libvorbis"])
# Treat minimp3 headers as system headers to avoid raising warnings. Not supported on MSVC.
if not env.msvc:
env_gdsdecomp.Append(CPPFLAGS=["-isystem", Dir(mmp3thirdparty_dir).path])
else:
env_gdsdecomp.Prepend(CPPPATH=[mmp3thirdparty_dir])
if env["builtin_libwebp"]:
env_gdsdecomp.Prepend(CPPPATH=[webpthirdparty_dir, webpthirdparty_dir + "src/"])
env_gdsdecomp.add_source_files(env.modules_sources, "*.cpp")
env_gdsdecomp.add_source_files(env.modules_sources, "bytecode/*.cpp")
env_gdsdecomp.add_source_files(env.modules_sources, "compat/*.cpp")
env_gdsdecomp.add_source_files(env.modules_sources, "editor/*.cpp")
env_gdsdecomp.add_source_files(env.modules_sources, "utility/*.cpp")
env_gdsdecomp.add_source_files(env.modules_sources, "external/toojpeg/*.cpp")