update the tooling to generate libraries.json from libraries.yaml

Change-Id: I960187ae02834f42a2b7fce2135a8b84b1f21979
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208260
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
This commit is contained in:
Devon Carew 2021-07-27 23:02:50 +00:00 committed by commit-bot@chromium.org
parent 94a40a6b09
commit c17e2a13da
4 changed files with 5 additions and 34 deletions

View file

@ -5,7 +5,7 @@
# Note: if you edit this file, you must also generate libraries.json in this
# directory:
#
# python3 ./tools/yaml2json.py sdk/lib/libraries.yaml sdk/lib/libraries.json
# dart tools/yaml2json.dart sdk/lib/libraries.yaml sdk/lib/libraries.json
#
# We currently have several different files that needs to be updated when
# changing libraries, sources, and patch files. See

View file

@ -5,7 +5,7 @@
# Note: if you edit this file, you must also generate libraries.json in this
# directory:
#
# python3 ./tools/yaml2json.py sdk/lib/vmservice_libraries.yaml sdk/lib/vmservice_libraries.json
# dart tools/yaml2json.dart sdk/lib/vmservice_libraries.yaml sdk/lib/vmservice_libraries.json
#
# We currently have several different files that needs to be updated when
# changing libraries, sources, and patch files. See

View file

@ -2,8 +2,6 @@
// 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.
// @dart = 2.9
import 'dart:io' show File, exit, stderr;
import 'dart:isolate' show RawReceivePort;
@ -12,7 +10,7 @@ import 'dart:convert' show JsonEncoder;
import 'package:yaml/yaml.dart' show loadYaml;
main(List<String> arguments) async {
main(List<String> arguments) {
var port = new RawReceivePort();
if (arguments.length != 2) {
stderr.writeln("Usage: yaml2json.dart input.yaml output.json");
@ -20,7 +18,7 @@ main(List<String> arguments) async {
}
Uri input = Uri.base.resolve(arguments[0]);
Uri output = Uri.base.resolve(arguments[1]);
Map yaml = loadYaml(await new File.fromUri(input).readAsString());
Map yaml = loadYaml(new File.fromUri(input).readAsStringSync());
Map<String, dynamic> result = new Map<String, dynamic>();
result["comment:0"] = "NOTE: THIS FILE IS GENERATED. DO NOT EDIT.";
result["comment:1"] =
@ -29,6 +27,6 @@ main(List<String> arguments) async {
result[key] = yaml[key];
}
File file = new File.fromUri(output);
await file.writeAsString(const JsonEncoder.withIndent(" ").convert(result));
file.writeAsStringSync(const JsonEncoder.withIndent(" ").convert(result));
port.close();
}

View file

@ -1,27 +0,0 @@
#!/usr/bin/env python3
# Copyright (c) 2017, 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 os
import subprocess
import sys
import utils
def Main():
args = sys.argv[1:]
yaml2json_dart = os.path.relpath(
os.path.join(os.path.dirname(__file__), "yaml2json.dart"))
command = [utils.CheckedInSdkExecutable(), yaml2json_dart] + args
with utils.CoreDumpArchiver(args):
exit_code = subprocess.call(command)
utils.DiagnoseExitCode(exit_code, command)
return exit_code
if __name__ == '__main__':
sys.exit(Main())