From 6740c5334148b46937c9e4ae73cb31b7fe3d401f Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 4 Dec 2008 14:53:45 +0000 Subject: Initial commit. --- org.rtems.cdt/.classpath | 7 + org.rtems.cdt/.project | 28 ++ org.rtems.cdt/.settings/org.eclipse.jdt.core.prefs | 7 + org.rtems.cdt/ChangeLog | 0 org.rtems.cdt/META-INF/MANIFEST.MF | 21 ++ org.rtems.cdt/build.properties | 6 + org.rtems.cdt/license.html | 319 +++++++++++++++++ org.rtems.cdt/plugin.xml | 389 +++++++++++++++++++++ org.rtems.cdt/src/org/rtems/cdt/Activator.java | 89 +++++ org.rtems.cdt/src/org/rtems/cdt/Constants.java | 110 ++++++ org.rtems.cdt/src/org/rtems/cdt/Storage.java | 347 ++++++++++++++++++ .../src/org/rtems/cdt/VolatilePreferenceStore.java | 37 ++ .../org/rtems/cdt/build/CommandLineGenerator.java | 92 +++++ .../cdt/build/CygwinCommandLineGenerator.java | 31 ++ .../rtems/cdt/build/CygwinEnvironmentSupplier.java | 31 ++ .../cdt/build/CygwinRunScannerInfoProvider.java | 31 ++ .../cdt/build/CygwinScannerInfoCollector.java | 70 ++++ .../org/rtems/cdt/build/EnvironmentSupplier.java | 66 ++++ .../rtems/cdt/build/RunScannerInfoProvider.java | 83 +++++ .../cdt/preferences/PreferenceInitializer.java | 42 +++ .../org/rtems/cdt/preferences/PreferencePage.java | 85 +++++ .../src/org/rtems/cdt/properties/PropertyPage.java | 115 ++++++ .../src/org/rtems/cdt/wizards/BasicSetup.java | 232 ++++++++++++ .../src/org/rtems/cdt/wizards/FinishSetup.java | 58 +++ 24 files changed, 2296 insertions(+) create mode 100644 org.rtems.cdt/.classpath create mode 100644 org.rtems.cdt/.project create mode 100644 org.rtems.cdt/.settings/org.eclipse.jdt.core.prefs create mode 100644 org.rtems.cdt/ChangeLog create mode 100644 org.rtems.cdt/META-INF/MANIFEST.MF create mode 100644 org.rtems.cdt/build.properties create mode 100644 org.rtems.cdt/license.html create mode 100644 org.rtems.cdt/plugin.xml create mode 100644 org.rtems.cdt/src/org/rtems/cdt/Activator.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/Constants.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/Storage.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/VolatilePreferenceStore.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/build/CommandLineGenerator.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/build/CygwinCommandLineGenerator.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/build/CygwinEnvironmentSupplier.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/build/CygwinRunScannerInfoProvider.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/build/CygwinScannerInfoCollector.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/build/EnvironmentSupplier.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/build/RunScannerInfoProvider.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/preferences/PreferenceInitializer.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/preferences/PreferencePage.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/properties/PropertyPage.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/wizards/BasicSetup.java create mode 100644 org.rtems.cdt/src/org/rtems/cdt/wizards/FinishSetup.java diff --git a/org.rtems.cdt/.classpath b/org.rtems.cdt/.classpath new file mode 100644 index 0000000..64c5e31 --- /dev/null +++ b/org.rtems.cdt/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.rtems.cdt/.project b/org.rtems.cdt/.project new file mode 100644 index 0000000..553b300 --- /dev/null +++ b/org.rtems.cdt/.project @@ -0,0 +1,28 @@ + + + org.rtems.cdt + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/org.rtems.cdt/.settings/org.eclipse.jdt.core.prefs b/org.rtems.cdt/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3ee1bd0 --- /dev/null +++ b/org.rtems.cdt/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +#Thu Dec 04 14:48:14 CET 2008 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/org.rtems.cdt/ChangeLog b/org.rtems.cdt/ChangeLog new file mode 100644 index 0000000..e69de29 diff --git a/org.rtems.cdt/META-INF/MANIFEST.MF b/org.rtems.cdt/META-INF/MANIFEST.MF new file mode 100644 index 0000000..95cc2a4 --- /dev/null +++ b/org.rtems.cdt/META-INF/MANIFEST.MF @@ -0,0 +1,21 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: RTEMS CDT Plug-in +Bundle-SymbolicName: org.rtems.cdt;singleton:=true +Bundle-Version: 1.0.0 +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Require-Bundle: org.eclipse.cdt.managedbuilder.core, + org.eclipse.swt, + org.eclipse.ui, + org.eclipse.core.resources, + org.eclipse.cdt.ui, + org.eclipse.core.runtime, + org.eclipse.cdt.managedbuilder.ui, + org.eclipse.cdt.core +Bundle-Vendor: Embedded Brains GmbH +Import-Package: org.eclipse.cdt.core.model, + org.eclipse.cdt.managedbuilder.ui.wizards, + org.eclipse.jface.resource, + org.eclipse.ui.wizards.newresource +Bundle-Activator: org.rtems.cdt.Activator +Bundle-ActivationPolicy: lazy diff --git a/org.rtems.cdt/build.properties b/org.rtems.cdt/build.properties new file mode 100644 index 0000000..f0f1974 --- /dev/null +++ b/org.rtems.cdt/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + license.html diff --git a/org.rtems.cdt/license.html b/org.rtems.cdt/license.html new file mode 100644 index 0000000..483f9a9 --- /dev/null +++ b/org.rtems.cdt/license.html @@ -0,0 +1,319 @@ + + + + + + + +Eclipse Public License - Version 1.0 + + + + +
+ +

