Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDorothea Pilz-Roeder2019-04-08 07:31:01 -0400
committerDorothea Pilz-Roeder2019-04-10 04:57:14 -0400
commit3dc407d008c3f085a1418e12533a885a6459b752 (patch)
tree47374c93c2334daf63564d02d5c17c0039585d70
parent290cb246b6d708e1634e3d07f0f929768ae2d9b1 (diff)
downloadorg.eclipse.cdt-3dc407d008c3f085a1418e12533a885a6459b752.tar.gz
org.eclipse.cdt-3dc407d008c3f085a1418e12533a885a6459b752.tar.xz
org.eclipse.cdt-3dc407d008c3f085a1418e12533a885a6459b752.zip
Bug 180451 - [Build] Build output directory should be selectable for
managed build Allow clients extend GnuMakefileGenerator and allow them to provide a different top build output directory. Change-Id: I37dd96089f6f4bed6f4255def4bef193fb27e7e4 Signed-off-by: Dorothea Pilz-Roeder <dorothea.pilz-roeder@advantest.com>
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java71
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java2
3 files changed, 62 insertions, 13 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF
index 25b39dcd4e..10e12c9038 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.core; singleton:=true
-Bundle-Version: 8.6.100.qualifier
+Bundle-Version: 8.7.0.qualifier
Bundle-Activator: org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
index 2bbd9347c7..82bd52a106 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
@@ -16,6 +16,7 @@
* James Blackburn (Broadcom Corp.)
* Marc-Andre Laperle
* Liviu Ionescu - [322168]
+ * Dorothea Pilz-Roeder (Advantest Europe GmbH) - [180451]
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu;
@@ -105,7 +106,6 @@ import org.eclipse.core.runtime.SubProgressMonitor;
* extensions present in Gnu Make.
*
* @since 1.2
- * @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
@@ -441,7 +441,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
builder = config.getEditableBuilder();
initToolInfos();
//set the top build dir path
- topBuildDir = project.getFolder(info.getConfigurationName()).getFullPath();
+ initializeTopBuildDir(info.getConfigurationName());
}
/**
@@ -620,7 +620,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
* 1. This is an incremental build, so if the top-level directory is not
* there, then a rebuild is needed.
*/
- IFolder folder = project.getFolder(config.getName());
+ IFolder folder = project.getFolder(computeTopBuildDir(config.getName()));
if (!folder.exists()) {
return regenerateMakefiles();
}
@@ -903,7 +903,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
}
// Create the top-level directory for the build output
- topBuildDir = createDirectory(config.getName());
+ ensureTopBuildDir();
checkCancel();
// Get the list of subdirectories
@@ -1196,7 +1196,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
//buffer.append(NEWLINE);
// include makefile.init supplementary makefile
- buffer.append("-include " + ROOT + SEPARATOR + MAKEFILE_INIT).append(NEWLINE); //$NON-NLS-1$
+ buffer.append("-include " + reachProjectRoot() + SEPARATOR + MAKEFILE_INIT).append(NEWLINE); //$NON-NLS-1$
buffer.append(NEWLINE);
// Get the clean command from the build model
@@ -1257,7 +1257,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
}
// Include makefile.defs supplemental makefile
- buffer.append("-include ").append(ROOT).append(SEPARATOR).append(MAKEFILE_DEFS).append(NEWLINE); //$NON-NLS-1$
+ buffer.append("-include ").append(reachProjectRoot()).append(SEPARATOR).append(MAKEFILE_DEFS).append(NEWLINE); //$NON-NLS-1$
return (buffer.append(NEWLINE));
}
@@ -1492,7 +1492,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
buffer.append(NEWLINE);
// Include makefile.targets supplemental makefile
- buffer.append("-include ").append(ROOT).append(SEPARATOR).append(MAKEFILE_TARGETS).append(NEWLINE); //$NON-NLS-1$
+ buffer.append("-include ").append(reachProjectRoot()).append(SEPARATOR).append(MAKEFILE_TARGETS) //$NON-NLS-1$
+ .append(NEWLINE);
return buffer;
}
@@ -1972,7 +1973,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
IResource[] resources = module.members();
IResourceInfo rcInfo;
- IFolder folder = project.getFolder(config.getName());
+ IFolder folder = project.getFolder(computeTopBuildDir(config.getName()));
for (IResource resource : resources) {
if (resource.getType() == IResource.FILE) {
@@ -2435,7 +2436,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
String defaultOutputName = EMPTY_STRING;
String primaryDependencyName = EMPTY_STRING;
String patternPrimaryDependencyName = EMPTY_STRING;
- String home = (generatedSource) ? DOT : ROOT;
+ String home = (generatedSource) ? DOT : reachProjectRoot();
String resourcePath = null;
boolean patternRule = true;
boolean isItLinked = false;
@@ -3729,7 +3730,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
if (generatedSource) {
srcName = "./" + srcPath.toString(); //$NON-NLS-1$
} else {
- srcName = ROOT + "/" + srcPath.toString(); //$NON-NLS-1$
+ srcName = reachProjectRoot() + SEPARATOR + srcPath.toString();
}
} else {
if (generatedSource && !sourceLocation.isAbsolute()) {
@@ -4547,7 +4548,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
initToolInfos();
//set the top build dir path
- topBuildDir = project.getFolder(cfg.getName()).getFullPath();
+ initializeTopBuildDir(cfg.getName());
srcEntries = config.getSourceEntries();
if (srcEntries.length == 0) {
@@ -4607,4 +4608,52 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
}
return h;
}
+
+ private void ensureTopBuildDir() throws CoreException {
+ IPath buildWorkingDir = getBuildWorkingDir();
+ if (buildWorkingDir != null) {
+ createDirectory(buildWorkingDir.toString());
+ }
+ }
+
+ private void initializeTopBuildDir(String configName) {
+ topBuildDir = project.getFolder(computeTopBuildDir(configName)).getFullPath();
+ }
+
+ /**
+ * Can be overwritten by a subclass to specify the top build directory to be
+ * used. Default implementation simply returns configuration name.
+ * <p>
+ * <strong>Note</strong>: be careful by overriding this method - all places in the custom code and related
+ * scripts using or referencing top build directory must also be changed to use same logic.
+ *
+ * @param configName name of the configuration
+ * @return project relative path for top build directory
+ * @since 8.7
+ */
+ protected IPath computeTopBuildDir(String configName) {
+ return new Path(configName);
+ }
+
+ /**
+ * @return As many ".." as required to get from getBuildWorkingDir() to the project root.
+ *
+ * E.g. If getBuildWorkingDir() is "Debug", then the function returns "..". If
+ * getBuildWorkingDir() returns "x86/Debug" then "../.." is returned.
+ *
+ * @since 8.7
+ */
+ public String reachProjectRoot() {
+ IPath buildWorkingDir = getBuildWorkingDir();
+ if (buildWorkingDir == null) {
+ return ROOT;
+ }
+ String root = ROOT;
+ int segCnt = buildWorkingDir.segmentCount();
+ for (int i = 1; i < segCnt; i++) {
+ root += SEPARATOR + ROOT;
+ }
+ return root;
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java
index df25344182..d7e08aaf0c 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java
@@ -996,7 +996,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
// create rule of the form
// OBJS = $(macroName1: ../%.input1=%.output1) ... $(macroNameN: ../%.inputN=%.outputN)
return IManagedBuilderMakefileGenerator.WHITESPACE + "$(" + macroName + //$NON-NLS-1$
- IManagedBuilderMakefileGenerator.COLON + IManagedBuilderMakefileGenerator.ROOT
+ IManagedBuilderMakefileGenerator.COLON + makeGen.reachProjectRoot()
+ IManagedBuilderMakefileGenerator.SEPARATOR + IManagedBuilderMakefileGenerator.WILDCARD + DOT
+ srcExtensionName + "=" + wildcard + OptDotExt + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}

Back to the top