diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2008-12-04 14:53:45 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2008-12-04 14:53:45 +0000 |
commit | 6740c5334148b46937c9e4ae73cb31b7fe3d401f (patch) | |
tree | b44b5bc0c5dfeaceea0be99a361c86a0b09bd6db | |
parent | Fixed synchronization problem between the wizard and the project properties. (diff) | |
download | rtems-eclipse-plug-in-6740c5334148b46937c9e4ae73cb31b7fe3d401f.tar.bz2 |
Initial commit.
24 files changed, 2296 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.rtems.cdt</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> 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 --- /dev/null +++ b/org.rtems.cdt/ChangeLog 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 @@ +<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head> + + +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta name="ProgId" content="Word.Document"> +<meta name="Generator" content="Microsoft Word 9"> +<meta name="Originator" content="Microsoft Word 9"> +<link rel="File-List" href="http://www.eclipse.org/legal/Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml"><title>Eclipse Public License - Version 1.0</title><!--[if gte mso 9]><xml> + <o:DocumentProperties> + <o:Revision>2</o:Revision> + <o:TotalTime>3</o:TotalTime> + <o:Created>2004-03-05T23:03:00Z</o:Created> + <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved> + <o:Pages>4</o:Pages> + <o:Words>1626</o:Words> + <o:Characters>9270</o:Characters> + <o:Lines>77</o:Lines> + <o:Paragraphs>18</o:Paragraphs> + <o:CharactersWithSpaces>11384</o:CharactersWithSpaces> + <o:Version>9.4402</o:Version> + </o:DocumentProperties> +</xml><![endif]--><!--[if gte mso 9]><xml> + <w:WordDocument> + <w:TrackRevisions/> + </w:WordDocument> +</xml><![endif]--> + + +<style> +<!-- + /* Font Definitions */ +@font-face + {font-family:Tahoma; + panose-1:2 11 6 4 3 5 4 4 2 4; + mso-font-charset:0; + mso-generic-font-family:swiss; + mso-font-pitch:variable; + mso-font-signature:553679495 -2147483648 8 0 66047 0;} + /* Style Definitions */ +p.MsoNormal, li.MsoNormal, div.MsoNormal + {mso-style-parent:""; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p + {margin-right:0in; + mso-margin-top-alt:auto; + mso-margin-bottom-alt:auto; + margin-left:0in; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p.BalloonText, li.BalloonText, div.BalloonText + {mso-style-name:"Balloon Text"; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:8.0pt; + font-family:Tahoma; + mso-fareast-font-family:"Times New Roman";} +@page Section1 + {size:8.5in 11.0in; + margin:1.0in 1.25in 1.0in 1.25in; + mso-header-margin:.5in; + mso-footer-margin:.5in; + mso-paper-source:0;} +div.Section1 + {page:Section1;} +--> +</style></head><body style="" lang="EN-US"> + +<div class="Section1"> + +<p style="text-align: center;" align="center"><b>Eclipse Public License - v 1.0</b> +</p> + +<p><span style="font-size: 10pt;">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.</span> </p> + +<p><b><span style="font-size: 10pt;">1. DEFINITIONS</span></b> </p> + +<p><span style="font-size: 10pt;">"Contribution" means:</span> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and<br clear="left"> +b) in the case of each subsequent Contributor:</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) +changes to the Program, and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) +additions to the Program;</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">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. </span></p> + +<p><span style="font-size: 10pt;">"Contributor" means any person or +entity that distributes the Program.</span> </p> + +<p><span style="font-size: 10pt;">"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. </span></p> + +<p><span style="font-size: 10pt;">"Program" means the Contributions +distributed in accordance with this Agreement.</span> </p> + +<p><span style="font-size: 10pt;">"Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.</span> </p> + +<p><b><span style="font-size: 10pt;">2. GRANT OF RIGHTS</span></b> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to<span style="color: red;"> </span>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.</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide,<span style="color: green;"> </span>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. </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">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.</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">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. </span></p> + +<p><b><span style="font-size: 10pt;">3. REQUIREMENTS</span></b> </p> + +<p><span style="font-size: 10pt;">A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that:</span> +</p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +it complies with the terms and conditions of this Agreement; and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) +its license agreement:</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">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; </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits; </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and</span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">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.<span style="color: blue;"> </span></span></p> + +<p><span style="font-size: 10pt;">When the Program is made available in source +code form:</span> </p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) +it must be made available under this Agreement; and </span></p> + +<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) a +copy of this Agreement must be included with each copy of the Program. </span></p> + +<p><span style="font-size: 10pt;">Contributors may not remove or alter any +copyright notices contained within the Program. </span></p> + +<p><span style="font-size: 10pt;">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. </span></p> + +<p><b><span style="font-size: 10pt;">4. COMMERCIAL DISTRIBUTION</span></b> </p> + +<p><span style="font-size: 10pt;">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.</span> </p> + +<p><span style="font-size: 10pt;">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.</span> </p> + +<p><b><span style="font-size: 10pt;">5. NO WARRANTY</span></b> </p> + +<p><span style="font-size: 10pt;">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. </span></p> + +<p><b><span style="font-size: 10pt;">6. DISCLAIMER OF LIABILITY</span></b> </p> + +<p><span style="font-size: 10pt;">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.</span> </p> + +<p><b><span style="font-size: 10pt;">7. GENERAL</span></b> </p> + +<p><span style="font-size: 10pt;">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.</span> </p> + +<p><span style="font-size: 10pt;">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. </span></p> + +<p><span style="font-size: 10pt;">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. </span></p> + +<p><span style="font-size: 10pt;">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.</span> </p> + +<p><span style="font-size: 10pt;">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.</span> </p> + +<p class="MsoNormal"><!--[if !supportEmptyParas]--> <!--[endif]--><o:p></o:p></p> + +</div> + +</body></html>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.2"?> + +<!-- + 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. +--> + +<plugin> + <!-- Scanner Configuration Discovery Profiles --> + <extension + id="RtemsSCDProfile" + name="RTEMS Scanner Configuration Discovery Profile" + point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile"> + <scannerInfoCollector + class="org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector" + scope="project"/> + <buildOutputProvider> + <open/> + <scannerInfoConsoleParser class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedGCCScannerInfoConsoleParser"/> + </buildOutputProvider> + <scannerInfoProvider providerId="specsFile"> + <run + arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" + class="org.rtems.cdt.build.RunScannerInfoProvider"/> + <scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser"/> + </scannerInfoProvider> + </extension> + <extension + id="RtemsSCDProfileC" + name="RTEMS Scanner Configuration Discovery Profile" + point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile"> + <scannerInfoCollector + class="org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector" + scope="project"/> + <buildOutputProvider> + <open/> + <scannerInfoConsoleParser class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedGCCScannerInfoConsoleParser"/> + </buildOutputProvider> + <scannerInfoProvider providerId="specsFile"> + <run + arguments="-E -P -v -dD ${plugin_state_location}/specs.c" + class="org.rtems.cdt.build.RunScannerInfoProvider"/> + <scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser"/> + </scannerInfoProvider> + </extension> + <extension + id="RtemsSCDProfileCPP" + name="RTEMS Scanner Configuration Discovery Profile" + point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile"> + <scannerInfoCollector + class="org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector" + scope="project"/> + <buildOutputProvider> + <open/> + <scannerInfoConsoleParser class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedGCCScannerInfoConsoleParser"/> + </buildOutputProvider> + <scannerInfoProvider providerId="specsFile"> + <run + arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" + class="org.rtems.cdt.build.RunScannerInfoProvider"/> + <scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser"/> + </scannerInfoProvider> + </extension> + <extension + id="RtemsSCDProfileWin" + name="RTEMS Scanner Configuration Discovery Profile (Windows)" + point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile"> + <scannerInfoCollector + class="org.rtems.cdt.build.CygwinScannerInfoCollector" + scope="project"/> + <buildOutputProvider> + <open/> + <scannerInfoConsoleParser class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedGCCScannerInfoConsoleParser"/> + </buildOutputProvider> + <scannerInfoProvider providerId="specsFile"> + <run + arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" + class="org.rtems.cdt.build.CygwinRunScannerInfoProvider"/> + <scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser"/> + </scannerInfoProvider> + </extension> + <extension + id="RtemsSCDProfileWinC" + name="RTEMS Scanner Configuration Discovery Profile (Windows)" + point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile"> + <scannerInfoCollector + class="org.rtems.cdt.build.CygwinScannerInfoCollector" + scope="project"/> + <buildOutputProvider> + <open/> + <scannerInfoConsoleParser class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedGCCScannerInfoConsoleParser"/> + </buildOutputProvider> + <scannerInfoProvider providerId="specsFile"> + <run + arguments="-E -P -v -dD ${plugin_state_location}/specs.c" + class="org.rtems.cdt.build.CygwinRunScannerInfoProvider"/> + <scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser"/> + </scannerInfoProvider> + </extension> + <extension + id="RtemsSCDProfileWinCPP" + name="RTEMS Scanner Configuration Discovery Profile (Windows)" + point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile"> + <scannerInfoCollector + class="org.rtems.cdt.build.CygwinScannerInfoCollector" + scope="project"/> + <buildOutputProvider> + <open/> + <scannerInfoConsoleParser class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedGCCScannerInfoConsoleParser"/> + </buildOutputProvider> + <scannerInfoProvider providerId="specsFile"> + <run + arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" + class="org.rtems.cdt.build.CygwinRunScannerInfoProvider"/> + <scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser"/> + </scannerInfoProvider> + </extension> + + <!-- Build Definitions --> + <extension + id="org.rtems.cdt.build" + point="org.eclipse.cdt.managedbuilder.core.buildDefinitions"> + + <!-- Configuration --> + <configuration + id="org.rtems.cdt.config.base" + name="RTEMS Configuration" + cleanCommand="rm -rf" + artifactExtension="exe"> + <enablement type="CONTAINER_ATTRIBUTE" + attribute="artifactExtension" + value="a" + extensionAdjustment="false"> + <checkBuildProperty + property="org.eclipse.cdt.build.core.buildArtefactType" + value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/> + </enablement> + </configuration> + + <!-- Toolchain (Standard) --> + <toolChain + archList="all" + configurationEnvironmentSupplier="org.rtems.cdt.build.EnvironmentSupplier" + id="org.rtems.cdt.toolchain" + name="RTEMS Toolchain" + osList="all" + scannerConfigDiscoveryProfileId="org.rtems.cdt.RtemsSCDProfile" + targetTool="org.rtems.cdt.linker.c;org.rtems.cdt.linker.cpp;org.rtems.cdt.archiver"> + <targetPlatform + id="org.rtems.cdt.target" + name="RTEMS Target" + binaryParser="org.eclipse.cdt.core.ELF" + osList="all" + archList="all"> + </targetPlatform> + <builder + id="org.rtems.cdt.builder" + superClass="cdt.managedbuild.target.gnu.builder"/> + <tool + id="org.rtems.cdt.assembler" + superClass="cdt.managedbuild.tool.gnu.assembler" + commandLineGenerator="org.rtems.cdt.build.CommandLineGenerator"> + </tool> + <tool + id="org.rtems.cdt.compiler.c" + superClass="cdt.managedbuild.tool.gnu.c.compiler" + commandLineGenerator="org.rtems.cdt.build.CommandLineGenerator"> + <inputType + id="org.rtems.cdt.compiler.input.c" + superClass="cdt.managedbuild.tool.gnu.c.compiler.input" + scannerConfigDiscoveryProfileId="org.rtems.cdt.RtemsSCDProfileC"/> + </tool> + <tool + id="org.rtems.cdt.compiler.cpp" + superClass="cdt.managedbuild.tool.gnu.cpp.compiler" + commandLineGenerator="org.rtems.cdt.build.CommandLineGenerator"> + <inputType + id="org.rtems.cdt.compiler.cpp.input" + superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input" + scannerConfigDiscoveryProfileId="org.rtems.cdt.RtemsSCDProfileCPP"/> + </tool> + <tool + id="org.rtems.cdt.linker.c" + superClass="cdt.managedbuild.tool.gnu.c.linker" + commandLineGenerator="org.rtems.cdt.build.CommandLineGenerator"> + <enablement type="ALL"> + <not> + <checkBuildProperty + property="org.eclipse.cdt.build.core.buildArtefactType" + value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/> + </not> + </enablement> + </tool> + <tool + id="org.rtems.cdt.linker.cpp" + superClass="cdt.managedbuild.tool.gnu.cpp.linker" + commandLineGenerator="org.rtems.cdt.build.CommandLineGenerator"> + <enablement type="ALL"> + <not> + <checkBuildProperty + property="org.eclipse.cdt.build.core.buildArtefactType" + value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/> + </not> + </enablement> + </tool> + <tool + id="org.rtems.cdt.archiver" + superClass="cdt.managedbuild.tool.gnu.archiver" + commandLineGenerator="org.rtems.cdt.build.CommandLineGenerator"> + <enablement type="ALL"> + <checkBuildProperty + property="org.eclipse.cdt.build.core.buildArtefactType" + value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/> + </enablement> + </tool> + </toolChain> + + <!-- Toolchain (Cygwin) --> + <toolChain + id="org.rtems.cdt.toolchain.cygwin" + name="RTEMS Toolchain (Cygwin)" + archList="all" + osList="win32" + targetTool="org.rtems.cdt.linker.c.cygwin;org.rtems.cdt.linker.cpp.cygwin;org.rtems.cdt.archiver.cygwin" + configurationEnvironmentSupplier="org.rtems.cdt.build.CygwinEnvironmentSupplier" + isToolChainSupported="org.eclipse.cdt.managedbuilder.gnu.cygwin.IsGnuCygwinToolChainSupported" + scannerConfigDiscoveryProfileId="org.rtems.cdt.RtemsSCDProfileWin"> + <targetPlatform + id="org.rtems.cdt.target.cygwin" + name="RTEMS Target" + binaryParser="org.eclipse.cdt.core.ELF" + osList="all" + archList="all"> + </targetPlatform> + <builder + id="org.rtems.cdt.builder.cygwin" + superClass="cdt.managedbuild.target.gnu.builder"/> + <tool + id="org.rtems.cdt.assembler.cygwin" + superClass="cdt.managedbuild.tool.gnu.assembler" + commandLineGenerator="org.rtems.cdt.build.CygwinCommandLineGenerator"> + </tool> + <tool + id="org.rtems.cdt.compiler.c.cygwin" + superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin" + commandLineGenerator="org.rtems.cdt.build.CygwinCommandLineGenerator"> + <inputType + id="org.rtems.cdt.compiler.input.c.cygwin" + superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin" + scannerConfigDiscoveryProfileId="org.rtems.cdt.RtemsSCDProfileWinC"/> + </tool> + <tool + id="org.rtems.cdt.compiler.cpp.cygwin" + superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin" + commandLineGenerator="org.rtems.cdt.build.CygwinCommandLineGenerator"> + <inputType + id="org.rtems.cdt.compiler.cpp.input.cygwin" + scannerConfigDiscoveryProfileId="org.rtems.cdt.RtemsSCDProfileWinCPP" + superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin"/> + </tool> + <tool + id="org.rtems.cdt.linker.c.cygwin" + superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin" + commandLineGenerator="org.rtems.cdt.build.CygwinCommandLineGenerator"> + <enablement type="ALL"> + <not> + <checkBuildProperty + property="org.eclipse.cdt.build.core.buildArtefactType" + value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/> + </not> + </enablement> + </tool> + <tool + id="org.rtems.cdt.linker.cpp.cygwin" + superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin" + commandLineGenerator="org.rtems.cdt.build.CygwinCommandLineGenerator"> + <enablement type="ALL"> + <not> + <checkBuildProperty + property="org.eclipse.cdt.build.core.buildArtefactType" + value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/> + </not> + </enablement> + </tool> + <tool + id="org.rtems.cdt.archiver.cygwin" + superClass="cdt.managedbuild.tool.gnu.archiver" + commandLineGenerator="org.rtems.cdt.build.CygwinCommandLineGenerator"> + <enablement type="ALL"> + <checkBuildProperty + property="org.eclipse.cdt.build.core.buildArtefactType" + value="org.eclipse.cdt.build.core.buildArtefactType.staticLib"/> + </enablement> + </tool> + </toolChain> + + <!-- Project Type --> + <projectType + buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" + id="org.rtems.cdt.projectType" + name="RTEMS Executable"> + <configuration + id="org.rtems.cdt.config" + name="RTEMS Executable Configuration" + parent="org.rtems.cdt.config.base"> + <toolChain + id="org.rtems.cdt.config.toolchain" + superClass="org.rtems.cdt.toolchain"> + </toolChain> + </configuration> + <configuration + id="org.rtems.cdt.config.cygwin" + name="RTEMS Executable Configuration" + parent="org.rtems.cdt.config.base"> + <toolChain + id="org.rtems.cdt.config.toolchain.cygwin" + superClass="org.rtems.cdt.toolchain.cygwin"> + </toolChain> + </configuration> + </projectType> + </extension> + + <!-- New Project Wizard --> + <extension + point="org.eclipse.cdt.managedbuilder.ui.newWizardPages"> + <wizardPage + ID="org.rtems.cdt.wizards.BasicSetup" + operationClass="org.rtems.cdt.wizards.FinishSetup" + pageClass="org.rtems.cdt.wizards.BasicSetup"/> + </extension> + + <!-- Preferences --> + <extension + point="org.eclipse.ui.preferencePages"> + <page + category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage" + class="org.rtems.cdt.preferences.PreferencePage" + id="org.rtems.cdt.preferences.PreferencePage" + name="RTEMS"> + </page> + </extension> + <extension + point="org.eclipse.core.runtime.preferences"> + <initializer + class="org.rtems.cdt.preferences.PreferenceInitializer"/> + </extension> + + <!-- Properties --> + <extension + point="org.eclipse.ui.propertyPages"> + <page + category="org.eclipse.cdt.managedbuilder.ui.properties.Page_head_build" + class="org.rtems.cdt.properties.PropertyPage" + id="org.rtems.cdt.properties.PropertyPage" + name="RTEMS"> + <filter + name="projectNature" + value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/> + <enabledWhen> + <or> + <instanceof value="org.eclipse.cdt.core.model.ICContainer"/> + <instanceof value="org.eclipse.cdt.core.model.ICProject"/> + <instanceof value="org.eclipse.cdt.core.model.ITranslationUnit"/> + <instanceof value="org.eclipse.core.resources.IFile"/> + <instanceof value="org.eclipse.core.resources.IFolder"/> + <instanceof value="org.eclipse.core.resources.IProject"/> + </or> + </enabledWhen> + </page> + </extension> +</plugin> 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<String, String> 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<String, String> 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<String> options = new LinkedList<String>(); + 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<String> options) { + List<String> filteredOptions = new LinkedList<String>(); + + // 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<String> includes = (List<String>) scannerInfo.get( ScannerInfoTypes.INCLUDE_PATHS); + List<String> translatedIncludes = CygpathTranslator.translateIncludePaths( mProject, includes); + + Iterator<String> 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); + } + } +} |