-
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.
Merge 73e2aa4 into dev
- Loading branch information
Showing
16 changed files
with
385 additions
and
100 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
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.