external make: optionally suppress module rebuild on dependency change (IDEA-95844)

This commit is contained in:
Eugene Zhuravlev
2013-02-25 13:16:48 +01:00
parent ddc7bffd3c
commit 29a4e1ba2b
7 changed files with 44 additions and 10 deletions
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.compiler.options.CompilerUIConfigurable">
<grid id="1663f" binding="myPanel" layout-manager="GridLayoutManager" row-count="10" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="1663f" binding="myPanel" layout-manager="GridLayoutManager" row-count="11" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="28" y="24" width="883" height="379"/>
@@ -10,7 +10,7 @@
<children>
<vspacer id="67edf">
<constraints>
<grid row="9" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="10" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="b341d" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="1">
@@ -95,7 +95,7 @@
</component>
<component id="17126" class="javax.swing.JLabel" binding="myHeapSizeLabel">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Compiler process heap size (Mbytes):"/>
@@ -103,7 +103,7 @@
</component>
<component id="a28b8" class="javax.swing.JTextField" binding="myHeapSizeField">
<constraints>
<grid row="7" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false">
<grid row="8" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="50" height="-1"/>
</grid>
</constraints>
@@ -111,7 +111,7 @@
</component>
<component id="5b86a" class="javax.swing.JLabel" binding="myVMOptionsLabel">
<constraints>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Additional compiler process VM options:"/>
@@ -119,7 +119,7 @@
</component>
<component id="b5547" class="javax.swing.JTextField" binding="myVMOptionsField">
<constraints>
<grid row="8" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="9" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
@@ -149,6 +149,14 @@
<text value="(only works while not running / debugging)"/>
</properties>
</component>
<component id="4b44" class="javax.swing.JCheckBox" binding="myCbRebuildOnDependencyChange" default-binding="true">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Rebuild module on dependency change"/>
</properties>
</component>
</children>
</grid>
</form>
@@ -55,6 +55,7 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
private JTextField myVMOptionsField;
private JLabel myHeapSizeLabel;
private JLabel myVMOptionsLabel;
private JCheckBox myCbRebuildOnDependencyChange;
public CompilerUIConfigurable(final Project project) {
myProject = project;
@@ -84,6 +85,7 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
myCbUseExternalBuild.setSelected(workspaceConfiguration.USE_COMPILE_SERVER);
myCbEnableAutomake.setSelected(workspaceConfiguration.MAKE_PROJECT_ON_SAVE);
myCbParallelCompilation.setSelected(workspaceConfiguration.PARALLEL_COMPILATION);
myCbRebuildOnDependencyChange.setSelected(workspaceConfiguration.REBUILD_ON_DEPENDENCY_CHANGE);
myHeapSizeField.setText(String.valueOf(workspaceConfiguration.COMPILER_PROCESS_HEAP_SIZE));
final String options = workspaceConfiguration.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS;
myVMOptionsField.setText(options == null? "" : options.trim());
@@ -115,6 +117,7 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
workspaceConfiguration.USE_COMPILE_SERVER = myCbUseExternalBuild.isSelected();
workspaceConfiguration.MAKE_PROJECT_ON_SAVE = myCbEnableAutomake.isSelected();
workspaceConfiguration.PARALLEL_COMPILATION = myCbParallelCompilation.isSelected();
workspaceConfiguration.REBUILD_ON_DEPENDENCY_CHANGE = myCbRebuildOnDependencyChange.isSelected();
try {
workspaceConfiguration.COMPILER_PROCESS_HEAP_SIZE = Integer.parseInt(myHeapSizeField.getText().trim());
}
@@ -173,6 +176,7 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
isModified |= ComparingUtils.isModified(myCbUseExternalBuild, workspaceConfiguration.USE_COMPILE_SERVER);
isModified |= ComparingUtils.isModified(myCbEnableAutomake, workspaceConfiguration.MAKE_PROJECT_ON_SAVE);
isModified |= ComparingUtils.isModified(myCbParallelCompilation, workspaceConfiguration.PARALLEL_COMPILATION);
isModified |= ComparingUtils.isModified(myCbRebuildOnDependencyChange, workspaceConfiguration.REBUILD_ON_DEPENDENCY_CHANGE);
isModified |= ComparingUtils.isModified(myHeapSizeField, workspaceConfiguration.COMPILER_PROCESS_HEAP_SIZE);
isModified |= ComparingUtils.isModified(myVMOptionsField, workspaceConfiguration.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS);
@@ -211,6 +215,7 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
private void updateExternalMakeOptionControls(boolean enabled) {
myCbEnableAutomake.setEnabled(enabled);
myCbParallelCompilation.setEnabled(enabled);
myCbRebuildOnDependencyChange.setEnabled(enabled);
myHeapSizeField.setEnabled(enabled);
myVMOptionsField.setEnabled(enabled);
myHeapSizeLabel.setEnabled(enabled);
@@ -827,6 +827,7 @@ public class BuildManager implements ApplicationComponent{
cmdLine.addParameter("-D"+ GlobalOptions.GENERATE_CLASSPATH_INDEX_OPTION +"=" + shouldGenerateIndex);
}
cmdLine.addParameter("-D"+ GlobalOptions.COMPILE_PARALLEL_OPTION +"=" + Boolean.toString(config.PARALLEL_COMPILATION));
cmdLine.addParameter("-D"+ GlobalOptions.REBUILD_ON_DEPENDENCY_CHANGE_OPTION + "=" + Boolean.toString(config.REBUILD_ON_DEPENDENCY_CHANGE));
if (Boolean.TRUE.equals(Boolean.valueOf(System.getProperty("java.net.preferIPv4Stack", "false")))) {
cmdLine.addParameter("-Djava.net.preferIPv4Stack=true");
@@ -42,6 +42,7 @@ public class CompilerWorkspaceConfiguration implements PersistentStateComponent<
public boolean PARALLEL_COMPILATION = false;
public int COMPILER_PROCESS_HEAP_SIZE = DEFAULT_COMPILE_PROCESS_HEAP_SIZE;
public String COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS = DEFAULT_COMPILE_PROCESS_VM_OPTIONS;
public boolean REBUILD_ON_DEPENDENCY_CHANGE = true;
public static CompilerWorkspaceConfiguration getInstance(Project project) {
return ServiceManager.getService(project, CompilerWorkspaceConfiguration.class);
@@ -25,4 +25,5 @@ public interface GlobalOptions {
String GENERATE_CLASSPATH_INDEX_OPTION = "generate.classpath.index";
String COMPILE_PARALLEL_OPTION = "compile.parallel";
String COMPILE_PARALLEL_MAX_THREADS_OPTION = "compile.parallel.max.threads";
String REBUILD_ON_DEPENDENCY_CHANGE_OPTION = "rebuild.on.dependency.change";
}
@@ -22,10 +22,13 @@ import org.jetbrains.jps.builders.*;
import org.jetbrains.jps.builders.impl.BuildOutputConsumerImpl;
import org.jetbrains.jps.builders.impl.BuildTargetChunk;
import org.jetbrains.jps.builders.impl.DirtyFilesHolderBase;
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
import org.jetbrains.jps.builders.logging.ProjectBuilderLogger;
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
import org.jetbrains.jps.cmdline.ProjectDescriptor;
import org.jetbrains.jps.incremental.fs.BuildFSState;
import org.jetbrains.jps.incremental.messages.BuildMessage;
import org.jetbrains.jps.incremental.messages.CompilerMessage;
import org.jetbrains.jps.incremental.messages.DoneSomethingNotification;
import org.jetbrains.jps.incremental.messages.FileDeletedEvent;
import org.jetbrains.jps.incremental.storage.BuildDataManager;
@@ -48,17 +51,25 @@ public class BuildOperations {
final ProjectDescriptor pd = context.getProjectDescriptor();
final Timestamps timestamps = pd.timestamps.getStorage();
final BuildTargetConfiguration configuration = pd.getTargetsState().getTargetConfiguration(target);
boolean isTargetConfigChange = false;
if (context.isProjectRebuild()) {
FSOperations.markDirtyFiles(context, target, timestamps, true, null, null);
pd.fsState.markInitialScanPerformed(target);
configuration.save();
}
else if (context.getScope().isRecompilationForced(target) || configuration.isTargetDirty() || configuration.outputRootWasDeleted(context)) {
else if (context.getScope().isRecompilationForced(target) ||
(isTargetConfigChange = configuration.isTargetDirty()) ||
configuration.outputRootWasDeleted(context)) {
initTargetFSState(context, target, true);
IncProjectBuilder.clearOutputFiles(context, target);
pd.dataManager.cleanTargetStorages(target);
configuration.save();
if (isTargetConfigChange && ModuleBuildTarget.REBUILD_ON_DEPENDENCY_CHANGE && JavaModuleBuildTargetType.PRODUCTION.equals(target.getTargetType())) {
final String moduleName = ((ModuleBuildTarget)target).getModule().getName();
context.processMessage(new CompilerMessage("", BuildMessage.Kind.INFO, "Rebuilding module \"" + moduleName + "\" because of dependencies change"));
}
}
else if (!pd.fsState.isInitialScanPerformed(target)) {
initTargetFSState(context, target, false);
@@ -22,6 +22,7 @@ import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.ProjectPaths;
import org.jetbrains.jps.api.GlobalOptions;
import org.jetbrains.jps.builders.*;
import org.jetbrains.jps.builders.java.ExcludedJavaSourceRootProvider;
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
@@ -50,6 +51,9 @@ import java.util.Set;
* @author nik
*/
public final class ModuleBuildTarget extends JVMModuleBuildTarget<JavaSourceRootDescriptor> {
public static final Boolean REBUILD_ON_DEPENDENCY_CHANGE = Boolean.valueOf(
System.getProperty(GlobalOptions.REBUILD_ON_DEPENDENCY_CHANGE_OPTION, "true")
);
private final JavaModuleBuildTargetType myTargetType;
public ModuleBuildTarget(@NotNull JpsModule module, JavaModuleBuildTargetType targetType) {
@@ -169,10 +173,13 @@ public final class ModuleBuildTarget extends JVMModuleBuildTarget<JavaSourceRoot
}
private int getDependenciesFingerprint() {
final JpsModule module = getModule();
int fingerprint = 0;
if (!REBUILD_ON_DEPENDENCY_CHANGE) {
return fingerprint;
}
final JpsModule module = getModule();
JpsJavaDependenciesEnumerator enumerator = JpsJavaExtensionService.dependencies(module).compileOnly();
if (!isTests()) {
enumerator = enumerator.productionOnly();