Skip to content

Commit 6d0bfb4

Browse files
srawlinsCommit Queue
authored andcommitted
Add an option for fetching devtools from source, and a script to build the app
Change-Id: If76e4374c3ab073db778e01015d3bcbdcef3febd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434020 Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Ivan Inozemtsev <[email protected]> Reviewed-by: Kenzie Davisson <[email protected]>
1 parent 1029af6 commit 6d0bfb4

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

DEPS

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ vars = {
101101
"browser-compat-data_tag": "ac8cae697014da1ff7124fba33b0b4245cc6cd1b", # v1.0.22
102102
"cpu_features_rev": "936b9ab5515dead115606559502e3864958f7f6e",
103103
"devtools_rev": "53b9620798ff824f016add0fa6c25e9cc399ea0b",
104+
# Use the SHA found in `flutter-candidate.txt` in the devtools repo.
105+
"flutter_rev": "36ea2bdeab611e908967b6fa57659998f600a2cb",
104106
"icu_rev": "43953f57b037778a1b8005564afabe214834f7bd",
105107
"jinja2_rev": "2222b31554f03e62600cd7e383376a7c187967a1",
106108
"libcxx_rev": "bd557f6f764d1e40b62528a13b124ce740624f8f",
@@ -169,10 +171,12 @@ vars = {
169171
"download_emscripten": False,
170172
"emsdk_rev": "e41b8c68a248da5f18ebd03bd0420953945d52ff",
171173
"emsdk_ver": "3.1.3",
174+
"build_devtools_from_sources": False,
172175
}
173176

174177
gclient_gn_args_file = Var("dart_root") + '/build/config/gclient_args.gni'
175178
gclient_gn_args = [
179+
"build_devtools_from_sources"
176180
]
177181

178182
deps = {
@@ -251,6 +255,11 @@ deps = {
251255
}],
252256
"dep_type": "cipd",
253257
},
258+
Var("dart_root") + "/third_party/devtools_src": {
259+
"url": Var("dart_git") + "external/github.com/flutter/devtools.git" +
260+
"@" + Var("devtools_rev"),
261+
"condition": "build_devtools_from_sources",
262+
},
254263
Var("dart_root") + "/tests/co19/src": {
255264
"packages": [{
256265
"package": "dart/third_party/co19",
@@ -297,6 +306,12 @@ deps = {
297306
Var("dart_git") + "external/github.com/emscripten-core/emsdk.git" +
298307
"@" + Var("emsdk_rev"),
299308

309+
Var("dart_root") + "/third_party/flutter": {
310+
"url": Var("dart_git") + "external/github.com/flutter/flutter.git" +
311+
"@" + Var("flutter_rev"),
312+
"condition": "build_devtools_from_sources",
313+
},
314+
300315
Var("dart_root") + "/third_party/jinja2":
301316
Var("chromium_git") + "/chromium/src/third_party/jinja2.git" +
302317
"@" + Var("jinja2_rev"),

tools/build_devtools.dart

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env dart
2+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
3+
// for details. All rights reserved. Use of this source code is governed by a
4+
// BSD-style license that can be found in the LICENSE file.
5+
6+
import 'dart:io';
7+
8+
import 'package:path/path.dart' as path;
9+
10+
// Builds the Flutter DevTools app from source.
11+
void main() {
12+
final flutterSdk = path.absolute('third_party', 'flutter', 'bin', 'flutter');
13+
if (!File(flutterSdk).existsSync()) {
14+
stderr.writeln('Missing Flutter SDK at "$flutterSdk"; '
15+
'make sure that "../.client" has a `custom_vars` section with '
16+
'`"build_devtools_from_sources": True,` and then run `gclient sync`');
17+
exitCode = 1;
18+
return;
19+
}
20+
21+
final devtoolsDir = path.absolute('third_party', 'devtools_src');
22+
if (!Directory(devtoolsDir).existsSync()) {
23+
stderr.writeln('Missing devtools dir in devtools sources "$devtoolsDir"; '
24+
'make sure that "../.client" has a `custom_vars` section with '
25+
'`"build_devtools_from_sources": True,` and then run `gclient sync`');
26+
exitCode = 1;
27+
return;
28+
}
29+
30+
final dtPath = path.absolute(devtoolsDir, 'tool', 'bin', 'dt.dart');
31+
final buildResult = Process.runSync(
32+
Platform.resolvedExecutable,
33+
[dtPath, '--flutter-sdk-path=$flutterSdk', 'build'],
34+
workingDirectory: devtoolsDir,
35+
);
36+
if (buildResult.exitCode != 0) {
37+
stderr.writeln(
38+
'\'${Platform.resolvedExecutable} $dtPath --flutter-sdk-path=$flutterSdk '
39+
'build\' failed: exit code ${buildResult.exitCode}');
40+
stderr.writeln('stdout: >>>${buildResult.stdout}<<<');
41+
stderr.writeln('stderr: >>>${buildResult.stderr}<<<');
42+
exitCode = 1;
43+
return;
44+
}
45+
46+
// One final check.
47+
final buildDir = path.absolute('third_party', 'devtools_src', 'packages',
48+
'devtools_app', 'build', 'web');
49+
final mainJs = path.absolute(buildDir, 'main.dart.js');
50+
final mainWasm = path.absolute(buildDir, 'main.dart.wasm');
51+
if (!File(mainJs).existsSync()) {
52+
stderr.writeln('Missing expected built JS app at "$mainJs"');
53+
exitCode = 1;
54+
return;
55+
}
56+
if (!File(mainWasm).existsSync()) {
57+
stderr.writeln('Missing expected built WASM app at "$mainWasm"');
58+
exitCode = 1;
59+
return;
60+
}
61+
62+
// Otherwise, this script is silent.
63+
}

0 commit comments

Comments
 (0)