29
29
30
30
package cc .arduino ;
31
31
32
+ import cc .arduino .cli .ArduinoCoreInstance ;
32
33
import cc .arduino .i18n .I18NAwareMessageConsumer ;
33
34
import cc .arduino .packages .BoardPort ;
34
35
import org .apache .commons .exec .CommandLine ;
@@ -142,6 +143,7 @@ enum BuilderAction {
142
143
private File buildCache ;
143
144
private final boolean verbose ;
144
145
private RunnerException exception ;
146
+ private ArduinoCoreInstance core ;
145
147
146
148
public Compiler (Sketch data ) {
147
149
this (data .getPrimaryFile ().getFile (), data );
@@ -150,6 +152,7 @@ public Compiler(Sketch data) {
150
152
public Compiler (File pathToSketch , Sketch sketch ) {
151
153
this .pathToSketch = pathToSketch ;
152
154
this .sketch = sketch ;
155
+ this .core = BaseNoGui .getArduinoCoreService ();
153
156
this .verbose = PreferencesData .getBoolean ("build.verbose" );
154
157
}
155
158
@@ -209,18 +212,7 @@ private String VIDPID() {
209
212
}
210
213
211
214
private PreferencesMap loadPreferences (TargetBoard board , TargetPlatform platform , TargetPackage aPackage , String vidpid ) throws RunnerException , IOException {
212
- ByteArrayOutputStream stdout = new ByteArrayOutputStream ();
213
- ByteArrayOutputStream stderr = new ByteArrayOutputStream ();
214
- MessageConsumerOutputStream err = new MessageConsumerOutputStream (new I18NAwareMessageConsumer (new PrintStream (stderr ), Compiler .this ), "\n " );
215
- try {
216
- callArduinoBuilder (board , platform , aPackage , vidpid , BuilderAction .DUMP_PREFS , stdout , err );
217
- } catch (RunnerException e ) {
218
- System .err .println (new String (stderr .toByteArray ()));
219
- throw e ;
220
- }
221
- PreferencesMap prefs = new PreferencesMap ();
222
- prefs .load (new ByteArrayInputStream (stdout .toByteArray ()));
223
- return prefs ;
215
+ return new PreferencesMap ();
224
216
}
225
217
226
218
private void addPathFlagIfPathExists (List <String > cmd , String flag , File folder ) {
@@ -294,7 +286,9 @@ private void callArduinoBuilder(TargetBoard board, TargetPlatform platform, Targ
294
286
295
287
int result ;
296
288
try {
297
- Process proc = ProcessUtils .exec (cmd .toArray (new String [0 ]));
289
+ core .compile (fqbn , pathToSketch .getAbsolutePath ());
290
+
291
+ /*
298
292
MessageSiphon in = new MessageSiphon(proc.getInputStream(), (msg) -> {
299
293
try {
300
294
outStream.write(msg.getBytes());
@@ -313,18 +307,12 @@ private void callArduinoBuilder(TargetBoard board, TargetPlatform platform, Targ
313
307
in.join();
314
308
err.join();
315
309
result = proc.waitFor();
310
+ */
316
311
} catch (Exception e ) {
317
312
throw new RunnerException (e );
318
313
}
319
314
320
- if (exception != null )
321
- throw exception ;
322
-
323
- if (result > 1 ) {
324
- System .err .println (I18n .format (tr ("{0} returned {1}" ), cmd .get (0 ), result ));
325
- }
326
-
327
- if (result != 0 ) {
315
+ if (exception != null ) {
328
316
RunnerException re = new RunnerException (I18n .format (tr ("Error compiling for board {0}." ), board .getName ()));
329
317
re .hideStackTrace ();
330
318
throw re ;
0 commit comments