compile contiki library update:

* including selected Contiki process source files automatically at compilation time.
-> removes the need for manually adding all source files in the cooja.config:s
-> only selected source files are compiled
This commit is contained in:
fros4943 2006-08-21 15:05:14 +00:00
parent e81861a0cd
commit facdd73eda
3 changed files with 66 additions and 44 deletions

View file

@ -70,8 +70,6 @@ MAINFILE = $(OUTPUT_DIR)/$(TYPEID).co
COOJA = $(CONTIKI)/platform/$(TARGET) COOJA = $(CONTIKI)/platform/$(TARGET)
CONTIKI_TARGET_DIRS = . dev lib sys CONTIKI_TARGET_DIRS = . dev lib sys
COOJA_APPS = testbutton.c testetimer.c testserial.c cooyah.c
COOJA_DEV = $(patsubst $(COOJA)/dev/%.c,%.c,$(wildcard $(COOJA)/dev/*.c)) COOJA_DEV = $(patsubst $(COOJA)/dev/%.c,%.c,$(wildcard $(COOJA)/dev/*.c))
COOJA_LIB = $(patsubst $(COOJA)/lib/%.c,%.c,$(wildcard $(COOJA)/lib/*.c)) COOJA_LIB = $(patsubst $(COOJA)/lib/%.c,%.c,$(wildcard $(COOJA)/lib/*.c))
@ -81,7 +79,7 @@ COOJA_SYS = $(patsubst $(COOJA)/sys/%.c,%.c,$(wildcard $(COOJA)/sys/*.c))
CORE_FILES = random.c sensors.c leds.c serial.c CORE_FILES = random.c sensors.c leds.c serial.c
CONTIKI_TARGET_SOURCEFILES = \ CONTIKI_TARGET_SOURCEFILES = \
$(COOJA_APPS) $(COOJA_DEV) $(COOJA_LIB) $(COOJA_SYS) $(CORE_FILES) $(COOJA_DEV) $(COOJA_LIB) $(COOJA_SYS) $(CORE_FILES)
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES) CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)

View file

@ -1 +1,3 @@
se.sics.cooja.contikimote.ContikiMoteType.C_SOURCES = + app1.c app2.c ## Not needed since update 2006-08-21.
## Processfiles are thrown to compilation explicitly.
#se.sics.cooja.contikimote.ContikiMoteType.C_SOURCES = + app1.c app2.c

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: ContikiMoteTypeDialog.java,v 1.1 2006/08/21 12:13:10 fros4943 Exp $ * $Id: ContikiMoteTypeDialog.java,v 1.2 2006/08/21 15:06:28 fros4943 Exp $
*/ */
package se.sics.cooja.contikimote; package se.sics.cooja.contikimote;
@ -889,11 +889,32 @@ public class ContikiMoteTypeDialog extends JDialog {
compilationThread = new Thread(new Runnable() { compilationThread = new Thread(new Runnable() {
public void run() { public void run() {
// Merge user platforms // Add all user platform directories
Vector<File> allUserPlatforms = (Vector<File>) GUI.currentGUI.getUserPlatforms().clone(); Vector<File> filesToCompile = (Vector<File>) GUI.currentGUI
allUserPlatforms.addAll(moteTypeUserPlatforms); .getUserPlatforms().clone();
compilationSucceded = ContikiMoteTypeDialog.compileLibrary(contikiDir, filesToCompile.addAll(moteTypeUserPlatforms);
allUserPlatforms, identifier, taskOutput, newMoteTypeConfig);
// Add source files from platform configs
String[] projectSourceFiles = newMoteTypeConfig.getStringArrayValue(
ContikiMoteType.class, "C_SOURCES");
for (String projectSourceFile : projectSourceFiles) {
if (!projectSourceFile.trim().equals("")) {
filesToCompile.add(new File(projectSourceFile));
}
}
// Add selected process source files
for (Component checkBox : processPanel.getComponents()) {
if (((JCheckBox) checkBox).isSelected()) {
String processName = ((JCheckBox) checkBox).getToolTipText();
if (processName != null) {
filesToCompile.add(new File(processName));
}
}
}
compilationSucceded = ContikiMoteTypeDialog.compileLibrary(identifier,
contikiDir, filesToCompile, taskOutput);
} }
}, "compilation thread"); }, "compilation thread");
compilationThread.start(); compilationThread.start();
@ -1074,21 +1095,21 @@ public class ContikiMoteTypeDialog extends JDialog {
} }
/** /**
* Compiles a mote type shared library using an external makefile. * Compiles a mote type shared library using the standard Contiki makefile.
* *
* @param contikiDir
* Contiki OS main directory
* @param userPlatformDirs
* COOJA user platforms (may be null)
* @param identifier * @param identifier
* Filename identifier * Mote type identifier
* @param contikiDir
* Contiki base directory
* @param sourceFiles
* Source files and directories to include in compilation
* @param appender * @param appender
* Optional component to append process output to * Component to append process output to (optional)
* @return False if an error was discovered, true otherwise * @return True if compilation succeded, false otherwise
*/ */
public static boolean compileLibrary(File contikiDir, Vector<File> userPlatformDirs, public static boolean compileLibrary(String identifier, File contikiDir,
String identifier, final MessageList appender, Vector<File> sourceFiles, final MessageList appender) {
PlatformConfig platformConfig) {
File libFile = new File(ContikiMoteType.tempOutputDirectory.getPath() File libFile = new File(ContikiMoteType.tempOutputDirectory.getPath()
+ File.separatorChar + identifier + ContikiMoteType.librarySuffix); + File.separatorChar + identifier + ContikiMoteType.librarySuffix);
File mapFile = new File(ContikiMoteType.tempOutputDirectory.getPath() File mapFile = new File(ContikiMoteType.tempOutputDirectory.getPath()
@ -1142,20 +1163,21 @@ public class ContikiMoteTypeDialog extends JDialog {
contikiDir.getPath().replace(File.separatorChar, '/') contikiDir.getPath().replace(File.separatorChar, '/')
+ "/Makefile.include"}; + "/Makefile.include"};
String projectDirs = System.getProperty("PROJECTDIRS", ""); String sourceDirs = System.getProperty("PROJECTDIRS", "");
if (userPlatformDirs != null) { String sourceFileNames = "";
for (File userPlatform : userPlatformDirs) {
projectDirs += " "
+ userPlatform.getPath().replace(File.separatorChar, '/');
}
}
String[] projectSourceFiles = platformConfig.getStringArrayValue( for (File sourceFile : sourceFiles) {
ContikiMoteType.class, "C_SOURCES"); if (sourceFile.isDirectory()) {
String sourceFiles = ""; // Add directory to search path
if (userPlatformDirs != null) { sourceDirs += " "
for (String sourceFile : projectSourceFiles) { + sourceFile.getPath().replace(File.separatorChar, '/');
sourceFiles += " " + sourceFile; } else if (sourceFile.isFile()) {
// Add both file name and directory
sourceDirs += " " + sourceFile.getParent();
sourceFileNames += " " + sourceFile.getName();
} else {
// Add filename and hope Contiki knows where to find it...
sourceFileNames += " " + sourceFile.getName();
} }
} }
@ -1167,7 +1189,8 @@ public class ContikiMoteTypeDialog extends JDialog {
"EXTRA_CC_ARGS=" + GUI.getExternalToolsSetting("COMPILER_ARGS", ""), "EXTRA_CC_ARGS=" + GUI.getExternalToolsSetting("COMPILER_ARGS", ""),
"CC=" + GUI.getExternalToolsSetting("PATH_C_COMPILER"), "CC=" + GUI.getExternalToolsSetting("PATH_C_COMPILER"),
"LD=" + GUI.getExternalToolsSetting("PATH_LINKER"), "COMPILE_MAIN=1", "LD=" + GUI.getExternalToolsSetting("PATH_LINKER"), "COMPILE_MAIN=1",
"PROJECTDIRS=" + projectDirs, "PROJECT_SOURCEFILES=" + sourceFiles, "PROJECTDIRS=" + sourceDirs,
"PROJECT_SOURCEFILES=" + sourceFileNames,
"PATH=" + System.getenv("PATH")}; "PATH=" + System.getenv("PATH")};
Process p = Runtime.getRuntime().exec(cmd, env, null); Process p = Runtime.getRuntime().exec(cmd, env, null);
@ -1489,11 +1512,10 @@ public class ContikiMoteTypeDialog extends JDialog {
if (confirmSelection) { if (confirmSelection) {
Object[] options = {"Create", "Cancel"}; Object[] options = {"Create", "Cancel"};
String question = "The process [PROC1] depends on the following process: [PROC2]\nDo you want to add this as well?"; String question = "The process " + processName
+ " depends on the following process: " + autostartProcess
+ "\nDo you want to add this as well?";
String title = "Add dependency process?"; String title = "Add dependency process?";
question = question.replaceFirst("\\[PROC1\\]", processName);
question = question.replaceFirst("\\[PROC2\\]",
autostartProcess);
int answer = JOptionPane.showOptionDialog(myDialog, question, int answer = JOptionPane.showOptionDialog(myDialog, question,
title, JOptionPane.DEFAULT_OPTION, title, JOptionPane.DEFAULT_OPTION,
JOptionPane.QUESTION_MESSAGE, null, options, options[0]); JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
@ -1867,8 +1889,8 @@ public class ContikiMoteTypeDialog extends JDialog {
// If user platforms exists, scan those too // If user platforms exists, scan those too
for (File userPlatform : GUI.currentGUI.getUserPlatforms()) { for (File userPlatform : GUI.currentGUI.getUserPlatforms()) {
processes.addAll(ContikiMoteTypeDialog processes
.scanForProcesses(userPlatform)); .addAll(ContikiMoteTypeDialog.scanForProcesses(userPlatform));
} }
if (moteTypeUserPlatforms != null) { if (moteTypeUserPlatforms != null) {
for (File userPlatform : moteTypeUserPlatforms) { for (File userPlatform : moteTypeUserPlatforms) {
@ -2002,8 +2024,8 @@ public class ContikiMoteTypeDialog extends JDialog {
// Find and load the mote interface classes // Find and load the mote interface classes
for (String moteInterface : moteInterfaces) { for (String moteInterface : moteInterfaces) {
Class<? extends MoteInterface> newMoteInterfaceClass = GUI.currentGUI.tryLoadClass(this, MoteInterface.class, Class<? extends MoteInterface> newMoteInterfaceClass = GUI.currentGUI
moteInterface); .tryLoadClass(this, MoteInterface.class, moteInterface);
if (newMoteInterfaceClass == null) { if (newMoteInterfaceClass == null) {
logger.warn("Failed to load mote interface: " + moteInterface); logger.warn("Failed to load mote interface: " + moteInterface);