Files
sdk/tools/list_dart_files_as_depfile.py
DEPS Autoroller 6152811eda Roll ninja from 2@1.11.1.chromium.6 to 3@1.13.1.chromium.4
If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/ninja-dart-sdk
Please CC dart-engprod@google.com,dart-vm-gardener@grotations.appspotmail.com,dart-vm-team@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in ninja: https://bugs.chromium.org/p/chromium/issues/list
To file a bug in Dart SDK: https://github.com/dart-lang/sdk/issues

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try;luci.dart.try:dart-sdk-linux-arm64-try;luci.dart.try:dart-sdk-mac-try;luci.dart.try:dart-sdk-mac-arm64-try;luci.dart.try:dart-sdk-win-try
Change-Id: I94379b6282696480ce450e9fb013e1b5f04be103
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450774
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-09-22 10:15:35 -07:00

60 lines
1.9 KiB
Python

#!/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.replace(" ", r"\ "))
out.write("\n")
out.close()
if __name__ == '__main__':
sys.exit(main(sys.argv))