add preference checkbox for core cache

This commit is contained in:
Martino Facchin 2017-03-20 12:46:42 +01:00 committed by Cristian Maglie
parent 2efa09507a
commit 5b6adec95f
3 changed files with 35 additions and 2 deletions

View File

@ -128,6 +128,7 @@ public class Preferences extends javax.swing.JDialog {
enableCodeFoldingBox = new javax.swing.JCheckBox();
verifyUploadBox = new javax.swing.JCheckBox();
externalEditorBox = new javax.swing.JCheckBox();
cacheCompiledCore = new javax.swing.JCheckBox();
checkUpdatesBox = new javax.swing.JCheckBox();
updateExtensionBox = new javax.swing.JCheckBox();
saveVerifyUploadBox = new javax.swing.JCheckBox();
@ -244,6 +245,9 @@ public class Preferences extends javax.swing.JDialog {
externalEditorBox.setText(tr("Use external editor"));
checkboxesContainer.add(externalEditorBox);
cacheCompiledCore.setText(tr("Aggressively cache compiled core"));
checkboxesContainer.add(cacheCompiledCore);
checkUpdatesBox.setText(tr("Check for updates on startup"));
checkboxesContainer.add(checkUpdatesBox);
@ -678,6 +682,7 @@ public class Preferences extends javax.swing.JDialog {
private javax.swing.JCheckBox enableCodeFoldingBox;
private javax.swing.JButton extendedAdditionalUrlFieldWindow;
private javax.swing.JCheckBox externalEditorBox;
private javax.swing.JCheckBox cacheCompiledCore;
private javax.swing.JTextField fontSizeField;
private javax.swing.JLabel fontSizeLabel;
private javax.swing.JLabel jLabel1;
@ -772,6 +777,8 @@ public class Preferences extends javax.swing.JDialog {
PreferencesData.setBoolean("editor.external", externalEditorBox.isSelected());
PreferencesData.setBoolean("compiler.cache_core", cacheCompiledCore.isSelected());
PreferencesData.setBoolean("update.check", checkUpdatesBox.isSelected());
PreferencesData.setBoolean("editor.update_extension", updateExtensionBox.isSelected());
@ -832,6 +839,8 @@ public class Preferences extends javax.swing.JDialog {
externalEditorBox.setSelected(PreferencesData.getBoolean("editor.external"));
cacheCompiledCore.setSelected(PreferencesData.get("compiler.cache_core") == null || PreferencesData.getBoolean("compiler.cache_core"));
checkUpdatesBox.setSelected(PreferencesData.getBoolean("update.check"));
updateExtensionBox.setSelected(PreferencesData.get("editor.update_extension") == null || PreferencesData.getBoolean("editor.update_extension"));

View File

@ -138,6 +138,7 @@ public class Compiler implements MessageConsumer {
private final File pathToSketch;
private final Sketch sketch;
private String buildPath;
private File buildCache;
private final boolean verbose;
private RunnerException exception;
@ -156,9 +157,10 @@ public class Compiler implements MessageConsumer {
listeners.add(progListener);
return this.build(listeners, exportHex);
}
public String build(ArrayList<CompilerProgressListener> progListeners, boolean exportHex) throws RunnerException, PreferencesMapException, IOException {
this.buildPath = sketch.getBuildPath().getAbsolutePath();
this.buildCache = BaseNoGui.getCachePath();
TargetBoard board = BaseNoGui.getTargetBoard();
if (board == null) {
@ -258,6 +260,11 @@ public class Compiler implements MessageConsumer {
cmd.add(buildPath);
cmd.add("-warnings=" + PreferencesData.get("compiler.warning_level"));
if (PreferencesData.getBoolean("compiler.cache_core") == true && buildCache != null) {
cmd.add("-build-cache");
cmd.add(buildCache.getAbsolutePath());
}
PreferencesData.getMap()
.subTree("runtime.build_properties_custom")
.entrySet()

View File

@ -21,6 +21,9 @@ import processing.app.legacy.PApplet;
import processing.app.packages.LibraryList;
import processing.app.packages.UserLibrary;
import cc.arduino.files.DeleteFilesOnShutdown;
import processing.app.helpers.FileUtils;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.File;
@ -100,6 +103,8 @@ public class BaseNoGui {
private static String boardManagerLink = "";
private static File buildCache;
// Returns a File object for the given pathname. If the pathname
// is not absolute, it is interpreted relative to the current
// directory when starting the IDE (which is not the same as the
@ -131,7 +136,7 @@ public class BaseNoGui {
if (board == null)
return null;
String boardId = board.getId();
PreferencesMap prefs = new PreferencesMap(board.getPreferences());
String extendedName = prefs.get("name");
@ -256,6 +261,18 @@ public class BaseNoGui {
return portableSketchbookFolder;
}
static public File getCachePath() {
if (buildCache == null) {
try {
buildCache = FileUtils.createTempFolder("arduino_cache_");
DeleteFilesOnShutdown.add(buildCache);
} catch (IOException e) {
return null;
}
}
return buildCache;
}
/**
* Convenience method to get a File object for the specified filename inside
* the settings folder.