-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsconstruct
More file actions
114 lines (99 loc) · 4.38 KB
/
Copy pathsconstruct
File metadata and controls
114 lines (99 loc) · 4.38 KB
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
109
110
111
112
113
114
import glob
import os
import shutil
from SCons.Script import Alias, AlwaysBuild, Default, Delete, Environment, Export, SConscript
if os.name != "nt":
raise RuntimeError("The aligned liblouis build currently supports Windows x64 only")
thirdPartyEnv = Environment(ENV=os.environ, TARGET_ARCH="x86_64", tools=["default", "m4"])
if not thirdPartyEnv.WhereIs("clang-cl"):
raise RuntimeError(
"clang-cl was not found; install Visual Studio 2022 C++ tools and Clang tools for Windows"
)
if not thirdPartyEnv.WhereIs("link"):
raise RuntimeError("MSVC linker was not found; run from a VS 2022 x64 environment")
thirdPartyEnv["nvdaHelperDebugFlags"] = []
thirdPartyEnv["certFile"] = ""
thirdPartyEnv["apiSigningToken"] = ""
thirdPartyEnv["signExec"] = None
thirdPartyEnv["release"] = True
thirdPartyEnv["M4"] = f'"{thirdPartyEnv.File("#miscDeps/tools/m4.exe")}"'
thirdPartyEnv.Append(
CPPDEFINES=[
"UNICODE",
"_CRT_SECURE_NO_DEPRECATE",
("_WIN32_WINNT", "_WIN32_WINNT_WIN10"),
"NOMINMAX",
"NDEBUG",
]
)
thirdPartyEnv.Append(CCFLAGS=["/O2", "/MT"])
thirdPartyEnv.Append(
LINKFLAGS=[
"/incremental:no",
"/WX",
"/subsystem:windows,10.00",
"/release",
"/OPT:REF",
"/OPT:NOICF",
"/EXPORT:lou_freeTableInfo",
"/CETCOMPAT",
]
)
thirdPartyEnv.Append(ARFLAGS=["/WX", "/subsystem:windows,10.00"])
thirdPartyEnv.Append(M4FLAGS="-G")
dist_root_dir = thirdPartyEnv.Dir("#vendor/nvda/liblouis/dist")
build_root_dir = thirdPartyEnv.Dir("#build/liblouis-temp")
client_root_dir = thirdPartyEnv.Dir("#client/braille")
dist_tables_dir = "#vendor/nvda/liblouis/dist/liblouis/tables"
client_tables_dir = "#client/braille/liblouis/tables"
def _remove_liblouis_artifacts(target, source, env):
root = env.Dir("#").abspath
patterns = (
"#vendor/nvda/liblouis/dist",
"#build/liblouis-temp",
"#vendor/nvda/liblouis/build/liblouis.h",
"#vendor/nvda/liblouis/build/liblouis.dll",
"#vendor/nvda/liblouis/build/*.obj",
"#vendor/nvda/liblouis/build/*.lib",
"#vendor/nvda/liblouis/build/*.exp",
"#vendor/nvda/liblouis/build/*.pdb",
"#include/liblouis/liblouis/liblouis.h",
"#client/braille/liblouis.dll",
"#client/braille/liblouis.lib",
"#client/braille/liblouis.exp",
"#client/braille/louis_helper.py",
"#client/braille/liblouis/__init__.py",
"#client/braille/liblouis/tables",
)
for pattern in patterns:
abs_pattern = os.path.join(root, pattern[2:].replace("/", os.sep))
matches = glob.glob(abs_pattern)
if not matches and not glob.has_magic(abs_pattern):
matches = [abs_pattern]
for path in matches:
if os.path.isdir(path):
shutil.rmtree(path, ignore_errors=True)
elif os.path.exists(path):
os.remove(path)
return None
sourceDir = dist_root_dir
buildDir = build_root_dir
Export("thirdPartyEnv", "sourceDir", "buildDir")
build_outputs = SConscript("vendor/nvda/liblouis/build/sconscript")
louis_lib_install, louis_python, louis_tables, *_ = build_outputs
helper_build = thirdPartyEnv.InstallAs(
"#vendor/nvda/liblouis/dist/louis_helper.py", "#vendor/nvda/liblouis/runtime/louis_helper.py"
)
cleanup_dist_tables = thirdPartyEnv.Command("clean-liblouis-dist-tables", [], Delete(dist_tables_dir))
thirdPartyEnv.Requires([louis_python, *louis_tables, helper_build], cleanup_dist_tables)
build = Alias("build", [*louis_lib_install, louis_python, *louis_tables, helper_build, cleanup_dist_tables])
cleanup_client_tables = thirdPartyEnv.Command("clean-liblouis-runtime-tables", [], Delete(client_tables_dir))
client_lib = thirdPartyEnv.Install(client_root_dir, louis_lib_install)
client_python = thirdPartyEnv.Install(client_root_dir.Dir("liblouis"), louis_python)
client_tables = thirdPartyEnv.Install(client_root_dir.Dir("liblouis").Dir("tables"), louis_tables)
client_helper = thirdPartyEnv.Install(client_root_dir, helper_build)
thirdPartyEnv.Requires([*client_lib, *client_python, *client_tables, *client_helper], [build, cleanup_client_tables])
install = Alias("install", [*client_lib, *client_python, *client_tables, *client_helper, cleanup_client_tables])
clean_liblouis = Alias("clean-liblouis", thirdPartyEnv.Command("clean-liblouis-artifacts", [], _remove_liblouis_artifacts))
AlwaysBuild(clean_liblouis)
Default(build)