Commit a66c49ab authored by Tim van der Lippe's avatar Tim van der Lippe Committed by Commit Bot

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/+/1713344Reviewed-by: default avatarErik Luo <luoe@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@google.com>
Cr-Commit-Position: refs/heads/master@{#680518}
parent 9df3a887
......@@ -18,4 +18,9 @@ npm-debug.log
/front_end/protocol_externs.js
package-lock.json
.vscode
/front_end/*/jsconfig.json
\ No newline at end of file
/front_end/*/jsconfig.json
# 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,10 +1402,6 @@ if (debug_devtools) {
action("build_debug_devtools") {
script = "scripts/build/build_debug_applications.py"
deps = [
":copy_generated_scripts",
]
inputs = all_devtools_files + application_templates
outputs = [
"$resources_out_debug_dir/devtools_app.html",
......@@ -1418,16 +1414,17 @@ if (debug_devtools) {
"$resources_out_debug_dir/worker_app.html",
]
args = devtools_applications + [
"--input_path",
rebase_path("front_end", root_build_dir),
"--output_path",
rebase_path(resources_out_debug_dir, root_build_dir),
]
args = [
"--input_path",
rebase_path("front_end", root_build_dir),
"--output_path",
rebase_path(resources_out_debug_dir, root_build_dir),
]
}
copy("copy_generated_scripts") {
deps = [
":build_debug_devtools",
":frontend_protocol_sources",
":supported_css_properties",
]
......
......@@ -25,28 +25,37 @@ def main(argv):
input_path = argv[input_path_flag_index + 1]
output_path_flag_index = argv.index('--output_path')
output_path = argv[output_path_flag_index + 1]
application_names = argv[1:input_path_flag_index]
except:
print('Usage: %s app_1 app_2 ... app_N --input_path <input_path> --output_path <output_path>' % argv[0])
raise
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()
symlink_dir_or_copy(input_path, output_path)
def symlink_or_copy_file(src, dest, safe=False):
if safe and path.exists(dest):
os.remove(dest)
def symlink_dir_or_copy(src, dest):
if hasattr(os, 'symlink'):
os.symlink(src, dest)
if path.exists(dest):
if os.path.islink(dest):
os.unlink(dest)
else:
shutil.rmtree(dest)
os.symlink(join(os.getcwd(), src), dest)
else:
shutil.copy(src, dest)
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):
os.remove(dest)
shutil.copy(src, dest)
def symlink_or_copy_dir(src, dest):
def copy_dir(src, dest):
if path.exists(dest):
shutil.rmtree(dest)
for src_dir, dirs, files in os.walk(src):
......@@ -56,37 +65,7 @@ def symlink_or_copy_dir(src, dest):
for name in files:
src_name = join(os.getcwd(), src_dir, name)
dest_name = join(dest_dir, 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)
copy_file(src_name, dest_name)
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