mirror of
https://github.com/dart-lang/sdk
synced 2024-07-01 07:14:29 +00:00
Reapply "[build] Track glob dependencies via depfiles, instead of always re-executing scripts at GN time."
Use a relative path for the depfile's target to match Ninja's expectation; otherwise it thinks the target is always dirty. TEST=build twice Bug: https://github.com/flutter/flutter/issues/81074 Change-Id: I4cae7ab55f79b5206521c7090502c0769d2b5277 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198443 Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
634cccccc6
commit
a22d5b98fd
|
@ -1,19 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2013, 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.
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
def main(args):
|
||||
for file_name in args[1:]:
|
||||
dir_name = os.path.dirname(file_name)
|
||||
if not os.path.exists(dir_name):
|
||||
os.mkdir(dir_name)
|
||||
open(file_name, 'w').close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
60
tools/list_dart_files_as_depfile.py
Normal file
60
tools/list_dart_files_as_depfile.py
Normal file
|
@ -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/Ninja depfile, whose format is a Makefile with one target.
|
||||
out = open(depfile, 'w')
|
||||
out.write(os.path.relpath(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))
|
|
@ -10,16 +10,15 @@ template("create_timestamp_file") {
|
|||
path = invoker.path
|
||||
output = invoker.output
|
||||
action(target_name) {
|
||||
list_args = [ path ]
|
||||
script = "$_dart_root/tools/list_dart_files_as_depfile.py"
|
||||
args = [
|
||||
rebase_path(output),
|
||||
path,
|
||||
]
|
||||
if (defined(invoker.pattern)) {
|
||||
list_args += [ invoker.pattern ]
|
||||
args += [ invoker.pattern ]
|
||||
}
|
||||
files = exec_script("$_dart_root/tools/list_dart_files.py",
|
||||
[ "absolute" ] + list_args,
|
||||
"list lines")
|
||||
inputs = [ "$_dart_root/tools/list_dart_files.py" ] + files
|
||||
depfile = output
|
||||
outputs = [ output ]
|
||||
script = "$_dart_root/tools/create_timestamp_file.py"
|
||||
args = [ rebase_path(output) ]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user