build/appini_header.py

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 # This Source Code Form is subject to the terms of the Mozilla Public
     2 # License, v. 2.0. If a copy of the MPL was not distributed with this
     3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     5 '''Parses a given application.ini file and outputs the corresponding
     6    XULAppData structure as a C++ header file'''
     8 import ConfigParser
     9 import sys
    11 def main(file):
    12     config = ConfigParser.RawConfigParser()
    13     config.read(file)
    14     flags = set()
    15     try:
    16         if config.getint('XRE', 'EnableExtensionManager') == 1:
    17             flags.add('NS_XRE_ENABLE_EXTENSION_MANAGER')
    18     except: pass
    19     try:
    20         if config.getint('XRE', 'EnableProfileMigrator') == 1:
    21             flags.add('NS_XRE_ENABLE_PROFILE_MIGRATOR')
    22     except: pass
    23     try:
    24         if config.getint('Crash Reporter', 'Enabled') == 1:
    25             flags.add('NS_XRE_ENABLE_CRASH_REPORTER')
    26     except: pass
    27     appdata = dict(("%s:%s" % (s, o), config.get(s, o)) for s in config.sections() for o in config.options(s))
    28     appdata['flags'] = ' | '.join(flags) if flags else '0'
    29     appdata['App:profile'] = '"%s"' % appdata['App:profile'] if 'App:profile' in appdata else 'NULL'
    30     expected = ('App:vendor', 'App:name', 'App:version', 'App:buildid',
    31                 'App:id', 'Gecko:minversion', 'Gecko:maxversion')
    32     missing = [var for var in expected if var not in appdata]
    33     if missing:
    34         print >>sys.stderr, \
    35             "Missing values in %s: %s" % (file, ', '.join(missing))
    36         sys.exit(1)
    38     if not 'Crash Reporter:serverurl' in appdata:
    39         appdata['Crash Reporter:serverurl'] = ''
    41     print '''#include "nsXREAppData.h"
    42              static const nsXREAppData sAppData = {
    43                  sizeof(nsXREAppData),
    44                  NULL, // directory
    45                  "%(App:vendor)s",
    46                  "%(App:name)s",
    47                  "%(App:version)s",
    48                  "%(App:buildid)s",
    49                  "%(App:id)s",
    50                  NULL, // copyright
    51                  %(flags)s,
    52                  NULL, // xreDirectory
    53                  "%(Gecko:minversion)s",
    54                  "%(Gecko:maxversion)s",
    55                  "%(Crash Reporter:serverurl)s",
    56                  %(App:profile)s
    57              };''' % appdata
    59 if __name__ == '__main__':
    60     if len(sys.argv) != 1:
    61         main(sys.argv[1])
    62     else:
    63         print >>sys.stderr, "Usage: %s /path/to/application.ini" % sys.argv[0]

mercurial