mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
Refactoring Compiler.compile() in preparation for integrating patch to build the core as a library instead of .o files.
This commit is contained in:
@ -325,161 +325,39 @@ public class Compiler implements MessageConsumer {
|
|||||||
baseCommandCompiler[baseCommandCompiler.length - 2] = sourceNames[i];
|
baseCommandCompiler[baseCommandCompiler.length - 2] = sourceNames[i];
|
||||||
baseCommandCompiler[baseCommandCompiler.length - 1] = "-o"+ objectNames[i];
|
baseCommandCompiler[baseCommandCompiler.length - 1] = "-o"+ objectNames[i];
|
||||||
//System.arraycopy(baseCommandCompiler.length
|
//System.arraycopy(baseCommandCompiler.length
|
||||||
if (Preferences.getBoolean("build.verbose")) {
|
result = execAsynchronously(baseCommandCompiler);
|
||||||
for(int j = 0; j < baseCommandCompiler.length; j++) {
|
if (result!=0)
|
||||||
System.out.print(baseCommandCompiler[j] + " ");
|
|
||||||
}
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
process = Runtime.getRuntime().exec(baseCommandCompiler);
|
|
||||||
new MessageSiphon(process.getInputStream(), this);
|
|
||||||
new MessageSiphon(process.getErrorStream(), this);
|
|
||||||
|
|
||||||
// wait for the process to finish. if interrupted
|
|
||||||
// before waitFor returns, continue waiting
|
|
||||||
//
|
|
||||||
compiling = true;
|
|
||||||
while (compiling) {
|
|
||||||
try {
|
|
||||||
result = process.waitFor();
|
|
||||||
//System.out.println("result is " + result);
|
|
||||||
compiling = false;
|
|
||||||
} catch (InterruptedException ignored) { }
|
|
||||||
}
|
|
||||||
if (exception != null) {
|
|
||||||
exception.hideStackTrace = true;
|
|
||||||
throw exception;
|
|
||||||
}
|
|
||||||
if(result!=0)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < fileCountCPP; i++) {
|
for(int i = 0; i < fileCountCPP; i++) {
|
||||||
baseCommandCompilerCPP[baseCommandCompilerCPP.length - 2] = sourceNamesCPP[i];
|
baseCommandCompilerCPP[baseCommandCompilerCPP.length - 2] = sourceNamesCPP[i];
|
||||||
baseCommandCompilerCPP[baseCommandCompilerCPP.length - 1] = "-o"+ objectNamesCPP[i];
|
baseCommandCompilerCPP[baseCommandCompilerCPP.length - 1] = "-o"+ objectNamesCPP[i];
|
||||||
if (Preferences.getBoolean("build.verbose")) {
|
result = execAsynchronously(baseCommandCompilerCPP);
|
||||||
for(int j = 0; j < baseCommandCompilerCPP.length; j++) {
|
if (result!=0)
|
||||||
System.out.print(baseCommandCompilerCPP[j] + " ");
|
|
||||||
}
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
process = Runtime.getRuntime().exec(baseCommandCompilerCPP);
|
|
||||||
new MessageSiphon(process.getInputStream(), this);
|
|
||||||
new MessageSiphon(process.getErrorStream(), this);
|
|
||||||
|
|
||||||
// wait for the process to finish. if interrupted
|
|
||||||
// before waitFor returns, continue waiting
|
|
||||||
//
|
|
||||||
compiling = true;
|
|
||||||
while (compiling) {
|
|
||||||
try {
|
|
||||||
result = process.waitFor();
|
|
||||||
//System.out.println("result is " + result);
|
|
||||||
compiling = false;
|
|
||||||
} catch (InterruptedException ignored) { }
|
|
||||||
}
|
|
||||||
if (exception != null) {
|
|
||||||
exception.hideStackTrace = true;
|
|
||||||
throw exception;
|
|
||||||
}
|
|
||||||
if(result!=0)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Preferences.getBoolean("build.verbose")) {
|
result = execAsynchronously(commandLinker);
|
||||||
for(int j = 0; j < commandLinker.length; j++) {
|
if (result!=0)
|
||||||
System.out.print(commandLinker[j] + " ");
|
|
||||||
}
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
process = Runtime.getRuntime().exec(commandLinker);
|
|
||||||
new MessageSiphon(process.getInputStream(), this);
|
|
||||||
new MessageSiphon(process.getErrorStream(), this);
|
|
||||||
compiling = true;
|
|
||||||
while(compiling) {
|
|
||||||
try {
|
|
||||||
result = process.waitFor();
|
|
||||||
compiling = false;
|
|
||||||
} catch (InterruptedException intExc) { }
|
|
||||||
}
|
|
||||||
if (exception != null) {
|
|
||||||
exception.hideStackTrace = true;
|
|
||||||
throw exception;
|
|
||||||
}
|
|
||||||
if(result!=0)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
baseCommandObjcopy[2] = "srec";
|
baseCommandObjcopy[2] = "srec";
|
||||||
baseCommandObjcopy[4] = ".eeprom";
|
baseCommandObjcopy[4] = ".eeprom";
|
||||||
baseCommandObjcopy[5] = buildPath + File.separator + sketch.name + ".elf";
|
baseCommandObjcopy[5] = buildPath + File.separator + sketch.name + ".elf";
|
||||||
baseCommandObjcopy[6] = buildPath + File.separator + sketch.name + ".rom";
|
baseCommandObjcopy[6] = buildPath + File.separator + sketch.name + ".rom";
|
||||||
if (Preferences.getBoolean("build.verbose")) {
|
result = execAsynchronously(baseCommandObjcopy);
|
||||||
for(int j = 0; j < baseCommandObjcopy.length; j++) {
|
if (result!=0)
|
||||||
System.out.print(baseCommandObjcopy[j] + " ");
|
|
||||||
}
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
process = Runtime.getRuntime().exec(baseCommandObjcopy);
|
|
||||||
new MessageSiphon(process.getInputStream(), this);
|
|
||||||
new MessageSiphon(process.getErrorStream(), this);
|
|
||||||
compiling = true;
|
|
||||||
while(compiling) {
|
|
||||||
try {
|
|
||||||
result = process.waitFor();
|
|
||||||
compiling = false;
|
|
||||||
} catch (InterruptedException intExc) { }
|
|
||||||
}
|
|
||||||
if (exception != null) {
|
|
||||||
exception.hideStackTrace = true;
|
|
||||||
throw exception;
|
|
||||||
}
|
|
||||||
if(result!=0)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
baseCommandObjcopy[2] = "ihex";
|
baseCommandObjcopy[2] = "ihex";
|
||||||
baseCommandObjcopy[4] = ".flash";
|
baseCommandObjcopy[4] = ".flash";
|
||||||
baseCommandObjcopy[5] = buildPath + File.separator + sketch.name + ".elf";
|
baseCommandObjcopy[5] = buildPath + File.separator + sketch.name + ".elf";
|
||||||
baseCommandObjcopy[6] = buildPath + File.separator + sketch.name + ".hex";
|
baseCommandObjcopy[6] = buildPath + File.separator + sketch.name + ".hex";
|
||||||
if (Preferences.getBoolean("build.verbose")) {
|
result = execAsynchronously(baseCommandObjcopy);
|
||||||
for(int j = 0; j < baseCommandObjcopy.length; j++) {
|
if (result!=0)
|
||||||
System.out.print(baseCommandObjcopy[j] + " ");
|
|
||||||
}
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
process = Runtime.getRuntime().exec(baseCommandObjcopy);
|
|
||||||
new MessageSiphon(process.getInputStream(), this);
|
|
||||||
new MessageSiphon(process.getErrorStream(), this);
|
|
||||||
compiling = true;
|
|
||||||
while(compiling) {
|
|
||||||
try {
|
|
||||||
result = process.waitFor();
|
|
||||||
compiling = false;
|
|
||||||
} catch (InterruptedException intExc) { }
|
|
||||||
}
|
|
||||||
if (exception != null) {
|
|
||||||
exception.hideStackTrace = true;
|
|
||||||
throw exception;
|
|
||||||
}
|
|
||||||
if(result!=0)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/*Process process = Runtime.getRuntime().exec(command);
|
|
||||||
new MessageSiphon(process.getInputStream(), this);
|
|
||||||
new MessageSiphon(process.getErrorStream(), this);
|
|
||||||
|
|
||||||
// wait for the process to finish. if interrupted
|
|
||||||
// before waitFor returns, continue waiting
|
|
||||||
//
|
|
||||||
boolean compiling = true;
|
|
||||||
while (compiling) {
|
|
||||||
try {
|
|
||||||
result = process.waitFor();
|
|
||||||
//System.out.println("result is " + result);
|
|
||||||
compiling = false;
|
|
||||||
} catch (InterruptedException ignored) { }
|
|
||||||
}*/
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String msg = e.getMessage();
|
String msg = e.getMessage();
|
||||||
if ((msg != null) && (msg.indexOf("avr-gcc: not found") != -1)) {
|
if ((msg != null) && (msg.indexOf("avr-gcc: not found") != -1)) {
|
||||||
@ -517,6 +395,41 @@ public class Compiler implements MessageConsumer {
|
|||||||
// success would mean that 'result' is set to zero
|
// success would mean that 'result' is set to zero
|
||||||
return (result == 0); // ? true : false;
|
return (result == 0); // ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int execAsynchronously(String[] command)
|
||||||
|
throws RunnerException, IOException {
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
if (Preferences.getBoolean("build.verbose")) {
|
||||||
|
for(int j = 0; j < command.length; j++) {
|
||||||
|
System.out.print(command[j] + " ");
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
Process process = Runtime.getRuntime().exec(command);
|
||||||
|
|
||||||
|
new MessageSiphon(process.getInputStream(), this);
|
||||||
|
new MessageSiphon(process.getErrorStream(), this);
|
||||||
|
|
||||||
|
// wait for the process to finish. if interrupted
|
||||||
|
// before waitFor returns, continue waiting
|
||||||
|
boolean compiling = true;
|
||||||
|
while (compiling) {
|
||||||
|
try {
|
||||||
|
result = process.waitFor();
|
||||||
|
//System.out.println("result is " + result);
|
||||||
|
compiling = false;
|
||||||
|
} catch (InterruptedException ignored) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exception != null) {
|
||||||
|
exception.hideStackTrace = true;
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean firstErrorFound;
|
boolean firstErrorFound;
|
||||||
|
Reference in New Issue
Block a user