mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
[vm service] generate the Java version of the library with the Dart version
Change-Id: Ie5caaee6343d616e93edcedcb2b7b9b6a4198e74 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111319 Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
This commit is contained in:
parent
ac45ee7e63
commit
44b81dff73
4
pkg/vm_service/.gitignore
vendored
4
pkg/vm_service/.gitignore
vendored
|
@ -2,3 +2,7 @@
|
|||
.dart_tool
|
||||
.packages
|
||||
pubspec.lock
|
||||
|
||||
java/build/
|
||||
java/dist/
|
||||
java/out/
|
||||
|
|
104
pkg/vm_service/java/.gitignore
vendored
104
pkg/vm_service/java/.gitignore
vendored
|
@ -1,4 +1,100 @@
|
|||
build/
|
||||
dist/
|
||||
out/
|
||||
src/gen/
|
||||
# This is a generated file.
|
||||
|
||||
src/org/dartlang/vm/service/VmService.java
|
||||
src/org/dartlang/vm/service/consumer/AllocationProfileConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/BreakpointConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/EvaluateConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/EvaluateInFrameConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/FlagListConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/GetInboundReferencesConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/GetIsolateConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/GetMemoryUsageConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/GetObjectConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/InstanceSetConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/InvokeConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/ReloadReportConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/RetainingPathConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/ScriptListConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/SourceReportConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/StackConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/SuccessConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/TimelineConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/TimelineFlagsConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/TimestampConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/VMConsumer.java
|
||||
src/org/dartlang/vm/service/consumer/VersionConsumer.java
|
||||
src/org/dartlang/vm/service/element/AllocationProfile.java
|
||||
src/org/dartlang/vm/service/element/BoundField.java
|
||||
src/org/dartlang/vm/service/element/BoundVariable.java
|
||||
src/org/dartlang/vm/service/element/Breakpoint.java
|
||||
src/org/dartlang/vm/service/element/ClassHeapStats.java
|
||||
src/org/dartlang/vm/service/element/ClassList.java
|
||||
src/org/dartlang/vm/service/element/ClassObj.java
|
||||
src/org/dartlang/vm/service/element/ClassRef.java
|
||||
src/org/dartlang/vm/service/element/Code.java
|
||||
src/org/dartlang/vm/service/element/CodeKind.java
|
||||
src/org/dartlang/vm/service/element/CodeRef.java
|
||||
src/org/dartlang/vm/service/element/Context.java
|
||||
src/org/dartlang/vm/service/element/ContextElement.java
|
||||
src/org/dartlang/vm/service/element/ContextRef.java
|
||||
src/org/dartlang/vm/service/element/ErrorKind.java
|
||||
src/org/dartlang/vm/service/element/ErrorObj.java
|
||||
src/org/dartlang/vm/service/element/ErrorRef.java
|
||||
src/org/dartlang/vm/service/element/Event.java
|
||||
src/org/dartlang/vm/service/element/EventKind.java
|
||||
src/org/dartlang/vm/service/element/ExceptionPauseMode.java
|
||||
src/org/dartlang/vm/service/element/ExtensionData.java
|
||||
src/org/dartlang/vm/service/element/Field.java
|
||||
src/org/dartlang/vm/service/element/FieldRef.java
|
||||
src/org/dartlang/vm/service/element/Flag.java
|
||||
src/org/dartlang/vm/service/element/FlagList.java
|
||||
src/org/dartlang/vm/service/element/Frame.java
|
||||
src/org/dartlang/vm/service/element/FrameKind.java
|
||||
src/org/dartlang/vm/service/element/Func.java
|
||||
src/org/dartlang/vm/service/element/FuncRef.java
|
||||
src/org/dartlang/vm/service/element/InboundReference.java
|
||||
src/org/dartlang/vm/service/element/InboundReferences.java
|
||||
src/org/dartlang/vm/service/element/Instance.java
|
||||
src/org/dartlang/vm/service/element/InstanceKind.java
|
||||
src/org/dartlang/vm/service/element/InstanceRef.java
|
||||
src/org/dartlang/vm/service/element/InstanceSet.java
|
||||
src/org/dartlang/vm/service/element/Isolate.java
|
||||
src/org/dartlang/vm/service/element/IsolateRef.java
|
||||
src/org/dartlang/vm/service/element/Library.java
|
||||
src/org/dartlang/vm/service/element/LibraryDependency.java
|
||||
src/org/dartlang/vm/service/element/LibraryRef.java
|
||||
src/org/dartlang/vm/service/element/LogRecord.java
|
||||
src/org/dartlang/vm/service/element/MapAssociation.java
|
||||
src/org/dartlang/vm/service/element/MemoryUsage.java
|
||||
src/org/dartlang/vm/service/element/Message.java
|
||||
src/org/dartlang/vm/service/element/Null.java
|
||||
src/org/dartlang/vm/service/element/NullRef.java
|
||||
src/org/dartlang/vm/service/element/Obj.java
|
||||
src/org/dartlang/vm/service/element/ObjRef.java
|
||||
src/org/dartlang/vm/service/element/ReloadReport.java
|
||||
src/org/dartlang/vm/service/element/Response.java
|
||||
src/org/dartlang/vm/service/element/RetainingObject.java
|
||||
src/org/dartlang/vm/service/element/RetainingPath.java
|
||||
src/org/dartlang/vm/service/element/Script.java
|
||||
src/org/dartlang/vm/service/element/ScriptList.java
|
||||
src/org/dartlang/vm/service/element/ScriptRef.java
|
||||
src/org/dartlang/vm/service/element/Sentinel.java
|
||||
src/org/dartlang/vm/service/element/SentinelKind.java
|
||||
src/org/dartlang/vm/service/element/SourceLocation.java
|
||||
src/org/dartlang/vm/service/element/SourceReport.java
|
||||
src/org/dartlang/vm/service/element/SourceReportCoverage.java
|
||||
src/org/dartlang/vm/service/element/SourceReportKind.java
|
||||
src/org/dartlang/vm/service/element/SourceReportRange.java
|
||||
src/org/dartlang/vm/service/element/Stack.java
|
||||
src/org/dartlang/vm/service/element/StepOption.java
|
||||
src/org/dartlang/vm/service/element/Success.java
|
||||
src/org/dartlang/vm/service/element/Timeline.java
|
||||
src/org/dartlang/vm/service/element/TimelineEvent.java
|
||||
src/org/dartlang/vm/service/element/TimelineFlags.java
|
||||
src/org/dartlang/vm/service/element/Timestamp.java
|
||||
src/org/dartlang/vm/service/element/TypeArguments.java
|
||||
src/org/dartlang/vm/service/element/TypeArgumentsRef.java
|
||||
src/org/dartlang/vm/service/element/UnresolvedSourceLocation.java
|
||||
src/org/dartlang/vm/service/element/VM.java
|
||||
src/org/dartlang/vm/service/element/VMRef.java
|
||||
src/org/dartlang/vm/service/element/Version.java
|
||||
|
|
|
@ -1 +1 @@
|
|||
version=3.23
|
||||
version=3.25
|
||||
|
|
|
@ -17,20 +17,11 @@ final bool _stampPubspecVersion = false;
|
|||
/// Parse the 'service.md' into a model and generate both Dart and Java
|
||||
/// libraries.
|
||||
main(List<String> args) async {
|
||||
bool generateJava = false;
|
||||
if (args.length != 0) {
|
||||
if ((args.length == 1) && (args.first == '--generate-java')) {
|
||||
generateJava = true;
|
||||
} else {
|
||||
print('Invalid options: $args. Usage: dart generate [--generate-java].');
|
||||
return;
|
||||
}
|
||||
}
|
||||
String appDirPath = dirname(Platform.script.toFilePath());
|
||||
|
||||
// Parse service.md into a model.
|
||||
var file =
|
||||
new File(join(appDirPath, '../../../runtime/vm/service/service.md'));
|
||||
var file = new File(
|
||||
normalize(join(appDirPath, '../../../runtime/vm/service/service.md')));
|
||||
var document = new Document();
|
||||
StringBuffer buf = new StringBuffer(file.readAsStringSync());
|
||||
var nodes = document.parseLines(buf.toString().split('\n'));
|
||||
|
@ -38,15 +29,14 @@ main(List<String> args) async {
|
|||
print('Service protocol version ${ApiParseUtil.parseVersionString(nodes)}.');
|
||||
|
||||
// Generate code from the model.
|
||||
print('');
|
||||
|
||||
await _generateDart(appDirPath, nodes);
|
||||
if (generateJava) {
|
||||
await _generateJava(appDirPath, nodes);
|
||||
}
|
||||
await _generateJava(appDirPath, nodes);
|
||||
await _generateAsserts(appDirPath, nodes);
|
||||
}
|
||||
|
||||
_generateDart(String appDirPath, List<Node> nodes) async {
|
||||
print('');
|
||||
var outDirPath = normalize(join(appDirPath, '..', 'lib'));
|
||||
var outDir = new Directory(outDirPath);
|
||||
if (!outDir.existsSync()) outDir.createSync(recursive: true);
|
||||
|
@ -71,14 +61,26 @@ _generateDart(String appDirPath, List<Node> nodes) async {
|
|||
}
|
||||
|
||||
_generateJava(String appDirPath, List<Node> nodes) async {
|
||||
print('');
|
||||
var srcDirPath = normalize(join(appDirPath, '..', 'java', 'src', 'gen'));
|
||||
assert(new Directory(srcDirPath).existsSync());
|
||||
var srcDirPath = normalize(join(appDirPath, '..', 'java', 'src'));
|
||||
var generator = new java.JavaGenerator(srcDirPath);
|
||||
java.api = new java.Api();
|
||||
java.api.parse(nodes);
|
||||
java.api.generate(generator);
|
||||
|
||||
// We generate files into the java/src/ folder; ensure the generated files
|
||||
// aren't committed to git (but manually maintained files in the same
|
||||
// directory are).
|
||||
List<String> generatedPaths = generator.allWrittenFiles
|
||||
.map((path) => relative(path, from: 'java'))
|
||||
.toList();
|
||||
generatedPaths.sort();
|
||||
File gitignoreFile = new File(join(appDirPath, '..', 'java', '.gitignore'));
|
||||
gitignoreFile.writeAsStringSync('''
|
||||
# This is a generated file.
|
||||
|
||||
${generatedPaths.join('\n')}
|
||||
''');
|
||||
|
||||
// Generate a version file.
|
||||
Version version = ApiParseUtil.parseVersionSemVer(nodes);
|
||||
File file = new File(join('java', 'version.properties'));
|
||||
|
@ -88,7 +90,6 @@ _generateJava(String appDirPath, List<Node> nodes) async {
|
|||
}
|
||||
|
||||
_generateAsserts(String appDirPath, List<Node> nodes) async {
|
||||
print('');
|
||||
var outDirPath = normalize(join(appDirPath, '..', 'example'));
|
||||
var outDir = new Directory(outDirPath);
|
||||
if (!outDir.existsSync()) outDir.createSync(recursive: true);
|
||||
|
|
|
@ -50,8 +50,12 @@ class JavaGenerator {
|
|||
/// The java source directory into which files are generated.
|
||||
final String srcDirPath;
|
||||
|
||||
Set<String> _generatedPaths = new Set();
|
||||
|
||||
JavaGenerator(this.srcDirPath);
|
||||
|
||||
Iterable<String> get allWrittenFiles => _generatedPaths;
|
||||
|
||||
/// Generate a Java class/interface in the given package
|
||||
void writeType(String typeName, WriteType write) {
|
||||
var classWriter = new TypeWriter(typeName);
|
||||
|
@ -61,6 +65,7 @@ class JavaGenerator {
|
|||
if (!pkgDir.existsSync()) pkgDir.createSync(recursive: true);
|
||||
var classFilePath = join(pkgDirPath, '${classNameFor(typeName)}.java');
|
||||
var classFile = new File(classFilePath);
|
||||
_generatedPaths.add(classFilePath);
|
||||
classFile.writeAsStringSync(classWriter.toSource());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue