compile method

Future compile(
  1. Uri srcUri,
  2. Uri dstUri
)

Implementation

Future compile(Uri srcUri, Uri dstUri) async {
  final res = await Process.run(
    "dart",
    [
      "compile",
      "exe",
      ...(context.environment?.entries.map((e) => "-D${e.key}=${e.value}") ??
          []),
      "-v",
      srcUri.toFilePath(windows: Platform.isWindows),
      "-o",
      dstUri.toFilePath(windows: Platform.isWindows)
    ],
    workingDirectory: context.buildApplicationDirectory.uri
        .toFilePath(windows: Platform.isWindows),
    runInShell: true,
  );

  if (res.exitCode != 0) {
    throw StateError(
      "'dart2native' failed with the following message: ${res.stderr}",
    );
  }
  print("${res.stdout}");
}