summaryrefslogtreecommitdiffstats
path: root/build/appini_header.py
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /build/appini_header.py
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'build/appini_header.py')
-rw-r--r--build/appini_header.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/build/appini_header.py b/build/appini_header.py
new file mode 100644
index 000000000..356a0692e
--- /dev/null
+++ b/build/appini_header.py
@@ -0,0 +1,60 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+'''Parses a given application.ini file and outputs the corresponding
+ XULAppData structure as a C++ header file'''
+
+import ConfigParser
+import sys
+
+def main(output, file):
+ config = ConfigParser.RawConfigParser()
+ config.read(file)
+ flags = set()
+ try:
+ if config.getint('XRE', 'EnableProfileMigrator') == 1:
+ flags.add('NS_XRE_ENABLE_PROFILE_MIGRATOR')
+ except: pass
+ try:
+ if config.getint('Crash Reporter', 'Enabled') == 1:
+ flags.add('NS_XRE_ENABLE_CRASH_REPORTER')
+ except: pass
+ appdata = dict(("%s:%s" % (s, o), config.get(s, o)) for s in config.sections() for o in config.options(s))
+ appdata['flags'] = ' | '.join(flags) if flags else '0'
+ appdata['App:profile'] = '"%s"' % appdata['App:profile'] if 'App:profile' in appdata else 'NULL'
+ expected = ('App:vendor', 'App:name', 'App:remotingname', 'App:version', 'App:buildid',
+ 'App:id', 'Gecko:minversion', 'Gecko:maxversion')
+ missing = [var for var in expected if var not in appdata]
+ if missing:
+ print >>sys.stderr, \
+ "Missing values in %s: %s" % (file, ', '.join(missing))
+ sys.exit(1)
+
+ if not 'Crash Reporter:serverurl' in appdata:
+ appdata['Crash Reporter:serverurl'] = ''
+
+ output.write('''#include "nsXREAppData.h"
+ static const nsXREAppData sAppData = {
+ sizeof(nsXREAppData),
+ NULL, // directory
+ "%(App:vendor)s",
+ "%(App:name)s",
+ "%(App:remotingname)s",
+ "%(App:version)s",
+ "%(App:buildid)s",
+ "%(App:id)s",
+ NULL, // copyright
+ %(flags)s,
+ NULL, // xreDirectory
+ "%(Gecko:minversion)s",
+ "%(Gecko:maxversion)s",
+ "%(Crash Reporter:serverurl)s",
+ %(App:profile)s
+ };''' % appdata)
+
+if __name__ == '__main__':
+ if len(sys.argv) != 1:
+ main(sys.stdout, sys.argv[1])
+ else:
+ print >>sys.stderr, "Usage: %s /path/to/application.ini" % sys.argv[0]