diff options
author | Doug Schaefer | 2016-02-08 19:09:56 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-02-09 21:40:46 +0000 |
commit | 44599764f00c7538a94cdc95e1fe158a22191372 (patch) | |
tree | 1ca7eb678e50f7762b1fa8852b7c5f29545b66a8 /build/org.eclipse.cdt.build.gcc.core | |
parent | 345877d034690244775cb5b40deb8be5aabab033 (diff) | |
download | org.eclipse.cdt-44599764f00c7538a94cdc95e1fe158a22191372.tar.gz org.eclipse.cdt-44599764f00c7538a94cdc95e1fe158a22191372.tar.xz org.eclipse.cdt-44599764f00c7538a94cdc95e1fe158a22191372.zip |
Support project scanner info in new build system for new class wiz.
The New Class Wizard asks scanner info for include paths for a project.
Need to decide whether that's a good thing or not but for now, add
support in the Qt config and GCC toolchain for it.
Change-Id: I5f037deb13db41fc0a083ea9fdc30ac1f61557e6
Diffstat (limited to 'build/org.eclipse.cdt.build.gcc.core')
-rw-r--r-- | build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java | 31 |
1 files changed, 17 insertions, 14 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 75c7b3d1c10..974aa96a8be 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 @@ -10,7 +10,6 @@ package org.eclipse.cdt.build.gcc.core; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; -import java.nio.file.FileAlreadyExistsException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -32,6 +31,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.launchbar.core.target.ILaunchTargetManager; @@ -151,23 +151,26 @@ public class GCCToolChain implements IToolChain { if (files.length > 0) { // replace it with a temp file Path parentPath = filePath.getParent(); - int n = 0; - while (true) { - // TODO need to know the language - tmpFile = parentPath.resolve(".sc" + n + ".cpp"); //$NON-NLS-1$ //$NON-NLS-2$ - commandLine.set(i, tmpFile.toString()); - try { - Files.createFile(tmpFile); - break; - } catch (FileAlreadyExistsException e) { - // try again - ++n; - } + String extension = files[0].getFileExtension(); + if (extension == null) { + // Not sure if this is a reasonable choice when there's + // no extension + extension = ".cpp"; //$NON-NLS-1$ + } else { + extension = '.' + extension; } - break; + tmpFile = Files.createTempFile(parentPath, ".sc", extension); //$NON-NLS-1$ + commandLine.set(i, tmpFile.toString()); } } } + if (tmpFile == null) { + // Have to assume there wasn't a source file. Add one in the + // resource's container + IPath parentPath = resource instanceof IFile ? resource.getParent().getLocation() : resource.getLocation(); + tmpFile = Files.createTempFile(parentPath.toFile().toPath(), ".sc", ".cpp"); //$NON-NLS-1$ //$NON-NLS-2$ + commandLine.add(tmpFile.toString()); + } Files.createDirectories(buildDirectory); |