mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Move the definition of primaryClassName in Sketch
Instead of defining in the preprocess method and returning, just define it in the build method. This makes sure the name is available before preprocessing, which is important for the upcoming commits. This commit should not change behaviour, only prepare for the next commits.
This commit is contained in:
@ -1312,11 +1312,11 @@ public class Sketch {
|
|||||||
* @param buildPath Location to copy all the .java files
|
* @param buildPath Location to copy all the .java files
|
||||||
* @return null if compilation failed, main class name if not
|
* @return null if compilation failed, main class name if not
|
||||||
*/
|
*/
|
||||||
public String preprocess(String buildPath) throws RunnerException {
|
public void preprocess(String buildPath) throws RunnerException {
|
||||||
return preprocess(buildPath, new PdePreprocessor());
|
preprocess(buildPath, new PdePreprocessor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String preprocess(String buildPath, PdePreprocessor preprocessor) throws RunnerException {
|
public void preprocess(String buildPath, PdePreprocessor preprocessor) throws RunnerException {
|
||||||
// make sure the user didn't hide the sketch folder
|
// make sure the user didn't hide the sketch folder
|
||||||
ensureExistence();
|
ensureExistence();
|
||||||
|
|
||||||
@ -1372,18 +1372,12 @@ public class Sketch {
|
|||||||
// 2. run preproc on that code using the sugg class name
|
// 2. run preproc on that code using the sugg class name
|
||||||
// to create a single .java file and write to buildpath
|
// to create a single .java file and write to buildpath
|
||||||
|
|
||||||
String primaryClassName = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Output file
|
// Output file
|
||||||
File streamFile = new File(buildPath, name + ".cpp");
|
File streamFile = new File(buildPath, name + ".cpp");
|
||||||
FileOutputStream outputStream = new FileOutputStream(streamFile);
|
FileOutputStream outputStream = new FileOutputStream(streamFile);
|
||||||
preprocessor.write(outputStream);
|
preprocessor.write(outputStream);
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
|
|
||||||
// store this for the compiler and the runtime
|
|
||||||
primaryClassName = name + ".cpp";
|
|
||||||
|
|
||||||
} catch (FileNotFoundException fnfe) {
|
} catch (FileNotFoundException fnfe) {
|
||||||
fnfe.printStackTrace();
|
fnfe.printStackTrace();
|
||||||
String msg = _("Build folder disappeared or could not be written");
|
String msg = _("Build folder disappeared or could not be written");
|
||||||
@ -1432,7 +1426,6 @@ public class Sketch {
|
|||||||
sc.addPreprocOffset(headerOffset);
|
sc.addPreprocOffset(headerOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return primaryClassName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1538,7 +1531,8 @@ public class Sketch {
|
|||||||
public String build(String buildPath, boolean verbose) throws RunnerException {
|
public String build(String buildPath, boolean verbose) throws RunnerException {
|
||||||
// run the preprocessor
|
// run the preprocessor
|
||||||
editor.status.progressUpdate(20);
|
editor.status.progressUpdate(20);
|
||||||
String primaryClassName = preprocess(buildPath);
|
String primaryClassName = name + ".cpp";
|
||||||
|
preprocess(buildPath);
|
||||||
|
|
||||||
// compile the program. errors will happen as a RunnerException
|
// compile the program. errors will happen as a RunnerException
|
||||||
// that will bubble up to whomever called build().
|
// that will bubble up to whomever called build().
|
||||||
|
Reference in New Issue
Block a user