Bumping manifests a=b2g-bump
[gecko.git] / build / appini_header.py
blobf97e5da0cd3109a116a48716f14febbc19534c5d
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', 'EnableProfileMigrator') == 1:
17 flags.add('NS_XRE_ENABLE_PROFILE_MIGRATOR')
18 except: pass
19 try:
20 if config.getint('Crash Reporter', 'Enabled') == 1:
21 flags.add('NS_XRE_ENABLE_CRASH_REPORTER')
22 except: pass
23 appdata = dict(("%s:%s" % (s, o), config.get(s, o)) for s in config.sections() for o in config.options(s))
24 appdata['flags'] = ' | '.join(flags) if flags else '0'
25 appdata['App:profile'] = '"%s"' % appdata['App:profile'] if 'App:profile' in appdata else 'NULL'
26 expected = ('App:vendor', 'App:name', 'App:version', 'App:buildid',
27 'App:id', 'Gecko:minversion', 'Gecko:maxversion')
28 missing = [var for var in expected if var not in appdata]
29 if missing:
30 print >>sys.stderr, \
31 "Missing values in %s: %s" % (file, ', '.join(missing))
32 sys.exit(1)
34 if not 'Crash Reporter:serverurl' in appdata:
35 appdata['Crash Reporter:serverurl'] = ''
37 print '''#include "nsXREAppData.h"
38 static const nsXREAppData sAppData = {
39 sizeof(nsXREAppData),
40 NULL, // directory
41 "%(App:vendor)s",
42 "%(App:name)s",
43 "%(App:version)s",
44 "%(App:buildid)s",
45 "%(App:id)s",
46 NULL, // copyright
47 %(flags)s,
48 NULL, // xreDirectory
49 "%(Gecko:minversion)s",
50 "%(Gecko:maxversion)s",
51 "%(Crash Reporter:serverurl)s",
52 %(App:profile)s
53 };''' % appdata
55 if __name__ == '__main__':
56 if len(sys.argv) != 1:
57 main(sys.argv[1])
58 else:
59 print >>sys.stderr, "Usage: %s /path/to/application.ini" % sys.argv[0]