Skip to content

Commit 4f48688

Browse files
Support setting the version with the MOZC_VERSION action_env variable.
* The version can be set with `--action_env`. + e.g. Bazel build package --action_env=MOZC_VERSION="2.31.5810.0" #codehealth PiperOrigin-RevId: 815576135
1 parent fa1d59f commit 4f48688

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/base/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ mozc_run_build_tool(
741741
outs = {
742742
"--output": "mozc_version.txt",
743743
},
744-
args = mozc_select(
744+
args = ["--use_mozc_version_env"] + mozc_select(
745745
android = ["--target_platform=Android"],
746746
chromiumos = ["--target_platform=ChromeOS"],
747747
default = ["--target_platform="],

src/build_tools/mozc_version.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,17 @@ def main():
345345
parser = optparse.OptionParser(usage='Usage: %prog ')
346346
parser.add_option('--template_path', dest='template_path',
347347
help='Path to a template version file.')
348+
parser.add_option(
349+
'--use_mozc_version_env',
350+
dest='use_mozc_version_env',
351+
action='store_true',
352+
help=(
353+
'If true and MOZC_VERSION environment variable is set, the variable'
354+
' is used as the version string. Otherwise the template file is used.'
355+
' The value is a four-digit number (e.g. 2.31.5840.0) or a single'
356+
' build number (e.g. 5840).'
357+
),
358+
)
348359
parser.add_option('--output', dest='output',
349360
help='Path to the output version file.')
350361
parser.add_option('--target_platform', dest='target_platform',
@@ -359,13 +370,18 @@ def main():
359370
assert options.output, 'No --output was specified.'
360371
assert options.target_platform, 'No --target_platform was specified.'
361372

362-
cl_number = _GetChangelistNumber(options.build_override,
363-
options.build_changelist_file)
373+
mozc_version_env = os.getenv('MOZC_VERSION')
374+
if options.use_mozc_version_env and mozc_version_env:
375+
version_override = mozc_version_env
376+
else:
377+
version_override = _GetChangelistNumber(
378+
options.build_override, options.build_changelist_file
379+
)
364380
GenerateVersionFile(
365381
version_template_path=options.template_path,
366382
version_path=options.output,
367383
target_platform=options.target_platform,
368-
version_override=cl_number)
384+
version_override=version_override)
369385

370386
if __name__ == '__main__':
371387
main()

0 commit comments

Comments
 (0)