1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 02:06:01 +02:00

Add ManagedBuildManager#createConfigurationForProject() (#131)

* Add ManagedBuildManager#createConfigurationForProject()

This should allow ISV's to create MBS based project with a
vendor-specific build-system ID without using internal API.

Update New & Noteworthy

Signed-off-by: 15knots <11367029+15knots@users.noreply.github.com>
This commit is contained in:
15knots 2022-11-04 21:30:22 +01:00 committed by GitHub
parent ac979bd9e1
commit 369ddea39c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 15 deletions

View file

@ -51,6 +51,11 @@ Job.getJobManager().join(ManagedBuilderCorePlugin.BUILD_SETTING_UPDATE_JOB_FAMIL
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.
## New method ManagedBuildManager#createConfigurationForProject()
This should allow ISV's to create MBS based project with a vendor-specific build-system ID without using internal API.
# 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).

View file

@ -3650,6 +3650,54 @@ public class ManagedBuildManager extends AbstractCExtension {
return null;
}
/**
* Creates a new <code>IConfiguration</code> object associated to the specified
* managed project and adds it to the corresponding project description.<br>
* This purpose of this method is to set up build configurations for MBS
* projects that are in the phase of being created programmatically.
*
* @param projectDescription the <code>ICProjectDescription</code> to use for
* creating the new configuration
* @param managedProject the managed project to associate the new
* <code>IConfiguration</code> with
* @param cloneConfiguration the <code>IConfiguration</code> to copy the
* settings from
* @param buildSystemId buildSystemId build system id, i.e. the extension
* id contributing to the
* org.eclipse.cdt.core.CConfigurationDataProvider
* extension point
*
* @return the newly created <code>IConfiguration</code> object
*
* @throws CoreException if the creation of a new
* ICConfigurationDescription failed
* @throws IllegalArgumentException if the <code>IProject</code> associated with
* the specified
* <code>ICProjectDescription</code> does not
* match the project associated with the given
* <code>IManagedProject</code>
* @since 9.5
*/
public static IConfiguration createConfigurationForProject(ICProjectDescription projectDescription,
IManagedProject managedProject, IConfiguration cloneConfiguration, String buildSystemId)
throws CoreException {
// sanity checks..
if (projectDescription.getProject() != managedProject.getOwner()) {
String msg = String.format(
"IProject associated with 'projectDescription' (%s) does not match the one associated with 'managedProject' (%s)", //$NON-NLS-1$
projectDescription.getProject(), managedProject.getOwner());
throw new IllegalArgumentException(msg);
}
String id = calculateChildId(cloneConfiguration.getId(), null);
Configuration config = new Configuration((ManagedProject) managedProject, (Configuration) cloneConfiguration,
id, false, true);
config.exportArtifactInfo();
CConfigurationData data = config.getConfigurationData();
ICConfigurationDescription cfgDes = projectDescription.createConfiguration(buildSystemId, data);
config.setConfigurationDescription(cfgDes);
return config;
}
/**
* Convert the IOption integer type ID to the {@link ICSettingEntry#getKind()} type ID
* @param type {@link IOption#getValueType()}

View file

@ -30,7 +30,6 @@ import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
import org.eclipse.cdt.internal.ui.wizards.ICDTCommonProjectWizard;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
@ -611,20 +610,14 @@ public class MBSWizardHandler extends CWizardHandler {
cfgs = CfgHolder.unique(cfgs);
cfgs = CfgHolder.reorder(cfgs);
ICConfigurationDescription cfgDebug = null;
ICConfigurationDescription cfgFirst = null;
subMonitor.worked(1);
IConfiguration active = null;
SubMonitor cfgMonitor = SubMonitor.convert(subMonitor.split(1), cfgs.length);
for (CfgHolder cfg : cfgs) {
cf = (Configuration) cfg.getConfiguration();
String id = ManagedBuildManager.calculateChildId(cf.getId(), null);
Configuration config = new Configuration(mProj, cf, id, false, true);
CConfigurationData data = config.getConfigurationData();
ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
config.setConfigurationDescription(cfgDes);
config.exportArtifactInfo();
IConfiguration config = ManagedBuildManager.createConfigurationForProject(des, mProj, cf,
ManagedBuildManager.CFG_DATA_PROVIDER_ID);
IBuilder bld = config.getEditableBuilder();
if (bld != null) {
bld.setManagedBuildOn(true);
@ -633,13 +626,18 @@ public class MBSWizardHandler extends CWizardHandler {
config.setName(cfg.getName());
config.setArtifactName(mProj.getDefaultArtifactName());
IBuildProperty b = config.getBuildProperties().getProperty(PROPERTY);
if (cfgDebug == null && b != null && b.getValue() != null && PROP_VAL.equals(b.getValue().getId()))
cfgDebug = cfgDes;
if (cfgFirst == null) // select at least first configuration
cfgFirst = cfgDes;
IBuildProperty b = config.getBuildProperties().getProperty(ManagedBuildManager.BUILD_TYPE_PROPERTY_ID);
if (active == null && b != null && b.getValue() != null
&& ManagedBuildManager.BUILD_TYPE_PROPERTY_DEBUG.equals(b.getValue().getId())) {
active = config;
}
cfgMonitor.worked(1);
}
// activate DEBUG configuration...
if (active != null) {
ICConfigurationDescription conf = ManagedBuildManager.getDescriptionForConfiguration(active);
des.setActiveConfiguration(conf);
}
mngr.setProjectDescription(project, des);
}