-mode idea

#KT-1893 Fixed
This commit is contained in:
Stepan Koltsov
2012-05-04 23:57:13 +04:00
parent 78a4ebe236
commit dd332bc08c
6 changed files with 20 additions and 5 deletions
@@ -145,6 +145,9 @@ public class CompileEnvironmentUtil {
else if (compilerDependencies.getCompilerSpecialMode() == CompilerSpecialMode.BUILTINS) {
// nop
}
else if (compilerDependencies.getCompilerSpecialMode() == CompilerSpecialMode.IDEA) {
// nop
}
else {
throw new IllegalStateException("unknown mode: " + compilerDependencies.getCompilerSpecialMode());
}
@@ -80,7 +80,9 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
CompilerSpecialMode compilerSpecialMode = compilerDependencies.getCompilerSpecialMode();
addToClasspath(compilerDependencies.getJdkJar());
if (compilerSpecialMode.includeJdk()) {
addToClasspath(compilerDependencies.getJdkJar());
}
if (compilerSpecialMode.includeJdkHeaders()) {
for (VirtualFile root : compilerDependencies.getJdkHeaderRoots()) {
@@ -45,6 +45,11 @@ public class CompilerDependencies {
this.jdkHeadersJar = jdkHeadersJar;
this.runtimeJar = runtimeJar;
if (compilerSpecialMode.includeJdk()) {
if (jdkJar == null) {
throw new IllegalArgumentException("jdk must be included for mode " + compilerSpecialMode);
}
}
if (compilerSpecialMode.includeJdkHeaders()) {
if (jdkHeadersJar == null) {
throw new IllegalArgumentException("jdkHeaders must be included for mode " + compilerSpecialMode);
@@ -101,7 +106,7 @@ public class CompilerDependencies {
public static CompilerDependencies compilerDependenciesForProduction(@NotNull CompilerSpecialMode compilerSpecialMode) {
return new CompilerDependencies(
compilerSpecialMode,
findRtJar(),
compilerSpecialMode.includeJdk() ? findRtJar() : null,
compilerSpecialMode.includeJdkHeaders() ? PathUtil.getAltHeadersPath() : null,
compilerSpecialMode.includeKotlinRuntime() ? PathUtil.getDefaultRuntimePath() : null);
}
@@ -24,17 +24,22 @@ public enum CompilerSpecialMode {
BUILTINS,
JDK_HEADERS,
STDLIB,
IDEA,
JS,
;
public boolean includeJdkHeaders() {
return this == REGULAR || this == STDLIB;
return this == REGULAR || this == STDLIB || this == IDEA;
}
public boolean includeKotlinRuntime() {
return this == REGULAR;
}
public boolean includeJdk() {
return this != IDEA;
}
public boolean isStubs() {
return this == BUILTINS || this == JDK_HEADERS;
}
@@ -52,7 +52,7 @@ public class CompileCompilerDependenciesTest {
public static CompilerDependencies compilerDependenciesForTests(@NotNull CompilerSpecialMode compilerSpecialMode, boolean mockJdk) {
return new CompilerDependencies(
compilerSpecialMode,
mockJdk ? JetTestUtils.findMockJdkRtJar() : CompilerDependencies.findRtJar(),
compilerSpecialMode.includeJdk() ? (mockJdk ? JetTestUtils.findMockJdkRtJar() : CompilerDependencies.findRtJar()) : null,
compilerSpecialMode.includeJdkHeaders() ? ForTestCompileJdkHeaders.jdkHeadersForTests() : null,
compilerSpecialMode.includeKotlinRuntime() ? ForTestCompileRuntime.runtimeJarForTests() : null);
}
@@ -259,7 +259,7 @@ public class JetCompiler implements TranslatingCompiler {
private static String[] commandLineArguments(VirtualFile outputDir, File scriptFile) {
return new String[]{"-module", scriptFile.getAbsolutePath(), "-output", path(outputDir), "-tags", "-verbose", "-version", "-mode",
"stdlib"};
"idea"};
}
private static void runOutOfProcess(final CompileContext compileContext,