Reland "Fix typescript compilation with ts_library"

This reverts commit a7de1bbca0.

Reason for revert: Suspected issue with local machine. Chromium CQ was green.

Original change's description:
> Revert "Fix typescript compilation with ts_library"
> 
> This reverts commit 85de0bc72e.
> 
> Reason for revert: From Chase: build error after this change rolled into Chromium at https://crrev.com/c/2008257
> 
> DISABLE_THIRD_PARTY_CHECK=Bypassing checks for revert
> 
> Original change's description:
> > Fix typescript compilation with ts_library
> >
> > This CL prepares ts_library to work correctly by building both in Chromium
> > as well as in DevTools. A follow-up CL will add a simple ts_library
> > to verify that it keeps on working.
> >
> > Bug: 1011811
> > Change-Id: I482761bfbcbf459478dc7f51f2df6576ac872de6
> > DISABLE_THIRD_PARTY_CHECK=TypeScript build configuration changes
> > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1960456
> > Reviewed-by: Paul Lewis <aerotwist@chromium.org>
> > Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
> 
> TBR=aerotwist@chromium.org,mathias@chromium.org,tvanderlippe@chromium.org
> 
> 
> Bug: 1011811
> Change-Id: Id354882f8f8706241ac377e62ff68cc9eb6ff994
> Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2013141
> Reviewed-by: Paul Lewis <aerotwist@chromium.org>
> Commit-Queue: Paul Lewis <aerotwist@chromium.org>

TBR=aerotwist@chromium.org,mathias@chromium.org,tvanderlippe@chromium.org

Change-Id: Iafc3a005d53fc040ca2a1708c6f2fef1ac53c48d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1011811
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2013144
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
This commit is contained in:
Tim van der Lippe
2020-01-22 11:45:33 +00:00
committed by Commit Bot
parent a327cdef91
commit 3bf1c19f97
7 changed files with 71 additions and 32 deletions
+16 -14
View File
@@ -2186,20 +2186,22 @@ group("devtools_all_files") {
]
}
devtools_frontend_resources_deps = [
":aria_properties",
":build_release_devtools",
":copy_devtools_modules",
":copy_embedder_scripts",
":copy_emulated_devices_images",
":copy_htaccess",
":copy_inspector_images",
":copy_lighthouse_locale_files",
":copy_wasm_deps",
":devtools_extension_api",
":frontend_protocol_sources",
":supported_css_properties",
]
devtools_typescript_deps = [ "front_end/common:common" ]
devtools_frontend_resources_deps = devtools_typescript_deps + [
":aria_properties",
":build_release_devtools",
":copy_devtools_modules",
":copy_embedder_scripts",
":copy_emulated_devices_images",
":copy_htaccess",
":copy_inspector_images",
":copy_lighthouse_locale_files",
":copy_wasm_deps",
":devtools_extension_api",
":frontend_protocol_sources",
":supported_css_properties",
]
if (debug_devtools) {
devtools_frontend_resources_deps += [
+5
View File
@@ -40,6 +40,11 @@ declare_args() {
# every toolchain can pass through the "global" value via toolchain_args().
host_toolchain = ""
# Needed to properly resolve the locations for the TypeScript build system
# when we are building for DevTools only. This arg will not be defined in
# Chromium itself.
use_devtools_typescript = true
# DON'T ADD MORE FLAGS HERE. Read the comment above.
}
+17
View File
@@ -0,0 +1,17 @@
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("../../third_party/typescript/typescript.gni")
group("common") {
public_deps = [
":trie",
]
}
ts_library("trie") {
sources = [
"Trie.js",
]
}
+14 -4
View File
@@ -11,11 +11,21 @@ from os import path
_CURRENT_DIR = path.join(path.dirname(__file__))
TSC_LOCATION = path.join(_CURRENT_DIR, '..', '..', 'node_modules', 'typescript', 'bin', 'tsc')
ROOT_TS_CONFIG_LOCATION = path.join(_CURRENT_DIR, 'tsconfig.json')
try:
old_sys_path = sys.path[:]
sys.path.append(path.join(_CURRENT_DIR, '..', '..', 'scripts'))
import devtools_paths
finally:
sys.path = old_sys_path
NODE_LOCATION = devtools_paths.node_path()
ROOT_TS_CONFIG_LOCATION = path.join(_CURRENT_DIR, '..', '..', 'tsconfig.json')
def runTsc(tsconfig_location):
process = subprocess.Popen([TSC_LOCATION, '-b', tsconfig_location], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process = subprocess.Popen([NODE_LOCATION, TSC_LOCATION, '-b', tsconfig_location],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
# TypeScript does not correctly write to stderr because of https://github.com/microsoft/TypeScript/issues/33849
return process.returncode, stdout + stderr
@@ -24,7 +34,7 @@ def runTsc(tsconfig_location):
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--sources', nargs='*', required=True, help='List of TypeScript source files')
parser.add_argument('-b', '--tsconfig_location', required=True)
parser.add_argument('-b', '--tsconfig_output_location', required=True)
opts = parser.parse_args()
with open(ROOT_TS_CONFIG_LOCATION) as root_tsconfig:
try:
@@ -33,7 +43,7 @@ def main():
print('Encountered error while loading root tsconfig:')
print(e)
return 1
tsconfig_output_location = path.join(os.getcwd(), opts.tsconfig_location)
tsconfig_output_location = path.join(os.getcwd(), opts.tsconfig_output_location)
tsconfig['files'] = [path.join(os.getcwd(), src) for src in opts.sources]
tsconfig['compilerOptions']['outDir'] = path.dirname(tsconfig_output_location)
with open(tsconfig_output_location, 'w') as generated_tsconfig:
-6
View File
@@ -1,6 +0,0 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext"
}
}
+19 -7
View File
@@ -2,7 +2,11 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
script_path = "//third_party/typescript"
if (defined(use_devtools_typescript) && use_devtools_typescript) {
devtools_location = ""
} else {
devtools_location = "third_party/devtools-frontend/src"
}
# Defines a target that compiles .ts files using TypeScript.
# A temporary tsconfig.json is generated which uses the
@@ -17,17 +21,25 @@ script_path = "//third_party/typescript"
# }
template("ts_library") {
action(target_name) {
script = "//third_party/typescript/ts_library.py"
script = "//$devtools_location/third_party/typescript/ts_library.py"
forward_variables_from(invoker, [ "sources", "visibility" ])
forward_variables_from(invoker,
[
"sources",
"visibility",
])
inputs = [
"//$devtools_location/tsconfig.json",
]
args = [
"--tsconfig_location",
rebase_path(target_gen_dir, root_build_dir) + "/tsconfig.json",
"--tsconfig_output_location",
rebase_path(target_gen_dir, root_build_dir) + "/$target_name-tsconfig.json",
]
args += [ "--sources" ] + rebase_path(sources, root_build_dir)
output_files = [ "$target_gen_dir/tsconfig.json" ]
output_files = [ "$target_gen_dir/$target_name-tsconfig.json" ]
foreach(src, sources) {
js_renamed_path =
@@ -42,5 +54,5 @@ template("ts_library") {
set_defaults("ts_library") {
# Build output should be private and directories should export all relevant
# components in a group
visibility = [":*"]
visibility = [ ":*" ]
}
-1
View File
@@ -18,6 +18,5 @@
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}
}
}