Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorDoug Schaefer2016-05-10 16:45:02 +0000
committerGerrit Code Review @ Eclipse.org2016-05-10 20:05:53 +0000
commit2c4921bca0925a343ba88f5fec731d6a463fd55e (patch)
treed81b9a02dcc2c89fd2125e036709af68078691ff /build
parent49e921843f89b9b2ce4ba38004d197428d4dc8cc (diff)
downloadorg.eclipse.cdt-2c4921bca0925a343ba88f5fec731d6a463fd55e.tar.gz
org.eclipse.cdt-2c4921bca0925a343ba88f5fec731d6a463fd55e.tar.xz
org.eclipse.cdt-2c4921bca0925a343ba88f5fec731d6a463fd55e.zip
Add binary parsers to new build system. Clean up some toolchain stuff.
new build configs now support binary parsers which are by default driven from the toolchains. Ran into problem with new versions of toolchains. Added versioning info to toolchains to take that into account. Change-Id: Ie1fb7755e84239b525dca0ae11759027a0b44574
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java40
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java76
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Msys2ToolChainProvider.java2
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java13
4 files changed, 74 insertions, 57 deletions
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 38a8de16414..460f9508ea1 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
@@ -47,6 +47,8 @@ import org.eclipse.core.runtime.PlatformObject;
public class GCCToolChain extends PlatformObject implements IToolChain {
private final IToolChainProvider provider;
+ private final String id;
+ private final String version;
private final String name;
private final Path path;
private final String prefix;
@@ -55,17 +57,19 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
protected String[] compileCommands;
- public GCCToolChain(IToolChainProvider provider, String name) {
- this(provider, name, null, null);
+ public GCCToolChain(IToolChainProvider provider, String id, String version) {
+ this(provider, id, version, null, null);
}
- public GCCToolChain(IToolChainProvider provider, String name, Path path) {
- this(provider, name, path, null);
+ public GCCToolChain(IToolChainProvider provider, String id, String version, Path path) {
+ this(provider, id, version, path, null);
}
- public GCCToolChain(IToolChainProvider provider, String name, Path path, String prefix) {
+ public GCCToolChain(IToolChainProvider provider, String id, String version, Path path, String prefix) {
this.provider = provider;
- this.name = name;
+ this.id = id;
+ this.version = version;
+ this.name = id + " - " + version; //$NON-NLS-1$
this.path = path;
this.prefix = prefix;
@@ -85,6 +89,16 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
}
@Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public String getVersion() {
+ return version;
+ }
+
+ @Override
public String getName() {
return name;
}
@@ -100,6 +114,20 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
}
return null;
}
+
+ @Override
+ public String getBinaryParserId() {
+ // Assume local builds
+ // TODO be smarter and use the id which should be the target
+ switch (Platform.getOS()) {
+ case Platform.OS_WIN32:
+ return CCorePlugin.PLUGIN_ID + ".PE"; //$NON-NLS-1$
+ case Platform.OS_MACOSX:
+ return CCorePlugin.PLUGIN_ID + ".MachO64"; //$NON-NLS-1$
+ default:
+ return CCorePlugin.PLUGIN_ID + ".ELF"; //$NON-NLS-1$
+ }
+ }
protected void addDiscoveryOptions(List<String> command) {
command.add("-E"); //$NON-NLS-1$
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java
index c057e806bda..f9967defeb3 100644
--- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java
@@ -28,15 +28,17 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
private static final String ID = "org.eclipse.cdt.build.gcc.core.gccPathProvider"; //$NON-NLS-1$
private static final Pattern gccPattern = Pattern.compile("(.*-)?(gcc|g\\+\\+|clang|clang\\+\\+)"); //$NON-NLS-1$
+ private static final Pattern versionPattern = Pattern.compile(".*(gcc|LLVM) version .*"); //$NON-NLS-1$
+ private static final Pattern targetPattern = Pattern.compile("Target: (.*)"); //$NON-NLS-1$
@Override
public String getId() {
return ID;
}
-
+
@Override
public void init(IToolChainManager manager) {
- Set<String> versions = new HashSet<>();
+ Set<String> names = new HashSet<>();
String path = System.getenv("PATH"); //$NON-NLS-1$
for (String dirStr : path.split(File.pathSeparator)) {
@@ -47,52 +49,40 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
if (matcher.matches()) {
String prefix = matcher.group(1);
String command = dirStr + File.separatorChar + file;
- String version = getVersion(command);
- if (version != null && !versions.contains(version)) {
- versions.add(version);
- manager.addToolChain(new GCCToolChain(this, version, dir.toPath(), prefix));
+ try {
+ Process proc = new ProcessBuilder(new String[] { command, "-v" }).redirectErrorStream(true) //$NON-NLS-1$
+ .start();
+ String version = null;
+ String target = null;
+ try (BufferedReader reader = new BufferedReader(
+ new InputStreamReader(proc.getInputStream()))) {
+ for (String line = reader.readLine(); line != null; line = reader.readLine()) {
+ Matcher versionMatcher = versionPattern.matcher(line);
+ if (versionMatcher.matches()) {
+ version = line.trim();
+ continue;
+ }
+ Matcher targetMatcher = targetPattern.matcher(line);
+ if (targetMatcher.matches()) {
+ target = targetMatcher.group(1);
+ continue;
+ }
+ }
+ }
+ if (target != null && version != null) {
+ String name = target + " - " + version; //$NON-NLS-1$
+ if (!names.contains(name)) {
+ names.add(name);
+ manager.addToolChain(new GCCToolChain(this, target, version, dir.toPath(), prefix));
+ }
+ }
+ } catch (IOException e) {
+ Activator.log(e);
}
}
}
}
}
}
-
- private static Pattern versionPattern = Pattern.compile(".*(gcc|LLVM) version .*"); //$NON-NLS-1$
- private static Pattern targetPattern = Pattern.compile("Target: (.*)"); //$NON-NLS-1$
-
- private String getVersion(String command) {
- try {
- Process proc = new ProcessBuilder(new String[] { command, "-v" }).redirectErrorStream(true) //$NON-NLS-1$
- .start();
- String version = null;
- String target = null;
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
- for (String line = reader.readLine(); line != null; line = reader.readLine()) {
- Matcher versionMatcher = versionPattern.matcher(line);
- if (versionMatcher.matches()) {
- version = line.trim();
- continue;
- }
- Matcher targetMatcher = targetPattern.matcher(line);
- if (targetMatcher.matches()) {
- target = targetMatcher.group(1);
- continue;
- }
- }
- }
- if (version != null) {
- if (target != null) {
- return version + " " + target; //$NON-NLS-1$
- } else {
- return version;
- }
- } else {
- return null;
- }
- } catch (IOException e) {
- return null;
- }
- }
}
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Msys2ToolChainProvider.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Msys2ToolChainProvider.java
index 263453a0950..64dec9b9496 100644
--- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Msys2ToolChainProvider.java
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Msys2ToolChainProvider.java
@@ -38,7 +38,7 @@ public class Msys2ToolChainProvider implements IToolChainProvider {
String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
Path gccPath = Paths.get(installLocation + "\\mingw64\\bin\\gcc.exe"); //$NON-NLS-1$
if (Files.exists(gccPath)) {
- manager.addToolChain(new GCCToolChain(this, "msys2.x86_64", gccPath.getParent())); //$NON-NLS-1$
+ manager.addToolChain(new GCCToolChain(this, "msys2.x86_64", "", gccPath.getParent())); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
index 3c9748dd41b..0b33e646af7 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java
@@ -30,13 +30,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
public class CMakeBuildConfiguration extends CBuildConfiguration {
- public CMakeBuildConfiguration(IBuildConfiguration config, String name) {
+ public CMakeBuildConfiguration(IBuildConfiguration config, String name) throws CoreException {
super(config, name);
}
public CMakeBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain) {
- super(config, name);
- setToolChain(toolChain);
+ super(config, name, toolChain);
}
@Override
@@ -54,7 +53,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
// TODO assuming cmake is in the path here, probably need a
// preference in case it isn't.
List<String> command = Arrays.asList("cmake", //$NON-NLS-1$
- "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", new File(project.getLocationURI()).getAbsolutePath());
+ "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", new File(project.getLocationURI()).getAbsolutePath()); //$NON-NLS-1$
ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile());
Process process = processBuilder.start();
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
@@ -63,8 +62,8 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
// TODO need to figure out which builder to call. Hardcoding to make
// for now.
- List<String> command = Arrays.asList("make");
- ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); //$NON-NLS-1$
+ List<String> command = Arrays.asList("make"); //$NON-NLS-1$
+ ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile());
Process process = processBuilder.start();
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
@@ -74,7 +73,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
return new IProject[] { project };
} catch (IOException e) {
- throw new CoreException(Activator.errorStatus("Building " + project.getName(), e));
+ throw new CoreException(Activator.errorStatus(String.format("Building %s", project.getName()), e));
}
}

Back to the top