1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-15 12:29:26 +01:00

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(); enableCodeFoldingBox = new javax.swing.JCheckBox();
verifyUploadBox = new javax.swing.JCheckBox(); verifyUploadBox = new javax.swing.JCheckBox();
externalEditorBox = new javax.swing.JCheckBox(); externalEditorBox = new javax.swing.JCheckBox();
cacheCompiledCore = new javax.swing.JCheckBox();
checkUpdatesBox = new javax.swing.JCheckBox(); checkUpdatesBox = new javax.swing.JCheckBox();
updateExtensionBox = new javax.swing.JCheckBox(); updateExtensionBox = new javax.swing.JCheckBox();
saveVerifyUploadBox = 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")); externalEditorBox.setText(tr("Use external editor"));
checkboxesContainer.add(externalEditorBox); checkboxesContainer.add(externalEditorBox);
cacheCompiledCore.setText(tr("Aggressively cache compiled core"));
checkboxesContainer.add(cacheCompiledCore);
checkUpdatesBox.setText(tr("Check for updates on startup")); checkUpdatesBox.setText(tr("Check for updates on startup"));
checkboxesContainer.add(checkUpdatesBox); checkboxesContainer.add(checkUpdatesBox);
@ -678,6 +682,7 @@ public class Preferences extends javax.swing.JDialog {
private javax.swing.JCheckBox enableCodeFoldingBox; private javax.swing.JCheckBox enableCodeFoldingBox;
private javax.swing.JButton extendedAdditionalUrlFieldWindow; private javax.swing.JButton extendedAdditionalUrlFieldWindow;
private javax.swing.JCheckBox externalEditorBox; private javax.swing.JCheckBox externalEditorBox;
private javax.swing.JCheckBox cacheCompiledCore;
private javax.swing.JTextField fontSizeField; private javax.swing.JTextField fontSizeField;
private javax.swing.JLabel fontSizeLabel; private javax.swing.JLabel fontSizeLabel;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
@ -772,6 +777,8 @@ public class Preferences extends javax.swing.JDialog {
PreferencesData.setBoolean("editor.external", externalEditorBox.isSelected()); PreferencesData.setBoolean("editor.external", externalEditorBox.isSelected());
PreferencesData.setBoolean("compiler.cache_core", cacheCompiledCore.isSelected());
PreferencesData.setBoolean("update.check", checkUpdatesBox.isSelected()); PreferencesData.setBoolean("update.check", checkUpdatesBox.isSelected());
PreferencesData.setBoolean("editor.update_extension", updateExtensionBox.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")); 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")); checkUpdatesBox.setSelected(PreferencesData.getBoolean("update.check"));
updateExtensionBox.setSelected(PreferencesData.get("editor.update_extension") == null || PreferencesData.getBoolean("editor.update_extension")); 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 File pathToSketch;
private final Sketch sketch; private final Sketch sketch;
private String buildPath; private String buildPath;
private File buildCache;
private final boolean verbose; private final boolean verbose;
private RunnerException exception; private RunnerException exception;
@ -159,6 +160,7 @@ public class Compiler implements MessageConsumer {
public String build(ArrayList<CompilerProgressListener> progListeners, boolean exportHex) throws RunnerException, PreferencesMapException, IOException { public String build(ArrayList<CompilerProgressListener> progListeners, boolean exportHex) throws RunnerException, PreferencesMapException, IOException {
this.buildPath = sketch.getBuildPath().getAbsolutePath(); this.buildPath = sketch.getBuildPath().getAbsolutePath();
this.buildCache = BaseNoGui.getCachePath();
TargetBoard board = BaseNoGui.getTargetBoard(); TargetBoard board = BaseNoGui.getTargetBoard();
if (board == null) { if (board == null) {
@ -258,6 +260,11 @@ public class Compiler implements MessageConsumer {
cmd.add(buildPath); cmd.add(buildPath);
cmd.add("-warnings=" + PreferencesData.get("compiler.warning_level")); 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() PreferencesData.getMap()
.subTree("runtime.build_properties_custom") .subTree("runtime.build_properties_custom")
.entrySet() .entrySet()

View File

@ -21,6 +21,9 @@ import processing.app.legacy.PApplet;
import processing.app.packages.LibraryList; import processing.app.packages.LibraryList;
import processing.app.packages.UserLibrary; import processing.app.packages.UserLibrary;
import cc.arduino.files.DeleteFilesOnShutdown;
import processing.app.helpers.FileUtils;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeSupport;
import java.io.File; import java.io.File;
@ -100,6 +103,8 @@ public class BaseNoGui {
private static String boardManagerLink = ""; private static String boardManagerLink = "";
private static File buildCache;
// Returns a File object for the given pathname. If the pathname // Returns a File object for the given pathname. If the pathname
// is not absolute, it is interpreted relative to the current // is not absolute, it is interpreted relative to the current
// directory when starting the IDE (which is not the same as the // directory when starting the IDE (which is not the same as the
@ -256,6 +261,18 @@ public class BaseNoGui {
return portableSketchbookFolder; 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 * Convenience method to get a File object for the specified filename inside
* the settings folder. * the settings folder.