toolkit/mozapps/installer/informulate.py

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 #!/usr/bin/env python
     2 # This Source Code Form is subject to the terms of the Mozilla Public
     3 # License, v. 2.0. If a copy of the MPL was not distributed with this
     4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     6 import sys
     7 import json
     8 import buildconfig
    11 def parse_cmdline(args):
    12     """Take a list of strings in the format K=V and turn them into a python
    13     dictionary"""
    14     contents = {}
    15     for arg in args:
    16         key, s, value = arg.partition("=")
    17         if s == '':
    18             print "ERROR: Malformed command line key value pairing (%s)" % arg
    19             exit(1)
    20         contents[key.lower()] = value
    21     return contents
    24 def main():
    25     if len(sys.argv) < 2:
    26         print "ERROR: You must specify an output file"
    27         exit(1)
    29     all_key_value_pairs = {}
    30     important_substitutions = [
    31         'target_alias', 'target_cpu', 'target_os', 'target_vendor',
    32         'host_alias', 'host_cpu', 'host_os', 'host_vendor',
    33         'MOZ_UPDATE_CHANNEL', 'MOZ_APP_VENDOR', 'MOZ_APP_NAME',
    34         'MOZ_APP_VERSION', 'MOZ_APP_MAXVERSION', 'MOZ_APP_ID',
    35         'CC', 'CXX', 'LD', 'AS']
    37     all_key_value_pairs = dict([(x.lower(), buildconfig.substs[x]) for x in important_substitutions])
    38     all_key_value_pairs.update(parse_cmdline(sys.argv[2:]))
    40     with open(sys.argv[1], "w+") as f:
    41         json.dump(all_key_value_pairs, f, indent=2, sort_keys=True)
    42         f.write('\n')
    45 if __name__=="__main__":
    46     main()

mercurial