Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2017-11-10 10:28:36 -0500
committerDoug Schaefer2017-11-10 14:49:16 -0500
commitb7b1d41f0844fa565ac58036c531b88ae1c4060c (patch)
tree2d6daf41f566e4b311318ca8e17f574240e9c2b7
parent45019ea7805777774f71d395e077fe36068d401f (diff)
downloadorg.eclipse.cdt-b7b1d41f0844fa565ac58036c531b88ae1c4060c.tar.gz
org.eclipse.cdt-b7b1d41f0844fa565ac58036c531b88ae1c4060c.tar.xz
org.eclipse.cdt-b7b1d41f0844fa565ac58036c531b88ae1c4060c.zip
Fixes for scanner info for Makefile projects.
Using ESP-IDF (the ESP32 FreeRTOS SDK) on MSYS2 as a test bed. Making sure the indexer picks up as much as it can. Removed -j since that messes up build output parsing. Add UI so you can put it back if you want. Change-Id: I767c739dce1412c75fb56d0bb1efceb913883a5f
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java21
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewGCCToolChainWizard.java8
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeBuildSettingsTab.java73
-rw-r--r--core/org.eclipse.cdt.core/.settings/.api_filters12
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java18
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java41
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java13
7 files changed, 162 insertions, 24 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 c922c4e32c..4b1bc8b16f 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
@@ -321,10 +321,13 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
if (tmpFile == null) {
// Have to assume there wasn't a source file. Add one in the
// resource's container
+ // TODO really?
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());
+ if (parentPath.toFile().exists()) {
+ tmpFile = Files.createTempFile(parentPath.toFile().toPath(), ".sc", ".cpp"); //$NON-NLS-1$ //$NON-NLS-2$
+ commandLine.add(tmpFile.toString());
+ }
}
return getScannerInfo(buildConfig, commandLine, buildDirectory, tmpFile);
@@ -490,7 +493,8 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
if (cCommand.contains("gcc")) { //$NON-NLS-1$
cppCommand = cCommand.replace("gcc", "g++"); //$NON-NLS-1$ //$NON-NLS-2$
// Also recognize c++ as an alias for g++
- commands = new String[] { cCommand, cppCommand, cCommand.replace("gcc", "c++"), "cc", "c++" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ commands = new String[] { cCommand, cppCommand, cCommand.replace("gcc", "cc"), //$NON-NLS-1$ //$NON-NLS-2$
+ cCommand.replace("gcc", "c++") }; //$NON-NLS-1$ //$NON-NLS-2$
} else if (cCommand.contains("clang")) { //$NON-NLS-1$
cppCommand = cCommand.replace("clang", "clang++"); //$NON-NLS-1$ //$NON-NLS-2$
commands = new String[] { cCommand, cppCommand };
@@ -533,12 +537,23 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
// ran into an option, we're done.
break;
}
+ if (i > 1 && cmd.get(i - 1).equals("-o")) { //$NON-NLS-1$
+ // this is an output file
+ --i;
+ continue;
+ }
try {
Path srcPath = Paths.get(arg);
URI uri;
if (srcPath.isAbsolute()) {
uri = srcPath.toUri();
} else {
+ if (arg.startsWith("/") && Platform.getOS().equals(Platform.OS_WIN32)) { //$NON-NLS-1$
+ String drive = srcPath.getName(0).toString();
+ if (drive.length() == 1) {
+ srcPath = Paths.get(drive + ":\\").resolve(srcPath.subpath(1, srcPath.getNameCount())); //$NON-NLS-1$
+ }
+ }
uri = Paths.get(buildDirectoryURI).resolve(srcPath).toUri().normalize();
}
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewGCCToolChainWizard.java b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewGCCToolChainWizard.java
index fd34546ad6..797a14f52b 100644
--- a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewGCCToolChainWizard.java
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewGCCToolChainWizard.java
@@ -30,8 +30,8 @@ public class NewGCCToolChainWizard extends ToolChainWizard {
@Override
public boolean performFinish() {
Path path = settingsPage.getPath();
- String os = settingsPage.getOS();
- String arch = settingsPage.getArch();
+ String os = settingsPage.getOS().trim();
+ String arch = settingsPage.getArch().trim();
IEnvironmentVariable[] envvars = envPage.getEnvVars();
new Job(Messages.NewGCCToolChainWizard_Add) {
@@ -47,7 +47,9 @@ public class NewGCCToolChainWizard extends ToolChainWizard {
}
GCCToolChain gcc = new GCCToolChain(provider, path, arch, envvars);
- gcc.setProperty(IToolChain.ATTR_OS, os);
+ if (!os.isEmpty()) {
+ gcc.setProperty(IToolChain.ATTR_OS, os);
+ }
provider.addToolChain(gcc);
return Status.OK_STATUS;
} catch (CoreException e) {
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeBuildSettingsTab.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeBuildSettingsTab.java
index 8910088d72..9a66e66d4b 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeBuildSettingsTab.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeBuildSettingsTab.java
@@ -25,11 +25,15 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
public class MakeBuildSettingsTab extends CommonBuildTab {
private Button projectButton;
private Button configButton;
+ private Text buildCmdText;
+ private Text cleanCmdText;
private boolean defaultProject;
@@ -49,18 +53,35 @@ public class MakeBuildSettingsTab extends CommonBuildTab {
tcControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
// Build Output Group
- Group group = new Group(comp, SWT.NONE);
- group.setText("Build Output Location");
- group.setLayout(new GridLayout());
- group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ Group outputGroup = new Group(comp, SWT.NONE);
+ outputGroup.setText("Build Output Location");
+ outputGroup.setLayout(new GridLayout());
+ outputGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- projectButton = new Button(group, SWT.RADIO);
+ projectButton = new Button(outputGroup, SWT.RADIO);
projectButton.setText("Build in project directory");
projectButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- configButton = new Button(group, SWT.RADIO);
+ configButton = new Button(outputGroup, SWT.RADIO);
configButton.setText("Build in configuration specific folder");
configButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ Group cmdGroup = new Group(comp, SWT.NONE);
+ cmdGroup.setText("Build Commands");
+ cmdGroup.setLayout(new GridLayout(2, false));
+ cmdGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ Label label = new Label(cmdGroup, SWT.NONE);
+ label.setText("Build:");
+
+ buildCmdText = new Text(cmdGroup, SWT.BORDER);
+ buildCmdText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ label = new Label(cmdGroup, SWT.NONE);
+ label.setText("Clean:");
+
+ cleanCmdText = new Text(cmdGroup, SWT.BORDER);
+ cleanCmdText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
}
@Override
@@ -85,6 +106,16 @@ public class MakeBuildSettingsTab extends CommonBuildTab {
defaultProject = false;
}
}
+
+ String buildCommand = properties.get(StandardBuildConfiguration.BUILD_COMMAND);
+ if (buildCommand != null && !buildCommand.trim().isEmpty()) {
+ buildCmdText.setText(buildCommand);
+ }
+
+ String cleanCommand = properties.get(StandardBuildConfiguration.CLEAN_COMMAND);
+ if (cleanCommand != null && !cleanCommand.trim().isEmpty()) {
+ cleanCmdText.setText(cleanCommand);
+ }
}
@Override
@@ -102,6 +133,16 @@ public class MakeBuildSettingsTab extends CommonBuildTab {
properties.put(StandardBuildConfiguration.BUILD_CONTAINER,
stdConfig.getProject().getFullPath().toString());
}
+
+ String buildCommand = buildCmdText.getText().trim();
+ if (!buildCommand.isEmpty()) {
+ properties.put(StandardBuildConfiguration.BUILD_COMMAND, buildCommand);
+ }
+
+ String cleanCommand = cleanCmdText.getText().trim();
+ if (!cleanCommand.isEmpty()) {
+ properties.put(StandardBuildConfiguration.CLEAN_COMMAND, cleanCommand);
+ }
}
} catch (CoreException e) {
MakeUIPlugin.log(e.getStatus());
@@ -125,6 +166,16 @@ public class MakeBuildSettingsTab extends CommonBuildTab {
defaultProject = false;
}
}
+
+ String buildCommand = buildConfig.getProperty(StandardBuildConfiguration.BUILD_COMMAND);
+ if (buildCommand != null && !buildCommand.trim().isEmpty()) {
+ buildCmdText.setText(buildCommand);
+ }
+
+ String cleanCommand = buildConfig.getProperty(StandardBuildConfiguration.CLEAN_COMMAND);
+ if (cleanCommand != null && !cleanCommand.trim().isEmpty()) {
+ cleanCmdText.setText(cleanCommand);
+ }
}
@Override
@@ -140,6 +191,16 @@ public class MakeBuildSettingsTab extends CommonBuildTab {
} else if (!defaultProject && projectButton.getSelection()) {
stdConfig.setBuildContainer(stdConfig.getProject());
}
+
+ String buildCommand = buildCmdText.getText().trim();
+ if (!buildCommand.isEmpty()) {
+ stdConfig.setBuildCommand(buildCommand.split(" ")); //$NON-NLS-1$
+ }
+
+ String cleanCommand = cleanCmdText.getText().trim();
+ if (!cleanCommand.isEmpty()) {
+ stdConfig.setCleanCommand(cleanCommand.split(" ")); //$NON-NLS-1$
+ }
}
} catch (CoreException e) {
MakeUIPlugin.log(e.getStatus());
diff --git a/core/org.eclipse.cdt.core/.settings/.api_filters b/core/org.eclipse.cdt.core/.settings/.api_filters
index b75949e3ad..e4899e4dd3 100644
--- a/core/org.eclipse.cdt.core/.settings/.api_filters
+++ b/core/org.eclipse.cdt.core/.settings/.api_filters
@@ -75,11 +75,23 @@
</filter>
</resource>
<resource path="src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java" type="org.eclipse.cdt.core.build.StandardBuildConfiguration">
+ <filter id="336658481">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.StandardBuildConfiguration"/>
+ <message_argument value="BUILD_COMMAND"/>
+ </message_arguments>
+ </filter>
<filter comment="No one extends this yet." id="336658481">
<message_arguments>
<message_argument value="org.eclipse.cdt.core.build.StandardBuildConfiguration"/>
<message_argument value="BUILD_CONTAINER"/>
</message_arguments>
</filter>
+ <filter id="336658481">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.StandardBuildConfiguration"/>
+ <message_argument value="CLEAN_COMMAND"/>
+ </message_arguments>
+ </filter>
</resource>
</component>
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
index ce7edae66b..e4ebbe6d4f 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
@@ -674,6 +674,7 @@ public abstract class CBuildConfiguration extends PlatformObject
// Make sure it's a compile command
String[] compileCommands = toolChain.getCompileCommands();
+ boolean found = false;
loop:
for (String arg : command) {
// TODO we should really ask the toolchain, not all args start with '-'
@@ -685,9 +686,26 @@ public abstract class CBuildConfiguration extends PlatformObject
for (String cc : compileCommands) {
if (arg.endsWith(cc)
&& (arg.equals(cc) || arg.endsWith("/" + cc) || arg.endsWith("\\" + cc))) { //$NON-NLS-1$ //$NON-NLS-2$
+ found = true;
break loop;
}
}
+
+ if (Platform.getOS().equals(Platform.OS_WIN32) && !arg.endsWith(".exe")) { //$NON-NLS-1$
+ // Try with exe
+ arg = arg + ".exe"; //$NON-NLS-1$
+ for (String cc : compileCommands) {
+ if (arg.endsWith(cc)
+ && (arg.equals(cc) || arg.endsWith("/" + cc) || arg.endsWith("\\" + cc))) { //$NON-NLS-1$ //$NON-NLS-2$
+ found = true;
+ break loop;
+ }
+ }
+ }
+ }
+
+ if (!found) {
+ return false;
}
try {
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java
index 01d6e4651c..3919f34371 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java
@@ -47,6 +47,14 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
* @since 6.4
*/
public static final String BUILD_CONTAINER = "stdbuild.build.container"; //$NON-NLS-1$
+ /**
+ * @since 6.4
+ */
+ public static final String BUILD_COMMAND = "stdbuild.build.command"; //$NON-NLS-1$
+ /**
+ * @since 6.4
+ */
+ public static final String CLEAN_COMMAND = "stdbuild.clean.command"; //$NON-NLS-1$
private String[] buildCommand;
private String[] cleanCommand;
@@ -54,6 +62,15 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
public StandardBuildConfiguration(IBuildConfiguration config, String name) throws CoreException {
super(config, name);
+ applyProperties();
+ }
+
+ public StandardBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain,
+ String launchMode) {
+ super(config, name, toolChain);
+ }
+
+ private void applyProperties() {
String container = getProperty(BUILD_CONTAINER);
if (container != null && !container.trim().isEmpty()) {
IPath containerLoc = new org.eclipse.core.runtime.Path(container);
@@ -63,11 +80,16 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
buildContainer = ResourcesPlugin.getWorkspace().getRoot().getFolder(containerLoc);
}
}
- }
- public StandardBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain,
- String launchMode) {
- super(config, name, toolChain);
+ String buildCmd = getProperty(BUILD_COMMAND);
+ if (buildCmd != null && !buildCmd.trim().isEmpty()) {
+ buildCommand = buildCmd.split(" "); //$NON-NLS-1$
+ }
+
+ String cleanCmd = getProperty(CLEAN_COMMAND);
+ if (cleanCmd != null && !cleanCmd.trim().isEmpty()) {
+ cleanCommand = cleanCmd.split(" "); //$NON-NLS-1$
+ }
}
public void setBuildContainer(IContainer buildContainer) {
@@ -77,6 +99,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
public void setBuildCommand(String[] buildCommand) {
this.buildCommand = buildCommand;
+ setProperty(BUILD_COMMAND, String.join(" ", buildCommand)); //$NON-NLS-1$
}
public void setCleanCommand(String[] cleanCommand) {
@@ -133,6 +156,15 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
}
@Override
+ public boolean setProperties(Map<String, String> properties) {
+ if (!super.setProperties(properties)) {
+ return false;
+ }
+ applyProperties();
+ return true;
+ }
+
+ @Override
public IProject[] build(int kind, Map<String, String> args, IConsole console, IProgressMonitor monitor)
throws CoreException {
IProject project = getProject();
@@ -153,7 +185,6 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
} else {
command = new ArrayList<>();
command.add(findCommand("make").toString()); //$NON-NLS-1$
- command.add("-j"); //$NON-NLS-1$
if (!getBuildContainer().equals(getProject())) {
Path makefile = Paths.get(getProject().getFile("Makefile").getLocationURI()); //$NON-NLS-1$
Path relative = getBuildDirectory().relativize(makefile);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java
index 97eee797d5..75964cc2bc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java
@@ -126,6 +126,12 @@ public class ToolChainPreferencePage extends PreferencePage implements IWorkbenc
availTable.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
+ toolChains = new ArrayList<IToolChain>();
+ try {
+ toolChains.addAll(manager.getAllToolChains());
+ } catch (CoreException e) {
+ CUIPlugin.log(e.getStatus());
+ }
return toolChains.toArray();
}
});
@@ -282,13 +288,6 @@ public class ToolChainPreferencePage extends PreferencePage implements IWorkbenc
}
});
- toolChains = new ArrayList<IToolChain>();
- try {
- toolChains.addAll(manager.getAllToolChains());
- } catch (CoreException e) {
- CUIPlugin.log(e.getStatus());
- }
-
availTable.setInput(manager);
userTable.setInput(manager);
updateButtons();

Back to the top