third_party/blink/tools/blinkpy/web_tests/port/factory.py
def _read_configuration_from_gn(fs, options):
    """Returns the configuration to used based on args.gn, if possible."""
    build_directory = getattr(options, 'build_directory', 'out')
    target = options.target
    finder = PathFinder(fs)
    path = fs.join(finder.chromium_base(), build_directory, target, 'args.gn')
    if not fs.exists(path):
        path = fs.join(finder.chromium_base(), build_directory, target,
                       'toolchain.ninja')
        if not fs.exists(path):
            # This does not appear to be a GN-based build directory, so we don't know
            # how to interpret it.
            return None

        # toolchain.ninja exists, but args.gn does not; this can happen when
        # `gn gen` is run with no --args.
        return 'Debug'

    args = fs.read_text_file(path)
    for line in args.splitlines():
        if re.match(r'^\s*is_debug\s*=\s*false(\s*$|\s*#.*$)', line):
            return 'Release'

    # If is_debug is set to anything other than false, or if it
    # does not exist at all, we should use the default value (True).
    return 'Debug'
Returns the configuration to used based on args.gn, if possible.
Returns the configuration to used based on args.gn, if possible.
Returns the configuration to used based on args . gn if possible .
def _read_configuration_from_gn(fs, options):
    build_directory = getattr(options, 'build_directory', 'out')
    target = options.target
    finder = PathFinder(fs)
    path = fs.join(finder.chromium_base(), build_directory, target, 'args.gn')
    if not fs.exists(path):
        path = fs.join(finder.chromium_base(), build_directory, target,
                       'toolchain.ninja')
        if not fs.exists(path):
            return None
        return 'Debug'
    args = fs.read_text_file(path)
    for line in args.splitlines():
        if re.match(r'^\s*is_debug\s*=\s*false(\s*$|\s*#.*$)', line):
            return 'Release'
    return 'Debug'
def _read_configuration_from_gn ( fs , options ) : build_directory = getattr ( options , 'build_directory' , 'out' ) target = options . target finder = PathFinder ( fs ) path = fs . join ( finder . chromium_base ( ) , build_directory , target , 'args.gn' ) if not fs . exists ( path ) : path = fs . join ( finder . chromium_base ( ) , build_directory , target , 'toolchain.ninja' ) if not fs . exists ( path ) : return None return 'Debug' args = fs . read_text_file ( path ) for line in args . splitlines ( ) : if re . match ( r'^\s*is_debug\s*=\s*false(\s*$|\s*#.*$)' , line ) : return 'Release' return 'Debug'
Returns the configuration to used based on args.gn, if possible.
Returns the configuration to used based on args . gn if possible .
"""Returns the configuration to used based on args.gn, if possible.""" # This does not appear to be a GN-based build directory, so we don't know # how to interpret it. # toolchain.ninja exists, but args.gn does not; this can happen when # `gn gen` is run with no --args. # If is_debug is set to anything other than false, or if it # does not exist at all, we should use the default value (True).
fs
options