Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
args = _parse_args()
# Build lookup map
manifest = ninja.load_manifest_from_args(args)
graph = {}
for build in manifest.builds:
for path in build.explicit_outs:
graph[path] = build
for path in build.implicit_outs:
graph[path] = build
# List all transitive targets
try:
builds = collect_build_targets(graph, args.target)
except KeyError:
print('error: Failed to find the target {}'.format(arg.target),
file=sys.stderr)
sys.exit(1)
# Print all targets
out_dir = posixpath.normpath(args.out_dir)
out_dir_pattern = re.compile(re.escape(out_dir) + '/')
out_host_dir_pattern = re.compile(re.escape(out_dir) + '/host/')
out_product_dir = out_dir + '/target/product/[^/]+'
def _normalize_path(path):
if path.startswith(out_dir + '/target'):
return path
return posixpath.join(out_product_dir, path)
installed_filter = [_normalize_path(path) for path in args.installed_filter]
installed_filter = re.compile(
'|'.join('(?:' + p + ')' for p in installed_filter))
manifest = ninja.load_manifest_from_args(args)
# Build lookup map
graph = {}
for build in manifest.builds:
for path in build.explicit_outs:
graph[path] = build
for path in build.implicit_outs:
graph[path] = build
# Collect all matching outputs
matched_files = [path for path in graph if installed_filter.match(path)]
matched_files.sort()
for path in matched_files:
source_files = collect_source_files(
graph, path, out_dir_pattern, out_host_dir_pattern)