Preprocess and compile all the code for this sketch. In an advanced program, the returned class name could be different, which is why the className is set based on the return value. A compilation error will burp up a RunnerException. @return null if compilation failed, main class name if not
(boolean verbose, boolean save)
| 641 | * @return null if compilation failed, main class name if not |
| 642 | */ |
| 643 | public String build(boolean verbose, boolean save) throws RunnerException, PreferencesMapException, IOException { |
| 644 | // run the preprocessor |
| 645 | for (CompilerProgressListener progressListener : editor.status.getCompilerProgressListeners()){ |
| 646 | progressListener.progress(20); |
| 647 | } |
| 648 | |
| 649 | EditorConsole.setCurrentEditorConsole(editor.console); |
| 650 | |
| 651 | ensureExistence(); |
| 652 | |
| 653 | |
| 654 | boolean deleteTemp = false; |
| 655 | File pathToSketch = sketch.getPrimaryFile().getFile(); |
| 656 | if (sketch.isModified()) { |
| 657 | // If any files are modified, make a copy of the sketch with the changes |
| 658 | // saved, so arduino-builder will see the modifications. |
| 659 | pathToSketch = saveSketchInTempFolder(); |
| 660 | deleteTemp = true; |
| 661 | } |
| 662 | |
| 663 | try { |
| 664 | return new Compiler(pathToSketch, sketch).build(editor.status.getCompilerProgressListeners(), save); |
| 665 | } finally { |
| 666 | // Make sure we clean up any temporary sketch copy |
| 667 | if (deleteTemp) |
| 668 | FileUtils.recursiveDelete(pathToSketch.getParentFile()); |
| 669 | } |
| 670 | } |
| 671 | |
| 672 | private File saveSketchInTempFolder() throws IOException { |
| 673 | File tempFolder = FileUtils.createTempFolder("arduino_modified_sketch_"); |
no test coverage detected