bug 700693 - OCSP stapling testing r=bsmith
[gecko.git] / build / appini_header.py
blob678c519764efecd26ff1a1def95a27d8d840840f
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'
31 print '''#include "nsXREAppData.h"
32 static const nsXREAppData sAppData = {
33 sizeof(nsXREAppData),
34 NULL, // directory
35 "%(App:vendor)s",
36 "%(App:name)s",
37 "%(App:version)s",
38 "%(App:buildid)s",
39 "%(App:id)s",
40 NULL, // copyright
41 %(flags)s,
42 NULL, // xreDirectory
43 "%(Gecko:minversion)s",
44 "%(Gecko:maxversion)s",
45 "%(Crash Reporter:serverurl)s",
46 %(App:profile)s
47 };''' % appdata
49 if __name__ == '__main__':
50 if len(sys.argv) != 1:
51 main(sys.argv[1])
52 else:
53 print >>sys.stderr, "Usage: %s /path/to/application.ini" % sys.argv[0]