# HG changeset patch # User stechong # Date 1271874059 18000 # Node ID 501f8a427af126f5b849c47e4c70d17e99189395 # Parent 323d745d1d2e28f6c8f6c182df2c8e5f6cc5ffd5 Fix for Bug 10757 (Build is not started when "Use default incremental builder" option is set in preferences). diff -r 323d745d1d2e -r 501f8a427af1 builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/builder/CarbideCPPBuilder.java --- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/builder/CarbideCPPBuilder.java Tue Apr 20 15:36:33 2010 -0500 +++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/builder/CarbideCPPBuilder.java Wed Apr 21 13:20:59 2010 -0500 @@ -147,6 +147,7 @@ IProject currentProject = getProject(); ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(currentProject); if (cpi != null) { + ICarbideBuildConfiguration defaultConfig = cpi.getDefaultConfiguration(); if (cpi.incrementalBuilderEnabled()) { // the callOnEmptyDelta builder attribute is set, so we get called // not matter what, even with an empty delta. this means that when the @@ -156,30 +157,29 @@ IResourceDelta delta = getDelta(currentProject); if (delta != null) { // something in the workspace has changed. see if a rebuild is needed. - if (!shouldRebuild(delta)) { - - // also rebuild if the project has errors - boolean hasErrors = false; - try { - for (IMarker currMarker : getProject().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE)){ - if (currMarker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR) == IMarker.SEVERITY_ERROR){ - hasErrors = true; - break; + if (shouldRebuild(delta)) { + // set rebuild flag in build configs + shouldRebuildConfigs(cpi); + } else { + if (defaultConfig != null) { + // check current build config to see if rebuild is needed + CarbideBuildConfiguration config = (CarbideBuildConfiguration) defaultConfig; + if (!config.getRebuildNeeded()) { + // also rebuild if the project has errors + if (!projectHasErrors()) { + return null; } } - - } catch (CoreException e){ - e.printStackTrace(); - } - - if (!hasErrors) { - return null; + } else { + // also rebuild if the project has errors + if (!projectHasErrors()) { + return null; + } } } } } - ICarbideBuildConfiguration defaultConfig = cpi.getDefaultConfiguration(); if (defaultConfig != null) { CarbideCommandLauncher launcher = new CarbideCommandLauncher(currentProject, monitor, getParserIdArray(defaultConfig.getErrorParserId()), cpi.getINFWorkingDirectory()); launcher.showCommand(true); @@ -187,6 +187,12 @@ } else { CarbideBuilderPlugin.createCarbideProjectMarker(currentProject, IMarker.SEVERITY_ERROR, "Project has no configurations.", IMarker.PRIORITY_HIGH); } + + if (!monitor.isCanceled() && cpi.incrementalBuilderEnabled() && defaultConfig != null) { + // reset rebuild flag in current build config after build succeeded + CarbideBuildConfiguration config = ((CarbideBuildConfiguration) defaultConfig); + config.setRebuildNeeded(false); + } } monitor.done(); @@ -218,6 +224,31 @@ return false; } + protected void shouldRebuildConfigs(ICarbideProjectInfo cpi) { + List configs = cpi.getBuildConfigurations(); + ICarbideBuildConfiguration defaultConfig = cpi.getDefaultConfiguration(); + for (ICarbideBuildConfiguration config : configs) { + CarbideBuildConfiguration cbc = (CarbideBuildConfiguration) config; + cbc.setRebuildNeeded(true); + } + } + + protected boolean projectHasErrors() { + boolean hasErrors = false; + try { + for (IMarker currMarker : getProject().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE)){ + if (currMarker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR) == IMarker.SEVERITY_ERROR){ + hasErrors = true; + break; + } + } + + } catch (CoreException e){ + e.printStackTrace(); + } + return hasErrors; + } + protected void clean(IProgressMonitor monitor) throws CoreException { SubMonitor subMonitor = SubMonitor.convert(monitor, 1); diff -r 323d745d1d2e -r 501f8a427af1 builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java --- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java Tue Apr 20 15:36:33 2010 -0500 +++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildConfiguration.java Wed Apr 21 13:20:59 2010 -0500 @@ -71,6 +71,7 @@ protected BuildConfigurationData buildConfigData; protected ROMBuilderInfo romBuilderInfo; protected SBSv2BuilderInfo sbsv2BuilderInfo; + protected boolean rebuildNeeded; public CarbideBuildConfiguration(IProject project, ISymbianBuildContext context) { super(context.getSDK(), context.getPlatformString(), context.getTargetString(), context.getSBSv2Alias()); @@ -83,6 +84,7 @@ if (context.getSBSv2Alias() != null){ sbsv2BuilderInfo = new SBSv2BuilderInfo(context); } + rebuildNeeded = true; } public void loadFromStorage(ICConfigurationDescription projDes) throws CoreException { @@ -448,4 +450,12 @@ return getSDK().getReleaseRoot().append(releasePlatform.toLowerCase()).append(getTargetString().toLowerCase()); } + public boolean getRebuildNeeded() { + return rebuildNeeded; + } + + public void setRebuildNeeded(boolean value) { + rebuildNeeded = value; + } + }