Pass arguments to the Compiler constructor

Previously, these arguments would be passed to the compile method.
However, passing them to the constructor makes sure that the build
preferences are created sooner, so they can be used by Sketch before
calling the compile method.

This commit shouldn't change any behaviour, but prepares for the next
commits.
This commit is contained in:
Matthijs Kooijman 2013-10-29 14:40:49 +01:00
parent 57551b9e79
commit beac88e039
2 changed files with 15 additions and 11 deletions

View File

@ -1542,8 +1542,8 @@ public class Sketch {
// compile the program. errors will happen as a RunnerException
// that will bubble up to whomever called build().
Compiler compiler = new Compiler();
if (compiler.compile(this, buildPath, primaryClassName, verbose)) {
Compiler compiler = new Compiler(this, buildPath, primaryClassName);
if (compiler.compile(verbose)) {
size(compiler.getBuildPreferences());
return primaryClassName;
}

View File

@ -64,24 +64,28 @@ public class Compiler implements MessageConsumer {
private RunnerException exception;
/**
* Compile sketch.
*
* Create a new Compiler
* @param _sketch Sketch object to be compiled.
* @param _buildPath Where the temporary files live and will be built from.
* @param _primaryClassName the name of the combined sketch file w/ extension
*/
public Compiler(Sketch _sketch, String _buildPath, String _primaryClassName)
throws RunnerException {
sketch = _sketch;
prefs = createBuildPreferences(_buildPath, _primaryClassName);
}
/**
* Compile sketch.
*
* @return true if successful.
* @throws RunnerException Only if there's a problem. Only then.
*/
public boolean compile(Sketch _sketch, String _buildPath,
String _primaryClassName, boolean _verbose)
throws RunnerException {
sketch = _sketch;
public boolean compile(boolean _verbose) throws RunnerException {
verbose = _verbose || Preferences.getBoolean("build.verbose");
sketchIsCompiled = false;
objectFiles = new ArrayList<File>();
prefs = createBuildPreferences(_buildPath, _primaryClassName);
// 0. include paths for core + all libraries
sketch.setCompilingProgress(20);
List<String> includePaths = new ArrayList<String>();