-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Marked as experimental, and only shown when verbose flag is passed: ``` $ dart help compile -v Compile Dart to various formats. Usage: dart [vm-options] compile <subcommand> [arguments] -h, --help Print this usage information. Available subcommands: aot-snapshot Compile Dart to an AOT snapshot. exe Compile Dart to a self-contained executable. jit-snapshot Compile Dart to a JIT snapshot. js Compile Dart to JavaScript. kernel Compile Dart to a kernel snapshot. wasm Compile Dart to a WebAssembly/WasmGC module (EXPERIMENTAL). ``` Change-Id: I6a0e65d4fbdd7b2782406b8b9969e14036bf0711 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304860 Reviewed-by: Ben Konyi <[email protected]> Commit-Queue: Michael Thomsen <[email protected]> Reviewed-by: Aske Simon Christensen <[email protected]>
- Loading branch information
Showing
10 changed files
with
371 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'dart:io'; | ||
import 'package:dart2wasm/compiler_options.dart'; | ||
import 'package:dart2wasm/compile.dart'; | ||
import 'package:front_end/src/api_unstable/vm.dart' show printDiagnosticMessage; | ||
export 'package:dart2wasm/compiler_options.dart'; | ||
|
||
typedef PrintError = void Function(String error); | ||
|
||
Future<int> generateWasm(WasmCompilerOptions options, | ||
{bool verbose = false, PrintError errorPrinter = print}) async { | ||
if (verbose) { | ||
print('Running dart compile wasm...'); | ||
print(' - input file name = ${options.mainUri}'); | ||
print(' - output file name = ${options.outputFile}'); | ||
print(' - sdkPath = ${options.sdkPath}'); | ||
print(' - librariesSpecPath = ${options.librariesSpecPath}'); | ||
print(' - packagesPath file = ${options.packagesPath}'); | ||
print(' - platformPath file = ${options.platformPath}'); | ||
} | ||
|
||
CompilerOutput? output = await compileToModule( | ||
options, (message) => printDiagnosticMessage(message, errorPrinter)); | ||
|
||
if (output == null) { | ||
return 1; | ||
} | ||
|
||
final File outFile = File(options.outputFile); | ||
outFile.parent.createSync(recursive: true); | ||
await outFile.writeAsBytes(output.wasmModule); | ||
|
||
final jsFile = options.outputJSRuntimeFile ?? | ||
'${options.outputFile.substring(0, options.outputFile.lastIndexOf('.'))}.mjs'; | ||
await File(jsFile).writeAsString(output.jsRuntime); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.