Skip to main content
summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorJames Blackburn2010-06-24 09:26:20 -0400
committerJames Blackburn2010-06-24 09:26:20 -0400
commit72d386703f223c9dc89e822850ac2adc81845286 (patch)
tree8088584230af45da9d59c44edbde545c0bcc3d81 /build
parent1285350432c8611ab48aced4bd96ef02001c9732 (diff)
downloadorg.eclipse.cdt-72d386703f223c9dc89e822850ac2adc81845286.tar.gz
org.eclipse.cdt-72d386703f223c9dc89e822850ac2adc81845286.tar.xz
org.eclipse.cdt-72d386703f223c9dc89e822850ac2adc81845286.zip
Bug 310819 Headless Builder need a way to extend set of -Ds -Is and -includes
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/plugin.xml8
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuildMessages.java3
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilder.java29
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilderExternalSettingsProvider.java104
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties3
5 files changed, 147 insertions, 0 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
index 8a67ab72ad..6501593188 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
@@ -597,5 +597,13 @@
</run>
</application>
</extension>
+ <extension
+ id="headlessSettings"
+ name="HeadlessBuilder Additional Settings"
+ point="org.eclipse.cdt.core.externalSettingsProvider">
+ <provider
+ class="org.eclipse.cdt.managedbuilder.internal.core.HeadlessBuilderExternalSettingsProvider">
+ </provider>
+ </extension>
</plugin>
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuildMessages.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuildMessages.java
index e0c991f874..b085625dec 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuildMessages.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuildMessages.java
@@ -24,6 +24,8 @@ public class HeadlessBuildMessages extends NLS {
public static String HeadlessBuilder_Directory;
public static String HeadlessBuilder_Error;
public static String HeadlessBuilder_importAll;
+ public static String HeadlessBuilder_IncludeFile;
+ public static String HeadlessBuilder_InlucdePath;
public static String HeadlessBuilder_invalid_argument;
public static String HeadlessBuilder_is_not_accessible;
public static String HeadlessBuilder_is_not_valid_in_workspace;
@@ -43,6 +45,7 @@ public class HeadlessBuildMessages extends NLS {
public static String HeadlessBuilder_usage_build;
public static String HeadlessBuilder_usage_clean_build;
public static String HeadlessBuilder_invalid_uri;
+ public static String HeadlessBuilder_PreprocessorDefine;
public static String HeadlessBuilder_usage_import;
public static String HeadlessBuilder_Workspace;
public static String HeadlessBuilder_WorkspaceInUse;
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilder.java
index 103eafc91c..c9c1519e09 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilder.java
@@ -30,6 +30,9 @@ import java.util.regex.PatternSyntaxException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.resources.ACBuilder;
+import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@@ -70,6 +73,9 @@ import org.eclipse.osgi.service.datalocation.Location;
* - Import all projects in the tree : -importAll {[uri:/]/path/to/projectTreeURI}
* - Build projects / the workspace : -build {project_name_reg_ex/config_name_reg_ex | all}
* - Clean build projects / the workspace : -cleanBuild {project_name_reg_ex/config_name_reg_ex | all}
+ * - Add Include path to build : -I {include_path}
+ * - Add Include file to build : -include {include_file}
+ * - Add preprocessor define to build : -D {prepoc_define}
*
* Build output is automatically sent to stdout.
* @since 6.0
@@ -363,6 +369,9 @@ public class HeadlessBuilder implements IApplication {
return status;
}
+ // Hook in our external settings to the build
+ HeadlessBuilderExternalSettingsProvider.hookExternalSettingsProvider();
+
IProject[] allProjects = root.getProjects();
// Map from Project -> Configurations to build. We also Build all projects which are clean'd
Map<IProject, Set<ICConfigurationDescription>> configsToBuild = new HashMap<IProject, Set<ICConfigurationDescription>>();
@@ -411,6 +420,8 @@ public class HeadlessBuilder implements IApplication {
} finally {
// Reset the build_all_configs preference value to its previous state
ACBuilder.setAllConfigBuild(buildAllConfigs);
+ // Unhook the external settings provider
+ HeadlessBuilderExternalSettingsProvider.unhookExternalSettingsProvider();
}
} finally {
// Wait for any outstanding jobs to finish
@@ -466,6 +477,9 @@ public class HeadlessBuilder implements IApplication {
* -importAll {[uri:/]/path/to/projectTreeURI} Import all projects in the tree
* -build {project_name_reg_ex/config_name_reg_ex | all}
* -cleanBuild {project_name_reg_ex/config_name_reg_ex | all}
+ * -I {include_path} additional include_path to add to tools
+ * -include {include_file} additional include_file to pass to tools
+ * -D {prepoc_define} addition preprocessor defines to pass to the tools
*
* Each argument may be specified more than once
* @param args String[] of arguments to parse
@@ -484,6 +498,18 @@ public class HeadlessBuilder implements IApplication {
projectRegExToBuild.add(args[++i]);
} else if ("-cleanBuild".equals(args[i])) { //$NON-NLS-1$
projectRegExToClean.add(args[++i]);
+ } else if ("-D".equals(args[i])) { //$NON-NLS-1$
+ String macro = args[++i];
+ String macroVal = ""; //$NON-NLS-1$
+ if (macro.indexOf('=') != -1) {
+ macroVal = macro.substring(macro.indexOf('=') + 1);
+ macro = macro.substring(0, macro.indexOf('='));
+ }
+ HeadlessBuilderExternalSettingsProvider.additionalSettings.add(new CMacroEntry(macro, macroVal, 0));
+ } else if ("-I".equals(args[i])) { //$NON-NLS-1$
+ HeadlessBuilderExternalSettingsProvider.additionalSettings.add(new CIncludePathEntry(args[++i], 0));
+ } else if ("-include".equals(args[i])) { //$NON-NLS-1$
+ HeadlessBuilderExternalSettingsProvider.additionalSettings.add(new CIncludeFileEntry(args[++i], 0));
} else {
throw new Exception(HeadlessBuildMessages.HeadlessBuilder_unknown_argument + args[i]);
}
@@ -497,6 +523,9 @@ public class HeadlessBuilder implements IApplication {
System.err.println(HeadlessBuildMessages.HeadlessBuilder_importAll);
System.err.println(HeadlessBuildMessages.HeadlessBuilder_usage_build);
System.err.println(HeadlessBuildMessages.HeadlessBuilder_usage_clean_build);
+ System.err.println(HeadlessBuildMessages.HeadlessBuilder_InlucdePath);
+ System.err.println(HeadlessBuildMessages.HeadlessBuilder_IncludeFile);
+ System.err.println(HeadlessBuildMessages.HeadlessBuilder_PreprocessorDefine);
return false;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilderExternalSettingsProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilderExternalSettingsProvider.java
new file mode 100644
index 0000000000..274f2ed79e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilderExternalSettingsProvider.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Broadcom Corporation 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
+ *
+ * Contributors:
+ * James Blackburn (Broadcom Corp.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.CExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.core.settings.model.extension.CExternalSettingProvider;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * This class allows extending the set of -D's, -I's and -includes that
+ * are passed to projects using the external settings provider mechanism.
+ */
+public class HeadlessBuilderExternalSettingsProvider extends CExternalSettingProvider {
+
+ private static final String ID = "org.eclipse.cdt.managedbuilder.core.headlessSettings"; //$NON-NLS-1$
+
+ /** List of external settings which should be appended to build */
+ static List<ICSettingEntry> additionalSettings = new ArrayList<ICSettingEntry>();
+
+ public HeadlessBuilderExternalSettingsProvider() {
+ }
+
+ @Override
+ public CExternalSetting[] getSettings(IProject project, ICConfigurationDescription cfg) {
+ if (additionalSettings.isEmpty())
+ return new CExternalSetting[0];
+ return new CExternalSetting[] { new CExternalSetting(null, null, null, additionalSettings.toArray(new ICSettingEntry[additionalSettings.size()])) };
+ }
+
+ /**
+ * Hook the external settings provider if the user has added c settings
+ */
+ static void hookExternalSettingsProvider() {
+ if (additionalSettings.isEmpty())
+ return;
+ // Remove the external settings providers from all the hooked projects
+ for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+ ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(project);
+ if (desc == null)
+ continue;
+ for (ICConfigurationDescription cfg : desc.getConfigurations()) {
+ String[] extSettingIds = cfg.getExternalSettingsProviderIds();
+ String[] newSettingIds = new String[extSettingIds.length + 1];
+ System.arraycopy(extSettingIds, 0, newSettingIds, 0, extSettingIds.length);
+ newSettingIds[extSettingIds.length] = ID;
+ cfg.setExternalSettingsProviderIds(newSettingIds);
+ }
+ try {
+ CoreModel.getDefault().setProjectDescription(project, desc);
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ }
+ }
+
+ /**
+ * Unhook the external settings provider if the user has added c settings
+ */
+ static void unhookExternalSettingsProvider() {
+ if (additionalSettings.isEmpty())
+ return;
+
+ // Remove the external settings providers from all the hooked projects
+ for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+ ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(project);
+ if (desc == null)
+ continue;
+ for (ICConfigurationDescription cfg : desc.getConfigurations()) {
+ ArrayList<String> extSettingIds = new ArrayList<String>(Arrays.asList(cfg.getExternalSettingsProviderIds()));
+ for (Iterator<String> it = extSettingIds.iterator(); it.hasNext();)
+ if (ID.equals(it.next()))
+ it.remove();
+ cfg.setExternalSettingsProviderIds(extSettingIds.toArray(new String[extSettingIds.size()]));
+ }
+ try {
+ CoreModel.getDefault().setProjectDescription(project, desc);
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
index cbc7764b07..32a56491b7 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
@@ -189,8 +189,11 @@ HeadlessBuilder_usage_build=\ \ \ -build {project_name_reg_ex{/config_reg_e
HeadlessBuilder_usage_clean_build=\ \ \ -cleanBuild {project_name_reg_ex{/config_reg_ex} | all}
HeadlessBuilder_usage_import=\ \ \ -import {[uri:/]/path/to/project}
HeadlessBuilder_importAll=\ \ \ -importAll {[uri:/]/path/to/projectTreeURI} Import all projects under URI
+HeadlessBuilder_IncludeFile=\ \ \ -include {include_file} additional include_file to pass to tools
+HeadlessBuilder_InlucdePath=\ \ \ -I {include_path} additional include_path to add to tools
HeadlessBuilder_invalid_uri=Invalid project URI:
HeadlessBuilder_MustSpecifyWorkspace=Must specify a location for the workspace. Restart with the '-data' switch.
+HeadlessBuilder_PreprocessorDefine=\ \ \ -D {prepoc_define} addition preprocessor defines to pass to the tools
HeadlessBuilder_Workspace=Workspace
HeadlessBuilder_WorkspaceInUse=Workspace already in use\!

Back to the top