build/clang-plugin/ThirdPartyPaths.py
author Emilio Cobos Álvarez <emilio@crisal.io>
Sat, 08 Aug 2020 16:21:35 +0000
changeset 544015 b579c12907dc3bb210177454a696ccc181c1ded0
parent 514987 7d9b567c6bf4deac7981cc234b7bd992c3e966df
permissions -rw-r--r--
Bug 1657437 - Don't treat lone CRs as segment breaks. r=jfkthame That prevents preceding whitespace from getting collapsed. When there's a single lone CR (so `a\rb`) our behavior here diverges from Chrome's but matches Safari's. We treat it as ZWSP. That matches the initial resolution of [1], but then there have been various doing and undoings of that resolution, so it's not totally clear to me what the correct behavior per spec should be. I think "treat it as other control character"? But I haven't dug into what that implies, so for now I've just kept behavior there as-is. [1]: https://github.com/w3c/csswg-drafts/issues/855 Differential Revision: https://phabricator.services.mozilla.com/D86188

#!/usr/bin/env python3

import json


def generate(output, *input_paths):
    """
    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 = []
    lines = set()

    for path in input_paths:
        with open(path) as f:
            lines.update(f.readlines())

    for line in lines:
        line = line.strip()
        if line.endswith('/'):
            line = line[:-1]
        tpp_list.append(line)
    tpp_strings = ',\n  '.join([json.dumps(tpp) for tpp in sorted(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)))