Skip to content

Commit 7c5ff24

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
Fix VS Code sync script on Windows
We need to resolve the file:// url on windows to import it. else we get error like: On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' Also fixes generated file ending to have better interop. Bug: none Change-Id: If127b319e6bb36782c136c2d19be767e8d3cdfc7 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6953788 Commit-Queue: Nikolay Vitkov <[email protected]> Reviewed-by: Alex Rudenko <[email protected]>
1 parent 5943ffc commit 7c5ff24

File tree

5 files changed

+35
-25
lines changed

5 files changed

+35
-25
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"collect-strings": "vpython3 third_party/node/node.py --output third_party/i18n/collect-strings.js front_end",
2424
"components-server": "vpython3 third_party/node/node.py --output scripts/component_server/server.js",
2525
"debug-webtest": "vpython3 third_party/node/node.py --output scripts/npm_test.js --debug-devtools",
26-
"generate-protocol-resources": "scripts/deps/generate_protocol_resources.py && git cl format --js",
27-
"install-deps": "scripts/deps/manage_node_deps.py",
26+
"generate-protocol-resources": "vpython3 scripts/deps/generate_protocol_resources.py && git cl format --js",
27+
"install-deps": "vpython3 scripts/deps/manage_node_deps.py",
2828
"lint": "vpython3 third_party/node/node.py --output --experimental-strip-types --no-warnings=ExperimentalWarning scripts/test/run_lint_check.mjs",
2929
"prebuild": "gn gen out/Default",
3030
"rdb": "rdb stream -new -realm chromium:public --",

scripts/build/code_generator_frontend.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@
3939
import simplejson as json
4040

4141
ROOT_DIRECTORY = path.join(path.dirname(__file__), '..', '..')
42-
GENERATED_LOCATION = path.join(ROOT_DIRECTORY, 'front_end', 'generated', 'InspectorBackendCommands.js')
43-
READ_LOCATION = path.join(ROOT_DIRECTORY, 'third_party', 'blink', 'public', 'devtools_protocol', 'browser_protocol.json')
42+
GENERATED_LOCATION = path.join(ROOT_DIRECTORY, 'front_end', 'generated',
43+
'InspectorBackendCommands.js')
44+
READ_LOCATION = path.join(ROOT_DIRECTORY, 'third_party', 'blink', 'public',
45+
'devtools_protocol', 'browser_protocol.json')
4446

4547

4648
def fix_camel_case(name):
@@ -227,7 +229,8 @@ def go():
227229
if domain_name_lower == "console":
228230
continue
229231

230-
Generator.backend_js_domain_initializer_list.append("// %s.\n" % domain_name)
232+
Generator.backend_js_domain_initializer_list.append("// %s.\n" %
233+
domain_name)
231234

232235
if "types" in json_domain:
233236
for json_type in json_domain["types"]:
@@ -238,8 +241,11 @@ def go():
238241
if "properties" in json_type:
239242
for json_property in json_type["properties"]:
240243
if "type" in json_property and json_property["type"] == "string" and "enum" in json_property:
241-
enum_name = "%s.%s%s" % (domain_name, json_type["id"], to_title_case(json_property["name"]))
242-
Generator.process_enum(json_property, enum_name)
244+
enum_name = "%s.%s%s" % (
245+
domain_name, json_type["id"],
246+
to_title_case(json_property["name"]))
247+
Generator.process_enum(
248+
json_property, enum_name)
243249

244250
if "events" in json_domain:
245251
for json_event in json_domain["events"]:
@@ -281,7 +287,8 @@ def go():
281287
def process_enum(json_enum, enum_name):
282288
enum_members = []
283289
for member in json_enum["enum"]:
284-
enum_members.append("%s: \"%s\"" % (fix_camel_case(member), member))
290+
enum_members.append("%s: \"%s\"" %
291+
(fix_camel_case(member), member))
285292

286293
Generator.backend_js_domain_initializer_list.append(
287294
"inspectorBackend.registerEnum(\"%s\", {%s});\n" % (enum_name, ", ".join(enum_members)))
@@ -404,7 +411,7 @@ def process_command(json_command, domain_name):
404411

405412
Generator.go()
406413

407-
backend_js_file = open(GENERATED_LOCATION, "w+")
414+
backend_js_file = open(GENERATED_LOCATION, "w+", newline='\n')
408415

409416
backend_js_file.write(
410417
Templates.backend_js.substitute(None, domainInitializers="".join(Generator.backend_js_domain_initializer_list)))

scripts/build/generate_aria.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@
1010
import sys
1111
from os import path
1212

