blob: 3e20772c6b66b0ffde61b3156d3fc324ed0cf33d [file] [log] [blame]
// Copyright (c) 2019, 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 'dart:io' show Platform, Process, ProcessResult;
import 'package:front_end/src/api_prototype/compiler_options.dart';
import 'package:kernel/ast.dart' as kernel show Version, defaultLanguageVersion;
import '../utils/io_utils.dart';
final String repoDir = computeRepoDir();
String get dartVm => Platform.executable;
main(List<String> args) async {
ProcessResult result = await
"python", ["tools/", "--no_git", "-q"],
workingDirectory: repoDir);
String stdout = result.stdout.toString();
String stderr = result.stderr.toString();
int exitCode = result.exitCode;
print("--- stdout ---");
print("--- stderr ---");
print("---exit code ---");
// E.g. "2.6.0-edge" (without the quotes).
String versionString = stdout.split("\n")[0];
List<String> dotSeparatedParts = versionString.split(".");
int major = int.tryParse(dotSeparatedParts[0]);
int minor = int.tryParse(dotSeparatedParts[1]);
kernel.Version version = new kernel.Version(major, minor);
if (kernel.defaultLanguageVersion != version) {
throw "Kernel defaults "
" does not match output from ($version)";
} else {
print("Kernel version matches.");
CompilerOptions compilerOptions = new CompilerOptions();
List<String> dotSeparatedPartsFromOptions =
int majorFromOptions = int.tryParse(dotSeparatedPartsFromOptions[0]);
int minorFromOptions = int.tryParse(dotSeparatedPartsFromOptions[1]);
if (majorFromOptions != major || minorFromOptions != minor) {
throw "CompilerOptions defaults "
" does not match output from ($major.$minor)";
} else {
print("CompilerOptions default version matches.");