From a858542c89adb85b901d55457bd74300bc083eab Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Mon, 12 Dec 2016 13:09:26 -0800 Subject: [PATCH] Make list_files.py and list_dart_files.py return absolute paths This makes doing an SDK build in the Fuchsia tree easier R=johnmccutchan@google.com Review-Url: https://codereview.chromium.org/2564413004 . --- BUILD.gn | 4 +--- pkg/BUILD.gn | 1 - runtime/vm/BUILD.gn | 10 +++++----- tools/list_dart_files.py | 4 +++- tools/list_files.py | 4 +++- utils/create_timestamp.gni | 11 +---------- 6 files changed, 13 insertions(+), 21 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index a027a2e6150..8303c50387e 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -88,9 +88,7 @@ action("create_sdk") { ], "list lines") - inputs = rebase_path(sdk_lib_files, "", "sdk/lib") + - rebase_path(preamble_files, "", "sdk/lib") + - rebase_path(sdk_bin_files, "", "sdk/bin") + + inputs = sdk_lib_files + preamble_files + sdk_bin_files + [ "sdk/lib/dart_client.platform", "sdk/lib/dart_server.platform", diff --git a/pkg/BUILD.gn b/pkg/BUILD.gn index e1ce11d2e4e..bd7eb4ca87a 100644 --- a/pkg/BUILD.gn +++ b/pkg/BUILD.gn @@ -16,7 +16,6 @@ template("make_third_party_pkg_files_stamp") { pattern = invoker.pattern } path = path - new_base = "//" output = "$target_gen_dir/third_party_pkg_files_$id.stamp" } } diff --git a/runtime/vm/BUILD.gn b/runtime/vm/BUILD.gn index 9bbc3a49538..cdd42f61b49 100644 --- a/runtime/vm/BUILD.gn +++ b/runtime/vm/BUILD.gn @@ -411,10 +411,10 @@ if (!defined(is_fuchsia) || !is_fuchsia) { script = "../../tools/patch_sdk.py" - # We list all files which make up the sdk (modulo patches) and get them back - # as a GN list object. + # We list all files which make up the sdk (modulo patches) and get them + # back as a GN list object. shared_sdk_sources = exec_script("../../tools/list_dart_files.py", - [ "../../sdk/lib" ], + [ rebase_path("../../sdk/lib") ], "list lines") # We list the `patch_sdk.dart` tool here because the [script] (which is @@ -423,8 +423,8 @@ if (!defined(is_fuchsia) || !is_fuchsia) { "../../tools/patch_sdk.dart", ] - # Files below are not patches, they will not be in [concatenation_files] but - # the `patch_sdk.dart` script will copy them into the patched sdk. + # Files below are not patches, they will not be in [concatenation_files] + # but the `patch_sdk.dart` script will copy them into the patched sdk. inputs += [ "../lib/typed_data.dart", "../bin/builtin.dart", diff --git a/tools/list_dart_files.py b/tools/list_dart_files.py index 60d2295652e..39ab36555cc 100755 --- a/tools/list_dart_files.py +++ b/tools/list_dart_files.py @@ -16,6 +16,8 @@ import sys def main(argv): directory = argv[1] + if not os.path.isabs(directory): + directory = os.path.realpath(directory) pattern = None if len(argv) > 2: @@ -34,7 +36,7 @@ def main(argv): for filename in files: if filename.endswith('.dart') and not filename.endswith('_test.dart'): - fullname = os.path.relpath(os.path.join(root, filename)) + fullname = os.path.join(directory, root, filename) fullname = fullname.replace(os.sep, '/') print fullname diff --git a/tools/list_files.py b/tools/list_files.py index ad277e853f0..f5dad8656d3 100755 --- a/tools/list_files.py +++ b/tools/list_files.py @@ -17,11 +17,13 @@ import sys def main(argv): pattern = re.compile(argv[1]) for directory in argv[2:]: + if not os.path.isabs(directory): + directory = os.path.realpath(directory) for root, directories, files in os.walk(directory): if '.git' in directories: directories.remove('.git') for filename in files: - fullname = os.path.relpath(os.path.join(root, filename)) + fullname = os.path.join(directory, root, filename) fullname = fullname.replace(os.sep, '/') if re.search(pattern, fullname): print fullname diff --git a/utils/create_timestamp.gni b/utils/create_timestamp.gni index c579da1e5e3..d43a1afd1d6 100644 --- a/utils/create_timestamp.gni +++ b/utils/create_timestamp.gni @@ -7,14 +7,6 @@ _dart_root = rebase_path("..") template("create_timestamp_file") { assert(defined(invoker.path), "Must specify 'path'") assert(defined(invoker.output), "Must specify 'output'") - new_base = "." - if (defined(invoker.new_base)) { - new_base = invoker.new_base - } - current_base = "." - if (defined(invoker.current_base)) { - current_base = invoker.current_base - } path = invoker.path output = invoker.output action(target_name) { @@ -25,8 +17,7 @@ template("create_timestamp_file") { files = exec_script("$_dart_root/tools/list_dart_files.py", list_args, "list lines") - inputs = [ "$_dart_root/tools/list_dart_files.py" ] + - rebase_path(files, new_base, current_base) + inputs = [ "$_dart_root/tools/list_dart_files.py" ] + files outputs = [ output, ]