@@ -32,6 +32,8 @@ import 'package:_fe_analyzer_shared/src/macros/executor/isolated_executor.dart'
32
32
as isolatedExecutor;
33
33
import 'package:_fe_analyzer_shared/src/macros/executor/process_executor.dart'
34
34
as processExecutor;
35
+ import 'package:_fe_analyzer_shared/src/macros/executor/multi_executor.dart'
36
+ as multiExecutor;
35
37
36
38
final _watch = Stopwatch ()..start ();
37
39
void _log (String message) {
@@ -47,6 +49,11 @@ final argParser = ArgParser()
47
49
allowed: ['aot' , 'isolate' ],
48
50
defaultsTo: 'aot' ,
49
51
help: 'The execution strategy for precompiled macros.' )
52
+ ..addOption ('communication-channel' ,
53
+ allowed: ['socket' , 'stdio' ],
54
+ defaultsTo: 'stdio' ,
55
+ help: 'The communication channel to use when running as a separate'
56
+ ' process.' )
50
57
..addFlag ('help' , negatable: false , hide: true );
51
58
52
59
// Run this script to print out the generated augmentation library for an example class.
@@ -82,6 +89,10 @@ void main(List<String> args) async {
82
89
Platform .script.path.endsWith ('.dill' )
83
90
? 'jit'
84
91
: 'aot' ;
92
+
93
+ var communicationChannel = parsedArgs['communication-channel' ] == 'stdio'
94
+ ? processExecutor.CommunicationChannel .stdio
95
+ : processExecutor.CommunicationChannel .socket;
85
96
_log ('''
86
97
Running with the following options:
87
98
@@ -130,13 +141,13 @@ Host app mode: $hostMode
130
141
}
131
142
132
143
_log ('Loading the macro executor' );
133
- var executor = macroExecutionStrategy == 'aot'
134
- ? await processExecutor.start (
135
- serverSerializationMode,
136
- processExecutor.CommunicationChannel .socket,
137
- kernelOutputFile.uri.toFilePath ())
144
+ var executorImpl = macroExecutionStrategy == 'aot'
145
+ ? await processExecutor.start (serverSerializationMode,
146
+ communicationChannel, kernelOutputFile.uri.toFilePath ())
138
147
: await isolatedExecutor.start (
139
148
serverSerializationMode, kernelOutputFile.uri);
149
+ var executor = multiExecutor.MultiMacroExecutor ()
150
+ ..registerExecutorFactory (() => executorImpl, {macroUri});
140
151
141
152
_log ('Instantiating macro' );
142
153
var instanceId = await executor.instantiateMacro (
0 commit comments