Skip to content

Commit

Permalink
Tools path unversioned properties are adjusted right before compiling.
Browse files Browse the repository at this point in the history
This way, when multiple versions of, e.g., bossac are installed and
a platform uses bossac 1.5, core author will be able to specify just
tools.bossac.path={runtime.tools.bossac.path}
and the IDE will set it to right version of bossac
Fixes #3325
  • Loading branch information
Federico Fissore committed Jul 1, 2015
1 parent 32cf196 commit fef4e56
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
14 changes: 7 additions & 7 deletions arduino-core/src/processing/app/BaseNoGui.java
Expand Up @@ -21,7 +21,6 @@
import processing.app.packages.UserLibrary;

import java.io.*;
import java.net.URISyntaxException;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -635,7 +634,7 @@ static public void initPackages() throws Exception {
loadHardware(getHardwareFolder());
loadContributedHardware(indexer);
loadHardware(getSketchbookHardwareFolder());
createToolPreferences(indexer);
createToolPreferences(indexer.getInstalledTools(), true);

librariesIndexer = new LibrariesIndexer(BaseNoGui.getSettingsFolder(), indexer);
File librariesIndexFile = librariesIndexer.getIndexFile();
Expand Down Expand Up @@ -826,12 +825,13 @@ static protected void loadContributedHardware(ContributionsIndexer indexer) {
}
}

static private void createToolPreferences(ContributionsIndexer indexer) {
// Remove previous runtime preferences
final String prefix = "runtime.tools.";
PreferencesData.removeAllKeysWithPrefix(prefix);
public static void createToolPreferences(Collection<ContributedTool> installedTools, boolean removeOldKeys) {
String prefix = "runtime.tools.";
if (removeOldKeys) {
PreferencesData.removeAllKeysWithPrefix(prefix);
}

for (ContributedTool tool : indexer.getInstalledTools()) {
for (ContributedTool tool : installedTools) {
File installedFolder = tool.getDownloadableContribution(getPlatform()).getInstalledFolder();
if (installedFolder != null) {
PreferencesData.set(prefix + tool.getName() + ".path", installedFolder.getAbsolutePath());
Expand Down
10 changes: 9 additions & 1 deletion arduino-core/src/processing/app/debug/Compiler.java
Expand Up @@ -34,6 +34,8 @@
import java.util.stream.Stream;

import cc.arduino.MyStreamPumper;
import cc.arduino.contributions.packages.ContributedPlatform;
import cc.arduino.contributions.packages.ContributedTool;
import cc.arduino.packages.BoardPort;
import cc.arduino.packages.Uploader;
import cc.arduino.packages.UploaderFactory;
Expand Down Expand Up @@ -613,7 +615,13 @@ private PreferencesMap createBuildPreferences(String _buildPath,
} else {
p.put("build.variant.path", "");
}


ContributedPlatform installedPlatform = BaseNoGui.indexer.getInstalled(referencePlatform.getContainerPackage().getId(), referencePlatform.getId());
if (installedPlatform != null) {
List<ContributedTool> tools = installedPlatform.getResolvedTools();
BaseNoGui.createToolPreferences(tools, false);
}

// Build Time
Date d = new Date();
GregorianCalendar cal = new GregorianCalendar();
Expand Down

0 comments on commit fef4e56

Please sign in to comment.