-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[build] Track glob dependencies via depfiles, instead of always re-ex…
…ecuting scripts at GN time. Bug: flutter/flutter#81074 Change-Id: I3fba7743f89b970dfd8d4d47b21f7d51be7a9cdb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196981 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Chinmay Garde <chinmaygarde@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com>
- Loading branch information
1 parent
4e2fac9
commit 8d436a2
Showing
3 changed files
with
67 additions
and
27 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | ||
# for details. All rights reserved. Use of this source code is governed by a | ||
# BSD-style license that can be found in the LICENSE file. | ||
"""Tool for listing Dart source files. | ||
If the first argument is 'relative', the script produces paths relative to the | ||
current working directory. If the first argument is 'absolute', the script | ||
produces absolute paths. | ||
Usage: | ||
python3 tools/list_dart_files_as_depfile.py <depfile> <directory> <pattern> | ||
""" | ||
|
||
import os | ||
import re | ||
import sys | ||
|
||
|
||
def main(argv): | ||
depfile = argv[1] | ||
directory = argv[2] | ||
if not os.path.isabs(directory): | ||
directory = os.path.realpath(directory) | ||
|
||
pattern = None | ||
if len(argv) > 3: | ||
pattern = re.compile(argv[3]) | ||
|
||
# Output a GN depfile, whose format is a Makefile with one target. | ||
out = open(depfile, 'w') | ||
out.write(depfile) | ||
out.write(":") | ||
|
||
for root, directories, files in os.walk(directory): | ||
# We only care about actual source files, not generated code or tests. | ||
for skip_dir in ['.git', 'gen', 'test']: | ||
if skip_dir in directories: | ||
directories.remove(skip_dir) | ||
|
||
# If we are looking at the root directory, filter the immediate | ||
# subdirectories by the given pattern. | ||
if pattern and root == directory: | ||
directories[:] = filter(pattern.match, directories) | ||
|
||
for filename in files: | ||
if filename.endswith( | ||
'.dart') and not filename.endswith('_test.dart'): | ||
fullname = os.path.join(directory, root, filename) | ||
fullname = fullname.replace(os.sep, '/') | ||
out.write(" \"") | ||
out.write(fullname) | ||
out.write("\"") | ||
|
||
out.write("\n") | ||
out.close() | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main(sys.argv)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters