# Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. # # Use of this source code is governed by a BSD-style license # that can be found in the LICENSE file in the root of the source # tree. An additional intellectual property rights grant can be found # in the file PATENTS. All contributing project authors may # be found in the AUTHORS file in the root of the source tree. """
This tool tries to fix (some) errors reported by `gn gen --check` or
`gn check`. If a command line flag `-C out/<dir>` is supplied, it will run `gn gen --check` in that directory. Otherwise it will run `mb gen` in a temporary directory
which is useful to check for different configurations.
def fix_errors(filename, missing_deps, deleted_sources): with open(filename) as file:
lines = file.readlines()
fixed_file = ''
indentation_level = None for line in lines:
match = TARGET_RE.match(line) if match:
target = match.group('target_name') if target in missing_deps:
indentation_level = match.group('indentation_level') elif indentation_level isnotNone:
match = re.match(indentation_level + '}$', line) if match:
line = ('deps = [\n' + ''.join(' "' + dep + '",\n' for dep in missing_deps[target])
+ ']\n') + line
indentation_level = None elif line.strip().startswith('deps = ['):
joined_deps = ''.join(' "' + dep + '",\n' for dep in missing_deps[target])
line = line.replace('deps = [', 'deps = [' + joined_deps)
indentation_level = None
if line.strip() notin deleted_sources:
fixed_file += line
with open(filename, 'w') as file:
file.write(fixed_file)
Run(['gn', 'format', filename])
def first_non_empty(iterable): """Return first item which evaluates to True, or fallback to None.""" return next((x for x in iterable if x), None)
def rebase(base_path, dependency_path, dependency): """Adapt paths so they work both in stand-alone WebRTC and Chromium tree.
To cope with varying top-level directory (WebRTC VS Chromium), we use:
* relative paths for WebRTC modules.
* absolute paths for shared ones.
E.g. '//common_audio/...' -> '../../common_audio/' '//third_party/...' remains asis.
Args:
base_path: current module path (E.g. '//video')
dependency_path: path from root (E.g. '//rtc_base/time')
dependency: target itself (E.g. 'timestamp_extrapolator')
Returns:
Full target path (E.g. '../rtc_base/time:timestamp_extrapolator'). """
root = first_non_empty(dependency_path.split('/')) if root in CHROMIUM_DIRS: # Chromium paths must remain absolute. E.g. # //third_party//abseil-cpp...
rebased = dependency_path else:
base_path = base_path.split(os.path.sep)
dependency_path = dependency_path.split(os.path.sep)
first_difference = None
shortest_length = min(len(dependency_path), len(base_path)) for i in range(shortest_length): if dependency_path[i] != base_path[i]:
first_difference = i break
def main():
helptext = """
This tool tries to fix (some) errors reported by `gn gen --check`.
If a command line flag `-C out/<dir>` is supplied, it will run `gn gen --check` in that directory. Otherwise it will run `mb gen` in a temporary directory with all other command line arguments forwarded to `mb gen`. This mode is
useful to check for different configurations."""
parser = argparse.ArgumentParser(
description=helptext,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-C',
dest='local_build_dir',
help='Path lo a local build dir, e.g. out/Default')
(flags, argv_to_forward) = parser.parse_known_args(sys.argv[1:])
for error in errors:
error = error.split('\n')
target_msg = 'The target:' if target_msg notin error:
target_msg = 'It is not in any dependency of' if target_msg notin error:
print('\n'.join(error)) continue
index = error.index(target_msg) + 1
path, target = error[index].strip().split(':') if error[index + 1] in ('is including a file from the target:', 'The include file is in the target(s):'):
dep = error[index + 2].strip()
dep_path, dep = dep.split(':')
dep = rebase(path, dep_path, dep) # Replacing /target:target with /target
dep = re.sub(r'/(\w+):(\1)$', r'/\1', dep) # Replacing target:target with target
dep = re.sub(r'^(\w+):(\1)$', r'\1', dep)
path = os.path.join(path[2:], 'BUILD.gn')
errors_by_file[path][target].add(dep) elif error[index + 1] == 'has a source file:':
deleted_file = '"' + os.path.basename(
error[index + 2].strip()) + '",'
deleted_sources.add(deleted_file) else:
print('\n'.join(error)) continue
for path, missing_deps in list(errors_by_file.items()):
fix_errors(path, missing_deps, deleted_sources)
return 0
if __name__ == '__main__':
sys.exit(main())
Messung V0.5
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.