-
Notifications
You must be signed in to change notification settings - Fork 83
[MV3 Debug Extension] Compile extension with Dart instead of shell script #1954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
00580bb
8de9846
2ca0da4
ff15136
dfa1c5f
5c24de5
4e7d541
30d5aba
304ebc1
86c5602
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// INSTRUCTIONS: | ||
|
||
// Builds the unminifed dart2js extension (see DDC issue: | ||
// see DDC issue: https://github.com/dart-lang/sdk/issues/49869). | ||
|
||
// Run from the extension root directory: | ||
// - For dev: dart run tool/build_extension.dart | ||
// - For prod: dart run tool/build_extension.dart prod | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:args/args.dart'; | ||
import 'package:path/path.dart' as p; | ||
|
||
const prodFlag = 'prod'; | ||
|
||
void main(List<String> arguments) { | ||
exitCode = 0; // presume success | ||
final parser = ArgParser() | ||
..addFlag(prodFlag, negatable: true, defaultsTo: false); | ||
final argResults = parser.parse(arguments); | ||
|
||
run(isProd: argResults[prodFlag] as bool); | ||
} | ||
|
||
Future<void> run({required bool isProd}) async { | ||
logInfo('Building extension for ${isProd ? 'prod' : 'dev'}'); | ||
logInfo('Compiling extension with dart2js to /compiled directory'); | ||
logOutput( | ||
await Process.run( | ||
'dart', | ||
['run', 'build_runner', 'build', 'web', '--output', 'build', '--release'], | ||
), | ||
); | ||
logInfo('Updating manifest.json in /compiled directory.'); | ||
logOutput( | ||
await Process.run( | ||
'dart', | ||
[p.join('tool', 'update_dev_files.dart')], | ||
), | ||
); | ||
} | ||
|
||
void logInfo(String message) { | ||
print('[BUILD STEP] $message'); | ||
} | ||
|
||
void logOutput(ProcessResult result) { | ||
final output = result.stdout; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably need to log the stderr as well. Suggestion - use transformers to listen to both and use a logger to report severe errors on failures (for example, any message from stderr, non-0 exit codes, or [SEVERE] output on stdout) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logging |
||
final outputList = output is List ? output : [output ?? '']; | ||
print(outputList.map((output) => '$output').join('\n')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we switch to using transformers on the stream to listen to lines instead and logging them one by one? That way we can see the output in progress, even if the process never ends, for example. Also it will allow us to fail early if needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the documentation:
|
||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add printing on errors, for example if the exist code is not 0? Or maybe return the exit code from
run
so the caller can check it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, now checking if the exit code is not 0, and is so printing the
stderr
.