Eclipse Public License - v 1.0 +

+ +

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.

+ +

1. DEFINITIONS

+ +

"Contribution" means:

+ +

a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and
+b) in the case of each subsequent Contributor:

+ +

i) +changes to the Program, and

+ +

ii) +additions to the Program;

+ +

where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program.

+ +

"Contributor" means any person or +entity that distributes the Program.

+ +

"Licensed Patents " mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program.

+ +

"Program" means the Contributions +distributed in accordance with this Agreement.

+ +

"Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.

+ +

2. GRANT OF RIGHTS

+ +

a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.

+ +

b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder.

+ +

c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.

+ +

d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement.

+ +

3. REQUIREMENTS

+ +

A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that: +

+ +

a) +it complies with the terms and conditions of this Agreement; and

+ +

b) +its license agreement:

+ +

i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose;

+ +

ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits;

+ +

iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and

+ +

iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.

+ +

When the Program is made available in source +code form:

+ +

a) +it must be made available under this Agreement; and

+ +

b) a +copy of this Agreement must be included with each copy of the Program.

+ +

Contributors may not remove or alter any +copyright notices contained within the Program.

+ +

Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution.

+ +

4. COMMERCIAL DISTRIBUTION

+ +

Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial +Contributor") hereby agrees to defend and indemnify every other +Contributor ("Indemnified Contributor") against any losses, damages and +costs (collectively "Losses") arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.

+ +

For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.

+ +

5. NO WARRANTY

+ +

EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations.

+ +

6. DISCLAIMER OF LIABILITY

+ +

EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.

+ +

7. GENERAL

+ +

If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.

+ +

If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed.

+ +

All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.

+ +

Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.

+ +

This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.

+ +

 

