From beac88e039be8b406db8011ec90f4192cbc3ca13 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 29 Oct 2013 14:40:49 +0100 Subject: [PATCH] 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. --- app/src/processing/app/Sketch.java | 4 ++-- app/src/processing/app/debug/Compiler.java | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 33f4111ef..3376ee18a 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -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; } diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 7cbba74c5..5bdb7d2e9 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -62,26 +62,30 @@ public class Compiler implements MessageConsumer { private String targetArch; 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(); - prefs = createBuildPreferences(_buildPath, _primaryClassName); - // 0. include paths for core + all libraries sketch.setCompilingProgress(20); List includePaths = new ArrayList();