mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Provide a way to wait on background build settings update job
Part of #117
This commit is contained in:
parent
23d44d05a4
commit
ad478cecc1
4 changed files with 69 additions and 56 deletions
|
@ -27,6 +27,22 @@ See [Bug 580873](https://bugs.eclipse.org/bugs/show_bug.cgi?id=580873).
|
|||
|
||||
Please see [CHANGELOG-API](CHANGELOG-API.md) for details on the breaking API changes in this release as well as future planned API changes.
|
||||
|
||||
## New Job Family for backgrond build settings update
|
||||
|
||||
When the project is modified the managed build settings needs to update settings.
|
||||
|
||||
While much of this update happens synchronously to the `IResourceChangeListener` calls, the final update is done with a job.
|
||||
If an update needs to be tracked for completion, after making an update the `IJobManager` can be queried using this family.
|
||||
|
||||
e.g. a join on the job being completed:
|
||||
|
||||
```java
|
||||
Job.getJobManager().join(ManagedBuilderCorePlugin.BUILD_SETTING_UPDATE_JOB_FAMILY, null);
|
||||
```
|
||||
|
||||
This new job family was added to improve stability of tests to ensure background operations are complete.
|
||||
It may have other uses to other API consumers as well and is therefore included here.
|
||||
|
||||
# Bugs Fixed in this Release
|
||||
|
||||
See [GitHub milestones](https://github.com/eclipse-cdt/cdt/milestone/2?closed=1) and for bugs that haven't been transitioned to GitHub please see Bugzilla report [Bugs Fixed in CDT 11.0](https://bugs.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED&classification=Tools&product=CDT&query_format=advanced&resolution=FIXED&target_milestone=11.0.0).
|
||||
|
|
|
@ -48,6 +48,7 @@ import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
|||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildDescription;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildIOType;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildResource;
|
||||
|
@ -63,7 +64,9 @@ import org.eclipse.core.resources.IProject;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
@ -125,6 +128,19 @@ public class BuildDescriptionModelTests extends TestCase {
|
|||
return new TestSuite(BuildDescriptionModelTests.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the CC Nature and wait until the project settings are fully updated.
|
||||
*/
|
||||
private void addCCNatureAndWait(IProject project) {
|
||||
try {
|
||||
CCProjectNature.addCCNature(project, null);
|
||||
// wait for the build setting update that is trigged by adding the CC nature finishes
|
||||
Job.getJobManager().join(ManagedBuilderCorePlugin.BUILD_SETTING_UPDATE_JOB_FAMILY, null);
|
||||
} catch (CoreException | OperationCanceledException | InterruptedException e1) {
|
||||
throw new RuntimeException("fail to add CC nature", e1);
|
||||
}
|
||||
}
|
||||
|
||||
public void testDes_Model() {
|
||||
IProject project = createProject(PREFIX + "1", "test30_2.tar");
|
||||
IFile aAsm = ManagedBuildTestHelper.createFile(project, "a.asm");
|
||||
|
@ -908,12 +924,7 @@ public class BuildDescriptionModelTests extends TestCase {
|
|||
|
||||
public void testDes_gnu30_exe() {
|
||||
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
|
||||
try {
|
||||
CCProjectNature.addCCNature(project, null);
|
||||
} catch (CoreException e1) {
|
||||
fail("fail to add CC nature");
|
||||
}
|
||||
|
||||
addCCNatureAndWait(project);
|
||||
ManagedBuildTestHelper.createFile(project, "a.c");
|
||||
ManagedBuildTestHelper.createFile(project, "b.c");
|
||||
ManagedBuildTestHelper.createFile(project, "c.cpp");
|
||||
|
@ -1020,11 +1031,7 @@ public class BuildDescriptionModelTests extends TestCase {
|
|||
|
||||
public void testDes_gnu30_exe_deps() {
|
||||
IProject project = createProject(PREFIX + "gnu30_exe_deps", "cdt.managedbuild.target.gnu30.exe");
|
||||
try {
|
||||
CCProjectNature.addCCNature(project, null);
|
||||
} catch (CoreException e1) {
|
||||
fail("fail to add CC nature");
|
||||
}
|
||||
addCCNatureAndWait(project);
|
||||
|
||||
ManagedBuildTestHelper.createFile(project, "a.c", "\n#include \"a.h\"\n#include \"d.h\"\n");
|
||||
ManagedBuildTestHelper.createFile(project, "b.c");
|
||||
|
@ -1174,11 +1181,7 @@ public class BuildDescriptionModelTests extends TestCase {
|
|||
|
||||
public void testDesTestgnu21_exe() {
|
||||
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.testgnu21.exe");
|
||||
try {
|
||||
CCProjectNature.addCCNature(project, null);
|
||||
} catch (CoreException e1) {
|
||||
fail("fail to add CC nature");
|
||||
}
|
||||
addCCNatureAndWait(project);
|
||||
|
||||
ManagedBuildTestHelper.createFile(project, "a.c");
|
||||
ManagedBuildTestHelper.createFile(project, "b.c");
|
||||
|
@ -1285,11 +1288,7 @@ public class BuildDescriptionModelTests extends TestCase {
|
|||
|
||||
public void testDesRcCfg() {
|
||||
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
|
||||
try {
|
||||
CCProjectNature.addCCNature(project, null);
|
||||
} catch (CoreException e1) {
|
||||
fail("fail to add CC nature");
|
||||
}
|
||||
addCCNatureAndWait(project);
|
||||
|
||||
IFile ac = ManagedBuildTestHelper.createFile(project, "a.c");
|
||||
ManagedBuildTestHelper.createFile(project, "b.c");
|
||||
|
@ -1402,11 +1401,7 @@ public class BuildDescriptionModelTests extends TestCase {
|
|||
|
||||
public void testDesRcbs() {
|
||||
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
|
||||
try {
|
||||
CCProjectNature.addCCNature(project, null);
|
||||
} catch (CoreException e1) {
|
||||
fail("fail to add CC nature");
|
||||
}
|
||||
addCCNatureAndWait(project);
|
||||
|
||||
ManagedBuildTestHelper.createFile(project, "a.c");
|
||||
ManagedBuildTestHelper.createFile(project, "b.c");
|
||||
|
@ -1586,11 +1581,7 @@ public class BuildDescriptionModelTests extends TestCase {
|
|||
|
||||
public void testDesAddlInVarUserObjs() {
|
||||
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
|
||||
try {
|
||||
CCProjectNature.addCCNature(project, null);
|
||||
} catch (CoreException e1) {
|
||||
fail("fail to add CC nature");
|
||||
}
|
||||
addCCNatureAndWait(project);
|
||||
|
||||
ManagedBuildTestHelper.createFile(project, "a.c");
|
||||
ManagedBuildTestHelper.createFile(project, "b.c");
|
||||
|
@ -1773,11 +1764,7 @@ public class BuildDescriptionModelTests extends TestCase {
|
|||
|
||||
public void testDesAddlInVar() {
|
||||
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.bdm.exe");
|
||||
try {
|
||||
CCProjectNature.addCCNature(project, null);
|
||||
} catch (CoreException e1) {
|
||||
fail("fail to add CC nature");
|
||||
}
|
||||
addCCNatureAndWait(project);
|
||||
|
||||
ManagedBuildTestHelper.createFile(project, "a.c");
|
||||
ManagedBuildTestHelper.createFile(project, "b.c");
|
||||
|
@ -1943,11 +1930,7 @@ public class BuildDescriptionModelTests extends TestCase {
|
|||
|
||||
public void testDes_gnu30_exe_objsInProj() {
|
||||
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
|
||||
try {
|
||||
CCProjectNature.addCCNature(project, null);
|
||||
} catch (CoreException e1) {
|
||||
fail("fail to add CC nature");
|
||||
}
|
||||
addCCNatureAndWait(project);
|
||||
|
||||
ManagedBuildTestHelper.createFile(project, "a.c");
|
||||
ManagedBuildTestHelper.createFile(project, "b.c");
|
||||
|
@ -2057,11 +2040,7 @@ public class BuildDescriptionModelTests extends TestCase {
|
|||
|
||||
public void testDesRebuildState() {
|
||||
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
|
||||
try {
|
||||
CCProjectNature.addCCNature(project, null);
|
||||
} catch (CoreException e1) {
|
||||
fail("fail to add CC nature");
|
||||
}
|
||||
addCCNatureAndWait(project);
|
||||
|
||||
ManagedBuildTestHelper.createFile(project, "a.c");
|
||||
ManagedBuildTestHelper.createFile(project, "b.c");
|
||||
|
@ -2400,11 +2379,7 @@ public class BuildDescriptionModelTests extends TestCase {
|
|||
public void testDesRebuildStateWithCustomBuildStep() {
|
||||
/* This test captures Bug 389536 */
|
||||
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
|
||||
try {
|
||||
CCProjectNature.addCCNature(project, null);
|
||||
} catch (CoreException e1) {
|
||||
fail("fail to add CC nature");
|
||||
}
|
||||
addCCNatureAndWait(project);
|
||||
|
||||
IFile testYFile = ManagedBuildTestHelper.createFile(project, "test.y");
|
||||
|
||||
|
@ -2605,11 +2580,7 @@ public class BuildDescriptionModelTests extends TestCase {
|
|||
|
||||
public void testDesRebuildStateInDescription() {
|
||||
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.bdm.exe");
|
||||
try {
|
||||
CCProjectNature.addCCNature(project, null);
|
||||
} catch (CoreException e1) {
|
||||
fail("fail to add CC nature");
|
||||
}
|
||||
addCCNatureAndWait(project);
|
||||
|
||||
ManagedBuildTestHelper.createFile(project, "a.c");
|
||||
ManagedBuildTestHelper.createFile(project, "b.c");
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEn
|
|||
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildPathEntryContainerInitializer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||
import org.eclipse.core.resources.IResourceChangeListener;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
@ -34,6 +35,7 @@ import org.eclipse.core.runtime.IStatus;
|
|||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.IJobManager;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
|
@ -53,6 +55,25 @@ public class ManagedBuilderCorePlugin extends Plugin {
|
|||
// The unique id for all managed make projects
|
||||
public static final String MANAGED_MAKE_PROJECT_ID = ManagedBuilderCorePlugin.getUniqueIdentifier()
|
||||
+ ".managedMake"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* When the project is modified the managed build settings needs to update settings.
|
||||
*
|
||||
* While much of this update happens synchronously to the {@link IResourceChangeListener}
|
||||
* calls, the final update is done with a job. If an update needs to be tracked for
|
||||
* completion, after making an update the {@link IJobManager} can be queried using
|
||||
* this family.
|
||||
*
|
||||
* e.g. a join on the job being completed:
|
||||
*
|
||||
* <pre>
|
||||
* Job.getJobManager().join(ManagedBuilderCorePlugin.BUILD_SETTING_UPDATE_JOB_FAMILY, null);
|
||||
* </pre>
|
||||
*
|
||||
* @since 9.5
|
||||
*/
|
||||
public static final Object BUILD_SETTING_UPDATE_JOB_FAMILY = new Object();
|
||||
|
||||
// NOTE: The code below is for tracking resource renaming and deleting. This is needed to keep
|
||||
// ResourceConfiguration elements up to date. It may also be needed by AdditionalInput
|
||||
// elements
|
||||
|
|
|
@ -207,6 +207,11 @@ class ResourceChangeHandler2 extends ResourceChangeHandlerBase {
|
|||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean belongsTo(Object family) {
|
||||
return family == ManagedBuilderCorePlugin.BUILD_SETTING_UPDATE_JOB_FAMILY;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
job.setRule(root);
|
||||
|
|
Loading…
Add table
Reference in a new issue