Bug 1388894 - Add function in Mach to load commands from files in bulk. r=mhentges

This reduces some code duplication and paves the way for modifying how
Mach loads modules.

The plan is to follow this up by making this function take a more fleshed out 'spec'
that maps command names to the files they're defined at and possibly more metadata.
Since this may affect how Mach works internally (e.g. with lazy loading in the roadmap),
it makes sense to move this logic inside the Mach class.

Differential Revision: https://phabricator.services.mozilla.com/D136789
This commit is contained in:
Alex Lopez
2022-02-02 20:25:20 +00:00
parent d4ba52a78b
commit 9e855ab2e8
3 changed files with 19 additions and 13 deletions

View File

@@ -359,12 +359,7 @@ def initialize(topsrcdir):
repo is not None and repo.sparse_checkout_present()
) or os.path.exists(os.path.join(topsrcdir, "INSTALL"))
for path in MACH_MODULES:
try:
driver.load_commands_from_file(os.path.join(topsrcdir, path))
except mach.base.MissingFileError:
if not missing_ok:
raise
driver.load_commands_from_spec(MACH_MODULES, topsrcdir, missing_ok=missing_ok)
return driver