@@ -35,6 +35,9 @@ bool get _isDevSdk => _dartVersion.isPreRelease;
35
35
/// The root of the Dart SDK.
36
36
final _sdkDir = p.dirname (p.dirname (Platform .resolvedExecutable));
37
37
38
+ /// Whether we're using a 64-bit Dart SDK.
39
+ bool get _is64Bit => Platform .version.contains ("x64" );
40
+
38
41
main (List <String > args) => grind (args);
39
42
40
43
@DefaultTask ('Compile async code and reformat.' )
@@ -49,22 +52,32 @@ format() {
49
52
..addAll (existingSourceDirs.map ((dir) => dir.path)));
50
53
}
51
54
52
- @Task ('Build Dart snapshot.' )
55
+ @Task ('Build Dart script snapshot.' )
53
56
snapshot () {
54
57
_ensureBuild ();
55
58
Dart .run ('bin/sass.dart' , vmArgs: ['--snapshot=build/sass.dart.snapshot' ]);
56
59
}
57
60
61
+ @Task ('Build Dart application snapshot.' )
62
+ appSnapshot () {
63
+ _ensureBuild ();
64
+ Dart .run ('bin/sass.dart' ,
65
+ arguments: ['tool/app-snapshot-input.scss' ],
66
+ vmArgs: [
67
+ '--snapshot=build/sass.dart.app.snapshot' ,
68
+ '--snapshot-kind=app-jit'
69
+ ],
70
+ quiet: true );
71
+ }
72
+
58
73
@Task ('Build standalone packages for all OSes.' )
59
- @Depends (snapshot)
74
+ @Depends (snapshot, appSnapshot )
60
75
package () async {
61
76
var client = new http.Client ();
62
- await _buildPackage (client, "linux" , "x64" );
63
- await _buildPackage (client, "linux" , "ia32" );
64
- await _buildPackage (client, "macos" , "x64" );
65
- await _buildPackage (client, "macos" , "ia32" );
66
- await _buildPackage (client, "windows" , "x64" );
67
- await _buildPackage (client, "windows" , "ia32" );
77
+ await Future .wait (["linux" , "macos" , "windows" ].expand ((os) => [
78
+ _buildPackage (client, os, x64: true ),
79
+ _buildPackage (client, os, x64: false )
80
+ ]));
68
81
client.close ();
69
82
}
70
83
@@ -245,10 +258,12 @@ void _ensureBuild() {
245
258
new Directory ('build' ).createSync (recursive: true );
246
259
}
247
260
248
- /// Builds a standalone Sass package for the given [os] and [ architecture] .
261
+ /// Builds a standalone Sass package for the given [os] and architecture.
249
262
///
250
263
/// The [client] is used to download the corresponding Dart SDK.
251
- Future _buildPackage (http.Client client, String os, String architecture) async {
264
+ Future _buildPackage (http.Client client, String os, {bool x64: true }) async {
265
+ var architecture = x64 ? "x64" : "ia32" ;
266
+
252
267
// TODO: Compile a single executable that embeds the Dart VM and the snapshot
253
268
// when dart-lang/sdk#27596 is fixed.
254
269
var channel = _isDevSdk ? "dev" : "stable" ;
@@ -267,13 +282,20 @@ Future _buildPackage(http.Client client, String os, String architecture) async {
267
282
? file.name.endsWith ("/bin/dart.exe" )
268
283
: file.name.endsWith ("/bin/dart" ));
269
284
var executable = DelegatingList .typed <int >(dartExecutable.content as List );
285
+
286
+ // Use the app snapshot when packaging for the current operating system.
287
+ //
288
+ // TODO: Use an app snapshot everywhere when dart-lang/sdk#28617 is fixed.
289
+ var snapshot = os == Platform .operatingSystem && x64 == _is64Bit
290
+ ? "build/sass.dart.app.snapshot"
291
+ : "build/sass.dart.snapshot" ;
292
+
270
293
var archive = new Archive ()
271
294
..addFile (_fileFromBytes (
272
295
"dart-sass/src/dart${os == 'windows' ? '.exe' : '' }" , executable,
273
296
executable: true ))
274
297
..addFile (_file ("dart-sass/src/DART_LICENSE" , p.join (_sdkDir, 'LICENSE' )))
275
- ..addFile (
276
- _file ("dart-sass/src/sass.dart.snapshot" , "build/sass.dart.snapshot" ))
298
+ ..addFile (_file ("dart-sass/src/sass.dart.snapshot" , snapshot))
277
299
..addFile (_file ("dart-sass/src/SASS_LICENSE" , "LICENSE" ))
278
300
..addFile (_fileFromString (
279
301
"dart-sass/dart-sass${os == 'windows' ? '.bat' : '' }" ,
0 commit comments