13-
PYJSON5_DIR = os.path.join(os.path.dirname(__file__), '..', '..', 'third_party', 'pyjson5', 'src')
13+
PYJSON5_DIR = os.path.join(os.path.dirname(__file__), '..', '..',
14+
'third_party', 'pyjson5', 'src')
1415
sys.path.append(PYJSON5_DIR)
1516

1617
import json5 # pylint: disable=import-error
1718

1819
ROOT_DIRECTORY = path.join(path.dirname(__file__), '..', '..')
19-
GENERATED_LOCATION = path.join(ROOT_DIRECTORY, 'front_end', 'generated', 'ARIAProperties.js')
20-
READ_LOCATION = path.join(ROOT_DIRECTORY, 'third_party', 'blink', 'renderer', 'core', 'html', 'aria_properties.json5')
20+
GENERATED_LOCATION = path.join(ROOT_DIRECTORY, 'front_end', 'generated',
21+
'ARIAProperties.js')
22+
READ_LOCATION = path.join(ROOT_DIRECTORY, 'third_party', 'blink', 'renderer',
23+
'core', 'html', 'aria_properties.json5')
24+
2125

2226
def properties_from_file(file_name):
2327
with open(os.path.abspath(file_name)) as json5_file:
@@ -27,9 +31,11 @@ def properties_from_file(file_name):
2731

2832
ARIA_PROPERTIES = properties_from_file(READ_LOCATION)
2933
now = datetime.datetime.now()
30-
with open(GENERATED_LOCATION, "w+") as f:
34+
with open(GENERATED_LOCATION, "w+", newline='\n') as f:
3135
f.write('// Copyright %d The Chromium Authors\n' % now.year)
32-
f.write('// Use of this source code is governed by a BSD-style license that can be\n')
36+
f.write(
37+
'// Use of this source code is governed by a BSD-style license that can be\n'
38+
)
3339
f.write('// found in the LICENSE file.\n')
3440
f.write('\n')
3541
f.write("export const config = %s;\n" %

scripts/build/generate_supported_css.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def properties_from_file(file_name):
9393

9494
properties, property_values, aliases_for = properties_from_file(READ_LOCATION)
9595
now = datetime.datetime.now()
96-
with open(GENERATED_LOCATION, "w+") as f:
96+
with open(GENERATED_LOCATION, "w+", newline='\n') as f:
9797
f.write('// Copyright %d The Chromium Authors\n' % now.year)
9898
f.write(
9999
'// Use of this source code is governed by a BSD-style license that can be\n'

scripts/deps/sync-vscode-settings.mjs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import childProcess from 'child_process';
66
import fs from 'fs';
77
import path from 'path';
8+
import url from 'url';
89

910
// JSON files under .vscode/ synced by this script
1011
const VSCODE_SETTINGS_TO_MERGE = [
@@ -23,15 +24,11 @@ if (Boolean(process.env['SKIP_VSCODE_SETTINGS_SYNC'])) {
2324
}
2425

2526
for (const { settingsFile, mergeField, byField } of VSCODE_SETTINGS_TO_MERGE) {
26-
const vscodeSettingsLocation = path.join(
27-
process.cwd(),
28-
'.vscode',
29-
settingsFile,
27+
const vscodeSettingsLocation = path.resolve(
28+
path.join(process.cwd(), '.vscode', settingsFile),
3029
);
31-
const devtoolsSettingsLocation = path.join(
32-
process.cwd(),
33-
'.vscode',
34-
'devtools-workspace-' + settingsFile,
30+
const devtoolsSettingsLocation = path.resolve(
31+
path.join(process.cwd(), '.vscode', 'devtools-workspace-' + settingsFile),
3532
);
3633

3734
// If there are no settings to copy and paste, skip.
@@ -41,14 +38,14 @@ for (const { settingsFile, mergeField, byField } of VSCODE_SETTINGS_TO_MERGE) {
4138

4239
try {
4340
const devtoolsSettings = (
44-
await import(devtoolsSettingsLocation, {
41+
await import(url.pathToFileURL(devtoolsSettingsLocation).href, {
4542
with: { type: 'json' },
4643
})
4744
).default;
4845
let preExistingSettings = {};
4946
if (fs.existsSync(vscodeSettingsLocation)) {
5047
preExistingSettings = (
51-
await import(vscodeSettingsLocation, {
48+
await import(url.pathToFileURL(vscodeSettingsLocation).href, {
5249
with: { type: 'json' },
5350
})
5451
).default;

0 commit comments

Comments
 (0)