|
12 | 12 | import java.util.ArrayList;
|
13 | 13 | import java.util.Arrays;
|
14 | 14 | import java.util.Collections;
|
15 |
| -import java.util.HashMap; |
16 | 15 | import java.util.List;
|
17 | 16 | import java.util.Map;
|
18 | 17 | import java.util.Map.Entry;
|
|
58 | 57 | import io.sloeber.core.api.BoardDescriptor;
|
59 | 58 | import io.sloeber.core.api.CompileOptions;
|
60 | 59 | import io.sloeber.core.api.Defaults;
|
| 60 | +import io.sloeber.core.api.PackageManager; |
61 | 61 | import io.sloeber.core.api.Preferences;
|
62 | 62 | import io.sloeber.core.common.Common;
|
63 | 63 | import io.sloeber.core.common.ConfigurationPreferences;
|
64 | 64 | import io.sloeber.core.common.Const;
|
65 | 65 | import io.sloeber.core.managers.ArduinoPlatform;
|
66 | 66 | import io.sloeber.core.managers.InternalPackageManager;
|
67 | 67 | import io.sloeber.core.managers.Library;
|
68 |
| -import io.sloeber.core.managers.Package; |
69 | 68 | import io.sloeber.core.managers.Tool;
|
70 | 69 | import io.sloeber.core.managers.ToolDependency;
|
71 | 70 |
|
@@ -644,8 +643,11 @@ private static boolean isLocalKey(String key) {
|
644 | 643 |
|
645 | 644 | }
|
646 | 645 |
|
647 |
| - private static void addPlatformFileTools(ArduinoPlatform platform, IContributedEnvironment contribEnv, |
| 646 | + public static void addPlatformFileTools(ArduinoPlatform platform, IContributedEnvironment contribEnv, |
648 | 647 | ICConfigurationDescription confDesc, boolean reportToolNotFound) {
|
| 648 | + if(platform==null) { |
| 649 | + return; |
| 650 | + } |
649 | 651 | if (platform.getToolsDependencies() == null) {
|
650 | 652 | return;
|
651 | 653 | }
|
@@ -680,48 +682,22 @@ private static void addDependentTools(Iterable<ToolDependency> tools, IContribut
|
680 | 682 | private static void setTheEnvironmentVariablesAddThePlatformInfo(BoardDescriptor boardDescriptor,
|
681 | 683 | IContributedEnvironment contribEnv, ICConfigurationDescription confDesc) {
|
682 | 684 |
|
683 |
| - String architecture = boardDescriptor.getArchitecture(); |
684 |
| - HashMap<String, ToolDependency> allTools = new HashMap<>(); |
685 |
| - for (ArduinoPlatform curPlatform : InternalPackageManager.getInstalledPlatforms()) { |
686 |
| - addPlatformFileTools(curPlatform, contribEnv, confDesc, false); |
687 |
| - if (architecture.equals(curPlatform.getArchitecture())) { |
688 |
| - Package pkg = curPlatform.getPackage(); |
689 |
| - if (pkg != null) { |
690 |
| - if (curPlatform.getToolsDependencies() != null) { |
691 |
| - for (ToolDependency curDependency : curPlatform.getToolsDependencies()) { |
692 |
| - String name = curDependency.getName(); |
693 |
| - ToolDependency previousDependency = allTools.get(name); |
694 |
| - if (previousDependency == null) { |
695 |
| - allTools.put(name, curDependency); |
696 |
| - } else { |
697 |
| - String prevVersion = previousDependency.getVersion().toLowerCase(); |
698 |
| - String curVersion = curDependency.getVersion(); |
699 |
| - if (Version.compare(curVersion, prevVersion) == 1) { |
700 |
| - allTools.put(name, curDependency); |
701 |
| - } |
702 |
| - } |
703 |
| - } |
704 |
| - } |
705 |
| - } |
706 |
| - } |
707 |
| - } |
708 |
| - addDependentTools(allTools.values(), contribEnv, confDesc, false); |
| 685 | + //update the gobal variables if needed |
| 686 | + PackageManager.updateGlobalEnvironmentVariables(); |
| 687 | + File referencingPlatformFile = boardDescriptor.getReferencingPlatformFile(); |
| 688 | + File referencedPlatformFile = boardDescriptor.getreferencedPlatformFile(); |
| 689 | + ArduinoPlatform referencingPlatform = InternalPackageManager.getPlatform(referencingPlatformFile); |
| 690 | + ArduinoPlatform referencedPlatform = InternalPackageManager.getPlatform(referencedPlatformFile); |
709 | 691 |
|
710 |
| - // overrule the Arduino IDE way of working and use the json refereced tools |
711 | 692 | boolean jsonBasedPlatformManagement = !Preferences.getUseArduinoToolSelection();
|
712 | 693 | if (jsonBasedPlatformManagement) {
|
713 |
| - File referencingPlatformFile = boardDescriptor.getReferencingPlatformFile(); |
714 |
| - File referencedPlatformFile = boardDescriptor.getreferencedPlatformFile(); |
715 |
| - // add the referenced platform before the real platform |
716 |
| - ArduinoPlatform referencedPlatform = InternalPackageManager.getPlatform(referencedPlatformFile); |
717 |
| - if (referencedPlatform != null) { |
718 |
| - addPlatformFileTools(referencedPlatform, contribEnv, confDesc, true); |
719 |
| - } |
720 |
| - // and the real platform |
721 |
| - ArduinoPlatform referencingPlatform = InternalPackageManager.getPlatform(referencingPlatformFile); |
722 |
| - if (referencingPlatform != null) { |
723 |
| - addPlatformFileTools(referencingPlatform, contribEnv, confDesc, false); |
724 |
| - } |
| 694 | + // overrule the Arduino IDE way of working and use the json refereced tools |
| 695 | + addPlatformFileTools(referencedPlatform, contribEnv, confDesc, true); |
| 696 | + addPlatformFileTools(referencingPlatform, contribEnv, confDesc, false); |
| 697 | + } else { |
| 698 | + //standard arduino IDE way |
| 699 | + addPlatformFileTools(referencingPlatform, contribEnv, confDesc, false); |
| 700 | + addPlatformFileTools(referencedPlatform, contribEnv, confDesc, true); |
725 | 701 | }
|
726 | 702 | }
|
727 | 703 |
|
|
0 commit comments