From 4231583f663e653f8888a4f4b8230dd4961848d9 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Sat, 17 Mar 2012 23:05:23 +0400 Subject: [PATCH] Added a -version option to the compiler --- TeamCityBuild.xml | 59 ++++++++++++++----- .../jetbrains/jet/cli/CompilerArguments.java | 3 + .../jetbrains/jet/cli/CompilerVersion.java | 26 ++++++++ .../org/jetbrains/jet/cli/KotlinCompiler.java | 6 ++ .../jet/plugin/compiler/JetCompiler.java | 2 +- 5 files changed, 80 insertions(+), 16 deletions(-) create mode 100644 compiler/cli/src/org/jetbrains/jet/cli/CompilerVersion.java diff --git a/TeamCityBuild.xml b/TeamCityBuild.xml index d88800f56fd..a20f0e8ebb3 100644 --- a/TeamCityBuild.xml +++ b/TeamCityBuild.xml @@ -8,7 +8,11 @@ - + + + + + @@ -42,36 +46,61 @@ - + + + + + + + + - + - - + + - + - + - + - + + + + + + + + - - - - + + + - + + + + + @@ -96,7 +125,7 @@ --> - + diff --git a/compiler/cli/src/org/jetbrains/jet/cli/CompilerArguments.java b/compiler/cli/src/org/jetbrains/jet/cli/CompilerArguments.java index 6aceae7ea6c..01aa2064306 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/CompilerArguments.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/CompilerArguments.java @@ -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; diff --git a/compiler/cli/src/org/jetbrains/jet/cli/CompilerVersion.java b/compiler/cli/src/org/jetbrains/jet/cli/CompilerVersion.java new file mode 100644 index 00000000000..674ba94041d --- /dev/null +++ b/compiler/cli/src/org/jetbrains/jet/cli/CompilerVersion.java @@ -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@"; +} diff --git a/compiler/cli/src/org/jetbrains/jet/cli/KotlinCompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/KotlinCompiler.java index 39a0969cd9c..13856d47d4a 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/KotlinCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/KotlinCompiler.java @@ -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); diff --git a/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java b/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java index 5c036dcb1a5..725053e9bb0 100644 --- a/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java +++ b/idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java @@ -268,7 +268,7 @@ public class JetCompiler implements TranslatingCompiler { Class kompiler = Class.forName(compilerClassName, true, loader); Method exec = kompiler.getDeclaredMethod("exec", PrintStream.class, String[].class); - String[] arguments = { "-module", scriptFile.getAbsolutePath(), "-output", path(outputDir), "-tags", "-verbose" }; + String[] arguments = { "-module", scriptFile.getAbsolutePath(), "-output", path(outputDir), "-tags", "-verbose", "-version" }; context.addMessage(INFORMATION, "Using kotlinHome=" + kotlinHome, "", -1, -1); context.addMessage(INFORMATION, "Invoking in-process compiler " + compilerClassName + " with arguments " + Arrays.asList(arguments), "", -1, -1);