config/system_header_util.py
author Dave Townsend <dtownsend@oxymoronical.com>
Mon, 10 Dec 2018 11:05:01 -0800
changeset 449725 c8d6599f45706bf05bebe60c068f8027f69baaee
parent 447669 b6c97b4db60a1d8169a3e798a248144ab2973506
child 481687 9c5b3c7e1ca2240f765d62466cc917ad778407ef
permissions -rw-r--r--
Bug 1513036: Ignore files generated in the source tree by lalrpop. r=ted

import os


def find_in_path(file, searchpath):
    for dir in searchpath.split(os.pathsep):
        f = os.path.join(dir, file)
        if os.path.exists(f):
            return f
    return ''


def header_path(header, compiler):
    if compiler == 'gcc':
        # we use include_next on gcc
        return header
    elif compiler == 'msvc':
        return find_in_path(header, os.environ.get('INCLUDE', ''))
    else:
        # hope someone notices this ...
        raise NotImplementedError(compiler)