bug 1442306 - simplify make-buildinfo-file by letting it assume Mozilla CI. r?build
The `make-buildinfo-file` target is called as part of `make package` to
generate a json file and a text file with some info about the build. Because
a few of those things like the Build ID and source repo / changeset are not
guaranteed to be set at configure time it has to pass them down from the make
environment.
In CI all of these things are passed in the environment, populated at task
graph generation time, so doing this work only in automation builds lets
us simplify things a bit.
MozReview-Commit-ID: 5Ygd3XmSA8x
--- a/toolkit/mozapps/installer/informulate.py
+++ b/toolkit/mozapps/installer/informulate.py
@@ -1,46 +1,46 @@
#!/usr/bin/env python
# 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/.
-import sys
+# Generate build info files for use by other tools.
+# This script assumes it is being run in a Mozilla CI build.
+
+from __future__ import unicode_literals
+
+from argparse import ArgumentParser
import json
import buildconfig
-
-
-def parse_cmdline(args):
- """Take a list of strings in the format K=V and turn them into a python
- dictionary"""
- contents = {}
- for arg in args:
- key, s, value = arg.partition("=")
- if s == '':
- print "ERROR: Malformed command line key value pairing (%s)" % arg
- exit(1)
- contents[key.lower()] = value
- return contents
+import os
def main():
- if len(sys.argv) < 2:
- print "ERROR: You must specify an output file"
- exit(1)
+ parser = ArgumentParser()
+ parser.add_argument('output', help='Output file')
+ # TODO: Move package-name.mk variables into moz.configure.
+ parser.add_argument('pkg_platform', help='Package platform identifier')
+ args = parser.parse_args()
- all_key_value_pairs = {}
important_substitutions = [
'target_alias', 'target_cpu', 'target_os', 'target_vendor',
'host_alias', 'host_cpu', 'host_os', 'host_vendor',
'MOZ_UPDATE_CHANNEL', 'MOZ_APP_VENDOR', 'MOZ_APP_NAME',
'MOZ_APP_VERSION', 'MOZ_APP_MAXVERSION', 'MOZ_APP_ID',
- 'CC', 'CXX', 'AS']
+ 'CC', 'CXX', 'AS', 'MOZ_SOURCE_REPO',
+ ]
- all_key_value_pairs = dict([(x.lower(), buildconfig.substs[x]) for x in important_substitutions])
- all_key_value_pairs.update(parse_cmdline(sys.argv[2:]))
+ all_key_value_pairs = {x.lower(): buildconfig.substs[x]
+ for x in important_substitutions}
+ all_key_value_pairs.update({
+ 'buildid': os.environ['MOZ_BUILD_DATE'],
+ 'moz_source_stamp': buildconfig.substs['MOZ_SOURCE_CHANGESET'],
+ 'moz_pkg_platform': args.pkg_platform,
+ })
- with open(sys.argv[1], "w+") as f:
+ with open(args.output, 'wb') as f:
json.dump(all_key_value_pairs, f, indent=2, sort_keys=True)
f.write('\n')
-if __name__=="__main__":
+if __name__ == '__main__':
main()
--- a/toolkit/mozapps/installer/packager.mk
+++ b/toolkit/mozapps/installer/packager.mk
@@ -99,23 +99,21 @@ make-sourcestamp-file::
$(NSINSTALL) -D $(DIST)/$(PKG_PATH)
@echo '$(BUILDID)' > $(MOZ_SOURCESTAMP_FILE)
ifdef MOZ_INCLUDE_SOURCE_INFO
@awk '$$2 == "MOZ_SOURCE_URL" {print $$3}' $(DEPTH)/source-repo.h >> $(MOZ_SOURCESTAMP_FILE)
endif
.PHONY: make-buildinfo-file
make-buildinfo-file:
+ifdef MOZ_AUTOMATION
$(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/informulate.py \
- $(MOZ_BUILDINFO_FILE) \
- BUILDID=$(BUILDID) \
- $(addprefix MOZ_SOURCE_REPO=,$(shell awk '$$2 == "MOZ_SOURCE_REPO" {print $$3}' $(DEPTH)/source-repo.h)) \
- MOZ_SOURCE_STAMP=$(shell awk '$$2 == "MOZ_SOURCE_STAMP" {print $$3}' $(DEPTH)/source-repo.h) \
- MOZ_PKG_PLATFORM=$(MOZ_PKG_PLATFORM)
+ $(MOZ_BUILDINFO_FILE) $(MOZ_PKG_PLATFORM)
echo "buildID=$(BUILDID)" > $(MOZ_BUILDID_INFO_TXT_FILE)
+endif
.PHONY: make-mozinfo-file
make-mozinfo-file:
cp $(DEPTH)/mozinfo.json $(MOZ_MOZINFO_FILE)
# The install target will install the application to prefix/lib/appname-version
install:: prepare-package
ifeq ($(OS_ARCH),WINNT)