1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-03-28 14:56:28 +01:00

Bug 580015: add support for multiple bin parsers #75

Removed ICBuildConfiguration.getBinaryParserId() and
IToolChain.getBinaryParserId(). Replaced with methods that return a list
of IDs.

Updated API changes doc.

Rearranged tests so that the test for IToolChain is in a new gcc test
plugin.
This commit is contained in:
John Moule 2022-11-15 02:03:52 +00:00 committed by Jonah Graham
parent c52de83035
commit 7759af22d6
17 changed files with 96 additions and 157 deletions

View file

@ -16,6 +16,8 @@ This section describes API removals that occurred in past releases, and upcoming
- [Removal of Qt plug-ins and features](#qt-plugins)
- [Removal of constructor org.eclipse.cdt.utils.coff.CodeViewReader(RandomAccessFile, int, boolean)](#CodeViewReader-constructor-removal)
- [Removal of 32-bit Binary parsers with 64-bit replacements](#32bitbinaryparsers)
- [Removal of method to get a single binary parser ID (ICBuildConfiguration.getBinaryParserId()) and replaced with method that returns a list of binary parser IDs (ICBuildConfiguration.getBinaryParserIds())](#getBinaryParserId)
- [Removal of method to get a single binary parser ID (IToolChain.getBinaryParserId()) and replaced with method that returns a list of binary parser IDs (IToolChain.getBinaryParserIds())](#getBinaryParserId)
## API Changes in CDT 10.5.0

View file

@ -0,0 +1,16 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.cdt.build.gcc.core.tests; singleton:=true
Bundle-Version: 1.0.0.qualifier
Require-Bundle: org.eclipse.core.resources,
org.eclipse.cdt.core,
org.junit,
org.eclipse.jdt.junit4.runtime,
org.eclipse.core.runtime,
org.eclipse.cdt.build.gcc.core
Automatic-Module-Name: org.eclipse.cdt.build.gcc.core.tests
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin

View file

@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>November 30, 2017</p>
<h3>License</h3>
<p>
The Eclipse Foundation makes available all content in this plug-in
(&quot;Content&quot;). Unless otherwise indicated below, the Content
is provided to you under the terms and conditions of the Eclipse
Public License Version 2.0 (&quot;EPL&quot;). A copy of the EPL is
available at <a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-2.0</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.
</p>
<p>
If you did not receive this Content directly from the Eclipse
Foundation, the Content is being redistributed by another party
(&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the
Redistributor's license that was provided with the Content. If no such
license exists, contact the Redistributor. Unless otherwise indicated
below, the terms and conditions of the EPL still apply to any source
code in the Content and such source code may be obtained at <a
href="https://www.eclipse.org/">https://www.eclipse.org</a>.
</p>
</body>
</html>

View file

@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
about.html,\
plugin.properties

View file

@ -0,0 +1,11 @@
##################################################################################
# Copyright (c) 2022 Renesas Electronics Europe.
# This program and the accompanying materials are made available under the terms
# of the Eclipse Public License 2.0 which accompanies this distribution, and is
# available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
##################################################################################
pluginName = GCC support for CDT Build Core Test
providerName = Renesas Electronics Europe

View file

@ -8,7 +8,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.cdt.core.build;
package org.eclipse.cdt.build.gcc.core.tests;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertNotNull;
@ -21,8 +21,10 @@ import java.util.List;
import java.util.Map;
import org.eclipse.cdt.build.gcc.core.GCCToolChain;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.core.build.IToolChainProvider;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -64,7 +66,8 @@ public class TestIToolChain {
}
/**
* Tests that IToolChain.getBinaryParserIds() can return a list of Binary Parser IDs.
* Tests that IToolChain.getBinaryParserIds() can return a list of Binary Parser
* IDs.
*/
@Test
public void getBinaryParserIdsTest01() throws Exception {
@ -75,7 +78,7 @@ public class TestIToolChain {
}
// Get our test toolchain.
Map props = new HashMap<String, String>();
Map<String, String> props = new HashMap<>();
props.put(IToolChain.ATTR_OS, "testOs");
props.put(IToolChain.ATTR_ARCH, "testArch");
Collection<IToolChain> testTcs = toolchainMgr.getToolChainsMatching(props);
@ -114,7 +117,7 @@ public class TestIToolChain {
}
private static <T> T getService(Class<T> serviceClass) {
BundleContext bundleContext = FrameworkUtil.getBundle(CTestPlugin.class).getBundleContext();
BundleContext bundleContext = FrameworkUtil.getBundle(TestIToolChain.class).getBundleContext();
ServiceReference<T> serviceReference = bundleContext.getServiceReference(serviceClass);
return bundleContext.getService(serviceReference);
}

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.build.gcc.core;singleton:=true
Bundle-Version: 1.2.0.qualifier
Bundle-Version: 2.0.0.qualifier
Bundle-Activator: org.eclipse.cdt.build.gcc.core.internal.Activator
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.runtime,

View file

@ -220,8 +220,7 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
properties.put(key, value);
}
@Override
public String getBinaryParserId() {
private String getBinaryParserId() {
// Assume local builds
// TODO be smarter and use the id which should be the target
switch (Platform.getOS()) {

View file

@ -45,8 +45,7 @@ Require-Bundle: org.eclipse.core.resources,
org.eclipse.ltk.core.refactoring;bundle-version="3.4.0",
org.hamcrest.core,
org.hamcrest.library,
com.google.gson;bundle-version="[2.8.6,3.0.0)",
org.eclipse.cdt.build.gcc.core
com.google.gson;bundle-version="[2.8.6,3.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Bundle-RequiredExecutionEnvironment: JavaSE-17

View file

@ -10,20 +10,12 @@
*******************************************************************************/
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 static org.junit.jupiter.api.Assertions.assertNull;
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;
@ -31,31 +23,13 @@ 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;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
/**
* Tests for org.eclipse.cdt.core.build.ICBuildConfiguration
*/
public class TestICBuildConfiguration {
private final static List<String> 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
public void shutdown() {
}
/**
* Tests that ICBuildConfiguration.getBinaryParserIds() meets API. <br>
* <code>
@ -69,93 +43,22 @@ public class TestICBuildConfiguration {
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<IToolChain> 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<String, String>();
props.put(IToolChain.ATTR_OS, "testOs");
props.put(IToolChain.ATTR_ARCH, "testArch");
Collection<IToolChain> 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();
}
/**
* Tests that ICBuildConfiguration.getBinaryParserIds() can return a list of Binary Parser IDs.
*/
@Test
public void getBinaryParserIdsTest01() throws Exception {
}
/**
* org.eclipse.cdt.internal.core.model.CModelManager.getBinaryParser(IProject)
*/
@Test
public void getBinaryParserTest00() throws Exception {
}
// ICBuildConfiguration cBuildConfig = null;
// String binParserId = cBuildConfig.getBinaryParserId();
// IBinary[] binaries = cBuildConfig.getBuildOutput();
// for (IBinary binary : binaries) {
// binary.exists();
// }
private static <T> T getService(Class<T> serviceClass) {
BundleContext bundleContext = FrameworkUtil.getBundle(CTestPlugin.class).getBundleContext();
ServiceReference<T> serviceReference = bundleContext.getServiceReference(serviceClass);
return bundleContext.getService(serviceReference);
/*
* It's difficult to create a functional BuildConfiguration without a toolchain, so just use
* this Error Build Configuration. It is adequate for simply testing the API.
*/
ErrorBuildConfiguration errorBuildConfiguration = new ErrorBuildConfiguration(buildConfig, "errorBuildConfig");
List<String> binaryParserIds = errorBuildConfiguration.getBinaryParserIds();
assertNull(binaryParserIds, "Must be null");
}
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<String> getBinaryParserIds() {
return expectedBinParserIds;
}
}
}

View file

@ -213,11 +213,6 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu
return config.getProject();
}
@Override
public String getBinaryParserId() throws CoreException {
return toolChain != null ? toolChain.getBinaryParserId() : CCorePlugin.DEFAULT_BINARY_PARSER_UNIQ_ID;
}
@Override
public List<String> getBinaryParserIds() throws CoreException {
return toolChain != null ? toolChain.getBinaryParserIds() : List.of(CCorePlugin.DEFAULT_BINARY_PARSER_UNIQ_ID);

View file

@ -131,12 +131,6 @@ public class ErrorBuildConfiguration extends PlatformObject implements ICBuildCo
return null;
}
@Override
public String getBinaryParserId() throws CoreException {
// TODO Auto-generated method stub
return null;
}
@Override
public IEnvironmentVariable getVariable(String name) throws CoreException {
// TODO Auto-generated method stub

View file

@ -74,17 +74,6 @@ public interface ICBuildConfiguration extends IAdaptable, IScannerInfoProvider {
return null;
}
/**
* Ids for the Binary Parsers to use when checking whether a file is a
* binary that can be launched.
*
* @return binary parser ids
* @throws CoreException
* @deprecated As of 8.0 replaced by {@link ICBuildConfiguration#getBinaryParserIds}
*/
@Deprecated(since = "8.0")
String getBinaryParserId() throws CoreException;
/**
* Ids for the Binary Parsers to use when checking whether a file is a
* binary that can be launched.

View file

@ -160,16 +160,6 @@ public interface IToolChain extends IAdaptable {
*/
String[] getErrorParserIds();
/**
* Returns the IDs for the binary parsers that can parse the build output of
* the toolchain.
*
* @return binary parser IDs for this toolchain
* @deprecated As of 8.0 replaced by {@link IToolChain#getBinaryParserIds}
*/
@Deprecated(since = "8.0")
String getBinaryParserId();
/**
* Returns the IDs for the binary parsers that can parse the build output of
* the toolchain.

View file

@ -170,8 +170,8 @@ public class ContainerGCCToolChain extends PlatformObject implements IToolChain,
}
@Override
public String getBinaryParserId() {
return CCorePlugin.PLUGIN_ID + ".ELF"; //$NON-NLS-1$
public List<String> getBinaryParserIds() {
return List.of(CCorePlugin.PLUGIN_ID + ".ELF"); //$NON-NLS-1$
}
protected void addDiscoveryOptions(List<String> command) {
@ -645,5 +645,4 @@ public class ContainerGCCToolChain extends PlatformObject implements IToolChain,
return p;
}
}

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.msw.build;singleton:=true
Bundle-Version: 1.3.0.qualifier
Bundle-Version: 2.0.0.qualifier
Bundle-Activator: org.eclipse.cdt.msw.build.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,

View file

@ -204,14 +204,9 @@ public class MSVCToolChain extends PlatformObject implements IToolChain {
};
}
@Override
public String getBinaryParserId() {
return CCorePlugin.PLUGIN_ID + ".PE64"; //$NON-NLS-1$
}
@Override
public List<String> getBinaryParserIds() {
return List.of(getBinaryParserId());
return List.of(CCorePlugin.PLUGIN_ID + ".PE64"); //$NON-NLS-1$
}
@Override