10
10
library language.working.macros.example.run;
11
11
12
12
import 'dart:io' ;
13
- import 'dart:isolate' ;
14
13
15
14
import 'package:dart_style/dart_style.dart' ;
16
15
@@ -20,19 +19,19 @@ import 'package:_fe_analyzer_shared/src/macros/api.dart';
20
19
// Private impls used actually execute the macro
21
20
import 'package:_fe_analyzer_shared/src/macros/bootstrap.dart' ;
22
21
import 'package:_fe_analyzer_shared/src/macros/executor.dart' ;
23
- import 'package:_fe_analyzer_shared/src/macros/executor_shared /introspection_impls.dart' ;
24
- import 'package:_fe_analyzer_shared/src/macros/executor_shared /remote_instance.dart' ;
25
- import 'package:_fe_analyzer_shared/src/macros/executor_shared /serialization.dart' ;
26
- import 'package:_fe_analyzer_shared/src/macros/isolated_executor/isolated_executor .dart'
27
- as isolatedExecutor ;
22
+ import 'package:_fe_analyzer_shared/src/macros/executor /introspection_impls.dart' ;
23
+ import 'package:_fe_analyzer_shared/src/macros/executor /remote_instance.dart' ;
24
+ import 'package:_fe_analyzer_shared/src/macros/executor /serialization.dart' ;
25
+ import 'package:_fe_analyzer_shared/src/macros/executor/process_executor .dart'
26
+ as processExecutor ;
28
27
29
28
final _watch = Stopwatch ()..start ();
30
29
void _log (String message) {
31
30
print ('${_watch .elapsed }: $message ' );
32
31
}
33
32
34
- var clientSerializationMode = SerializationMode .jsonClient ;
35
- var serverSerializationMode = SerializationMode .jsonServer ;
33
+ const clientSerializationMode = SerializationMode .byteDataClient ;
34
+ const serverSerializationMode = SerializationMode .byteDataServer ;
36
35
37
36
// Run this script to print out the generated augmentation library for an example class.
38
37
void main () async {
@@ -43,7 +42,7 @@ void main() async {
43
42
print ('This script must be ran from the `macros` directory.' );
44
43
exit (1 );
45
44
}
46
- var executor = await isolatedExecutor .start (serverSerializationMode);
45
+ var executor = await processExecutor .start (serverSerializationMode);
47
46
var tmpDir = Directory .systemTemp.createTempSync ('data_class_macro_example' );
48
47
try {
49
48
var macroUri = thisFile.absolute.uri;
@@ -60,11 +59,13 @@ void main() async {
60
59
var kernelOutputFile =
61
60
File (tmpDir.uri.resolve ('main.dart.dill' ).toFilePath ());
62
61
_log ('Compiling DataClass macro' );
63
- var buildSnapshotResult = await Process .run (Platform .resolvedExecutable , [
64
- '--snapshot=${ kernelOutputFile . uri . toFilePath ()} ' ,
65
- '--snapshot-kind=kernel ' ,
66
- '--packages=${( await Isolate . packageConfig )!} ' ,
62
+ var buildSnapshotResult = await Process .run ('dart' , [
63
+ 'compile ' ,
64
+ 'exe ' ,
65
+ '--packages=.dart_tool/package_config.json ' ,
67
66
bootstrapFile.uri.toFilePath (),
67
+ '-o' ,
68
+ kernelOutputFile.uri.toFilePath (),
68
69
]);
69
70
70
71
if (buildSnapshotResult.exitCode != 0 ) {
0 commit comments