From c52de830355e15c5de53cadc93f51d962a33640c Mon Sep 17 00:00:00 2001 From: John Moule Date: Wed, 28 Sep 2022 23:21:10 +0100 Subject: [PATCH] Update for major version bump Update since tags to 8.0. Remove api filter. Fix other since tags after removing of api filter. Remove interface defaults. Add default implementations where necessary. Update tests - TBC. --- .../cdt/build/gcc/core/GCCToolChain.java | 5 + .../core/build/TestICBuildConfiguration.java | 90 +++++++ .../.settings/.api_filters | 255 ------------------ .../core/build/ErrorBuildConfiguration.java | 7 + .../cdt/core/build/ICBuildConfiguration.java | 10 +- .../eclipse/cdt/core/build/IToolChain.java | 10 +- .../cdt/msw/build/core/MSVCToolChain.java | 5 + 7 files changed, 115 insertions(+), 267 deletions(-) delete mode 100644 core/org.eclipse.cdt.core/.settings/.api_filters diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java index 8b1631594f6..ee8c4d00e3c 100644 --- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java +++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java @@ -234,6 +234,11 @@ public class GCCToolChain extends PlatformObject implements IToolChain { } } + @Override + public List getBinaryParserIds() { + return List.of(getBinaryParserId()); + } + protected void addDiscoveryOptions(List command) { command.add("-E"); //$NON-NLS-1$ command.add("-P"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/build/TestICBuildConfiguration.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/build/TestICBuildConfiguration.java index 2d427aa5a14..f96b4228dde 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/build/TestICBuildConfiguration.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/build/TestICBuildConfiguration.java @@ -10,7 +10,27 @@ *******************************************************************************/ package org.eclipse.cdt.core.build; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.nio.file.Path; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.build.gcc.core.GCCToolChain; +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.testplugin.CTestPlugin; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.NullProgressMonitor; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -23,8 +43,13 @@ import org.osgi.framework.ServiceReference; */ public class TestICBuildConfiguration { + private final static List expectedBinParserIds = List.of("binParserId0", "binParserId1"); + private IToolChainManager toolchainMgr = null; + @Before public void setup() { + toolchainMgr = getService(IToolChainManager.class); + assertNotNull("toolchainMgr must not be null", toolchainMgr); } @After @@ -39,6 +64,36 @@ public class TestICBuildConfiguration { */ @Test public void getBinaryParserIdsTest00() throws Exception { + IProject proj = getProject(); + IBuildConfiguration[] buildConfigs = proj.getBuildConfigs(); + assertNotNull(buildConfigs, "Must not be null"); + assertNotEquals(0, buildConfigs.length, "Must not be empty"); + IBuildConfiguration buildConfig = buildConfigs[0]; + // ICBuildConfiguration adapter = buildConfig.getAdapter(ICBuildConfiguration.class); + // assertNotNull(adapter, "Must not be null"); + + // TODO: rationalise this so the TC uses common in TestIToolChain too. + // Add our test toolchain. + Collection toolChains = toolchainMgr.getAllToolChains(); + { + // TODO: fix this. Can't use null for pathToToolChain + IToolChain testTc = new TestToolchain(null, null, "testArch", null); + toolchainMgr.addToolChain(testTc); + } + + // Get our test toolchain. + Map props = new HashMap(); + props.put(IToolChain.ATTR_OS, "testOs"); + props.put(IToolChain.ATTR_ARCH, "testArch"); + Collection testTcs = toolchainMgr.getToolChainsMatching(props); + assertTrue("toolChains list must contain exactly 1 item", testTcs.size() == 1); + IToolChain testTc = testTcs.iterator().next(); + assertNotNull("ourTc must not be null", testTc); + + StandardBuildConfiguration sbc = new StandardBuildConfiguration(buildConfig, "name", testTc, "run"); + assertNotNull(sbc, "Must not be null"); + + sbc.getBinaryParserIds(); } /** @@ -68,4 +123,39 @@ public class TestICBuildConfiguration { return bundleContext.getService(serviceReference); } + private IProject getProject() throws Exception { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceRoot root = workspace.getRoot(); + IProjectDescription desc = root.getWorkspace().newProjectDescription("test"); + // desc.setNatureIds(new String[] { "org.eclipse.linuxtools.tmf.project.nature" }); + IProject project = root.getProject("testProj"); + project.create(desc, new NullProgressMonitor()); + project.open(new NullProgressMonitor()); + return project; + } + + private class TestToolchain extends GCCToolChain { + + public TestToolchain(IToolChainProvider provider, Path pathToToolChain, String arch, + IEnvironmentVariable[] envVars) { + super(provider, pathToToolChain, arch, envVars); + } + + @Override + public String getProperty(String key) { + if (key.equals(IToolChain.ATTR_OS)) { + return "testOs"; + } else if (key.equals(IToolChain.ATTR_ARCH)) { + return "testArch"; + } else { + return super.getProperty(key); + } + } + + @Override + public List getBinaryParserIds() { + return expectedBinParserIds; + } + } + } diff --git a/core/org.eclipse.cdt.core/.settings/.api_filters b/core/org.eclipse.cdt.core/.settings/.api_filters deleted file mode 100644 index 27d8c70d449..00000000000 --- a/core/org.eclipse.cdt.core/.settings/.api_filters +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ErrorBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ErrorBuildConfiguration.java index 585030ac91a..342b43928d5 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ErrorBuildConfiguration.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ErrorBuildConfiguration.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.core.build; import java.io.IOException; import java.net.URI; +import java.util.List; import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; @@ -148,4 +149,10 @@ public class ErrorBuildConfiguration extends PlatformObject implements ICBuildCo return null; } + @Override + public List getBinaryParserIds() throws CoreException { + // TODO Auto-generated method stub + return null; + } + } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java index 949913322c0..7ea205d9271 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/ICBuildConfiguration.java @@ -80,9 +80,9 @@ public interface ICBuildConfiguration extends IAdaptable, IScannerInfoProvider { * * @return binary parser ids * @throws CoreException - * @deprecated As of 10.??? replaced by {@link ICBuildConfiguration#getBinaryParserIds} + * @deprecated As of 8.0 replaced by {@link ICBuildConfiguration#getBinaryParserIds} */ - @Deprecated(since = "7.5") + @Deprecated(since = "8.0") String getBinaryParserId() throws CoreException; /** @@ -91,11 +91,9 @@ public interface ICBuildConfiguration extends IAdaptable, IScannerInfoProvider { * * @return binary parser ids * @throws CoreException - * @since 7.5 + * @since 8.0 */ - default List getBinaryParserIds() throws CoreException { - return List.of(getBinaryParserId()); - } + List getBinaryParserIds() throws CoreException; /** * Return a build environment variable with a given name. diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java index aa509dac0c3..20511479894 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java @@ -165,9 +165,9 @@ public interface IToolChain extends IAdaptable { * the toolchain. * * @return binary parser IDs for this toolchain - * @deprecated As of 7.5 replaced by {@link IToolChain#getBinaryParserIds} + * @deprecated As of 8.0 replaced by {@link IToolChain#getBinaryParserIds} */ - @Deprecated(since = "7.5") + @Deprecated(since = "8.0") String getBinaryParserId(); /** @@ -175,11 +175,9 @@ public interface IToolChain extends IAdaptable { * the toolchain. * * @return binary parser IDs for this toolchain - * @since 7.5 + * @since 8.0 */ - default List getBinaryParserIds() { - return List.of(getBinaryParserId()); - } + List getBinaryParserIds(); /** * Get the scanner info for a given build config, command, base scanner diff --git a/windows/org.eclipse.cdt.msw.build/src/org/eclipse/cdt/msw/build/core/MSVCToolChain.java b/windows/org.eclipse.cdt.msw.build/src/org/eclipse/cdt/msw/build/core/MSVCToolChain.java index 2297dec6e16..3789b431ca6 100644 --- a/windows/org.eclipse.cdt.msw.build/src/org/eclipse/cdt/msw/build/core/MSVCToolChain.java +++ b/windows/org.eclipse.cdt.msw.build/src/org/eclipse/cdt/msw/build/core/MSVCToolChain.java @@ -209,6 +209,11 @@ public class MSVCToolChain extends PlatformObject implements IToolChain { return CCorePlugin.PLUGIN_ID + ".PE64"; //$NON-NLS-1$ } + @Override + public List getBinaryParserIds() { + return List.of(getBinaryParserId()); + } + @Override public Path getCommandPath(Path command) { if (command.isAbsolute()) {