Reland "Reland "use python3 in devtools-frontend by default""

This reverts commit 7c57958680.

Reason for revert:
This uses dict instead of set in modular_build.py for deterministic
output.
ref: https://softwaremaniacs.org/blog/2020/02/05/dicts-ordered/en/

I confirmed that devtools_app.js is the same in repeated builds.

Original change's description:
> Revert "Reland "use python3 in devtools-frontend by default""
>
> This reverts commit 0d4947c37e.
>
> Reason for revert: https://crbug.com/1211770
>
> Original change's description:
> > Reland "use python3 in devtools-frontend by default"
> >
> > This reverts commit a8336c1e58.
> >
> > Reason for revert:
> > use universal_newlines instead of text for
> > https://docs.python.org/3/library/subprocess.html#subprocess.Popen
> >
> > I tried to divide this CL in to make py2/3 compatible and switch in
> > another CL. But that hit another issue due to the difference of string
> > type around io.StringIO and cStringIO.StringIO like
> > https://logs.chromium.org/logs/devtools-frontend/buildbucket/cr-buildbucket.appspot.com/8846743161604002304/+/u/compile/raw_io.output_failure_summary_
> >
> > So decided to re-land the switch with fix for known issue.
> >
> > I confirmed this works for python3.6 too.
> >
> > Original change's description:
> > > Revert "use python3 in devtools-frontend by default"
> > >
> > > This reverts commit 37c0bf698d.
> > >
> > > Reason for revert:
> > > Compatibility issues with python 3.6.
> > >
> > > Original change's description:
> > > > use python3 in devtools-frontend by default
> > > >
> > > > Fixed: 1205624, 1205625
> > > > Change-Id: Iddaf2a49bffd92140d1877784ffd9f5dd83ac3de
> > > > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2902988
> > > > Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
> > > > Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
> > > > Reviewed-by: Michael Achenbach <machenbach@chromium.org>
> > > > Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
> > >
> > > Change-Id: Ic426154f58798dd8631f9bac101521f0b25ea54c
> > > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2906060
> > > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> > > Commit-Queue: Michael Achenbach <machenbach@chromium.org>
> >
> > Bug: 1210939, 1205624, 1205625
> > Change-Id: Ia7ddf5ab37c8df3e2f682bf89cb55ef30e663341
> > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2909053
> > Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
> > Reviewed-by: Michael Achenbach <machenbach@chromium.org>
>
> Bug: 1210939
> Bug: 1205624
> Bug: 1205625
> Bug: 1211770
> No-Tree-Checks: true
> No-Presubmit: true
> Change-Id: Ic3a6add15b4126dfe818b445a5227253d296ee96
> Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2910016
> Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
> Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
> Reviewed-by: Michael Achenbach <machenbach@chromium.org>

Bug: 1210939
Bug: 1205624
Bug: 1205625
Bug: 1211770
Change-Id: I2acb2968e68f55a663cd5221c1c92b16301392cd
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2910020
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
This commit is contained in:
Takuto Ikuta
2021-05-24 09:58:37 +00:00
committed by Devtools-frontend LUCI CQ
parent c808e3c1c7
commit 0e87680f36
5 changed files with 20 additions and 19 deletions
+1 -4
View File
@@ -2,8 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/python.gni")
import("./config/gni/all_devtools_files.gni")
import("./config/gni/devtools_grd_files.gni")
import("./config/gni/devtools_image_files.gni")
@@ -247,8 +245,7 @@ if (!is_debug) {
build_release_devtools_args += [ "--rollup" ]
}
# TODO(crbug.com/1112471): Get this to work cleanly under Python3.
python2_action("build_release_devtools") {
action("build_release_devtools") {
script = "scripts/build/build_release_applications.py"
helper_scripts = [
+1 -3
View File
@@ -2,13 +2,11 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/python.gni")
import("../third_party/typescript/typescript.gni")
resources_out_dir = "$root_out_dir/resources/inspector_overlay"
# TODO(crbug.com/1112471): Get this to work under Python 3.
python2_action("build_inspector_overlay") {
action("build_inspector_overlay") {
script = "../scripts/build/build_inspector_overlay.py"
inputs = [
+4 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env vpython
# -*- coding: UTF-8 -*-
# -*- coding: utf-8 -*-
#
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
@@ -44,7 +44,9 @@ def rollup(input_path, output_path, filename, max_size, rollup_plugin):
['--format', 'iife', '-n', 'InspectorOverlay'] + ['--input', target] +
['--plugin', rollup_plugin, '--plugin', 'terser'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
universal_newlines=True,
encoding='utf-8')
out, error = rollup_process.communicate()
if not out:
raise Exception("rollup failed: " + error)
+6 -5
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env vpython
# -*- coding: UTF-8 -*-
# -*- coding: utf-8 -*-
#
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
@@ -10,7 +10,7 @@ Builds applications in release mode:
and the application loader into a single script.
"""
from cStringIO import StringIO
from io import StringIO
from os import path
from os.path import join
import copy
@@ -152,8 +152,7 @@ class ReleaseBuilder(object):
resource_content = read_file(path.join(self.application_dir, resource_name))
if not (resource_name.endswith('.html')
or resource_name.endswith('md')):
resource_content += resource_source_url(resource_name).encode(
'utf-8')
resource_content += resource_source_url(resource_name)
resource_content = resource_content.replace('\\', '\\\\')
resource_content = resource_content.replace('\n', '\\n')
resource_content = resource_content.replace('"', '\\"')
@@ -179,7 +178,9 @@ class ReleaseBuilder(object):
def _concatenate_application_script(self, output):
output.write('Root.allDescriptors.push(...%s);' % self._release_module_descriptors())
if self.descriptors.extends:
output.write('Root.applicationDescriptor.modules.push(...%s);' % json.dumps(self.descriptors.application.values()))
output.write(
'Root.applicationDescriptor.modules.push(...%s);' %
json.dumps(list(self.descriptors.application.values())))
else:
output.write('Root.applicationDescriptor = %s;' % self.descriptors.application_json())
+8 -5
View File
@@ -20,7 +20,7 @@ except ImportError:
def read_file(filename):
with open(path.normpath(filename), 'rt') as input:
with open(path.normpath(filename), 'rt', encoding='utf-8') as input:
return input.read()
@@ -30,7 +30,7 @@ def write_file(filename, content):
directory = path.dirname(filename)
if not path.exists(directory):
os.makedirs(directory)
with open(filename, 'wt') as output:
with open(filename, 'wt', encoding='utf-8') as output:
output.write(content)
@@ -59,7 +59,7 @@ class Descriptors:
def application_json(self):
result = dict()
result['modules'] = self.application.values()
result['modules'] = list(self.application.values())
return json.dumps(result)
def module_resources(self, name):
@@ -70,7 +70,10 @@ class Descriptors:
return self._cached_sorted_modules
result = []
unvisited_modules = set(self.modules)
# Use dict instead of set for deterministic iteration order.
unvisited_modules = {module: None for module in self.modules}
temp_modules = set()
def visit(parent, name):
@@ -87,7 +90,7 @@ class Descriptors:
bad_dep = visit(name, dep_name)
if bad_dep:
return bad_dep
unvisited_modules.remove(name)
del unvisited_modules[name]
temp_modules.remove(name)
result.append(name)
return None