build/clang-plugin/ThirdPartyPaths.py
author Tom Ritter <tom@mozilla.com>
Sat, 19 May 2018 01:26:33 -0500
changeset 475965 bf7ac536eb942fe12ef60f082f20ce30f0ec75a3
parent 405933 bf1c55598c82e26cce1eadbccd066d0510823aee
child 476321 afa720beeefb08b8f0c3e2a7f88fde4530eddd69
permissions -rw-r--r--
Bug 1457162 Remove -TC from CFLAGS r=ted -TC specifies 'treat all inputs at C files' which breaks things when you specify a @list file of inputs. During configure, -TP is required for C++ configure checks (although we could probably make it smart and not need it at all), but -TC does not seem to be required. MozReview-Commit-ID: DNA8vUMdIXb

#!/usr/bin/env python

import json

def generate(output, tpp_txt):
    """
    This file generates a ThirdPartyPaths.cpp file from the ThirdPartyPaths.txt
    file in /tools/rewriting, which is used by the Clang Plugin to help identify
    sources which should be ignored.
    """

    tpp_list = []
    with open(tpp_txt) as f:
        for line in f.readlines():
            line = line.strip()
            if line.endswith('/'):
                line = line[:-1]
            tpp_list.append(line)
    tpp_strings = ',\n  '.join([json.dumps(tpp) for tpp in tpp_list])

    output.write("""\
/* THIS FILE IS GENERATED BY ThirdPartyPaths.py - DO NOT EDIT */

#include <stdint.h>

const char* MOZ_THIRD_PARTY_PATHS[] = {
  %s
};

extern const uint32_t MOZ_THIRD_PARTY_PATHS_COUNT = %d;

""" % (tpp_strings, len(tpp_list)))