1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 from mozfile
import which
12 from mozboot
.base
import BaseBootstrapper
15 def is_aarch64_host():
16 from ctypes
import wintypes
18 kernel32
= ctypes
.windll
.kernel32
19 IMAGE_FILE_MACHINE_UNKNOWN
= 0
20 IMAGE_FILE_MACHINE_ARM64
= 0xAA64
23 iswow64process2
= kernel32
.IsWow64Process2
25 # If we can't access the symbol, we know we're not on aarch64.
28 currentProcess
= kernel32
.GetCurrentProcess()
29 processMachine
= wintypes
.USHORT(IMAGE_FILE_MACHINE_UNKNOWN
)
30 nativeMachine
= wintypes
.USHORT(IMAGE_FILE_MACHINE_UNKNOWN
)
32 gotValue
= iswow64process2(
33 currentProcess
, ctypes
.byref(processMachine
), ctypes
.byref(nativeMachine
)
35 # If this call fails, we have no idea.
39 return nativeMachine
.value
== IMAGE_FILE_MACHINE_ARM64
42 class WindowsBootstrapper(BaseBootstrapper
):
43 """Bootstrapper for msys2 based environments for building in Windows."""
46 "mingw-w64-x86_64-make",
47 "mingw-w64-x86_64-perl",
53 "mingw-w64-x86_64-toolchain", # TODO: Remove when Mercurial is installable from a wheel.
54 "mingw-w64-i686-toolchain",
57 BROWSER_PACKAGES
= ["mingw-w64-x86_64-nasm", "mingw-w64-i686-nsis"]
59 def __init__(self
, **kwargs
):
61 "MOZ_WINDOWS_BOOTSTRAP" not in os
.environ
62 or os
.environ
["MOZ_WINDOWS_BOOTSTRAP"] != "1"
64 raise NotImplementedError(
65 "Bootstrap support for Windows is under development. For "
66 "now use MozillaBuild to set up a build environment on "
67 "Windows. If you are testing Windows Bootstrap support, "
68 "try `export MOZ_WINDOWS_BOOTSTRAP=1`"
70 BaseBootstrapper
.__init
__(self
, **kwargs
)
71 if not which("pacman"):
72 raise NotImplementedError(
73 "The Windows bootstrapper only works with msys2 with "
74 "pacman. Get msys2 at http://msys2.github.io/"
76 print("Using an experimental bootstrapper for Windows.")
78 def install_system_packages(self
):
79 self
.pacman_install(*self
.SYSTEM_PACKAGES
)
81 def upgrade_mercurial(self
, current
):
82 self
.pip_install("mercurial")
84 def install_browser_packages(self
, mozconfig_builder
):
85 self
.pacman_install(*self
.BROWSER_PACKAGES
)
87 def install_mobile_android_packages(self
, mozconfig_builder
):
88 raise NotImplementedError(
89 "We do not support building Android on Windows. Sorry!"
92 def ensure_mobile_android_packages(self
):
93 raise NotImplementedError(
94 "We do not support building Android on Windows. Sorry!"
97 def install_mobile_android_artifact_mode_packages(self
, mozconfig_builder
):
98 raise NotImplementedError(
99 "We do not support building Android on Windows. Sorry!"
102 def _update_package_manager(self
):
105 def run(self
, command
):
106 subprocess
.check_call(command
, stdin
=sys
.stdin
)
108 def pacman_update(self
):
109 command
= ["pacman", "--sync", "--refresh"]
112 def pacman_upgrade(self
):
113 command
= ["pacman", "--sync", "--refresh", "--sysupgrade"]
116 def pacman_install(self
, *packages
):
117 command
= ["pacman", "--sync", "--needed"]
118 if self
.no_interactive
:
119 command
.append("--noconfirm")
121 command
.extend(packages
)
124 def pip_install(self
, *packages
):
125 command
= ["pip", "install", "--upgrade"]
126 command
.extend(packages
)