Commit 9a2b5dd0 authored by Jeff Fisher's avatar Jeff Fisher Committed by Commit Bot

Revert "Symlink debug folder instead of symlinking individual files"

This reverts commit a66c49ab.

Reason for revert: This breaks building chromium on Windows:

Traceback (most recent call last):
  File "../../third_party/blink/renderer/devtools/scripts/build/build_debug_applications.py", line 72, in <module>
    sys.exit(main(sys.argv))
  File "../../third_party/blink/renderer/devtools/scripts/build/build_debug_applications.py", line 32, in main
    symlink_dir_or_copy(input_path, output_path)
  File "../../third_party/blink/renderer/devtools/scripts/build/build_debug_applications.py", line 49, in symlink_dir_or_copy
    copy_file(src, join(dest, filename), safe=True)
  File "../../third_party/blink/renderer/devtools/scripts/build/build_debug_applications.py", line 54, in copy_file
    os.remove(dest)
WindowsError: [Error 5] Access is denied: 'resources/inspector/debug\\accessibility'


Original change's description:
> Symlink debug folder instead of symlinking individual files
>
> The original behavior of build_debug_applications.py was to traverse all
> files recursively in the front_end folder and symlink each individual
> file to the version in third_party/blink/renderer/devtools/front_end.
>
> However, this requires rebuilding of Chrome when new files are added to
> the application. After this CL, the developer experience is more
> What-You-See-Is-What-You-Get.
>
> This CL is also in preparation to remove the logic in C++-land to remove
> the need for a separate debug folder. A follow-up CL will change the
> behavior of `debug_devtools` to symlink directly into
> out/[NAME]/resources/inspector, rather than an explicit sub-directory.
>
> As a nice side-effect of this change, we are no longer symlinking the
> debug folder for every version of the application. Previously, it would
> iterate through all `application_names` and symlink the full debug
> folder. This is time-consuming and did not provide any actual benefit.
> Since we now symlink directly to the local version, we no longer need to
> build the HTML files directly.
>
> Bug: 986365
> Change-Id: I7e54ac3af57e0a3941b88a46b71b3ddacd5664f2
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1713344
> Reviewed-by: Erik Luo <luoe@chromium.org>
> Commit-Queue: Tim van der Lippe <tvanderlippe@google.com>
> Cr-Commit-Position: refs/heads/master@{#680518}

Change-Id: I8511095bb6f3dc8e4e7871afd3ef8c91fa63a069
Bug: 986365
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1717594Reviewed-by: default avatarJoel Einbinder <einbinder@chromium.org>
Commit-Queue: Jeff Fisher <jeffish@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#680679}
parent 531253ee
...@@ -18,9 +18,4 @@ npm-debug.log ...@@ -18,9 +18,4 @@ npm-debug.log
/front_end/protocol_externs.js /front_end/protocol_externs.js
package-lock.json package-lock.json
.vscode .vscode
/front_end/*/jsconfig.json /front_end/*/jsconfig.json
\ No newline at end of file
# These are generated for build and would be put in the symlinked folder (thus this folder)
front_end/InspectorBackendCommands.js
front_end/SupportedCSSProperties.js
front_end/accessibility/ARIAProperties.js
\ No newline at end of file
...@@ -1402,6 +1402,10 @@ if (debug_devtools) { ...@@ -1402,6 +1402,10 @@ if (debug_devtools) {
action("build_debug_devtools") { action("build_debug_devtools") {
script = "scripts/build/build_debug_applications.py" script = "scripts/build/build_debug_applications.py"
deps = [
":copy_generated_scripts",
]
inputs = all_devtools_files + application_templates inputs = all_devtools_files + application_templates
outputs = [ outputs = [
"$resources_out_debug_dir/devtools_app.html", "$resources_out_debug_dir/devtools_app.html",
...@@ -1414,17 +1418,16 @@ if (debug_devtools) { ...@@ -1414,17 +1418,16 @@ if (debug_devtools) {
"$resources_out_debug_dir/worker_app.html", "$resources_out_debug_dir/worker_app.html",
] ]
args = [ args = devtools_applications + [
"--input_path", "--input_path",
rebase_path("front_end", root_build_dir), rebase_path("front_end", root_build_dir),
"--output_path", "--output_path",
rebase_path(resources_out_debug_dir, root_build_dir), rebase_path(resources_out_debug_dir, root_build_dir),
] ]
} }
copy("copy_generated_scripts") { copy("copy_generated_scripts") {
deps = [ deps = [
":build_debug_devtools",
":frontend_protocol_sources", ":frontend_protocol_sources",
":supported_css_properties", ":supported_css_properties",
] ]
......
...@@ -25,37 +25,28 @@ def main(argv): ...@@ -25,37 +25,28 @@ def main(argv):
input_path = argv[input_path_flag_index + 1] input_path = argv[input_path_flag_index + 1]
output_path_flag_index = argv.index('--output_path') output_path_flag_index = argv.index('--output_path')
output_path = argv[output_path_flag_index + 1] output_path = argv[output_path_flag_index + 1]
application_names = argv[1:input_path_flag_index]
except: except:
print('Usage: %s app_1 app_2 ... app_N --input_path <input_path> --output_path <output_path>' % argv[0]) print('Usage: %s app_1 app_2 ... app_N --input_path <input_path> --output_path <output_path>' % argv[0])
raise raise
symlink_dir_or_copy(input_path, output_path) loader = modular_build.DescriptorLoader(input_path)
for app in application_names:
descriptors = loader.load_application(app)
builder = DebugBuilder(app, descriptors, input_path, output_path)
builder.build_app()
def symlink_dir_or_copy(src, dest): def symlink_or_copy_file(src, dest, safe=False):
if hasattr(os, 'symlink'):
if path.exists(dest):
if os.path.islink(dest):
os.unlink(dest)
else:
shutil.rmtree(dest)
os.symlink(join(os.getcwd(), src), dest)
else:
for filename in os.listdir(src):
src = join(os.getcwd(), src, filename)
if os.path.isdir(src):
copy_dir(src, join(dest, filename))
else:
copy_file(src, join(dest, filename), safe=True)
def copy_file(src, dest, safe=False):
if safe and path.exists(dest): if safe and path.exists(dest):
os.remove(dest) os.remove(dest)
shutil.copy(src, dest) if hasattr(os, 'symlink'):
os.symlink(src, dest)
else:
shutil.copy(src, dest)
def copy_dir(src, dest): def symlink_or_copy_dir(src, dest):
if path.exists(dest): if path.exists(dest):
shutil.rmtree(dest) shutil.rmtree(dest)
for src_dir, dirs, files in os.walk(src): for src_dir, dirs, files in os.walk(src):
...@@ -65,7 +56,37 @@ def copy_dir(src, dest): ...@@ -65,7 +56,37 @@ def copy_dir(src, dest):
for name in files: for name in files:
src_name = join(os.getcwd(), src_dir, name) src_name = join(os.getcwd(), src_dir, name)
dest_name = join(dest_dir, name) dest_name = join(dest_dir, name)
copy_file(src_name, dest_name) symlink_or_copy_file(src_name, dest_name)
# Outputs:
# <app_name>.html as-is
# <app_name>.js as-is
# <module_name>/<all_files>
class DebugBuilder(object):
def __init__(self, application_name, descriptors, application_dir, output_dir):
self.application_name = application_name
self.descriptors = descriptors
self.application_dir = application_dir
self.output_dir = output_dir
def app_file(self, extension):
return self.application_name + '.' + extension
def build_app(self):
if self.descriptors.has_html:
self._build_html()
for filename in os.listdir(self.application_dir):
src = join(os.getcwd(), self.application_dir, filename)
if os.path.isdir(src):
symlink_or_copy_dir(src, join(self.output_dir, filename))
else:
symlink_or_copy_file(src, join(self.output_dir, filename), safe=True)
def _build_html(self):
html_name = self.app_file('html')
symlink_or_copy_file(join(os.getcwd(), self.application_dir, html_name), join(self.output_dir, html_name), True)
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment