diff options
-rw-r--r-- | plugins/languages/cpp/org.eclipse.papyrus.designer.languages.cpp.cdt.project/src/org/eclipse/papyrus/designer/languages/cpp/cdt/project/C_CppProjectSupportNoUI.java | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/plugins/languages/cpp/org.eclipse.papyrus.designer.languages.cpp.cdt.project/src/org/eclipse/papyrus/designer/languages/cpp/cdt/project/C_CppProjectSupportNoUI.java b/plugins/languages/cpp/org.eclipse.papyrus.designer.languages.cpp.cdt.project/src/org/eclipse/papyrus/designer/languages/cpp/cdt/project/C_CppProjectSupportNoUI.java index 5a1e4ceff..32de063b7 100644 --- a/plugins/languages/cpp/org.eclipse.papyrus.designer.languages.cpp.cdt.project/src/org/eclipse/papyrus/designer/languages/cpp/cdt/project/C_CppProjectSupportNoUI.java +++ b/plugins/languages/cpp/org.eclipse.papyrus.designer.languages.cpp.cdt.project/src/org/eclipse/papyrus/designer/languages/cpp/cdt/project/C_CppProjectSupportNoUI.java @@ -16,7 +16,6 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue; -import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IProjectType; import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; @@ -86,8 +85,9 @@ public class C_CppProjectSupportNoUI extends C_CppProjectSupport implements ILan } /** - * Basic configuration of a CDT project with managed builds created from type - * map + * Basic configuration of a CDT project with managed builds created from type map. + * The function uses the first (supported) tool-chain for the current platform that + * produces an executable. * * @throws CoreException */ @@ -98,29 +98,40 @@ public class C_CppProjectSupportNoUI extends C_CppProjectSupport implements ILan if (cdesc == null) { cdesc = mngr.createProjectDescription(project, true); } + SortedMap<String, IProjectType> typeMap = ManagedBuildManager.getExtensionProjectTypeMap(); for (Map.Entry<String, IProjectType> e : typeMap.entrySet()) { IProjectType pt = e.getValue(); IBuildPropertyValue type = pt.getBuildArtefactType(); - if (!type.getName().equals(EXECUTABLE)) { - // only look for executable builds - break; + // always only check supported toolchains (might change, if running in docker?) + boolean isValid = type.getName().equals(EXECUTABLE) && pt.isSupported() + && !pt.isAbstract() && !pt.isSystemObject(); + if (!isValid) { + continue; } IToolChain[] tcs = ManagedBuildManager.getExtensionToolChains(pt); - if (tcs.length > 0) { - var cfgs = ManagedBuildManager.getExtensionConfigurations(tcs[0], pt); - if (cfgs.length > 0) { - IConfiguration firstCF = cfgs[0]; + for (IToolChain tc : tcs) { + if (ManagedBuildManager.isPlatformOk(tc)) { + var cfgs = ManagedBuildManager.getExtensionConfigurations(tc, pt); ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project); - ManagedProject mProj = new ManagedProject(project, firstCF.getProjectType()); + ManagedProject mProj = new ManagedProject(project, pt); info.setManagedProject(mProj); - info.setDefaultConfiguration(firstCF); + // typically debug and release configurations + boolean firstCF = true; for (var cf : cfgs) { - // typically debug and release configurations + if (firstCF) { + firstCF = false; + info.setDefaultConfiguration(cf); + } + // set artifact name (otherwise build does not run) + cf.setArtifactName(mProj.getDefaultArtifactName()); ManagedBuildManager.createConfigurationForProject(cdesc, mProj, cf, ManagedBuildManager.CFG_DATA_PROVIDER_ID); } + // a tool-chain for the current platform has been added, don't check further + break; } + } } mngr.setProjectDescription(project, cdesc, true, null); |