using new compiler library for configuration wizard

This commit is contained in:
fros4943 2009-03-11 08:44:32 +00:00
parent 8ec6bbd32b
commit f46770ae85

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: ConfigurationWizard.java,v 1.1 2009/02/20 16:51:25 fros4943 Exp $ * $Id: ConfigurationWizard.java,v 1.2 2009/03/11 08:44:32 fros4943 Exp $
*/ */
package se.sics.cooja.dialogs; package se.sics.cooja.dialogs;
@ -56,7 +56,6 @@ import se.sics.cooja.GUI;
import se.sics.cooja.SectionMoteMemory; import se.sics.cooja.SectionMoteMemory;
import se.sics.cooja.MoteType.MoteTypeCreationException; import se.sics.cooja.MoteType.MoteTypeCreationException;
import se.sics.cooja.contikimote.ContikiMoteType; import se.sics.cooja.contikimote.ContikiMoteType;
import se.sics.cooja.contikimote.ContikiMoteTypeDialog;
public class ConfigurationWizard extends JDialog { public class ConfigurationWizard extends JDialog {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -401,6 +400,7 @@ public class ConfigurationWizard extends JDialog {
private static void prepareShowTestProgress(JFrame parent, String desc) { private static void prepareShowTestProgress(JFrame parent, String desc) {
output = new MessageList(); output = new MessageList();
output.addPopupMenuItem(null, true);
progressDialog = new JDialog(parent, desc); progressDialog = new JDialog(parent, desc);
button = new JButton("Close"); button = new JButton("Close");
progressBar = new JProgressBar(0, 100); progressBar = new JProgressBar(0, 100);
@ -514,7 +514,7 @@ public class ConfigurationWizard extends JDialog {
javaLibraryName = "LibTest" + testCounter; javaLibraryName = "LibTest" + testCounter;
cLibraryName = "libtest" + testCounter; cLibraryName = "libtest" + testCounter;
cLibrarySourceFile = new File(ContikiMoteType.tempOutputDirectory, cLibraryName + ".c"); cLibrarySourceFile = new File(ContikiMoteType.tempOutputDirectory, cLibraryName + ".c");
cLibraryFile = new File(ContikiMoteType.tempOutputDirectory, cLibraryName + ".library"); cLibraryFile = new File(ContikiMoteType.tempOutputDirectory, cLibraryName + ContikiMoteType.librarySuffix);
testOutput.addMessage("### Reading C library template source: " + testTemplate, MessageList.NORMAL); testOutput.addMessage("### Reading C library template source: " + testTemplate, MessageList.NORMAL);
BufferedReader templateReader = null; BufferedReader templateReader = null;
@ -522,7 +522,7 @@ public class ConfigurationWizard extends JDialog {
if ((new File(testTemplate)).exists()) { if ((new File(testTemplate)).exists()) {
templateReader = new BufferedReader(new FileReader(testTemplate)); templateReader = new BufferedReader(new FileReader(testTemplate));
} else { } else {
InputStream input = ContikiMoteTypeDialog.class.getResourceAsStream('/' + testTemplate); InputStream input = ConfigurationWizard.class.getResourceAsStream('/' + testTemplate);
if (input == null) { if (input == null) {
throw new FileNotFoundException("File not found: " + testTemplate); throw new FileNotFoundException("File not found: " + testTemplate);
} }
@ -564,17 +564,45 @@ public class ConfigurationWizard extends JDialog {
return false; return false;
} }
/* Prepare compiler environment */
testOutput.addMessage("### Preparing compiler environment");
String[][] env;
try {
env = CompileContiki.createCompilationEnvironment(
cLibraryName,
new File(cLibraryName + ".c"),
new File(cLibraryName + ContikiMoteType.mapSuffix),
new File(cLibraryName + ContikiMoteType.librarySuffix),
new File(cLibraryName + ContikiMoteType.dependSuffix)
);
} catch (Exception e) {
testOutput.addMessage("### Error: Compiler environment failed", MessageList.ERROR);
return false;
}
String[] envOneDimension = new String[env.length];
for (int i=0; i < env.length; i++) {
envOneDimension[i] = env[i][0] + "=" + env[i][1];
}
testOutput.addMessage("### Compiling C library source: " + cLibrarySourceFile.getName()); testOutput.addMessage("### Compiling C library source: " + cLibrarySourceFile.getName());
boolean compileOK = ContikiMoteTypeDialog.compileLibrary( try {
cLibraryName, String contikiPath = GUI.getExternalToolsSetting("PATH_CONTIKI").replaceAll("\\\\", "/");
new File(GUI.getExternalToolsSetting("PATH_CONTIKI")), System.out.println(" CURR DIR: " + new File(".").getAbsolutePath());
new Vector<File>(), CompileContiki.compile(
false, "make " +
ContikiMoteType.CommunicationStack.RIME, "-f " + contikiPath + "/Makefile.include " +
normalStream, "CONTIKI=" + contikiPath + " " +
errorStream "obj_cooja/" + cLibraryName + ".cooja " +
); "TARGET=cooja CONTIKI_APP_OBJ=",
if (!compileOK) { envOneDimension,
null,
new File("."),
null,
null,
testOutput,
true
);
} catch (Exception e) {
testOutput.addMessage("### Error: Compilation failed", MessageList.ERROR); testOutput.addMessage("### Error: Compilation failed", MessageList.ERROR);
return false; return false;
} }