mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
Fixing some compilations bugs:
- including .cpp and .c files from sketch - adjusting error line highlighted according to the number of function prototypes generated - taking into account preprocessor offset on the first .pde file
This commit is contained in:
parent
2fa8deb92d
commit
ae98fbfee8
@ -1275,7 +1275,7 @@ public class Sketch {
|
|||||||
name,
|
name,
|
||||||
codeFolderPackages,
|
codeFolderPackages,
|
||||||
target);
|
target);
|
||||||
headerOffset = preprocessor.headerCount;
|
headerOffset = preprocessor.headerCount + preprocessor.prototypeCount;
|
||||||
|
|
||||||
if (className == null) {
|
if (className == null) {
|
||||||
throw new RunnerException("Could not find main class");
|
throw new RunnerException("Could not find main class");
|
||||||
|
@ -133,14 +133,14 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
for (int i = 0; i < sketch.getCodeCount(); i++) {
|
for (int i = 0; i < sketch.getCodeCount(); i++) {
|
||||||
//if (sketch.getCode(i).preprocName != null) {
|
//if (sketch.getCode(i).preprocName != null) {
|
||||||
if (sketch.getCode(i).isExtension(".c")) {
|
if (sketch.getCode(i).isExtension("c")) {
|
||||||
sourceNames.add(buildPath + File.separator + sketch.getCode(i).getPrettyName());
|
sourceNames.add(buildPath + File.separator + sketch.getCode(i).getFileName());
|
||||||
objectNames.add(buildPath + File.separator + sketch.getCode(i).getPrettyName() + ".o");
|
objectNames.add(buildPath + File.separator + sketch.getCode(i).getFileName() + ".o");
|
||||||
sketchObjectNames.add(buildPath + File.separator + sketch.getCode(i).getPrettyName() + ".o");
|
sketchObjectNames.add(buildPath + File.separator + sketch.getCode(i).getFileName() + ".o");
|
||||||
} else if (sketch.getCode(i).isExtension(".cpp")) {
|
} else if (sketch.getCode(i).isExtension("cpp")) {
|
||||||
sourceNamesCPP.add(buildPath + File.separator + sketch.getCode(i).getPrettyName());
|
sourceNamesCPP.add(buildPath + File.separator + sketch.getCode(i).getFileName());
|
||||||
objectNamesCPP.add(buildPath + File.separator + sketch.getCode(i).getPrettyName() + ".o");
|
objectNamesCPP.add(buildPath + File.separator + sketch.getCode(i).getFileName() + ".o");
|
||||||
sketchObjectNames.add(buildPath + File.separator + sketch.getCode(i).getPrettyName() + ".o");
|
sketchObjectNames.add(buildPath + File.separator + sketch.getCode(i).getFileName() + ".o");
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
@ -377,27 +377,23 @@ public class Compiler implements MessageConsumer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the "1" corresponds to the amount of lines written to the main code
|
|
||||||
// file by PdePreprocessor's writeHeader() routine before prototypes
|
|
||||||
if (fileIndex == 0)
|
|
||||||
lineNumber -= 1;
|
|
||||||
|
|
||||||
//System.out.println("pde / line number: " + lineNumber);
|
//System.out.println("pde / line number: " + lineNumber);
|
||||||
|
|
||||||
if (fileIndex == 0) { // main class, figure out which tab
|
if (fileIndex == 0) { // main class, figure out which tab
|
||||||
for (int i = 1; i < sketch.getCodeCount(); i++) {
|
for (int i = 1; i < sketch.getCodeCount(); i++) {
|
||||||
if (sketch.getCode(i).isExtension("pde")) {
|
if (sketch.getCode(i).isExtension("pde")) {
|
||||||
//System.out.println("preprocOffset "+ sketch.code[i].preprocOffset);
|
//System.out.println("preprocOffset "+ sketch.getCode(i).getPreprocOffset());
|
||||||
if (sketch.getCode(i).getPreprocOffset() < lineNumber) {
|
if (sketch.getCode(i).getPreprocOffset() < lineNumber) {
|
||||||
fileIndex = i;
|
fileIndex = i;
|
||||||
//System.out.println("i'm thinkin file " + i);
|
//System.out.println("i'm thinkin file " + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fileIndex != 0) { // if found another culprit
|
// 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();
|
lineNumber -= sketch.getCode(fileIndex).getPreprocOffset();
|
||||||
//System.out.println("i'm sayin line " + lineNumber);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//String s2 = s1.substring(colon + 2);
|
//String s2 = s1.substring(colon + 2);
|
||||||
|
@ -72,7 +72,8 @@ public class PdePreprocessor {
|
|||||||
public int prototypeCount = 0;
|
public int prototypeCount = 0;
|
||||||
|
|
||||||
// stores number of included library headers written
|
// stores number of included library headers written
|
||||||
public int headerCount = 0;
|
// we always write one header: WProgram.h
|
||||||
|
public int headerCount = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These may change in-between (if the prefs panel adds this option)
|
* These may change in-between (if the prefs panel adds this option)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user