Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
dart-lang
sdk
tools
fuchsia
find_resources.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
#
3
# Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
4
# for details. All rights reserved. Use of this source code is governed by a
5
# BSD-style license that can be found in the LICENSE file.
6
#
7
8
# Finds files in the given directories and their subdirectories, and prints them
9
# in the json format expected by GN fuchsia_component's resources arg:
10
# [
11
# {
12
# "path": "path/to/file.dart",
13
# "dest": "data/path/to/file.dart"
14
# },
15
# ...
16
# ]
17
18
import
sys
19
import
os
20
21
from
os.path
import
join, abspath, relpath
22
23
DART_DIR = abspath(join(__file__,
'..'
,
'..'
,
'..'
))
24
25
26
def
listFiles
(path):
27
allFiles = []
28
for
dirpath, dirs, files
in
os.walk(join(DART_DIR, path)):
29
allFiles += [
30
relpath(abspath(join(dirpath, p)), DART_DIR)
for
p
in
files
31
]
32
return
allFiles
33
34
35
def
printOutput
(files):
36
print
(
'['
)
37
print
(
',\n'
.join([
38
' {\n "path": "%s",\n "dest": "data/%s"\n }'
% (f, f)
39
for
f
in
files
40
]))
41
print
(
']'
)
42
43
44
def
main
():
45
if
len(sys.argv) < 2:
46
print
(
'Expected at least 1 arg, the paths to search.'
)
47
return
1
48
allFiles = []
49
for
directory
in
sys.argv[1:]:
50
files =
listFiles
(directory)
51
if
len(files) == 0:
52
print
(
'Did not find any files in the directory: '
+ directory)
53
return
2
54
allFiles += files
55
printOutput
(sorted(allFiles))
56
return
0
57
58
59
if
__name__ ==
'__main__'
:
60
sys.exit(
main
())
print
void print(void *str)
Definition
bridge.cpp:126
find_resources.main
main()
Definition
find_resources.py:44
find_resources.listFiles
listFiles(path)
Definition
find_resources.py:26
find_resources.printOutput
printOutput(files)
Definition
find_resources.py:35
main
Definition
main.py:1
Generated on Fri Apr 26 2024 06:15:22 for Flutter Engine by
1.9.8