mirror of
https://github.com/esp8266/Arduino.git
synced 2025-08-01 03:47:23 +03:00
Syncing with Processing 1.0.7 (5692); needs testing.
Also, the Sketchbook and Examples menus are currently disabled on the Mac to work-around a bug in Apple's implementation of Java. I think this bug may have been solved, so I should try re-enabling the menus and see what happens (on 10.4 and 10.5 and 10.6). Also, I may still need to update the jre / jdk on Linux.
This commit is contained in:
@ -73,7 +73,7 @@ public class Compiler implements MessageConsumer {
|
||||
MessageStream pms = new MessageStream(this);
|
||||
|
||||
String avrBasePath = Base.getAvrBasePath();
|
||||
|
||||
|
||||
List<File> objectFiles = new ArrayList<File>();
|
||||
|
||||
List includePaths = new ArrayList();
|
||||
@ -99,15 +99,15 @@ public class Compiler implements MessageConsumer {
|
||||
List commandAR = new ArrayList(baseCommandAR);
|
||||
commandAR.add(file.getAbsolutePath());
|
||||
execAsynchronously(commandAR);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
||||
|
||||
|
||||
// use library directories as include paths for all libraries
|
||||
for (File file : sketch.getImportedLibraries()) {
|
||||
includePaths.add(file.getPath());
|
||||
}
|
||||
|
||||
|
||||
for (File libraryFolder : sketch.getImportedLibraries()) {
|
||||
File outputFolder = new File(buildPath, libraryFolder.getName());
|
||||
createFolder(outputFolder);
|
||||
@ -125,17 +125,17 @@ public class Compiler implements MessageConsumer {
|
||||
findFilesInFolder(new File(libraryFolder, "utility"), "cpp", false)));
|
||||
// other libraries should not see this library's utility/ folder
|
||||
includePaths.remove(includePaths.size() - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 3. compile the sketch (already in the buildPath)
|
||||
|
||||
|
||||
objectFiles.addAll(
|
||||
compileFiles(avrBasePath, buildPath, includePaths,
|
||||
findFilesInPath(buildPath, "c", false),
|
||||
findFilesInPath(buildPath, "cpp", false)));
|
||||
|
||||
|
||||
// 4. link it all together into the .elf file
|
||||
|
||||
|
||||
List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
|
||||
avrBasePath + "avr-gcc",
|
||||
"-Os",
|
||||
@ -144,7 +144,7 @@ public class Compiler implements MessageConsumer {
|
||||
"-o",
|
||||
buildPath + File.separator + primaryClassName + ".elf"
|
||||
}));
|
||||
|
||||
|
||||
for (File file : objectFiles) {
|
||||
baseCommandLinker.add(file.getAbsolutePath());
|
||||
}
|
||||
@ -185,14 +185,14 @@ public class Compiler implements MessageConsumer {
|
||||
execAsynchronously(commandObjcopy);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private List<File> compileFiles(String avrBasePath,
|
||||
String buildPath, List<File> includePaths,
|
||||
List<File> cSources, List<File> cppSources)
|
||||
throws RunnerException {
|
||||
|
||||
|
||||
List<File> objectPaths = new ArrayList<File>();
|
||||
|
||||
for (File file : cSources) {
|
||||
@ -201,7 +201,7 @@ public class Compiler implements MessageConsumer {
|
||||
execAsynchronously(getCommandCompilerC(avrBasePath, includePaths,
|
||||
file.getAbsolutePath(),
|
||||
objectPath));
|
||||
}
|
||||
}
|
||||
|
||||
for (File file : cppSources) {
|
||||
String objectPath = buildPath + File.separator + file.getName() + ".o";
|
||||
@ -209,12 +209,12 @@ public class Compiler implements MessageConsumer {
|
||||
execAsynchronously(getCommandCompilerCPP(avrBasePath, includePaths,
|
||||
file.getAbsolutePath(),
|
||||
objectPath));
|
||||
}
|
||||
}
|
||||
|
||||
return objectPaths;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
boolean firstErrorFound;
|
||||
boolean secondErrorFound;
|
||||
|
||||
@ -229,9 +229,9 @@ public class Compiler implements MessageConsumer {
|
||||
if (verbose || Preferences.getBoolean("build.verbose")) {
|
||||
for(int j = 0; j < command.length; j++) {
|
||||
System.out.print(command[j] + " ");
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
firstErrorFound = false; // haven't found any errors yet
|
||||
secondErrorFound = false;
|
||||
@ -244,8 +244,8 @@ public class Compiler implements MessageConsumer {
|
||||
RunnerException re = new RunnerException(e.getMessage());
|
||||
re.hideStackTrace();
|
||||
throw re;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MessageSiphon in = new MessageSiphon(process.getInputStream(), this);
|
||||
MessageSiphon err = new MessageSiphon(process.getErrorStream(), this);
|
||||
|
||||
@ -263,7 +263,7 @@ public class Compiler implements MessageConsumer {
|
||||
compiling = false;
|
||||
} catch (InterruptedException ignored) { }
|
||||
}
|
||||
|
||||
|
||||
// an error was queued up by message(), barf this back to compile(),
|
||||
// which will barf it back to Editor. if you're having trouble
|
||||
// discerning the imagery, consider how cows regurgitate their food
|
||||
@ -271,18 +271,18 @@ public class Compiler implements MessageConsumer {
|
||||
//
|
||||
//System.out.println("throwing up " + exception);
|
||||
if (exception != null) { throw exception; }
|
||||
|
||||
|
||||
if (result > 1) {
|
||||
// a failure in the tool (e.g. unable to locate a sub-executable)
|
||||
System.err.println(command[0] + " returned " + result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (result != 0) {
|
||||
RunnerException re = new RunnerException("Error compiling.");
|
||||
re.hideStackTrace();
|
||||
throw re;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -312,14 +312,14 @@ public class Compiler implements MessageConsumer {
|
||||
String partialTempPath = null;
|
||||
int partialStartIndex = -1; //s.indexOf(partialTempPath);
|
||||
int fileIndex = -1; // use this to build a better exception
|
||||
|
||||
|
||||
// check the main sketch file first.
|
||||
partialTempPath = buildPathSubst + primaryClassName;
|
||||
partialStartIndex = s.indexOf(partialTempPath);
|
||||
|
||||
if (partialStartIndex != -1) {
|
||||
fileIndex = 0;
|
||||
} else {
|
||||
} else {
|
||||
// wasn't there, check the other (non-pde) files in the sketch.
|
||||
// iterate through the project files to see who's causing the trouble
|
||||
for (int i = 0; i < sketch.getCodeCount(); i++) {
|
||||
@ -332,7 +332,7 @@ public class Compiler implements MessageConsumer {
|
||||
fileIndex = i;
|
||||
//System.out.println("fileIndex is " + fileIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//+ className + ".java";
|
||||
}
|
||||
@ -353,7 +353,7 @@ public class Compiler implements MessageConsumer {
|
||||
System.err.print(s1);
|
||||
//firstErrorFound = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int lineNumber;
|
||||
try {
|
||||
@ -361,7 +361,7 @@ public class Compiler implements MessageConsumer {
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.print(s1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//System.out.println("pde / line number: " + lineNumber);
|
||||
|
||||
@ -372,15 +372,15 @@ public class Compiler implements MessageConsumer {
|
||||
if (sketch.getCode(i).getPreprocOffset() < lineNumber) {
|
||||
fileIndex = i;
|
||||
//System.out.println("i'm thinkin file " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// XXX: DAM: if the lineNumber is less than sketch.getCode(0).getPreprocOffset()
|
||||
// we shouldn't subtract anything from it, as the error is above the
|
||||
// location where the function prototypes and #include "WProgram.h"
|
||||
// were inserted.
|
||||
lineNumber -= sketch.getCode(fileIndex).getPreprocOffset();
|
||||
}
|
||||
}
|
||||
|
||||
//String s2 = s1.substring(colon + 2);
|
||||
int err = s1.indexOf(":");
|
||||
@ -391,7 +391,7 @@ public class Compiler implements MessageConsumer {
|
||||
if (firstErrorFound) {
|
||||
secondErrorFound = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if executing at this point, this is *at least* the first error
|
||||
firstErrorFound = true;
|
||||
@ -421,13 +421,13 @@ public class Compiler implements MessageConsumer {
|
||||
// are probably associated with the first error message,
|
||||
// which is already in the status bar, and are likely to be
|
||||
// of interest to the user, so spit them to the console.
|
||||
//
|
||||
//
|
||||
if (!secondErrorFound) {
|
||||
System.err.println(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static private List getCommandCompilerC(String avrBasePath, List includePaths,
|
||||
@ -447,13 +447,13 @@ public class Compiler implements MessageConsumer {
|
||||
for (int i = 0; i < includePaths.size(); i++) {
|
||||
baseCommandCompiler.add("-I" + (String) includePaths.get(i));
|
||||
}
|
||||
|
||||
|
||||
baseCommandCompiler.add(sourceName);
|
||||
baseCommandCompiler.add("-o"+ objectName);
|
||||
|
||||
|
||||
return baseCommandCompiler;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static private List getCommandCompilerCPP(String avrBasePath,
|
||||
List includePaths, String sourceName, String objectName) {
|
||||
@ -472,15 +472,15 @@ public class Compiler implements MessageConsumer {
|
||||
|
||||
for (int i = 0; i < includePaths.size(); i++) {
|
||||
baseCommandCompilerCPP.add("-I" + (String) includePaths.get(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
baseCommandCompilerCPP.add(sourceName);
|
||||
baseCommandCompilerCPP.add("-o"+ objectName);
|
||||
|
||||
|
||||
return baseCommandCompilerCPP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
Reference in New Issue
Block a user