|
| 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