Unverified Commit be97d03a authored by Jackson Gardner's avatar Jackson Gardner Committed by GitHub

Use depfile with dart2wasm to determine when to rebuild. (#122817)

Use depfile with dart2wasm to determine when to rebuild.
parent 245d6d45
......@@ -295,6 +295,7 @@ class Dart2WasmTarget extends Dart2WebTarget {
final BuildMode buildMode = getBuildModeForName(buildModeEnvironment);
final Artifacts artifacts = globals.artifacts!;
final File outputWasmFile = environment.buildDir.childFile('main.dart.wasm');
final File depFile = environment.buildDir.childFile('dart2wasm.d');
final String dartSdkPath = artifacts.getArtifactPath(Artifact.engineDartSdkPath, platform: TargetPlatform.web_javascript);
final String dartSdkRoot = environment.fileSystem.directory(dartSdkPath).parent.path;
......@@ -319,10 +320,12 @@ class Dart2WasmTarget extends Dart2WebTarget {
dartSdkRoot,
'--libraries-spec',
artifacts.getHostArtifact(HostArtifact.flutterWebLibrariesJson).path,
'--depfile=${depFile.path}',
environment.buildDir.childFile('main.dart').path, // dartfile
outputWasmFile.path,
];
globals.printTrace('compiling dart code to wasm with command "${compilationArgs.join(' ')}"');
final ProcessResult compileResult = await globals.processManager.run(compilationArgs);
if (compileResult.exitCode != 0) {
throw Exception(_collectOutput(compileResult));
......@@ -335,6 +338,11 @@ class Dart2WasmTarget extends Dart2WebTarget {
@override
String get name => 'dart2wasm';
@override
List<String> get depfiles => const <String>[
'dart2wasm.d',
];
@override
List<Source> get outputs => const <Source>[
Source.pattern('{OUTPUT_DIR}/main.dart.wasm'),
......
......@@ -778,6 +778,8 @@ void main() {
environment.defines[kBuildMode] = 'profile';
environment.defines[kDartDefines] = encodeDartDefines(<String>['FOO=bar', 'BAZ=qux']);
final File depFile = environment.buildDir.childFile('dart2wasm.d');
processManager.addCommand(FakeCommand(
command: <String>[
'bin/cache/dart-sdk/bin/dartaotruntime',
......@@ -796,6 +798,7 @@ void main() {
'bin/cache',
'--libraries-spec',
'bin/cache/flutter_web_sdk/libraries.json',
'--depfile=${depFile.absolute.path}',
environment.buildDir.childFile('main.dart').absolute.path,
environment.buildDir.childFile('main.dart.wasm').absolute.path,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment