-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17e4220
commit 54a861c
Showing
11 changed files
with
104 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:dart_model/dart_model.dart'; | ||
|
||
/// Creates the entrypoint script for [macros]. | ||
String createBootstrap(List<QualifiedName> macros) { | ||
final script = StringBuffer(); | ||
for (var i = 0; i != macros.length; ++i) { | ||
final macro = macros[i]; | ||
// TODO(davidmorgan): pick non-clashing prefixes. | ||
script.writeln("import '${macro.uri}' as m$i;"); | ||
} | ||
script.write(''' | ||
import 'dart:convert' as convert; | ||
import 'package:_macro_client/macro_client.dart' as macro_client; | ||
import 'package:macro_service/macro_service.dart' as macro_service; | ||
void main(List<String> arguments) { | ||
macro_client.MacroClient.run( | ||
endpoint: macro_service.HostEndpoint.fromJson( | ||
convert.json.decode(arguments[0])), | ||
macros: ['''); | ||
for (var i = 0; i != macros.length; ++i) { | ||
final macro = macros[i]; | ||
script.write('m$i.${macro.name}()'); | ||
if (i != macros.length - 1) script.write(', '); | ||
} | ||
script.writeln(']);'); | ||
script.writeln('}'); | ||
return script.toString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters