cli: store unused arguments
This commit is contained in:
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@@ -96,7 +97,7 @@ public class BytecodeCompiler {
|
|||||||
*/
|
*/
|
||||||
public void sourcesToDir ( @NotNull String src, @NotNull String output, @Nullable String stdlib, @Nullable String[] classpath ) {
|
public void sourcesToDir ( @NotNull String src, @NotNull String output, @Nullable String stdlib, @Nullable String[] classpath ) {
|
||||||
try {
|
try {
|
||||||
boolean success = KotlinToJVMBytecodeCompiler.compileBunchOfSources(env(stdlib, classpath), src, null, output, true
|
boolean success = KotlinToJVMBytecodeCompiler.compileBunchOfSources(env(stdlib, classpath), Collections.singletonList(src), null, output, true
|
||||||
/* Last arg is ignored anyway */);
|
/* Last arg is ignored anyway */);
|
||||||
if ( ! success ) {
|
if ( ! success ) {
|
||||||
throw new CompileEnvironmentException( errorMessage( src, false ));
|
throw new CompileEnvironmentException( errorMessage( src, false ));
|
||||||
@@ -119,7 +120,7 @@ public class BytecodeCompiler {
|
|||||||
*/
|
*/
|
||||||
public void sourcesToJar ( @NotNull String src, @NotNull String jar, boolean includeRuntime, @Nullable String stdlib, @Nullable String[] classpath ) {
|
public void sourcesToJar ( @NotNull String src, @NotNull String jar, boolean includeRuntime, @Nullable String stdlib, @Nullable String[] classpath ) {
|
||||||
try {
|
try {
|
||||||
boolean success = KotlinToJVMBytecodeCompiler.compileBunchOfSources(env(stdlib, classpath), src, jar, null, includeRuntime);
|
boolean success = KotlinToJVMBytecodeCompiler.compileBunchOfSources(env(stdlib, classpath), Collections.singletonList(src), jar, null, includeRuntime);
|
||||||
if ( ! success ) {
|
if ( ! success ) {
|
||||||
throw new CompileEnvironmentException( errorMessage( src, false ));
|
throw new CompileEnvironmentException( errorMessage( src, false ));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public abstract class CLICompiler<A extends CompilerArguments, C extends Compile
|
|||||||
*/
|
*/
|
||||||
protected boolean parseArguments(@NotNull PrintStream errStream, @NotNull A arguments, @NotNull String[] args) {
|
protected boolean parseArguments(@NotNull PrintStream errStream, @NotNull A arguments, @NotNull String[] args) {
|
||||||
try {
|
try {
|
||||||
Args.parse(arguments, args);
|
arguments.freeArgs = Args.parse(arguments, args);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException e) {
|
catch (IllegalArgumentException e) {
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ public abstract class CompilerArguments {
|
|||||||
this.compilerPlugins = compilerPlugins;
|
this.compilerPlugins = compilerPlugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> freeArgs;
|
||||||
|
|
||||||
public abstract boolean isHelp();
|
public abstract boolean isHelp();
|
||||||
public abstract boolean isTags();
|
public abstract boolean isTags();
|
||||||
public abstract boolean isVersion();
|
public abstract boolean isVersion();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.cli.jvm;
|
|||||||
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.Disposable;
|
import com.intellij.openapi.Disposable;
|
||||||
import com.intellij.util.ArrayUtil;
|
import com.intellij.util.ArrayUtil;
|
||||||
import com.intellij.util.Function;
|
import com.intellij.util.Function;
|
||||||
@@ -124,8 +125,13 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
|||||||
arguments.includeRuntime);
|
arguments.includeRuntime);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
List<String> sources = Lists.newArrayList();
|
||||||
|
if (arguments.src != null) {
|
||||||
|
sources.add(arguments.src);
|
||||||
|
}
|
||||||
|
sources.addAll(arguments.freeArgs);
|
||||||
noErrors = KotlinToJVMBytecodeCompiler.compileBunchOfSources(configuration,
|
noErrors = KotlinToJVMBytecodeCompiler.compileBunchOfSources(configuration,
|
||||||
arguments.src, arguments.jar, arguments.outputDir,
|
sources, arguments.jar, arguments.outputDir,
|
||||||
arguments.includeRuntime);
|
arguments.includeRuntime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -159,8 +159,10 @@ public class KotlinToJVMBytecodeCompiler {
|
|||||||
public static boolean compileBunchOfSources(
|
public static boolean compileBunchOfSources(
|
||||||
K2JVMCompileEnvironmentConfiguration configuration,
|
K2JVMCompileEnvironmentConfiguration configuration,
|
||||||
|
|
||||||
String sourceFileOrDir, String jar, String outputDir, boolean includeRuntime) {
|
List<String> sourceFilesOrDirs, String jar, String outputDir, boolean includeRuntime) {
|
||||||
configuration.getEnvironment().addSources(sourceFileOrDir);
|
for (String sourceFileOrDir : sourceFilesOrDirs) {
|
||||||
|
configuration.getEnvironment().addSources(sourceFileOrDir);
|
||||||
|
}
|
||||||
|
|
||||||
return compileBunchOfSources(configuration, jar, outputDir, includeRuntime);
|
return compileBunchOfSources(configuration, jar, outputDir, includeRuntime);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user