Skip to content

Commit

Permalink
windows arm64 build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nulano committed Nov 16, 2023
1 parent da0b826 commit d794ef9
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions winbuild/build_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ def cmd_msbuild(
"(LEGAL ISSUES\n============\n\n.+?)\n\nREFERENCES\n=========="
".+(libjpeg-turbo Licenses\n======================\n\n.+)$"
),
"patch": {
r"CMakeLists.txt": {
# libjpeg-turbo does not detect MSVC x86_arm64 cross-compiler correctly
'if(MSVC_IDE AND CMAKE_GENERATOR_PLATFORM MATCHES "arm64")': "if({architecture} STREQUAL ARM64)", # noqa: E501
},
},
"build": [
*cmds_cmake(
("jpeg-static", "cjpeg-static", "djpeg-static"),
Expand Down Expand Up @@ -327,6 +333,8 @@ def cmd_msbuild(
"CMakeLists.txt": {
"if(OPENMP_FOUND)": "if(false)",
"install": "#install",
# libimagequant does not detect MSVC x86_arm64 cross-compiler correctly
"if(${{CMAKE_SYSTEM_PROCESSOR}} STREQUAL ARM64)": "if({architecture} STREQUAL ARM64)", # noqa: E501
}
},
"build": [
Expand Down Expand Up @@ -367,12 +375,17 @@ def cmd_msbuild(


# based on distutils._msvccompiler from CPython 3.7.4
def find_msvs() -> dict[str, str] | None:
def find_msvs(architecture) -> dict[str, str] | None:
root = os.environ.get("ProgramFiles(x86)") or os.environ.get("ProgramFiles")
if not root:
print("Program Files not found")
return None

if architecture == "ARM64":
tools = "Microsoft.VisualStudio.Component.VC.Tools.ARM64"
else:
tools = "Microsoft.VisualStudio.Component.VC.Tools.x86.x64"

try:
vspath = (
subprocess.check_output(
Expand All @@ -383,7 +396,7 @@ def find_msvs() -> dict[str, str] | None:
"-latest",
"-prerelease",
"-requires",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
tools,
"-property",
"installationPath",
"-products",
Expand Down Expand Up @@ -654,7 +667,7 @@ def build_dep_all() -> None:
arch_prefs = ARCHITECTURES[args.architecture]
print("Target architecture:", args.architecture)

msvs = find_msvs()
msvs = find_msvs(args.architecture)
if msvs is None:
msg = "Visual Studio not found. Please install Visual Studio 2017 or newer."
raise RuntimeError(msg)
Expand Down Expand Up @@ -689,6 +702,11 @@ def build_dep_all() -> None:
disabled += ["libimagequant"]
if args.no_fribidi:
disabled += ["fribidi"]
elif args.architecture == "ARM64" and platform.machine() != "ARM64":
print(
"\nWarning: Cross-compiling FriBiDi is currently not supported, disabling"
)
disabled += ["fribidi"]

prefs = {
"architecture": args.architecture,
Expand Down

0 comments on commit d794ef9

Please sign in to comment.