diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/build/mach_initialize.py | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream/1%115.7.0.tar.xz thunderbird-upstream/1%115.7.0.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/build/mach_initialize.py')
-rw-r--r-- | comm/build/mach_initialize.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/comm/build/mach_initialize.py b/comm/build/mach_initialize.py new file mode 100644 index 0000000000..17d2019ca6 --- /dev/null +++ b/comm/build/mach_initialize.py @@ -0,0 +1,64 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +""" +mach_initialize.py + +This file contains initialization code for mach commands that are outside of +the Firefox source repository. +""" + +import os +import sys + +from build import mach_initialize as mach_init + +# Individual files that provide mach commands +MACH_MODULES = [ + "comm/python/l10n/mach_commands.py", + "comm/tools/lint/mach_commands.py", + "comm/tools/esmify/mach_commands.py", + "comm/mail/components/storybook/mach_commands.py", +] + +CATEGORIES = { + "thunderbird": { + "short": "Thunderbird Development", + "long": "Mach commands that aid Thunderbird Development", + "priority": 65, + }, +} + + +def mach_sys_path(mozilla_dir): + from mach.requirements import MachEnvRequirements + + requirements = MachEnvRequirements.from_requirements_definition( + mozilla_dir, + True, # is_thunderbird + False, + os.path.join(mozilla_dir, "comm/python/sites/tb_common.txt"), + ) + return sorted( + [ + os.path.normcase(os.path.join(mozilla_dir, pth.path)) + for pth in requirements.pth_requirements + ] + ) + + +def initialize(topsrcdir): + driver = mach_init.initialize(topsrcdir) + + # Add comm Python module paths + sys.path.extend(mach_sys_path(topsrcdir)) + + # Define Thunderbird mach command categories + for category, meta in CATEGORIES.items(): + driver.define_category(category, meta["short"], meta["long"], meta["priority"]) + + for path in MACH_MODULES: + driver.load_commands_from_file(os.path.join(topsrcdir, path)) + + return driver |