Added incremental compilation flag. For publishing intermediate implementation.
This commit is contained in:
@@ -30,6 +30,7 @@ import org.jetbrains.jet.codegen.context.CodegenContext;
|
||||
import org.jetbrains.jet.codegen.context.MethodContext;
|
||||
import org.jetbrains.jet.codegen.context.PackageContext;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.config.IncrementalCompilation;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
@@ -168,6 +169,10 @@ public class CodegenUtil {
|
||||
PackageFragmentDescriptor fragment1 = (PackageFragmentDescriptor) owner1;
|
||||
PackageFragmentDescriptor fragment2 = (PackageFragmentDescriptor) owner2;
|
||||
|
||||
if (!IncrementalCompilation.ENABLED) {
|
||||
return fragment1 == fragment2;
|
||||
}
|
||||
|
||||
// backing field should be used directly within same module of same package
|
||||
// TODO calls from other modules/libraries should use facade: KT-4590
|
||||
return fragment1.getFqName().equals(fragment2.getFqName()) && DescriptorUtils.areInSameModule(fragment1, fragment2);
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.jetbrains.jet.codegen.context.MethodContext;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.codegen.context.PackageContext;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.config.IncrementalCompilation;
|
||||
import org.jetbrains.jet.descriptors.serialization.*;
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedCallableMemberDescriptor;
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedPropertyDescriptor;
|
||||
@@ -113,6 +114,10 @@ public class PackageCodegen extends GenerationStateAware {
|
||||
|
||||
@Nullable
|
||||
private PackageFragmentDescriptor getCompiledPackageFragment() {
|
||||
if (!IncrementalCompilation.ENABLED) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO rewrite it to something more robust when module system is implemented
|
||||
for (PackageFragmentDescriptor anotherFragment : packageFragment.getContainingDeclaration().getPackageFragmentProvider()
|
||||
.getPackageFragments(packageFragment.getFqName())) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.jet.codegen.signature.BothSignatureWriter;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodParameterKind;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodParameterSignature;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.config.IncrementalCompilation;
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedCallableMemberDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
|
||||
@@ -132,7 +133,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
if (file != null) {
|
||||
return PackageCodegen.getPackagePartInternalName(file);
|
||||
}
|
||||
if (descriptor instanceof DeserializedCallableMemberDescriptor) {
|
||||
if (descriptor instanceof DeserializedCallableMemberDescriptor && IncrementalCompilation.ENABLED) {
|
||||
//
|
||||
// TODO calls from other modules/libraries should use facade: KT-4590
|
||||
return PackageCodegen.getPackagePartInternalName((DeserializedCallableMemberDescriptor) descriptor);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.config;
|
||||
|
||||
public class IncrementalCompilation {
|
||||
public static final boolean ENABLED = "true".equals(System.getProperty("kotlin.incremental.compilation"));
|
||||
}
|
||||
+4
-3
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.jet.compiler.runner;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.config.IncrementalCompilation;
|
||||
import org.jetbrains.jet.utils.Printer;
|
||||
|
||||
import java.io.File;
|
||||
@@ -85,13 +86,13 @@ public class KotlinModuleXmlBuilderFactory implements KotlinModuleDescriptionBui
|
||||
public void processClassPathSection(@NotNull String sectionDescription, @NotNull Collection<File> files) {
|
||||
p.println("<!-- ", sectionDescription, " -->");
|
||||
for (File file : files) {
|
||||
boolean isOutput = directoriesToFilterOut.contains(file); // TODO make it optional
|
||||
boolean isOutput = directoriesToFilterOut.contains(file) && !IncrementalCompilation.ENABLED;
|
||||
if (isOutput) {
|
||||
// For IDEA's make (incremental compilation) purposes, output directories of the current module and its dependencies
|
||||
// appear on the class path, so we are at risk of seeing the results of the previous build, i.e. if some class was
|
||||
// removed in the sources, it may still be there in binaries. Thus, we delete these entries from the classpath.
|
||||
p.println("<!-- Output directory, commented out -->");
|
||||
//p.println("<!-- ");
|
||||
p.println("<!-- ");
|
||||
p.pushIndent();
|
||||
}
|
||||
|
||||
@@ -99,7 +100,7 @@ public class KotlinModuleXmlBuilderFactory implements KotlinModuleDescriptionBui
|
||||
|
||||
if (isOutput) {
|
||||
p.popIndent();
|
||||
//p.println("-->");
|
||||
p.println("-->");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.jps.build;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -35,6 +36,7 @@ import org.jetbrains.jet.compiler.runner.CompilerEnvironment;
|
||||
import org.jetbrains.jet.compiler.runner.CompilerRunnerConstants;
|
||||
import org.jetbrains.jet.compiler.runner.OutputItemsCollectorImpl;
|
||||
import org.jetbrains.jet.compiler.runner.SimpleOutputItem;
|
||||
import org.jetbrains.jet.config.IncrementalCompilation;
|
||||
import org.jetbrains.jet.jps.JpsKotlinCompilerSettings;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
@@ -191,9 +193,11 @@ public class KotlinBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
|
||||
for (SimpleOutputItem outputItem : outputItemCollector.getOutputs()) {
|
||||
// TODO this is a hack: we don't remove
|
||||
if (outputItem.getOutputFile().getName().endsWith("Package.class")) {
|
||||
continue;
|
||||
if (IncrementalCompilation.ENABLED) {
|
||||
// TODO this is a hack: we don't remove
|
||||
if (outputItem.getOutputFile().getName().endsWith("Package.class")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
BuildTarget<?> target = null;
|
||||
Collection<File> sourceFiles = outputItem.getSourceFiles();
|
||||
@@ -208,14 +212,19 @@ public class KotlinBuilder extends ModuleLevelBuilder {
|
||||
paths(sourceFiles));
|
||||
}
|
||||
|
||||
// TODO should mark dependencies as dirty, as well
|
||||
FSOperations.markDirty(context, chunk, new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(@NotNull File file) {
|
||||
return !allCompiledFiles.contains(file);
|
||||
}
|
||||
});
|
||||
return ExitCode.ADDITIONAL_PASS_REQUIRED;
|
||||
if (IncrementalCompilation.ENABLED) {
|
||||
// TODO should mark dependencies as dirty, as well
|
||||
FSOperations.markDirty(context, chunk, new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(@NotNull File file) {
|
||||
return !allCompiledFiles.contains(file);
|
||||
}
|
||||
});
|
||||
return ExitCode.ADDITIONAL_PASS_REQUIRED;
|
||||
}
|
||||
else {
|
||||
return ExitCode.OK;
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<File> getAllCompiledFilesContainer(CompileContext context) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.compiler.runner.KotlinModuleDescriptionBuilder;
|
||||
import org.jetbrains.jet.compiler.runner.KotlinModuleDescriptionBuilderFactory;
|
||||
import org.jetbrains.jet.compiler.runner.KotlinModuleXmlBuilderFactory;
|
||||
import org.jetbrains.jet.config.IncrementalCompilation;
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.builders.logging.ProjectBuilderLogger;
|
||||
@@ -56,7 +57,7 @@ public class KotlinBuilderModuleScriptGenerator {
|
||||
public static File generateModuleDescription(
|
||||
CompileContext context,
|
||||
ModuleChunk chunk,
|
||||
List<File> sourceFiles
|
||||
List<File> sourceFiles // ignored for non-incremental compilation
|
||||
)
|
||||
throws IOException
|
||||
{
|
||||
@@ -72,6 +73,10 @@ public class KotlinBuilderModuleScriptGenerator {
|
||||
for (ModuleBuildTarget target : chunk.getTargets()) {
|
||||
File outputDir = getOutputDir(target);
|
||||
|
||||
if (!IncrementalCompilation.ENABLED) {
|
||||
sourceFiles = new ArrayList<File>(KotlinSourceFileCollector.getAllKotlinSourceFiles(target));
|
||||
}
|
||||
|
||||
if (sourceFiles.size() > 0) {
|
||||
noSources = false;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.jps.builders.logging.BuildLoggingManager
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
||||
import org.jetbrains.jps.util.JpsPathUtil
|
||||
import com.intellij.testFramework.UsefulTestCase
|
||||
import org.jetbrains.jet.config.IncrementalCompilation
|
||||
|
||||
public class IncrementalJpsTest : JpsBuildTestCase() {
|
||||
private val testDataDir: File
|
||||
@@ -64,6 +65,10 @@ public class IncrementalJpsTest : JpsBuildTestCase() {
|
||||
}
|
||||
|
||||
private fun doTest() {
|
||||
if (!IncrementalCompilation.ENABLED) {
|
||||
return
|
||||
}
|
||||
|
||||
addModule("module", array<String>(getAbsolutePath("src")), null, null, addJdk("my jdk"))
|
||||
AbstractKotlinJpsBuildTestCase.addKotlinRuntimeDependency(myProject!!)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user