Added a -version option to the compiler

This commit is contained in:
Andrey Breslav
2012-03-17 23:05:23 +04:00
parent cfe39d4025
commit 4231583f66
5 changed files with 80 additions and 16 deletions
@@ -59,6 +59,9 @@ public class CompilerArguments {
@Argument(value = "verbose", description = "Enable verbose logging output")
public boolean verbose;
@Argument(value = "version", description = "Display compiler version")
public boolean version;
public String getClasspath() {
return classpath;
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.cli;
/**
* @author abreslav
*/
public class CompilerVersion {
// The value of this constant is generated by the build script
// DON'T MODIFY IT
public static final String VERSION = "@snapshot@";
}
@@ -20,6 +20,7 @@ import com.sampullara.cli.Args;
import org.jetbrains.jet.compiler.CompileEnvironment;
import org.jetbrains.jet.compiler.CompileEnvironmentException;
import org.jetbrains.jet.compiler.MessageRenderer;
import org.jetbrains.jet.lang.diagnostics.Severity;
import java.io.PrintStream;
@@ -91,6 +92,11 @@ public class KotlinCompiler {
System.setProperty("java.awt.headless", "true");
MessageRenderer messageRenderer = arguments.tags ? MessageRenderer.TAGS : MessageRenderer.PLAIN;
if (arguments.version) {
errStream.println(messageRenderer.render(Severity.INFO, "Kotlin Compiler version " + CompilerVersion.VERSION, null, -1, -1));
}
CompileEnvironment environment = new CompileEnvironment(messageRenderer, arguments.verbose);
try {
configureEnvironment(environment, arguments, errStream);