Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 169384 Details for
Bug 310819
Headless Builder need a way to extend set of -Ds -Is and -includes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch 1
bug_310819.patch (text/plain), 10.12 KB, created by
James Blackburn
on 2010-05-20 13:31:55 EDT
(
hide
)
Description:
patch 1
Filename:
MIME Type:
Creator:
James Blackburn
Created:
2010-05-20 13:31:55 EDT
Size:
10.12 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.cdt.managedbuilder.core >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/plugin.xml,v >retrieving revision 1.53 >diff -u -r1.53 plugin.xml >--- plugin.xml 23 Mar 2010 02:59:42 -0000 1.53 >+++ plugin.xml 20 May 2010 17:30:21 -0000 >@@ -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> >Index: src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilder.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilder.java,v >retrieving revision 1.9 >diff -u -r1.9 HeadlessBuilder.java >--- src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilder.java 19 May 2010 10:23:47 -0000 1.9 >+++ src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilder.java 20 May 2010 17:30:21 -0000 >@@ -30,6 +30,9 @@ > > 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 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 @@ > 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 @@ > } 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 @@ > * -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 @@ > 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 @@ > System.err.println(HeadlessBuildMessages.HeadlessBuilder_importAll); > System.err.println(HeadlessBuildMessages.HeadlessBuilder_usage_build); > System.err.println(HeadlessBuildMessages.HeadlessBuilder_usage_clean_build); >+ System.err.println(" -I {include_path} additional include_path to add to tools"); >+ System.err.println(" -include {include_file} additional include_file to pass to tools"); >+ System.err.println(" -D {prepoc_define} addition preprocessor defines to pass to the tools"); > return false; > } > >Index: src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilderExternalSettingsProvider.java >=================================================================== >RCS file: src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilderExternalSettingsProvider.java >diff -N src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilderExternalSettingsProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/managedbuilder/internal/core/HeadlessBuilderExternalSettingsProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -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); >+ } >+ } >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
jamesblackburn+eclipse
:
iplog-
Actions:
View
|
Diff
Attachments on
bug 310819
: 169384