mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-21 15:54:39 +01:00
Refactoring compile and upload to speed-up compilation, too.
This commit is contained in:
parent
a29866f7da
commit
24a0dfdf00
@ -1210,11 +1210,39 @@ public class Sketch {
|
|||||||
// won't be able to delete them, so we need to force a gc here
|
// won't be able to delete them, so we need to force a gc here
|
||||||
System.gc();
|
System.gc();
|
||||||
|
|
||||||
// note that we can't remove the builddir itself, otherwise
|
if (deleteFilesOnNextBuild) {
|
||||||
// the next time we start up, internal runs using Runner won't
|
// delete the entire directory and all contents
|
||||||
// work because the build dir won't exist at startup, so the classloader
|
// when we know something changed and all objects
|
||||||
// will ignore the fact that that dir is in the CLASSPATH in run.sh
|
// need to be recompiled, or if the board does not
|
||||||
Base.removeDescendants(tempBuildFolder);
|
// use setting build.dependency
|
||||||
|
//Base.removeDir(tempBuildFolder);
|
||||||
|
|
||||||
|
// note that we can't remove the builddir itself, otherwise
|
||||||
|
// the next time we start up, internal runs using Runner won't
|
||||||
|
// work because the build dir won't exist at startup, so the classloader
|
||||||
|
// will ignore the fact that that dir is in the CLASSPATH in run.sh
|
||||||
|
Base.removeDescendants(tempBuildFolder);
|
||||||
|
|
||||||
|
deleteFilesOnNextBuild = false;
|
||||||
|
} else {
|
||||||
|
// delete only stale source files, from the previously
|
||||||
|
// compiled sketch. This allows multiple windows to be
|
||||||
|
// used. Keep everything else, which might be reusable
|
||||||
|
if (tempBuildFolder.exists()) {
|
||||||
|
String files[] = tempBuildFolder.list();
|
||||||
|
for (String file : files) {
|
||||||
|
if (file.endsWith(".c") || file.endsWith(".cpp") || file.endsWith(".s")) {
|
||||||
|
File deleteMe = new File(tempBuildFolder, file);
|
||||||
|
if (!deleteMe.delete()) {
|
||||||
|
System.err.println("Could not delete " + deleteMe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a fresh applet folder (needed before preproc is run below)
|
||||||
|
//tempBuildFolder.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1612,49 +1640,12 @@ public class Sketch {
|
|||||||
*/
|
*/
|
||||||
public boolean exportApplet(String appletPath, boolean usingProgrammer)
|
public boolean exportApplet(String appletPath, boolean usingProgrammer)
|
||||||
throws RunnerException, IOException, SerialException {
|
throws RunnerException, IOException, SerialException {
|
||||||
|
|
||||||
// Make sure the user didn't hide the sketch folder
|
|
||||||
ensureExistence();
|
|
||||||
|
|
||||||
current.setProgram(editor.getText());
|
|
||||||
|
|
||||||
// Reload the code when an external editor is being used
|
|
||||||
if (Preferences.getBoolean("editor.external")) {
|
|
||||||
current = null;
|
|
||||||
// nuke previous files and settings
|
|
||||||
load();
|
|
||||||
}
|
|
||||||
|
|
||||||
File appletFolder = new File(appletPath);
|
|
||||||
if (deleteFilesOnNextBuild) {
|
|
||||||
// delete the entire directory and all contents
|
|
||||||
// when we know something changed and all objects
|
|
||||||
// need to be recompiled, or if the board does not
|
|
||||||
// use setting build.dependency
|
|
||||||
Base.removeDir(appletFolder);
|
|
||||||
deleteFilesOnNextBuild = false;
|
|
||||||
} else {
|
|
||||||
// delete only stale source files, from the previously
|
|
||||||
// compiled sketch. This allows multiple windows to be
|
|
||||||
// used. Keep everything else, which might be reusable
|
|
||||||
if (appletFolder.exists()) {
|
|
||||||
String files[] = appletFolder.list();
|
|
||||||
for (String file : files) {
|
|
||||||
if (file.endsWith(".c") || file.endsWith(".cpp") || file.endsWith(".s")) {
|
|
||||||
File deleteMe = new File(appletFolder, file);
|
|
||||||
if (!deleteMe.delete()) {
|
|
||||||
System.err.println("Could not delete " + deleteMe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Create a fresh applet folder (needed before preproc is run below)
|
|
||||||
appletFolder.mkdirs();
|
|
||||||
|
|
||||||
|
prepare();
|
||||||
|
|
||||||
// build the sketch
|
// build the sketch
|
||||||
editor.status.progressNotice(_("Compiling sketch..."));
|
editor.status.progressNotice(_("Compiling sketch..."));
|
||||||
String foundName = build(appletFolder.getPath(), false);
|
String foundName = build(appletPath, false);
|
||||||
// (already reported) error during export, exit this function
|
// (already reported) error during export, exit this function
|
||||||
if (foundName == null) return false;
|
if (foundName == null) return false;
|
||||||
|
|
||||||
@ -1668,7 +1659,7 @@ public class Sketch {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
editor.status.progressNotice(_("Uploading..."));
|
editor.status.progressNotice(_("Uploading..."));
|
||||||
upload(appletFolder.getPath(), foundName, usingProgrammer);
|
upload(appletPath, foundName, usingProgrammer);
|
||||||
editor.status.progressUpdate(100);
|
editor.status.progressUpdate(100);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user