summaryrefslogtreecommitdiffstats
path: root/testing/mozharness/mozharness/mozilla/l10n/multi_locale_build.py
blob: 6b1f8c47827d7686c0fcc7254350e957a4ef68dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env python
# ***** BEGIN LICENSE BLOCK *****
# 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/.
# ***** END LICENSE BLOCK *****
"""multi_locale_build.py

This should be a mostly generic multilocale build script.
"""

import os
import sys

from mozharness.base.errors import MakefileErrorList
from mozharness.base.vcs.vcsbase import MercurialScript
from mozharness.mozilla.l10n.locales import LocalesMixin

sys.path.insert(1, os.path.dirname(os.path.dirname(sys.path[0])))


# MultiLocaleBuild {{{1
class MultiLocaleBuild(LocalesMixin, MercurialScript):
    """This class targets Fennec multilocale builds.
    We were considering this for potential Firefox desktop multilocale.
    Now that we have a different approach for B2G multilocale,
    it's most likely misnamed."""

    config_options = [
        [
            ["--locale"],
            {
                "action": "extend",
                "dest": "locales",
                "type": "string",
                "help": "Specify the locale(s) to repack",
            },
        ],
        [
            ["--objdir"],
            {
                "action": "store",
                "dest": "objdir",
                "type": "string",
                "default": "objdir",
                "help": "Specify the objdir",
            },
        ],
        [
            ["--l10n-base"],
            {
                "action": "store",
                "dest": "hg_l10n_base",
                "type": "string",
                "help": "Specify the L10n repo base directory",
            },
        ],
        [
            ["--l10n-tag"],
            {
                "action": "store",
                "dest": "hg_l10n_tag",
                "type": "string",
                "help": "Specify the L10n tag",
            },
        ],
        [
            ["--tag-override"],
            {
                "action": "store",
                "dest": "tag_override",
                "type": "string",
                "help": "Override the tags set for all repos",
            },
        ],
    ]

    def __init__(self, require_config_file=True):
        LocalesMixin.__init__(self)
        MercurialScript.__init__(
            self,
            config_options=self.config_options,
            all_actions=["pull-locale-source", "package-multi", "summary"],
            require_config_file=require_config_file,
        )

    # pull_locale_source() defined in LocalesMixin.

    def _run_mach_command(self, args):
        dirs = self.query_abs_dirs()

        mach = [sys.executable, "mach"]

        return_code = self.run_command(
            command=mach + ["--log-no-times"] + args,
            cwd=dirs["abs_src_dir"],
        )

        if return_code:
            self.fatal(
                "'mach %s' did not run successfully. Please check "
                "log for errors." % " ".join(args)
            )

    def package_multi(self):
        dirs = self.query_abs_dirs()
        objdir = dirs["abs_obj_dir"]

        # This will error on non-0 exit code.
        locales = list(sorted(self.query_locales()))
        self._run_mach_command(["package-multi-locale", "--locales"] + locales)

        command = "make package-tests AB_CD=multi"
        self.run_command(
            command, cwd=objdir, error_list=MakefileErrorList, halt_on_failure=True
        )
        # TODO deal with buildsymbols


# __main__ {{{1
if __name__ == "__main__":
    pass