3
3
# This file may be used under the terms of the GNU General Public License, version 2 or later.
4
4
# For more details see: https://www.gnu.org/licenses/gpl-2.0.html
5
5
6
+ import glob
7
+ import os
6
8
import sysconfig
7
9
10
+ from SCons.Tool.MSCommon.vc import find_vc_pdir
11
+
8
12
Import(
9
13
"env",
10
14
"sourceDir",
@@ -68,21 +72,23 @@ def COMProxyDllBuilder(env, target, source, proxyClsid):
68
72
69
73
env.AddMethod(COMProxyDllBuilder, "COMProxyDll")
70
74
71
- # We only support compiling with MSVC 14.2 (2019 ) or newer
72
- if not env.get("MSVC_VERSION") or tuple(map(int, env.get("MSVC_VERSION").split("."))) < (14, 2 ):
73
- raise RuntimeError("Visual C++ 14.2 (Visual Studio 2019 ) or newer not found")
75
+ # We only support compiling with MSVC 14.3 (2022 ) or newer
76
+ if not env.get("MSVC_VERSION") or tuple(map(int, env.get("MSVC_VERSION").split("."))) < (14, 3 ):
77
+ raise RuntimeError("Visual C++ 14.3 (Visual Studio 2022 ) or newer not found")
74
78
75
79
PYTHON_PLATFORM = sysconfig.get_platform()
76
80
TARGET_ARCH = env["TARGET_ARCH"]
81
+ isArm64EC = env.get("isArm64EC", False)
77
82
78
83
79
84
isNVDACoreArch = (
80
85
(PYTHON_PLATFORM == "win32" and TARGET_ARCH == "x86")
81
86
or (PYTHON_PLATFORM == "win-amd64" and TARGET_ARCH == "x86_64")
82
87
or (PYTHON_PLATFORM == "win-arm64" and TARGET_ARCH == "arm64")
83
88
)
84
-
85
-
89
+ isNVDAHelperLocalArch = isNVDACoreArch or (
90
+ PYTHON_PLATFORM == "win-amd64" and TARGET_ARCH == "arm64" and isArm64EC
91
+ )
86
92
debug = env["nvdaHelperDebugFlags"]
87
93
release = env["release"]
88
94
signExec = env["signExec"] if (bool(env["certFile"]) ^ bool(env["apiSigningToken"])) else None
@@ -124,7 +130,7 @@ env.Append(
124
130
if TARGET_ARCH == "x86_64":
125
131
env.Append(MIDLFLAGS="/x64")
126
132
elif TARGET_ARCH == "arm64":
127
- env.Append(MIDLFLAGS="/arm64")
133
+ env.Append(MIDLFLAGS="/x64" if isArm64EC else "/ arm64")
128
134
else:
129
135
env.Append(MIDLFLAGS="/win32")
130
136
@@ -146,7 +152,8 @@ if "RTC" in debug:
146
152
# We always want debug symbols
147
153
env.Append(PDB="${TARGET}.pdb")
148
154
env.Append(
149
- LINKFLAGS="/OPT:REF"
155
+ LINKFLAGS="/OPT:REF",
156
+ ARFLAGS="/LTCG"
150
157
) # having symbols usually turns this off but we have no need for unused symbols
151
158
152
159
env.Append(
@@ -160,6 +167,11 @@ env.Append(
160
167
]
161
168
)
162
169
170
+ if isArm64EC:
171
+ env.Append(CCFLAGS="/arm64EC")
172
+ env.Append(LINKFLAGS="/machine:arm64ec")
173
+ env.Append(ARFLAGS="/machine:arm64ec")
174
+
163
175
if "debugCRT" in debug:
164
176
env.Append(CCFLAGS=["/MTd"])
165
177
else:
@@ -221,7 +233,7 @@ Export("detoursLib")
221
233
apiHookObj = env.Object("apiHook", "common/apiHook.cpp")
222
234
Export("apiHookObj")
223
235
224
- if isNVDACoreArch :
236
+ if isNVDAHelperLocalArch :
225
237
localLib = env.SConscript("local/sconscript")
226
238
Export("localLib")
227
239
if signExec:
@@ -250,11 +262,41 @@ if signExec:
250
262
env.AddPostAction(remoteLib[0], [signExec])
251
263
env.Install(libInstallDir, remoteLib)
252
264
253
- remoteLoaderProgram = env.SConscript("remoteLoader/sconscript")
254
- if signExec:
255
- env.AddPostAction(remoteLoaderProgram, [signExec])
256
- env.Install(libInstallDir, remoteLoaderProgram)
265
+ if not isNVDAHelperLocalArch:
266
+ remoteLoaderProgram = env.SConscript("remoteLoader/sconscript")
267
+ if signExec:
268
+ env.AddPostAction(remoteLoaderProgram, [signExec])
269
+ env.Install(libInstallDir, remoteLoaderProgram)
257
270
258
271
if isNVDACoreArch:
259
272
thirdPartyEnv.SConscript("espeak/sconscript")
260
273
thirdPartyEnv.SConscript("liblouis/sconscript")
274
+
275
+ # UWP dlls can only be dynamically linked with the CRT,
276
+ # but some systems might not have this version of the CRT.
277
+ # Therefore, we must include it.
278
+ # VS keeps changing the path to reflect the latest major.minor.build version which we canot easily find out.
279
+ # Therefore Search these versioned directories from newest to oldest to collect all the files we need.
280
+ msvc = env.get("MSVC_VERSION")
281
+ vcRedistDirs = glob.glob(
282
+ os.path.join(
283
+ find_vc_pdir(msvc, env), rf"Redist\MSVC\{msvc[:2]}*\x86\Microsoft.VC{msvc.replace('.', '')}.CRT"
284
+ )
285
+ )
286
+ if len(vcRedistDirs) == 0:
287
+ raise RuntimeError(
288
+ "Could not locate vc redistributables. Perhaps the Universal Windows Platform component in visual Studio is not installed"
289
+ )
290
+ vcRedistDirs.sort(reverse=True)
291
+ for fn in ("msvcp140.dll", "vccorlib140.dll", "vcruntime140.dll"):
292
+ for vcRedistDir in vcRedistDirs:
293
+ path = os.path.join(vcRedistDir, fn)
294
+ if os.path.isfile(path):
295
+ env.Install(sourceDir, path)
296
+ break
297
+ else:
298
+ raise RuntimeError(
299
+ "Could not locate %s. Perhaps the Universal Windows Platform component in visual Studio is not installed"
300
+ % fn
301
+ )
302
+
0 commit comments