summaryrefslogtreecommitdiffstats
path: root/org.rtems.cdt/src/org/rtems
diff options
context:
space:
mode:
Diffstat (limited to 'org.rtems.cdt/src/org/rtems')
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/Activator.java89
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/Constants.java110
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/Storage.java347
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/VolatilePreferenceStore.java37
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/build/CommandLineGenerator.java92
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/build/CygwinCommandLineGenerator.java31
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/build/CygwinEnvironmentSupplier.java31
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/build/CygwinRunScannerInfoProvider.java31
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/build/CygwinScannerInfoCollector.java70
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/build/EnvironmentSupplier.java66
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/build/RunScannerInfoProvider.java83
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/preferences/PreferenceInitializer.java42
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/preferences/PreferencePage.java85
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/properties/PropertyPage.java115
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/wizards/BasicSetup.java232
-rw-r--r--org.rtems.cdt/src/org/rtems/cdt/wizards/FinishSetup.java58
16 files changed, 1519 insertions, 0 deletions
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);
+ }
+ }
+}