@@ -33,6 +33,14 @@ import 'utils.dart';
3333/// This defaults to [name] .
3434final standaloneName = InternalConfigVariable .fn <String >(() => name.value);
3535
36+ /// Whether to build a native executable for the current platform instead of an
37+ /// AOT snapshot.
38+ /// Defined as a function of a [CliPlatform] to allow different behavior on
39+ /// different platforms.
40+ ///
41+ /// This defaults to `CliPlatform::useExe` .
42+ final useExe = InternalConfigVariable .value< bool Function (CliPlatform )> ((CliPlatform platform) => platform.useExe);
43+
3644/// For each executable entrypoint in [executables] , builds a portable module
3745/// (kernel) to `build/${executable}.snapshot` .
3846void _compileSnapshot () {
@@ -66,7 +74,8 @@ void _compileSnapshot() {
6674}
6775
6876/// For each executable entrypoint in [executables] , builds an AOT module
69- /// (aot-snapshot) to `build/${executable}.native` .
77+ /// (aot-snapshot) or standalone executable (exe) to
78+ /// `build/${executable}.native` .
7079///
7180/// If [enableAsserts] is `true` , this compiles with `--enable-asserts` .
7281void _compileNative ({bool enableAsserts = false }) {
@@ -85,7 +94,7 @@ void _compileNative({bool enableAsserts = false}) {
8594 'dart' ,
8695 arguments: [
8796 'compile' ,
88- CliPlatform .current.useExe ? 'exe' : 'aot-snapshot' ,
97+ useExe. value ( CliPlatform .current) ? 'exe' : 'aot-snapshot' ,
8998 if (enableAsserts) '--enable-asserts' ,
9099 for (var entry in environmentConstants.value.entries)
91100 '-D${entry .key }=${entry .value }' ,
@@ -109,6 +118,7 @@ void addStandaloneTasks() {
109118
110119 freezeSharedVariables ();
111120 standaloneName.freeze ();
121+ useExe.freeze ();
112122
113123 addTask (
114124 GrinderTask (
@@ -211,7 +221,7 @@ Future<void> _buildPackage(CliPlatform platform) async {
211221 var archive = Archive ()
212222 ..addFile (fileFromString ("$standaloneName /src/LICENSE" , await license));
213223
214- if (! platform.useExe) {
224+ if (! ( platform.useNative && useExe. value (platform)) ) {
215225 archive.addFile (
216226 fileFromBytes (
217227 "$standaloneName /src/dart${platform .binaryExtension }" ,
@@ -222,7 +232,7 @@ Future<void> _buildPackage(CliPlatform platform) async {
222232 }
223233
224234 for (var name in executables.value.keys) {
225- if (platform.useExe) {
235+ if (platform.useNative && useExe. value (platform) ) {
226236 archive.addFile (
227237 file (
228238 "$standaloneName /$name ${platform .binaryExtension }" ,
@@ -240,7 +250,7 @@ Future<void> _buildPackage(CliPlatform platform) async {
240250 }
241251 }
242252
243- if (! platform.useExe) {
253+ if (! ( platform.useNative && useExe. value (platform)) ) {
244254 // Do this separately from adding entrypoints because multiple executables
245255 // may have the same entrypoint.
246256 for (var name in executables.value.keys) {
0 commit comments