summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2008-11-28 16:15:26 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2008-11-28 16:15:26 +0000
commit9e420b1ece6f28b6d940ecfa59dd29a1a0ac7a23 (patch)
tree55c28edce14780cd2b8686313ddd255eb8892c1b
parentAdded "macosx" to the "osList" for the "RTEMS Toolchain (UNIX). (diff)
downloadrtems-eclipse-plug-in-9e420b1ece6f28b6d940ecfa59dd29a1a0ac7a23.tar.bz2
Added Makefile to obtain BSP information.
TODO: o Parse make output and provide tool and tool option properties. o Use tool and tool option properties in the command line generator. o Remove obsolete version and target properties and preferences. o Remove wizard.
-rw-r--r--org.rtems.cdt.toolchain2/org/rtems/cdt/Activator.java51
-rw-r--r--org.rtems.cdt.toolchain2/org/rtems/cdt/Constants.java40
-rw-r--r--org.rtems.cdt.toolchain2/org/rtems/cdt/Storage.java45
-rw-r--r--org.rtems.cdt.toolchain2/org/rtems/cdt/build/EnvironmentSupplier.java4
-rw-r--r--org.rtems.cdt.toolchain2/org/rtems/cdt/properties/PropertyPage.java7
5 files changed, 130 insertions, 17 deletions
diff --git a/org.rtems.cdt.toolchain2/org/rtems/cdt/Activator.java b/org.rtems.cdt.toolchain2/org/rtems/cdt/Activator.java
index 91c0faa..3376ca1 100644
--- a/org.rtems.cdt.toolchain2/org/rtems/cdt/Activator.java
+++ b/org.rtems.cdt.toolchain2/org/rtems/cdt/Activator.java
@@ -12,19 +12,21 @@
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;
+import org.rtems.cdt.Constants;
public class Activator extends AbstractUIPlugin {
private static Activator mPlugin;
-
- public Activator() {
- super();
- }
public void start( BundleContext context) throws Exception {
super.start( context);
mPlugin = this;
+ createBSPInfoMakefile();
}
public void stop( BundleContext context) throws Exception {
@@ -35,4 +37,45 @@ public class Activator extends AbstractUIPlugin {
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 $(RTEMS_MAKEFILE_PATH)/Makefile.inc\n"
+ + "include $(RTEMS_CUSTOM)\n"
+ + "include $(PROJECT_ROOT)/make/leaf.cfg\n"
+ + "\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.toolchain2/org/rtems/cdt/Constants.java b/org.rtems.cdt.toolchain2/org/rtems/cdt/Constants.java
index 1be8557..f18093b 100644
--- a/org.rtems.cdt.toolchain2/org/rtems/cdt/Constants.java
+++ b/org.rtems.cdt.toolchain2/org/rtems/cdt/Constants.java
@@ -26,6 +26,8 @@ public class Constants {
{"SPARC", "sparc"},
{"SuperH", "sh"}
};
+
+ public static final String PATH_SEPERATOR = System.getProperty( "path.separator");
public static final String DEFAULT_BASE_PATH = "/opt/rtems-4.9";
@@ -38,14 +40,44 @@ public class Constants {
public static final String DEFAULT_TARGET = TARGETS [DEFAULT_TARGET_INDEX][1];
public static final String DEFAULT_BSP_PATH = "/opt/rtems-4.9/powerpc-rtems4.9/psim";
+
+ public static final String KEY_PREFIX = "org.rtems.cdt.key";
+
+ public static final String BASE_PATH_KEY = KEY_PREFIX + ".basePath";
+
+ public static final String VERSION_KEY = KEY_PREFIX + ".version";
+
+ public static final String TARGET_KEY = KEY_PREFIX + ".target";
+
+ public static final String BSP_PATH_KEY = KEY_PREFIX + ".bspPath";
+
+ 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 TOOL_COMPILER_C_KEY = TOOL_KEY_PREFIX + ".compiler.c";
+
+ public static final String TOOL_COMPILER_CPP_KEY = TOOL_KEY_PREFIX + ".compiler.cpp";
+
+ public static final String TOOL_LINKER_C_KEY = TOOL_KEY_PREFIX + ".linker.c";
+
+ public static final String TOOL_LINKER_CPP_KEY = TOOL_KEY_PREFIX + ".linker.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 BASE_PATH_KEY = "org.rtems.cdt.key.basePath";
+ public static final String TOOL_OPTIONS_COMPILER_C_KEY = TOOL_COMPILER_C_KEY + TOOL_OPTIONS_KEY_POSTFIX;
- public static final String VERSION_KEY = "org.rtems.cdt.key.version";
+ public static final String TOOL_OPTIONS_COMPILER_CPP_KEY = TOOL_COMPILER_CPP_KEY + TOOL_OPTIONS_KEY_POSTFIX;
- public static final String TARGET_KEY = "org.rtems.cdt.key.target";
+ public static final String TOOL_OPTIONS_LINKER_C_KEY = TOOL_LINKER_C_KEY + TOOL_OPTIONS_KEY_POSTFIX;
- public static final String BSP_PATH_KEY = "org.rtems.cdt.key.bspPath";
+ public static final String TOOL_OPTIONS_LINKER_CPP_KEY = TOOL_LINKER_CPP_KEY + TOOL_OPTIONS_KEY_POSTFIX;
private Constants() {
// Do nothing
diff --git a/org.rtems.cdt.toolchain2/org/rtems/cdt/Storage.java b/org.rtems.cdt.toolchain2/org/rtems/cdt/Storage.java
index f4d247b..6fce4fe 100644
--- a/org.rtems.cdt.toolchain2/org/rtems/cdt/Storage.java
+++ b/org.rtems.cdt.toolchain2/org/rtems/cdt/Storage.java
@@ -12,8 +12,16 @@
package org.rtems.cdt;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Map;
+
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.QualifiedName;
import org.rtems.cdt.Activator;
@@ -34,8 +42,12 @@ public class Storage {
String value = getPristineProperty( project, key);
if (value == null) {
- value = Activator.getDefault().getPreferenceStore().getString( key);
- setProperty( project, key, value);
+ if (key.startsWith( Constants.TOOL_KEY_PREFIX)) {
+ reloadBSPInformation( project);
+ } else {
+ value = Activator.getDefault().getPreferenceStore().getString( key);
+ setProperty( project, key, value);
+ }
}
return value;
@@ -49,6 +61,35 @@ public class Storage {
}
}
+ public static void reloadBSPInformation( IProject project) {
+ // Create make process builder
+ ProcessBuilder pb = new ProcessBuilder( "make");
+
+ // Prepend RTEMS base binary path to PATH environment variable
+ Map<String, String> env = pb.environment();
+ IPath binPath = new Path( getProperty( project, Constants.BASE_PATH_KEY)).append( "bin");
+ env.put( "PATH", binPath.toOSString() + Constants.PATH_SEPERATOR + env.get( "PATH"));
+
+ // Provide RTEMS_MAKEFILE_PATH environment variable
+ env.put( "RTEMS_MAKEFILE_PATH", getProperty( project, Constants.BSP_PATH_KEY));
+
+ // Change working directory to the Makefile location
+ pb.directory( Activator.getDefault().getMakefileLocation().toFile());
+
+ // Start make process and parse its output
+ try {
+ Process p = pb.start();
+ InputStream is = p.getInputStream();
+ BufferedReader br = new BufferedReader( new InputStreamReader( is));
+ String line;
+ while ((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
private Storage() {
// Do nothing
}
diff --git a/org.rtems.cdt.toolchain2/org/rtems/cdt/build/EnvironmentSupplier.java b/org.rtems.cdt.toolchain2/org/rtems/cdt/build/EnvironmentSupplier.java
index 8eaf7a6..d8decf5 100644
--- a/org.rtems.cdt.toolchain2/org/rtems/cdt/build/EnvironmentSupplier.java
+++ b/org.rtems.cdt.toolchain2/org/rtems/cdt/build/EnvironmentSupplier.java
@@ -28,8 +28,6 @@ public class EnvironmentSupplier implements IProjectEnvironmentVariableSupplier
private static final int VARIABLE_COUNT = 1;
- private static final String PATH_SEPERATOR = System.getProperty( "path.separator");
-
public EnvironmentSupplier() {
// Do nothing
}
@@ -41,7 +39,7 @@ public class EnvironmentSupplier implements IProjectEnvironmentVariableSupplier
);
path = path.append( "bin");
- return new BuildEnvVar( name, path.toOSString(), IBuildEnvironmentVariable.ENVVAR_PREPEND, PATH_SEPERATOR);
+ return new BuildEnvVar( name, path.toOSString(), IBuildEnvironmentVariable.ENVVAR_PREPEND, Constants.PATH_SEPERATOR);
}
return null;
diff --git a/org.rtems.cdt.toolchain2/org/rtems/cdt/properties/PropertyPage.java b/org.rtems.cdt.toolchain2/org/rtems/cdt/properties/PropertyPage.java
index 59d8d90..e6973ce 100644
--- a/org.rtems.cdt.toolchain2/org/rtems/cdt/properties/PropertyPage.java
+++ b/org.rtems.cdt.toolchain2/org/rtems/cdt/properties/PropertyPage.java
@@ -14,7 +14,6 @@ package org.rtems.cdt.properties;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.preference.DirectoryFieldEditor;
import org.eclipse.jface.preference.ComboFieldEditor;
@@ -23,9 +22,6 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbenchPropertyPage;
import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable;
-import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore;
import org.rtems.cdt.Activator;
import org.rtems.cdt.Constants;
import org.rtems.cdt.Storage;
@@ -113,6 +109,9 @@ public class PropertyPage extends FieldEditorPreferencePage implements IWorkbenc
setProperty( Constants.VERSION_KEY);
setProperty( Constants.TARGET_KEY);
setProperty( Constants.BSP_PATH_KEY);
+
+ // Reload BSP information
+ Storage.reloadBSPInformation( mProject);
return true;
}