Skip to content

Commit beac88e

Browse files
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.
1 parent 57551b9 commit beac88e

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

app/src/processing/app/Sketch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,8 +1542,8 @@ public String build(String buildPath, boolean verbose) throws RunnerException {
15421542

15431543
// compile the program. errors will happen as a RunnerException
15441544
// that will bubble up to whomever called build().
1545-
Compiler compiler = new Compiler();
1546-
if (compiler.compile(this, buildPath, primaryClassName, verbose)) {
1545+
Compiler compiler = new Compiler(this, buildPath, primaryClassName);
1546+
if (compiler.compile(verbose)) {
15471547
size(compiler.getBuildPreferences());
15481548
return primaryClassName;
15491549
}

app/src/processing/app/debug/Compiler.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,30 @@ public class Compiler implements MessageConsumer {
6262
private String targetArch;
6363

6464
private RunnerException exception;
65-
65+
6666
/**
67-
* Compile sketch.
68-
*
67+
* Create a new Compiler
6968
* @param _sketch Sketch object to be compiled.
7069
* @param _buildPath Where the temporary files live and will be built from.
7170
* @param _primaryClassName the name of the combined sketch file w/ extension
72-
* @return true if successful.
73-
* @throws RunnerException Only if there's a problem. Only then.
7471
*/
75-
public boolean compile(Sketch _sketch, String _buildPath,
76-
String _primaryClassName, boolean _verbose)
72+
public Compiler(Sketch _sketch, String _buildPath, String _primaryClassName)
7773
throws RunnerException {
7874
sketch = _sketch;
75+
prefs = createBuildPreferences(_buildPath, _primaryClassName);
76+
}
77+
78+
/**
79+
* Compile sketch.
80+
*
81+
* @return true if successful.
82+
* @throws RunnerException Only if there's a problem. Only then.
83+
*/
84+
public boolean compile(boolean _verbose) throws RunnerException {
7985
verbose = _verbose || Preferences.getBoolean("build.verbose");
8086
sketchIsCompiled = false;
8187
objectFiles = new ArrayList<File>();
8288

83-
prefs = createBuildPreferences(_buildPath, _primaryClassName);
84-
8589
// 0. include paths for core + all libraries
8690
sketch.setCompilingProgress(20);
8791
List<String> includePaths = new ArrayList<String>();

0 commit comments

Comments
 (0)