forked from mirrors/gecko-dev
Bug 1866711 - On Windows, check that topsrcdir is on a ReFS drive (Dev Drive) during bootstrap r=firefox-build-system-reviewers,nalexander
The use of input() to pause the text scrolling is intentional. Users might otherwise not see the message. It ensures the user makes an informed decision and either switches to a Dev Drive, or hides the recommendation. Differential Revision: https://phabricator.services.mozilla.com/D194716
This commit is contained in:
parent
acc3d6027d
commit
004a78a943
1 changed files with 93 additions and 0 deletions
|
|
@ -162,6 +162,25 @@ We recommend upgrading to at least version "{minimum_recommended_version}" to im
|
|||
performance.
|
||||
""".strip()
|
||||
|
||||
# Dev Drives were added in 22621.2338 and should be available in all subsequent versions
|
||||
DEV_DRIVE_MINIMUM_VERSION = Version("10.0.22621.2338")
|
||||
DEV_DRIVE_SUGGESTION = """
|
||||
Mach has detected that the Firefox source repository ({}) is located on an {} drive.
|
||||
Your current version of Windows ({}) supports ReFS drives (Dev Drive).
|
||||
|
||||
It has been shown that Firefox builds are 5-10% faster on
|
||||
ReFS, it is recommended that you create an ReFS drive and move the Firefox
|
||||
source repository to it before proceeding.
|
||||
|
||||
The instructions for how to do that can be found here: https://learn.microsoft.com/en-us/windows/dev-drive/
|
||||
|
||||
If you wish disregard this recommendation, you can hide this message by setting
|
||||
'MACH_HIDE_DEV_DRIVE_SUGGESTION=1' in your environment variables (and restarting your shell)."""
|
||||
DEV_DRIVE_DETECTION_ERROR = """
|
||||
Error encountered while checking for Dev Drive.
|
||||
Reason: {} (skipping)
|
||||
"""
|
||||
|
||||
|
||||
def check_for_hgrc_state_dir_mismatch(state_dir):
|
||||
ignore_hgrc_state_dir_mismatch = os.environ.get(
|
||||
|
|
@ -419,6 +438,9 @@ class Bootstrapper(object):
|
|||
self.instance.validate_environment()
|
||||
self._validate_python_environment(checkout_root)
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
self._check_for_dev_drive(checkout_root)
|
||||
|
||||
if self.instance.no_system_changes:
|
||||
self.maybe_install_private_packages_or_exit(application, checkout_type)
|
||||
self._output_mozconfig(application, mozconfig_builder)
|
||||
|
|
@ -484,6 +506,77 @@ class Bootstrapper(object):
|
|||
% name
|
||||
)
|
||||
|
||||
def _check_for_dev_drive(self, topsrcdir):
|
||||
def extract_windows_version_number(raw_ver_output):
|
||||
pattern = re.compile(r"\bVersion (\d+(\.\d+)*)\b")
|
||||
match = pattern.search(raw_ver_output)
|
||||
|
||||
if match:
|
||||
windows_version_number = match.group(1)
|
||||
return Version(windows_version_number)
|
||||
|
||||
return Version("0")
|
||||
|
||||
if os.environ.get("MACH_HIDE_DEV_DRIVE_SUGGESTION"):
|
||||
return
|
||||
|
||||
print("Checking for Dev Drive...")
|
||||
|
||||
try:
|
||||
ver_output = subprocess.run(
|
||||
["cmd.exe", "/c", "ver"], capture_output=True, text=True, check=True
|
||||
).stdout
|
||||
current_windows_version = extract_windows_version_number(ver_output)
|
||||
|
||||
if current_windows_version < DEV_DRIVE_MINIMUM_VERSION:
|
||||
return
|
||||
|
||||
topsrcdir_drive_letter = Path(topsrcdir).drive[0]
|
||||
|
||||
volume_info = subprocess.run(
|
||||
[
|
||||
"powershell",
|
||||
"-command",
|
||||
"Get-Volume",
|
||||
"-DriveLetter",
|
||||
topsrcdir_drive_letter,
|
||||
],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
).stdout
|
||||
volume_info = volume_info.lstrip().rstrip().split("\n")
|
||||
type_index = volume_info[0].find("FileSystemType")
|
||||
file_system_type = volume_info[2][type_index : type_index + 4]
|
||||
drive_letter_index = volume_info[0].find("DriveLetter")
|
||||
drive_letter = volume_info[2][drive_letter_index]
|
||||
|
||||
if topsrcdir_drive_letter == drive_letter:
|
||||
if file_system_type == "ReFS":
|
||||
print(" The Firefox source repository is on a Dev Drive.")
|
||||
else:
|
||||
print(
|
||||
DEV_DRIVE_SUGGESTION.format(
|
||||
topsrcdir, file_system_type, current_windows_version
|
||||
)
|
||||
)
|
||||
if self.instance.no_interactive:
|
||||
pass
|
||||
else:
|
||||
input("\nPress enter to continue.")
|
||||
else:
|
||||
print(
|
||||
DEV_DRIVE_DETECTION_ERROR.format(
|
||||
"Drive letter mismatch. Did 'Get-Volume' output change?"
|
||||
)
|
||||
)
|
||||
|
||||
except subprocess.CalledProcessError as error:
|
||||
print(
|
||||
DEV_DRIVE_DETECTION_ERROR.format(f"CalledProcessError: {error.stderr}")
|
||||
)
|
||||
pass
|
||||
|
||||
def _default_mozconfig_path(self):
|
||||
return Path(self.mach_context.topdir) / "mozconfig"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue