1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/installer/informulate.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 1.4 +#!/usr/bin/env python 1.5 +# This Source Code Form is subject to the terms of the Mozilla Public 1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + 1.9 +import sys 1.10 +import json 1.11 +import buildconfig 1.12 + 1.13 + 1.14 +def parse_cmdline(args): 1.15 + """Take a list of strings in the format K=V and turn them into a python 1.16 + dictionary""" 1.17 + contents = {} 1.18 + for arg in args: 1.19 + key, s, value = arg.partition("=") 1.20 + if s == '': 1.21 + print "ERROR: Malformed command line key value pairing (%s)" % arg 1.22 + exit(1) 1.23 + contents[key.lower()] = value 1.24 + return contents 1.25 + 1.26 + 1.27 +def main(): 1.28 + if len(sys.argv) < 2: 1.29 + print "ERROR: You must specify an output file" 1.30 + exit(1) 1.31 + 1.32 + all_key_value_pairs = {} 1.33 + important_substitutions = [ 1.34 + 'target_alias', 'target_cpu', 'target_os', 'target_vendor', 1.35 + 'host_alias', 'host_cpu', 'host_os', 'host_vendor', 1.36 + 'MOZ_UPDATE_CHANNEL', 'MOZ_APP_VENDOR', 'MOZ_APP_NAME', 1.37 + 'MOZ_APP_VERSION', 'MOZ_APP_MAXVERSION', 'MOZ_APP_ID', 1.38 + 'CC', 'CXX', 'LD', 'AS'] 1.39 + 1.40 + all_key_value_pairs = dict([(x.lower(), buildconfig.substs[x]) for x in important_substitutions]) 1.41 + all_key_value_pairs.update(parse_cmdline(sys.argv[2:])) 1.42 + 1.43 + with open(sys.argv[1], "w+") as f: 1.44 + json.dump(all_key_value_pairs, f, indent=2, sort_keys=True) 1.45 + f.write('\n') 1.46 + 1.47 + 1.48 +if __name__=="__main__": 1.49 + main()