+ +
+ + \ No newline at end of file diff --git a/org.rtems.cdt/plugin.xml b/org.rtems.cdt/plugin.xml new file mode 100644 index 0000000..9eabb6a --- /dev/null +++ b/org.rtems.cdt/plugin.xml @@ -0,0 +1,389 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.rtems.cdt/src/org/rtems/cdt/Activator.java b/org.rtems.cdt/src/org/rtems/cdt/Activator.java new file mode 100644 index 0000000..810e356 --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/Activator.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt; + +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +public class Activator extends AbstractUIPlugin { + private static Activator mPlugin; + + public void start( BundleContext context) throws Exception { + super.start( context); + mPlugin = this; + createBSPInfoMakefile(); + } + + public void stop( BundleContext context) throws Exception { + mPlugin = null; + super.stop( context); + } + + public static Activator getDefault() { + return mPlugin; + } + + public IPath getMakefileLocation() { + return getStateLocation(); + } + + private void createBSPInfoMakefile() { + IPath makefile = getMakefileLocation().append( "Makefile"); + BufferedWriter out = null; + try { + out = new BufferedWriter( new FileWriter( makefile.toFile())); + out.write( + "include $(" + Constants.BSP_PATH_MAKE_VARIABLE + ")/Makefile.inc\n" + + "include $(RTEMS_CUSTOM)\n" + + "include $(PROJECT_ROOT)/make/leaf.cfg\n" + + "all:\n" + + "\t@echo " + Constants.TOOL_ARCHIVER_KEY + "\n" + + "\t@for i in $(AR) ; do printf \"\\t%s\\n\" \"$$i\" ; done\n" + + "\t@echo " + Constants.TOOL_ASSEMBLER_KEY + "\n" + + "\t@for i in $(AS) ; do printf \"\\t%s\\n\" \"$$i\" ; done\n" + + "\t@echo " + Constants.TOOL_COMPILER_C_KEY + "\n" + + "\t@for i in $(COMPILE.c) ; do printf \"\\t%s\\n\" \"$$i\" ; done\n" + + "\t@echo " + Constants.TOOL_COMPILER_CPP_KEY + "\n" + + "\t@for i in $(COMPILE.cc) ; do printf \"\\t%s\\n\" \"$$i\" ; done\n" + + "\t@echo " + Constants.TOOL_LINKER_C_KEY + "\n" + + "\t@for i in $(LINK.c) ; do printf \"\\t%s\\n\" \"$$i\" ; done\n" + + "\t@echo " + Constants.TOOL_LINKER_CPP_KEY + "\n" + + "\t@for i in $(LINK.cc) ; do printf \"\\t%s\\n\" \"$$i\" ; done\n" + ); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (out != null) { + out.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/Constants.java b/org.rtems.cdt/src/org/rtems/cdt/Constants.java new file mode 100644 index 0000000..a991a9c --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/Constants.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt; + +import java.util.Map; + +public class Constants { + public static final String PATH_SEPARATOR = System.getProperty( "path.separator"); + + public static final String PATH_VARIABLE_NAME = getPathVariableName(); + + public static final String PLATFORM_DEFAULT = "default"; + + public static final String PLATFORM_CYGWIN = "cygwin"; + + public static final String BSP_PATH_MAKE_VARIABLE = "PROJECT_RELEASE"; + + public static final String DEFAULT_BASE_PATH = "/opt/rtems-4.9"; + + public static final String DEFAULT_BSP_PATH = "/opt/rtems-4.9/powerpc-rtems4.9/psim"; + + public static final String DEFAULT_CYGWIN_PATH = "C:\\"; + + public static final String DEFAULT_MINGW_PATH = "C:\\"; + + public static final String DEFAULT_MSYS_PATH = "C:\\"; + + public static final String KEY_PREFIX = "org.rtems.cdt"; + + public static final String PLATFORM_KEY = KEY_PREFIX + ".platform"; + + public static final String BASE_PATH_KEY = KEY_PREFIX + ".basePath"; + + public static final String BSP_PATH_KEY = KEY_PREFIX + ".bspPath"; + + public static final String CYGWIN_PATH_KEY = KEY_PREFIX + ".cygwinPath"; + + public static final String MINGW_PATH_KEY = KEY_PREFIX + ".mingwPath"; + + public static final String MSYS_PATH_KEY = KEY_PREFIX + ".msysPath"; + + public static final String PATH_PREPEND_KEY = KEY_PREFIX + ".pathPrepend"; + + public static final String TOOL_KEY_PREFIX = KEY_PREFIX + ".tool"; + + public static final String TOOL_ARCHIVER_KEY = TOOL_KEY_PREFIX + ".archiver"; + + public static final String TOOL_ASSEMBLER_KEY = TOOL_KEY_PREFIX + ".assembler"; + + public static final String COMPILER_KEY_PREFIX = TOOL_KEY_PREFIX + ".compiler"; + + public static final String TOOL_COMPILER_C_KEY = COMPILER_KEY_PREFIX + ".c"; + + public static final String TOOL_COMPILER_CPP_KEY = COMPILER_KEY_PREFIX + ".cpp"; + + public static final String LINKER_KEY_PREFIX = TOOL_KEY_PREFIX + ".linker"; + + public static final String TOOL_LINKER_C_KEY = LINKER_KEY_PREFIX + ".c"; + + public static final String TOOL_LINKER_CPP_KEY = LINKER_KEY_PREFIX + ".cpp"; + + public static final String TOOL_OPTIONS_KEY_POSTFIX = ".options"; + + public static final String TOOL_OPTIONS_ARCHIVER_KEY = TOOL_ARCHIVER_KEY + TOOL_OPTIONS_KEY_POSTFIX; + + public static final String TOOL_OPTIONS_ASSEMBLER_KEY = TOOL_ASSEMBLER_KEY + TOOL_OPTIONS_KEY_POSTFIX; + + public static final String TOOL_OPTIONS_COMPILER_C_KEY = TOOL_COMPILER_C_KEY + TOOL_OPTIONS_KEY_POSTFIX; + + public static final String TOOL_OPTIONS_COMPILER_CPP_KEY = TOOL_COMPILER_CPP_KEY + TOOL_OPTIONS_KEY_POSTFIX; + + public static final String TOOL_OPTIONS_LINKER_C_KEY = TOOL_LINKER_C_KEY + TOOL_OPTIONS_KEY_POSTFIX; + + public static final String TOOL_OPTIONS_LINKER_CPP_KEY = TOOL_LINKER_CPP_KEY + TOOL_OPTIONS_KEY_POSTFIX; + + private static String getPathVariableName() { + Map env = System.getenv(); + for (String name : env.keySet()) { + if (name.equalsIgnoreCase( "PATH")) { + return name; + } + } + + return "PATH"; + } + + private Constants() { + // Do nothing + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/Storage.java b/org.rtems.cdt/src/org/rtems/cdt/Storage.java new file mode 100644 index 0000000..2e0aee7 --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/Storage.java @@ -0,0 +1,347 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext; +import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.QualifiedName; + +public class Storage { + private static final String OPTION_SEPARATOR = "\0"; + + private static final String VALUE_START_TOKEN = "\t"; + + private static final int EXPECT_OPTION = 0; + + private static final int EXPECT_COMMAND = 1; + + private static final int EXPECT_KEY = 2; + + private static final int TOOL_COMPLETE = 3; + + public static String getPreference( String key) { + return Activator.getDefault().getPreferenceStore().getString( key); + } + + public static String getPristineProperty( IProject project, String key) { + String value = null; + + try { + value = project.getPersistentProperty( new QualifiedName( "", key)); + } catch (CoreException e) { + e.printStackTrace(); + } + + return value; + } + + public static String getProperty( IProject project, String key) { + String value = getPristineProperty( project, key); + + if (value == null) { + if (key.startsWith( Constants.TOOL_KEY_PREFIX)) { + changePlatform( project, Constants.PLATFORM_DEFAULT); + } else { + value = getPreference( key); + setProperty( project, key, value); + } + } + + return value; + } + + public static void setProperty( IProject project, String key, String value) { + try { + project.setPersistentProperty( new QualifiedName( "", key), value); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + public static IConfiguration [] getConfigurations( IProject project) { + ICProjectDescription pd = CoreModel.getDefault().getProjectDescription( project); + + ICConfigurationDescription cds [] = pd.getConfigurations(); + IConfiguration cfgs [] = new IConfiguration [cds.length]; + for (int i = 0; i < cds.length; ++i) { + cfgs [i] = ManagedBuildManager.getConfigurationForDescription( cds [i]); + } + + return cfgs; + } + + public static IConfiguration getActiveConfiguration( IProject project) { + ICProjectDescription pd = CoreModel.getDefault().getProjectDescription( project); + + ICConfigurationDescription cd = pd.getActiveConfiguration(); + IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription( cd); + + return cfg; + } + + public static String prependToPath( String path, String part) { + if (path == null || path.isEmpty()) { + return part; + } else { + return part + Constants.PATH_SEPARATOR + path; + } + } + + public static String prependToPathByPreference( String path, String key) { + String basePath = getPreference( key); + + if (basePath != null) { + IPath part = new Path( basePath).append( "bin"); + + return prependToPath( path, part.toOSString()); + } + + return path; + } + + public static String prependToPathByProperty( IProject project, String path, String key) { + String basePath = getProperty( project, key); + + if (basePath != null) { + IPath part = new Path( basePath).append( "bin"); + + return prependToPath( path, part.toOSString()); + } + + return path; + } + + public static void clearPlatform( IProject project) { + setProperty( project, Constants.PLATFORM_KEY, null); + + // Delete discovered paths for all configurations of the project + for (IConfiguration cfg : getConfigurations( project)) { + CfgDiscoveredPathManager.getInstance().removeDiscoveredInfo( + project, + new CfgInfoContext( cfg) + ); + } + } + + public static String getPlatform( IProject project) { + return getPristineProperty( project, Constants.PLATFORM_KEY); + } + + public static void changePlatform( IProject project, String newPlatform) { + String platform = getPlatform( project); + + // Check if we have already the requested platform + if (platform != null && platform == newPlatform) { + // Nothing to do + return; + } + + // Set new platform + setProperty( project, Constants.PLATFORM_KEY, newPlatform); + + // Update path prepends + String path = null; + if (Platform.getOS().equals( Platform.OS_WIN32)) { + if (newPlatform.equals( Constants.PLATFORM_CYGWIN)) { + path = prependToPathByPreference( path, Constants.CYGWIN_PATH_KEY); + } else { + path = prependToPathByPreference( path, Constants.MINGW_PATH_KEY); + path = prependToPathByPreference( path, Constants.MSYS_PATH_KEY); + } + } + path = prependToPathByProperty( project, path, Constants.BASE_PATH_KEY); + setProperty( project, Constants.PATH_PREPEND_KEY, path); + + // Update tools + updateTools( project, newPlatform); + } + + private static void updateTools( IProject project, String platform) { + String bspPath = getProperty( project, Constants.BSP_PATH_KEY); + IPath make = new Path( "make"); + + // Translate path if necessary + if (Platform.getOS().equals( Platform.OS_WIN32)) { + if (platform.equals( Constants.PLATFORM_CYGWIN)) { + String s [] = bspPath.split( ":"); + if (s.length > 0) { + bspPath = bspPath.replaceFirst( "^" + s [0] + ":", "/cygdrive/" + s [0]); + } + } + bspPath = bspPath.replaceAll( "\\\\", "/"); + } + + // Create make process builder + ProcessBuilder pb = new ProcessBuilder(); + + // Change working directory to the Makefile location + pb.directory( Activator.getDefault().getMakefileLocation().toFile()); + + // Update path environment variable + Map env = pb.environment(); + String path = env.get( Constants.PATH_VARIABLE_NAME); + String part = getProperty( project, Constants.PATH_PREPEND_KEY); + path = Storage.prependToPath( path, part); + env.put( Constants.PATH_VARIABLE_NAME, path); + + // On windows we have to search for the make program in the new path environment + if (Platform.getOS().equals( Platform.OS_WIN32)) { + String parts [] = path.split( Constants.PATH_SEPARATOR); + for (String p : parts) { + IPath makeCandidate = new Path( p).append( "make.exe"); + File file = new File( makeCandidate.toOSString()); + if (file.exists()) { + make = makeCandidate; + break; + } + } + } + + // Set command line + pb.command( + make.toOSString(), + Constants.BSP_PATH_MAKE_VARIABLE + "=" + bspPath + ); + + // Start make process and parse its output + Process p = null; + try { + p = pb.start(); + InputStream is = p.getInputStream(); + BufferedReader br = new BufferedReader( new InputStreamReader( is)); + String line = br.readLine(); + String key = null; + String command = null; + List options = new LinkedList(); + int state = EXPECT_KEY; + while (line != null) { + switch (state) { + case EXPECT_OPTION: + if (line.startsWith( VALUE_START_TOKEN)) { + options.add( line.substring( 1)); + } else { + state = TOOL_COMPLETE; + continue; + } + break; + case EXPECT_COMMAND: + if (line.startsWith( VALUE_START_TOKEN)) { + command = line.substring( 1); + state = EXPECT_OPTION; + } else { + throw new IOException( "Unexpected line format"); + } + break; + case EXPECT_KEY: + if (line.length() > Constants.TOOL_KEY_PREFIX.length()) { + key = line; + state = EXPECT_COMMAND; + } else { + throw new IOException( "Unexpected line format"); + } + break; + case TOOL_COMPLETE: + updateTool( project, key, command, options); + options.clear(); + state = EXPECT_KEY; + continue; + default: + throw new IOException( "Unexpected state"); + } + line = br.readLine(); + } + if (state == EXPECT_OPTION) { + updateTool( project, key, command, options); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + while (true) { + try { + p.waitFor(); + break; + } catch (InterruptedException e) { + continue; + } + } + } + } + + private static void updateTool( IProject project, String toolKey, String command, List options) { + List filteredOptions = new LinkedList(); + + // Filter options + if (toolKey.startsWith( Constants.COMPILER_KEY_PREFIX) || toolKey.startsWith( Constants.LINKER_KEY_PREFIX)) { + for (String option : options) { + if (!(option.isEmpty() || option.trim().matches( "^-c|-O[0123s]|-g|-W[\\w-]*$"))) { + filteredOptions.add( option); + } + } + } else { + filteredOptions = options; + } + + // Transform filtered option list into option string value + String optionsValue = new String(); + if (!options.isEmpty()) { + optionsValue = filteredOptions.get( 0); + filteredOptions.remove( 0); + } + for (String option : filteredOptions) { + optionsValue += OPTION_SEPARATOR + option; + } + + // Set properties + setProperty( project, toolKey, command); + setProperty( project, toolKey + Constants.TOOL_OPTIONS_KEY_POSTFIX, optionsValue); + } + + public static String [] getToolOptions( IProject project, String toolKey) { + String optionsValue = getProperty( project, toolKey + Constants.TOOL_OPTIONS_KEY_POSTFIX); + + return optionsValue.split( OPTION_SEPARATOR); + } + + private Storage() { + // Do nothing + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/VolatilePreferenceStore.java b/org.rtems.cdt/src/org/rtems/cdt/VolatilePreferenceStore.java new file mode 100644 index 0000000..019a23c --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/VolatilePreferenceStore.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt; + +import java.io.OutputStream; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceStore; + +public class VolatilePreferenceStore extends PreferenceStore implements IPreferenceStore { + public void save() { + // Do nothing + } + + public void save( OutputStream out, String header) { + // Do nothing + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/build/CommandLineGenerator.java b/org.rtems.cdt/src/org/rtems/cdt/build/CommandLineGenerator.java new file mode 100644 index 0000000..8ea99e1 --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/build/CommandLineGenerator.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt.build; + +import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator; +import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo; +import org.eclipse.cdt.managedbuilder.core.ITool; +import org.eclipse.cdt.managedbuilder.internal.core.ManagedCommandLineGenerator; +import org.eclipse.core.resources.IProject; +import org.rtems.cdt.Constants; +import org.rtems.cdt.Storage; + +public class CommandLineGenerator extends ManagedCommandLineGenerator implements IManagedCommandLineGenerator { + protected String getPlatform() { + return Constants.PLATFORM_DEFAULT; + } + + public IManagedCommandLineInfo generateCommandLineInfo( + ITool tool, + String commandName, + String [] userOptions, + String outputFlag, + String outputPrefix, + String outputName, + String [] inputResources, + String commandLinePattern + ) { + // Get associated project of the tool + IProject project = (IProject) tool.getParentResourceInfo().getParent().getOwner(); + + // Change platform + Storage.changePlatform( project, getPlatform()); + + // Determine tool key via the tool ID + String id = tool.getId(); + String toolKey = "gcc"; + if (id.contains( "archiver")) { + toolKey = Constants.TOOL_ARCHIVER_KEY; + } else if (id.contains( "assembler")) { + toolKey = Constants.TOOL_ASSEMBLER_KEY; + } else if (id.contains( "compiler.cpp")) { + toolKey = Constants.TOOL_COMPILER_CPP_KEY; + } else if (id.contains( "compiler.c")) { + toolKey = Constants.TOOL_COMPILER_C_KEY; + } else if (id.contains( "linker.cpp")) { + toolKey = Constants.TOOL_LINKER_CPP_KEY; + } else if (id.contains( "linker.c")) { + toolKey = Constants.TOOL_LINKER_C_KEY; + } + + // Set command name + commandName = Storage.getProperty( project, toolKey); + tool.setToolCommand( commandName); + + // Combine tool and user options + String [] toolOptions = Storage.getToolOptions( project, toolKey); + String options [] = new String [toolOptions.length + userOptions.length]; + System.arraycopy( toolOptions, 0, options, 0, toolOptions.length); + System.arraycopy( userOptions, 0, options, toolOptions.length, userOptions.length); + + return super.generateCommandLineInfo( + tool, + commandName, + options, + outputFlag, + outputPrefix, + outputName, + inputResources, + commandLinePattern + ); + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/build/CygwinCommandLineGenerator.java b/org.rtems.cdt/src/org/rtems/cdt/build/CygwinCommandLineGenerator.java new file mode 100644 index 0000000..9e9f33f --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/build/CygwinCommandLineGenerator.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt.build; + +import org.rtems.cdt.Constants; + +public class CygwinCommandLineGenerator extends CommandLineGenerator { + protected String getPlatform() { + return Constants.PLATFORM_CYGWIN; + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/build/CygwinEnvironmentSupplier.java b/org.rtems.cdt/src/org/rtems/cdt/build/CygwinEnvironmentSupplier.java new file mode 100644 index 0000000..892f611 --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/build/CygwinEnvironmentSupplier.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt.build; + +import org.rtems.cdt.Constants; + +public class CygwinEnvironmentSupplier extends EnvironmentSupplier { + protected String getPlatform() { + return Constants.PLATFORM_CYGWIN; + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/build/CygwinRunScannerInfoProvider.java b/org.rtems.cdt/src/org/rtems/cdt/build/CygwinRunScannerInfoProvider.java new file mode 100644 index 0000000..03a3837 --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/build/CygwinRunScannerInfoProvider.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt.build; + +import org.rtems.cdt.Constants; + +public class CygwinRunScannerInfoProvider extends RunScannerInfoProvider { + protected String getPlatform() { + return Constants.PLATFORM_CYGWIN; + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/build/CygwinScannerInfoCollector.java b/org.rtems.cdt/src/org/rtems/cdt/build/CygwinScannerInfoCollector.java new file mode 100644 index 0000000..a67a718 --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/build/CygwinScannerInfoCollector.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt.build; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.make.core.scannerconfig.InfoContext; +import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3; +import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes; +import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector; +import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator; +import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector; +import org.eclipse.core.resources.IProject; + +/** + * This class exists only to disable the specialized UI elements of the scanner configuration. + * + * See also 'org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGnuWinScannerInfoCollector'. + */ +public class CygwinScannerInfoCollector extends PerProjectSICollector implements IScannerInfoCollector3, IManagedScannerInfoCollector { + private IProject mProject; + + public void contributeToScannerConfig( Object resource, Map scannerInfo) { + List includes = (List) scannerInfo.get( ScannerInfoTypes.INCLUDE_PATHS); + List translatedIncludes = CygpathTranslator.translateIncludePaths( mProject, includes); + + Iterator iter = translatedIncludes.listIterator(); + while (iter.hasNext()) { + String convertedPath = iter.next(); + if (convertedPath.startsWith( "/")) { + iter.remove(); + } + } + scannerInfo.put( ScannerInfoTypes.INCLUDE_PATHS, translatedIncludes); + + super.contributeToScannerConfig( resource, scannerInfo); +} + + public void setProject( IProject project) { + mProject = project; + super.setProject( project); + } + + public void setInfoContext( InfoContext context) { + mProject = context.getProject(); + super.setInfoContext( context); + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/build/EnvironmentSupplier.java b/org.rtems.cdt/src/org/rtems/cdt/build/EnvironmentSupplier.java new file mode 100644 index 0000000..80f88b2 --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/build/EnvironmentSupplier.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt.build; + +import org.eclipse.core.resources.IProject; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; +import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier; +import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider; +import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar; +import org.rtems.cdt.Constants; +import org.rtems.cdt.Storage; + +public class EnvironmentSupplier implements IConfigurationEnvironmentVariableSupplier { + private static final int PATH_INDEX = 0; + + private static final int VARIABLE_COUNT = 1; + + protected String getPlatform() { + return Constants.PLATFORM_DEFAULT; + } + + public IBuildEnvironmentVariable getVariable( String name, IConfiguration configuration, IEnvironmentVariableProvider provider) { + if (name.equals( "PATH")) { + IProject project = (IProject) configuration.getOwner(); + + // Change platform + Storage.changePlatform( project, getPlatform()); + + // Get path parts + String part = Storage.getProperty( project, Constants.PATH_PREPEND_KEY); + + return new BuildEnvVar( name, part, IBuildEnvironmentVariable.ENVVAR_PREPEND, Constants.PATH_SEPARATOR); + } + + return null; + } + + public IBuildEnvironmentVariable [] getVariables( IConfiguration configuration, IEnvironmentVariableProvider provider) { + IBuildEnvironmentVariable variables [] = new IBuildEnvironmentVariable [VARIABLE_COUNT]; + + variables [PATH_INDEX] = getVariable( "PATH", configuration, provider); + + return variables; + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/build/RunScannerInfoProvider.java b/org.rtems.cdt/src/org/rtems/cdt/build/RunScannerInfoProvider.java new file mode 100644 index 0000000..6408cda --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/build/RunScannerInfoProvider.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt.build; + +import org.eclipse.cdt.make.internal.core.scannerconfig2.GCCSpecsRunSIProvider; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; +import org.rtems.cdt.Constants; +import org.rtems.cdt.Storage; + +public class RunScannerInfoProvider extends GCCSpecsRunSIProvider { + protected String getPlatform() { + return Constants.PLATFORM_DEFAULT; + } + + protected boolean initialize() { + if (!super.initialize()) { + return false; + } + + IProject project = resource.getProject(); + + /* + * FIXME: This is a hack to avoid to early discovery of internal + * compiler include paths and symbols. The discovery is suppressed for + * empty projects which contain only the '.project' and '.cproject' + * files. + */ + try { + if (project.members().length < 3) { + return false; + } + } catch (CoreException e) { + e.printStackTrace(); + return false; + } + + // Change platform + Storage.changePlatform( project, getPlatform()); + + /* + * FIXME: Added absolute path since it seams that the build + * environment is ignored. + */ + fCompileCommand = new Path( + Storage.getProperty( project, Constants.BASE_PATH_KEY) + ); + fCompileCommand = fCompileCommand.append( "bin"); + fCompileCommand = fCompileCommand.append( + Storage.getProperty( project, Constants.TOOL_COMPILER_C_KEY) + ); + + // Add the standard options to the command arguments + String options [] = Storage.getToolOptions( project, Constants.TOOL_COMPILER_C_KEY); + String newCompileArguments [] = new String [options.length + fCompileArguments.length]; + System.arraycopy( options, 0, newCompileArguments, 0, options.length); + System.arraycopy( fCompileArguments, 0, newCompileArguments, options.length, fCompileArguments.length); + fCompileArguments = newCompileArguments; + + return true; + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/preferences/PreferenceInitializer.java b/org.rtems.cdt/src/org/rtems/cdt/preferences/PreferenceInitializer.java new file mode 100644 index 0000000..9e07c35 --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/preferences/PreferenceInitializer.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt.preferences; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; +import org.rtems.cdt.Activator; +import org.rtems.cdt.Constants; + +public class PreferenceInitializer extends AbstractPreferenceInitializer { + public void initializeDefaultPreferences() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + store.setDefault( Constants.BASE_PATH_KEY, Constants.DEFAULT_BASE_PATH); + store.setDefault( Constants.BSP_PATH_KEY, Constants.DEFAULT_BSP_PATH); + if (Platform.getOS().equals( Platform.OS_WIN32)) { + store.setDefault( Constants.CYGWIN_PATH_KEY, Constants.DEFAULT_CYGWIN_PATH); + store.setDefault( Constants.MINGW_PATH_KEY, Constants.DEFAULT_MINGW_PATH); + store.setDefault( Constants.MSYS_PATH_KEY, Constants.DEFAULT_MSYS_PATH); + } + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/preferences/PreferencePage.java b/org.rtems.cdt/src/org/rtems/cdt/preferences/PreferencePage.java new file mode 100644 index 0000000..c56379a --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/preferences/PreferencePage.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt.preferences; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.preference.DirectoryFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.IWorkbench; +import org.rtems.cdt.Activator; +import org.rtems.cdt.Constants; + +public class PreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + public PreferencePage() { + super( GRID); + setPreferenceStore( Activator.getDefault().getPreferenceStore()); + setDescription( "Select the RTEMS base installation path and the board support package (BSP) installation path. This provides the default values for all projects."); + } + + public void createFieldEditors() { + addField( + new DirectoryFieldEditor( + Constants.BASE_PATH_KEY, + "Base path:", + getFieldEditorParent() + ) + ); + addField( + new DirectoryFieldEditor( + Constants.BSP_PATH_KEY, + "BSP path:", + getFieldEditorParent() + ) + ); + if (Platform.getOS().equals( Platform.OS_WIN32)) { + addField( + new DirectoryFieldEditor( + Constants.CYGWIN_PATH_KEY, + "Cygwin path:", + getFieldEditorParent() + ) + ); + addField( + new DirectoryFieldEditor( + Constants.MINGW_PATH_KEY, + "MinGW path:", + getFieldEditorParent() + ) + ); + addField( + new DirectoryFieldEditor( + Constants.MSYS_PATH_KEY, + "MSYS path:", + getFieldEditorParent() + ) + ); + } + } + + public void init( IWorkbench workbench) { + // Do nothing + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/properties/PropertyPage.java b/org.rtems.cdt/src/org/rtems/cdt/properties/PropertyPage.java new file mode 100644 index 0000000..638d39e --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/properties/PropertyPage.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt.properties; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.preference.DirectoryFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.ui.IWorkbenchPropertyPage; +import org.eclipse.cdt.core.model.ICElement; +import org.rtems.cdt.Activator; +import org.rtems.cdt.Constants; +import org.rtems.cdt.Storage; +import org.rtems.cdt.VolatilePreferenceStore; + +public class PropertyPage extends FieldEditorPreferencePage implements IWorkbenchPropertyPage { + private IAdaptable mElement; + + private IPreferenceStore mStore; + + private IProject mProject; + + public PropertyPage() { + super( GRID); + + // Store properties in a volatile preference store + mStore = new VolatilePreferenceStore(); + setPreferenceStore( mStore); + + setDescription( "You can change the RTEMS base installation path and the board support package (BSP) installation path. This affects only the current project."); + } + + private void setupStoreValue( IPreferenceStore defaultStore, String key) { + mStore.setDefault( key, defaultStore.getString( key)); + mStore.setValue( key, Storage.getProperty( mProject, key)); + } + + protected void createFieldEditors() { + // Get current project + mProject = ((IResource) getElement().getAdapter( IResource.class)).getProject(); + if (mProject == null) { + mProject = ((ICElement) getElement().getAdapter( ICElement.class)).getCProject().getProject(); + } + + // Get the default values from the current workbench preferences + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + + // Setup store values + setupStoreValue( store, Constants.BASE_PATH_KEY); + setupStoreValue( store, Constants.BSP_PATH_KEY); + + // Add field editors + addField( + new DirectoryFieldEditor( + Constants.BASE_PATH_KEY, + "Base path:", + getFieldEditorParent() + ) + ); + addField( + new DirectoryFieldEditor( + Constants.BSP_PATH_KEY, + "BSP path:", + getFieldEditorParent() + ) + ); + } + + private void setProperty( String key) { + Storage.setProperty( mProject, key, mStore.getString( key)); + } + + public boolean performOk() { + super.performOk(); + + // Set the new properties + setProperty( Constants.BASE_PATH_KEY); + setProperty( Constants.BSP_PATH_KEY); + + // Clear platform + Storage.clearPlatform( mProject); + + return true; + } + + public IAdaptable getElement() { + return mElement; + } + + public void setElement( IAdaptable element) { + this.mElement = element; + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/wizards/BasicSetup.java b/org.rtems.cdt/src/org/rtems/cdt/wizards/BasicSetup.java new file mode 100644 index 0000000..d2bd4cc --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/wizards/BasicSetup.java @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt.wizards; + +import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPage; +import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager; +import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard; +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +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.DirectoryDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.SWT; +import org.rtems.cdt.Constants; +import org.rtems.cdt.Storage; + +public class BasicSetup extends MBSCustomPage { + public static final String PAGE_ID = "org.rtems.cdt.wizards.BasicSetup"; + + public static final String BROWSE = " &Browse... "; + + private Composite mComposite; + + private Text mBasePath; + + private Text mBSPPath; + + public BasicSetup() { + pageID = PAGE_ID; + } + + public boolean canFlipToNextPage() { + return MBSCustomPageManager.getNextPage( pageID) != null; + } + + public String getName() { + return "Basic Setup Page"; + } + + public void createControl( Composite parent) { + // Create base widget + mComposite = new Composite( parent, SWT.NONE); + + GridData gd = new GridData( GridData.FILL_BOTH); + mComposite.setLayoutData( gd); + + GridLayout layout = new GridLayout(); + layout.numColumns = 3; + mComposite.setLayout( layout); + + // Base path + Label label = new Label( mComposite, SWT.LEFT); + label.setText( "Base path:"); + + mBasePath = new Text( mComposite, SWT.LEFT | SWT.BORDER); + gd = new GridData( GridData.FILL_HORIZONTAL); + mBasePath.setLayoutData( gd); + + Button button = new Button( mComposite, SWT.PUSH); + button.setText( BROWSE); + button.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected( SelectionEvent e) { + browseForPath( mBasePath); + } + } + ); + + // BSP path + label = new Label( mComposite, SWT.LEFT); + label.setText( "BSP path:"); + + mBSPPath = new Text( mComposite, SWT.LEFT | SWT.BORDER); + gd = new GridData( GridData.FILL_HORIZONTAL); + mBSPPath.setLayoutData( gd); + + button = new Button( mComposite, SWT.PUSH); + button.setText( BROWSE); + button.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected( SelectionEvent e) { + browseForPath( mBSPPath); + } + } + ); + + // Connect user input + mBasePath.addModifyListener( + new ModifyListener() { + public void modifyText( ModifyEvent e) { + basePathChanged(); + } + } + ); + mBSPPath.addModifyListener( + new ModifyListener() { + public void modifyText( ModifyEvent e) { + bspPathChanged(); + } + } + ); + + // Trigger initial setup + basePathChanged(); + bspPathChanged(); + } + + public void dispose() { + mComposite.dispose(); + } + + public Control getControl() { + return mComposite; + } + + public String getDescription() { + return "Select the RTEMS base installation path and the board support package (BSP) installation path."; + } + + public String getErrorMessage() { + return null; + } + + public Image getImage() { + return wizard.getDefaultPageImage(); + } + + public String getMessage() { + return null; + } + + public String getTitle() { + return "RTEMS Setup"; + } + + public void performHelp() { + // Do nothing + } + + public void setDescription( String description) { + // Do nothing + } + + public void setImageDescriptor( ImageDescriptor image) { + // Do nothing + } + + public void setTitle( String title) { + // Do nothing + } + + public void setVisible( boolean visible) { + // Get current project + CDTCommonProjectWizard wizard = (CDTCommonProjectWizard) getWizard(); + IProject project = wizard.getLastProject(); + + /* + * Here we have to take care about the synchronization between the wizard + * and the properties of the new project (advanced settings dialog). + */ + if (visible) { + if (project != null) { + // For already created projects use the properties + mBasePath.setText( Storage.getProperty( project, Constants.BASE_PATH_KEY)); + mBSPPath.setText( Storage.getProperty( project, Constants.BSP_PATH_KEY)); + } else { + // For not yet created projects use the preferences + mBasePath.setText( Storage.getPreference( Constants.BASE_PATH_KEY)); + mBSPPath.setText( Storage.getPreference( Constants.BSP_PATH_KEY)); + } + } else { + if (project != null) { + // Store the wizard values in the properties if the project exists already + Storage.setProperty( project, Constants.BASE_PATH_KEY, mBasePath.getText()); + Storage.setProperty( project, Constants.BSP_PATH_KEY, mBSPPath.getText()); + } + } + + mComposite.setVisible( visible); + } + + protected boolean isCustomPageComplete() { + return true; + } + + private void browseForPath( Text text) { + DirectoryDialog dialog = new DirectoryDialog( mComposite.getShell(), SWT.NONE); + dialog.setFilterPath( text.getText()); + String path = dialog.open(); + if (path != null) { + text.setText( path); + } + } + + private void basePathChanged() { + MBSCustomPageManager.addPageProperty( pageID, Constants.BASE_PATH_KEY, mBasePath.getText()); + } + + private void bspPathChanged() { + MBSCustomPageManager.addPageProperty( pageID, Constants.BSP_PATH_KEY, mBSPPath.getText()); + } +} diff --git a/org.rtems.cdt/src/org/rtems/cdt/wizards/FinishSetup.java b/org.rtems.cdt/src/org/rtems/cdt/wizards/FinishSetup.java new file mode 100644 index 0000000..0724413 --- /dev/null +++ b/org.rtems.cdt/src/org/rtems/cdt/wizards/FinishSetup.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2008 Embedded Brains GmbH and others. + * + * Embedded Brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * rtems@embedded-brains.de + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License Version 1.0 ("EPL") + * which accompanies this distribution and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * For purposes of the EPL, "Program" will mean the Content. + * + * Contributors: + * + * Sebastian Huber (Embedded Brains GmbH) - Initial API and implementation. + */ + +package org.rtems.cdt.wizards; + +import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager; +import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard; +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.wizard.IWizardPage; +import org.rtems.cdt.Constants; +import org.rtems.cdt.Storage; + +public class FinishSetup implements Runnable { + public void run() { + // Get a handle to the wizard + IWizardPage [] pages = MBSCustomPageManager.getPages(); + + if (pages != null && pages.length > 0) { + // Get last project + CDTCommonProjectWizard wizard = (CDTCommonProjectWizard) pages [0].getWizard(); + IProject project = wizard.getLastProject(); + + // Get wizard values + String basePath = (String) MBSCustomPageManager.getPageProperty( + BasicSetup.PAGE_ID, Constants.BASE_PATH_KEY + ); + String bspPath = (String) MBSCustomPageManager.getPageProperty( + BasicSetup.PAGE_ID, Constants.BSP_PATH_KEY + ); + + // Set project properties + Storage.setProperty( project, Constants.BASE_PATH_KEY, basePath); + Storage.setProperty( project, Constants.BSP_PATH_KEY, bspPath); + + // Clear platform + Storage.clearPlatform( project); + } + } +} -- cgit v1.2.3