Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorDoug Schaefer2017-11-09 19:13:35 +0000
committerDoug Schaefer2017-11-10 01:35:17 +0000
commit45019ea7805777774f71d395e077fe36068d401f (patch)
tree2f729e5005a6a26f0219c6e54699638a8758ebd2 /build
parent18f76e8313432b297765c23b95f1d5033789195e (diff)
downloadorg.eclipse.cdt-45019ea7805777774f71d395e077fe36068d401f.tar.gz
org.eclipse.cdt-45019ea7805777774f71d395e077fe36068d401f.tar.xz
org.eclipse.cdt-45019ea7805777774f71d395e077fe36068d401f.zip
Add settings to Makefile build configs to build at project root.
Often Makefile projects are intended to be built from the project root directory, such as ESP32 IDF projects. This adds a setting to control that. Change-Id: I151ebf60a7609461d24e192a9d6418fccb737055
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.make.core/plugin.xml2
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakefileBuildConfigurationProvider.java (renamed from build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakefileBuildConfigurationProvider.java)6
-rw-r--r--build/org.eclipse.cdt.make.core/templates/simple/Makefile9
-rw-r--r--build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF3
-rw-r--r--build/org.eclipse.cdt.make.ui/plugin.xml7
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeBuildSettingsTab.java149
6 files changed, 170 insertions, 6 deletions
diff --git a/build/org.eclipse.cdt.make.core/plugin.xml b/build/org.eclipse.cdt.make.core/plugin.xml
index 63816b70211..5de1999d0e0 100644
--- a/build/org.eclipse.cdt.make.core/plugin.xml
+++ b/build/org.eclipse.cdt.make.core/plugin.xml
@@ -197,7 +197,7 @@
<extension
point="org.eclipse.cdt.core.buildConfigProvider">
<provider
- class="org.eclipse.cdt.make.internal.core.MakefileBuildConfigurationProvider"
+ class="org.eclipse.cdt.make.core.MakefileBuildConfigurationProvider"
id="org.eclipse.cdt.make.core.provider"
natureId="org.eclipse.cdt.make.core.makeNature">
</provider>
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakefileBuildConfigurationProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakefileBuildConfigurationProvider.java
index f820c4eb7e9..1406011df48 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakefileBuildConfigurationProvider.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakefileBuildConfigurationProvider.java
@@ -5,19 +5,21 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package org.eclipse.cdt.make.internal.core;
+package org.eclipse.cdt.make.core;
import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
import org.eclipse.cdt.core.build.ICBuildConfigurationProvider;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.StandardBuildConfiguration;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+/**
+ * @since 7.4
+ */
public class MakefileBuildConfigurationProvider implements ICBuildConfigurationProvider {
public static final String ID = "org.eclipse.cdt.make.core.provider"; //$NON-NLS-1$
diff --git a/build/org.eclipse.cdt.make.core/templates/simple/Makefile b/build/org.eclipse.cdt.make.core/templates/simple/Makefile
index 02622849e17..404907713d5 100644
--- a/build/org.eclipse.cdt.make.core/templates/simple/Makefile
+++ b/build/org.eclipse.cdt.make.core/templates/simple/Makefile
@@ -1,11 +1,16 @@
+PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
+
OBJS = ${projectName}.o
all: ${projectName}
${projectName}: $(OBJS)
- $(CC) -o $@ $^
+ $(CXX) -o $@ $^
+
+%.o: $(PROJECT_ROOT)%.cpp
+ $(CXX) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
-%.o: ../../%.cpp
+%.o: $(PROJECT_ROOT)%.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
clean:
diff --git a/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF
index aa7adc5bd1d..02ee6cafbcf 100644
--- a/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF
@@ -37,7 +37,8 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
org.eclipse.compare;bundle-version="[3.3.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="1.2.0",
org.eclipse.tools.templates.ui;bundle-version="1.1.1",
- org.eclipse.tools.templates.freemarker;bundle-version="1.0.0"
+ org.eclipse.tools.templates.freemarker;bundle-version="1.0.0",
+ org.eclipse.cdt.launch;bundle-version="9.2.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.ibm.icu.text
diff --git a/build/org.eclipse.cdt.make.ui/plugin.xml b/build/org.eclipse.cdt.make.ui/plugin.xml
index 430a7a35fd2..e4c1f7bbd09 100644
--- a/build/org.eclipse.cdt.make.ui/plugin.xml
+++ b/build/org.eclipse.cdt.make.ui/plugin.xml
@@ -651,4 +651,11 @@
label="Make">
</tag>
</extension>
+ <extension
+ point="org.eclipse.cdt.launch.coreBuildTab">
+ <provider
+ nature="org.eclipse.cdt.make.core.makeNature"
+ tabClass="org.eclipse.cdt.make.internal.ui.MakeBuildSettingsTab">
+ </provider>
+ </extension>
</plugin>
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
new file mode 100644
index 00000000000..8910088d725
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeBuildSettingsTab.java
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2017 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.make.internal.ui;
+
+import java.util.Map;
+
+import org.eclipse.cdt.core.build.ICBuildConfiguration;
+import org.eclipse.cdt.core.build.StandardBuildConfiguration;
+import org.eclipse.cdt.launch.ui.corebuild.CommonBuildTab;
+import org.eclipse.cdt.make.core.MakefileBuildConfigurationProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+
+public class MakeBuildSettingsTab extends CommonBuildTab {
+
+ private Button projectButton;
+ private Button configButton;
+
+ private boolean defaultProject;
+
+ @Override
+ protected String getBuildConfigProviderId() {
+ return MakefileBuildConfigurationProvider.ID;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ comp.setLayout(new GridLayout());
+ setControl(comp);
+
+ // Toolchain selector
+ Control tcControl = createToolchainSelector(comp);
+ 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));
+
+ projectButton = new Button(group, 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.setText("Build in configuration specific folder");
+ configButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ }
+
+ @Override
+ public String getName() {
+ return "Makefile";
+ }
+
+ @Override
+ protected void restoreProperties(Map<String, String> properties) {
+ // TODO Auto-generated method stub
+ super.restoreProperties(properties);
+
+ String container = properties.get(StandardBuildConfiguration.BUILD_CONTAINER);
+ if (container != null && !container.trim().isEmpty()) {
+ IPath containerLoc = new Path(container);
+ if (containerLoc.segmentCount() == 1) {
+ // TODO what if it's not the project?
+ projectButton.setSelection(true);
+ defaultProject = true;
+ } else {
+ configButton.setSelection(true);
+ defaultProject = false;
+ }
+ }
+ }
+
+ @Override
+ protected void saveProperties(Map<String, String> properties) {
+ super.saveProperties(properties);
+
+ try {
+ ICBuildConfiguration buildConfig = getBuildConfiguration();
+ if (buildConfig instanceof StandardBuildConfiguration) {
+ StandardBuildConfiguration stdConfig = (StandardBuildConfiguration) buildConfig;
+ if (defaultProject && !projectButton.getSelection()) {
+ properties.put(StandardBuildConfiguration.BUILD_CONTAINER,
+ stdConfig.getDefaultBuildContainer().getFullPath().toString());
+ } else if (!defaultProject && projectButton.getSelection()) {
+ properties.put(StandardBuildConfiguration.BUILD_CONTAINER,
+ stdConfig.getProject().getFullPath().toString());
+ }
+ }
+ } catch (CoreException e) {
+ MakeUIPlugin.log(e.getStatus());
+ }
+ }
+
+ @Override
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ super.initializeFrom(configuration);
+
+ ICBuildConfiguration buildConfig = getBuildConfiguration();
+ String container = buildConfig.getProperty(StandardBuildConfiguration.BUILD_CONTAINER);
+ if (container != null && !container.trim().isEmpty()) {
+ IPath containerLoc = new Path(container);
+ if (containerLoc.segmentCount() == 1) {
+ // TODO what if it's not the project?
+ projectButton.setSelection(true);
+ defaultProject = true;
+ } else {
+ configButton.setSelection(true);
+ defaultProject = false;
+ }
+ }
+ }
+
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ super.performApply(configuration);
+
+ try {
+ ICBuildConfiguration buildConfig = getBuildConfiguration();
+ if (buildConfig instanceof StandardBuildConfiguration) {
+ StandardBuildConfiguration stdConfig = (StandardBuildConfiguration) buildConfig;
+ if (defaultProject && !projectButton.getSelection()) {
+ stdConfig.setBuildContainer(stdConfig.getDefaultBuildContainer());
+ } else if (!defaultProject && projectButton.getSelection()) {
+ stdConfig.setBuildContainer(stdConfig.getProject());
+ }
+ }
+ } catch (CoreException e) {
+ MakeUIPlugin.log(e.getStatus());
+ }
+ }
+
+}

Back to the top