summaryrefslogtreecommitdiff
path: root/scripts/export-xcconfig.py
blob: 75fe933e24960287ca45d25e4ec03aff47dfda95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python

import sys, ast, re

ILLEGAL_CHAR_RE = re.compile(r"\W")

def main():
    with open(sys.argv[1], "r") as in_file, open(sys.argv[2], "w") as out_file:
        config = ast.literal_eval(in_file.read())
        variables = ["// Do not edit -- generated by export-xcconfig.py\n"]
        assert(type(config) is dict)
        assert(type(config["variables"]) is dict)
        for variable, flags in config["variables"].iteritems():
            variable = ILLEGAL_CHAR_RE.sub("_", variable.rstrip("%"))
            flags = " ".join('"%s"' % flag for flag in flags)
            variables.append("%s = %s\n" % (variable, flags))
        out_file.writelines(variables)

if __name__ == '__main__':
    main()