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:
Matthijs Kooijman 2013-10-29 14:57:31 +01:00
parent beac88e039
commit 7b7f447a4a
1 changed files with 5 additions and 11 deletions

View File

@ -1312,11 +1312,11 @@ public class Sketch {
* @param buildPath Location to copy all the .java files
* @return null if compilation failed, main class name if not
*/
public String preprocess(String buildPath) throws RunnerException {
return preprocess(buildPath, new PdePreprocessor());
public void preprocess(String buildPath) throws RunnerException {
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
ensureExistence();
@ -1372,18 +1372,12 @@ public class Sketch {
// 2. run preproc on that code using the sugg class name
// to create a single .java file and write to buildpath
String primaryClassName = null;
try {
// Output file
File streamFile = new File(buildPath, name + ".cpp");
FileOutputStream outputStream = new FileOutputStream(streamFile);
preprocessor.write(outputStream);
outputStream.close();
// store this for the compiler and the runtime
primaryClassName = name + ".cpp";
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
String msg = _("Build folder disappeared or could not be written");
@ -1432,7 +1426,6 @@ public class Sketch {
sc.addPreprocOffset(headerOffset);
}
}
return primaryClassName;
}
@ -1538,7 +1531,8 @@ public class Sketch {
public String build(String buildPath, boolean verbose) throws RunnerException {
// run the preprocessor
editor.status.progressUpdate(20);
String primaryClassName = preprocess(buildPath);
String primaryClassName = name + ".cpp";
preprocess(buildPath);
// compile the program. errors will happen as a RunnerException
// that will bubble up to whomever called build().