Merge remote-tracking branch 'origin/master'
Conflicts: js/js.tests/test/org/jetbrains/k2js/test/SingleFileTranslationTest.java js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibTestToJSTest.java
This commit is contained in:
@@ -71,7 +71,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments, K2JSCompile
|
||||
return ExitCode.INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
JetCoreEnvironment environmentForJS = JetCoreEnvironment.getCoreEnvironmentForJS(rootDisposable);
|
||||
JetCoreEnvironment environmentForJS = JetCoreEnvironment.createCoreEnvironmentForJS(rootDisposable);
|
||||
|
||||
for (String sourceFile : arguments.sourceFiles) {
|
||||
environmentForJS.addSources(sourceFile);
|
||||
|
||||
@@ -37,7 +37,6 @@ import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.cli.common.ExitCode.*;
|
||||
@@ -58,17 +57,17 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
||||
protected ExitCode doExecute(K2JVMCompilerArguments arguments, PrintingMessageCollector messageCollector, Disposable rootDisposable) {
|
||||
|
||||
CompilerSpecialMode mode = parseCompilerSpecialMode(arguments);
|
||||
File jdkHeadersJar;
|
||||
if (mode.includeJdkHeaders()) {
|
||||
if (arguments.jdkHeaders != null) {
|
||||
jdkHeadersJar = new File(arguments.jdkHeaders);
|
||||
File jdkAnnotationsJar;
|
||||
if (mode.includeJdkAnnotations()) {
|
||||
if (arguments.jdkAnnotations != null) {
|
||||
jdkAnnotationsJar = new File(arguments.jdkAnnotations);
|
||||
}
|
||||
else {
|
||||
jdkHeadersJar = PathUtil.getAltHeadersPath();
|
||||
jdkAnnotationsJar = PathUtil.getJdkAnnotationsPath();
|
||||
}
|
||||
}
|
||||
else {
|
||||
jdkHeadersJar = null;
|
||||
jdkAnnotationsJar = null;
|
||||
}
|
||||
File runtimeJar;
|
||||
|
||||
@@ -84,7 +83,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
||||
runtimeJar = null;
|
||||
}
|
||||
|
||||
CompilerDependencies dependencies = new CompilerDependencies(mode, CompilerDependencies.findRtJar(), jdkHeadersJar, runtimeJar);
|
||||
CompilerDependencies dependencies = new CompilerDependencies(mode, CompilerDependencies.findRtJar(), jdkAnnotationsJar, runtimeJar);
|
||||
|
||||
final List<String> argumentsSourceDirs = arguments.getSourceDirs();
|
||||
if (!arguments.script &&
|
||||
@@ -97,7 +96,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
||||
return ExitCode.OK;
|
||||
}
|
||||
|
||||
JetCoreEnvironment environment = JetCoreEnvironment.getCoreEnvironmentForJVM(rootDisposable, dependencies);
|
||||
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, dependencies);
|
||||
K2JVMCompileEnvironmentConfiguration configuration = new K2JVMCompileEnvironmentConfiguration(environment, messageCollector, arguments.script);
|
||||
|
||||
messageCollector.report(CompilerMessageSeverity.LOGGING, "Configuring the compilation environment",
|
||||
@@ -206,6 +205,12 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
||||
List<File> classpath = getClasspath(arguments);
|
||||
CompileEnvironmentUtil.addToClasspath(configuration.getEnvironment(), Iterables.toArray(classpath, File.class));
|
||||
}
|
||||
|
||||
if (arguments.annotations != null) {
|
||||
for (String root : Splitter.on(File.pathSeparatorChar).split(arguments.annotations)) {
|
||||
configuration.getEnvironment().addExternalAnnotationsRoot(PathUtil.jarFileOrDirectoryToVirtualFile(new File(root)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -48,14 +48,17 @@ public class K2JVMCompilerArguments extends CompilerArguments {
|
||||
@Argument(value = "classpath", description = "classpath to use when compiling")
|
||||
public String classpath;
|
||||
|
||||
@Argument(value = "annotations", description = "paths to external annotations")
|
||||
public String annotations;
|
||||
|
||||
@Argument(value = "includeRuntime", description = "include Kotlin runtime in to resulting jar")
|
||||
public boolean includeRuntime;
|
||||
|
||||
@Argument(value = "stdlib", description = "Path to the stdlib.jar")
|
||||
public String stdlib;
|
||||
|
||||
@Argument(value = "jdkHeaders", description = "Path to the kotlin-jdk-headers.jar")
|
||||
public String jdkHeaders;
|
||||
@Argument(value = "jdkAnnotations", description = "Path to the kotlin-jdk-annotations.jar")
|
||||
public String jdkAnnotations;
|
||||
|
||||
@Argument(value = "mode", description = "Special compiler modes: stubs or jdkHeaders")
|
||||
public String mode;
|
||||
|
||||
@@ -140,7 +140,7 @@ public class CompileEnvironmentUtil {
|
||||
}
|
||||
};
|
||||
CompilerDependencies dependencies = CompilerDependencies.compilerDependenciesForProduction(CompilerSpecialMode.REGULAR);
|
||||
JetCoreEnvironment scriptEnvironment = JetCoreEnvironment.getCoreEnvironmentForJVM(disposable, dependencies);
|
||||
JetCoreEnvironment scriptEnvironment = JetCoreEnvironment.createCoreEnvironmentForJVM(disposable, dependencies);
|
||||
scriptEnvironment.addSources(moduleScriptFile);
|
||||
|
||||
GenerationState generationState = KotlinToJVMBytecodeCompiler
|
||||
|
||||
@@ -33,6 +33,8 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||
import org.jetbrains.jet.lang.resolve.java.JetFilesProvider;
|
||||
import org.jetbrains.jet.lang.resolve.java.extAnnotations.CoreAnnotationsProvider;
|
||||
import org.jetbrains.jet.lang.resolve.java.extAnnotations.ExternalAnnotationsProvider;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.plugin.JetFileType;
|
||||
|
||||
@@ -47,14 +49,15 @@ import java.util.List;
|
||||
*/
|
||||
public class JetCoreEnvironment extends JavaCoreEnvironment {
|
||||
private final List<JetFile> sourceFiles = new ArrayList<JetFile>();
|
||||
private final CoreAnnotationsProvider annotationsProvider;
|
||||
|
||||
@NotNull
|
||||
public static JetCoreEnvironment getCoreEnvironmentForJS(Disposable disposable) {
|
||||
public static JetCoreEnvironment createCoreEnvironmentForJS(Disposable disposable) {
|
||||
return new JetCoreEnvironment(disposable, CompilerDependencies.compilerDependenciesForProduction(CompilerSpecialMode.JS));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetCoreEnvironment getCoreEnvironmentForJVM(Disposable disposable, @NotNull CompilerDependencies dependencies) {
|
||||
public static JetCoreEnvironment createCoreEnvironmentForJVM(Disposable disposable, @NotNull CompilerDependencies dependencies) {
|
||||
return new JetCoreEnvironment(disposable, dependencies);
|
||||
}
|
||||
|
||||
@@ -86,11 +89,15 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
|
||||
addToClasspath(compilerDependencies.getJdkJar());
|
||||
}
|
||||
|
||||
if (compilerSpecialMode.includeJdkHeaders()) {
|
||||
for (VirtualFile root : compilerDependencies.getJdkHeaderRoots()) {
|
||||
addLibraryRoot(root);
|
||||
annotationsProvider = new CoreAnnotationsProvider();
|
||||
if (compilerSpecialMode.includeJdkAnnotations()) {
|
||||
for (VirtualFile root : compilerDependencies.getJdkAnnotationsRoots()) {
|
||||
annotationsProvider.addExternalAnnotationsRoot(root);
|
||||
}
|
||||
}
|
||||
|
||||
myProject.registerService(ExternalAnnotationsProvider.class, annotationsProvider);
|
||||
|
||||
if (compilerSpecialMode.includeKotlinRuntime()) {
|
||||
addToClasspath(compilerDependencies.getRuntimeJar());
|
||||
}
|
||||
@@ -98,6 +105,10 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
|
||||
JetStandardLibrary.initialize(getProject());
|
||||
}
|
||||
|
||||
public void addExternalAnnotationsRoot(VirtualFile root) {
|
||||
annotationsProvider.addExternalAnnotationsRoot(root);
|
||||
}
|
||||
|
||||
public MockApplication getApplication() {
|
||||
return myApplication;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
import org.jetbrains.jet.plugin.JetMainDetector;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
import org.jetbrains.jet.utils.Progress;
|
||||
|
||||
import java.io.File;
|
||||
@@ -79,6 +80,10 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
configuration.getEnvironment().addToClasspath(new File(classpathRoot));
|
||||
}
|
||||
|
||||
for (String annotationsRoot : moduleBuilder.getAnnotationsRoots()) {
|
||||
configuration.getEnvironment().addExternalAnnotationsRoot(PathUtil.jarFileOrDirectoryToVirtualFile(new File(annotationsRoot)));
|
||||
}
|
||||
|
||||
GenerationState generationState = analyzeAndGenerate(configuration);
|
||||
if (generationState == null) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user