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

Reland "Symlink debug folder instead of symlinking individual files"

This reverts commit 9a2b5dd0.

The assignment on line 45 was overwriting the parameter `src`, which
then would result in the for-loop on line 44 to traverse into the wrong
directory. Renaming the assignment to variable `new_src` resolves that
issue.

Confirmed working locally by commenting out the `if symlink exists`
branch and ran it on my Linux machine. (I could reproduce the error by
simply commenting and can confirm that it is now working with the fix)

TBR=luoe@chromium.org

Change-Id: Idc3dbddd9db620169f7e9fbd60e306755eb1b4c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715303Reviewed-by: default avatarYang Guo <yangguo@chromium.org>
Reviewed-by: default avatarErik Luo <luoe@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@google.com>
Cr-Commit-Position: refs/heads/master@{#681390}
parent 042b1776
......@@ -19,3 +19,8 @@ npm-debug.log
package-lock.json
.vscode
/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,7 +1414,7 @@ if (debug_devtools) {
"$resources_out_debug_dir/worker_app.html",
]
args = devtools_applications + [
args = [
"--input_path",
rebase_path("front_end", root_build_dir),
"--output_path",
......@@ -1428,6 +1424,7 @@ if (debug_devtools) {
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:
for filename in os.listdir(src):
new_src = join(os.getcwd(), src, filename)
if os.path.isdir(new_src):
copy_dir(new_src, join(dest, filename))
else:
copy_file(new_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