diff --git a/images_plugin_dev_setup/SVG_Logo/splash.svg b/images_plugin_dev_setup/SVG_Logo/splash.svg
index 22c2eb0e3..d624f2ffa 100644
--- a/images_plugin_dev_setup/SVG_Logo/splash.svg
+++ b/images_plugin_dev_setup/SVG_Logo/splash.svg
@@ -9,7 +9,7 @@
version="1.1"
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
sodipodi:docname="splash.svg"
- inkscape:export-filename="..\..\..\..\..\..\test\splash.png"
+ inkscape:export-filename="..\..\..\..\Desktop\splash.jpg"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
xml:space="preserve"
@@ -28,16 +28,16 @@
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:zoom="1"
- inkscape:cx="-262.5"
+ inkscape:cx="-345"
inkscape:cy="-55.5"
inkscape:document-units="px"
inkscape:current-layer="layer4"
showgrid="false"
units="px"
inkscape:window-width="1920"
- inkscape:window-height="991"
- inkscape:window-x="-9"
- inkscape:window-y="-9"
+ inkscape:window-height="1009"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:snap-global="false"
showguides="true"
@@ -2678,7 +2678,7 @@
id="tspan4789"
x="315.39621"
y="212.03772"
- style="font-size:25px;line-height:1.25">BerylliumBoron
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/io.sloeber.autoBuild.test/.settings/org.eclipse.jdt.core.prefs b/io.sloeber.autoBuild.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..23fa13b17
--- /dev/null
+++ b/io.sloeber.autoBuild.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,9 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
+org.eclipse.jdt.core.compiler.compliance=21
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=21
diff --git a/io.sloeber.autoBuild.test/META-INF/MANIFEST.MF b/io.sloeber.autoBuild.test/META-INF/MANIFEST.MF
index 1166e9fdb..4f2c8325f 100644
--- a/io.sloeber.autoBuild.test/META-INF/MANIFEST.MF
+++ b/io.sloeber.autoBuild.test/META-INF/MANIFEST.MF
@@ -7,7 +7,6 @@ Require-Bundle: io.sloeber.autoBuild,
junit-jupiter-api;bundle-version="5.0.0",
junit-jupiter-params;bundle-version="5.0.0",
org.eclipse.core.resources,
- org.apache.log4j;bundle-version="1.2.24",
org.eclipse.cdt.core;bundle-version="7.4.200",
org.eclipse.osgi,
org.eclipse.core.jobs,
@@ -22,4 +21,4 @@ Require-Bundle: io.sloeber.autoBuild,
junit-platform-engine;bundle-version="1.10.2",
junit-platform-suite-api;bundle-version="1.10.2"
Automatic-Module-Name: io.sloeber.autoBuild.test
-Bundle-RequiredExecutionEnvironment: JavaSE-17
+Bundle-RequiredExecutionEnvironment: JavaSE-21
diff --git a/io.sloeber.autoBuild.test/launch/AutoBuildRegression_linux_jantje.launch b/io.sloeber.autoBuild.test/launch/AutoBuildRegression_linux_jantje.launch
new file mode 100644
index 000000000..5679f78c0
--- /dev/null
+++ b/io.sloeber.autoBuild.test/launch/AutoBuildRegression_linux_jantje.launch
@@ -0,0 +1,308 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/io.sloeber.autoBuild.test/src/io/sloeber/autoBuilld/investigate/CConfigurationDescriptionInvestigation.java b/io.sloeber.autoBuild.test/src/io/sloeber/autoBuilld/investigate/CConfigurationDescriptionInvestigation.java
deleted file mode 100644
index 4895e1489..000000000
--- a/io.sloeber.autoBuild.test/src/io/sloeber/autoBuilld/investigate/CConfigurationDescriptionInvestigation.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package io.sloeber.autoBuilld.investigate;
-
-import static io.sloeber.autoBuild.helpers.Defaults.*;
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICFolderDescription;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescription;
-import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCache;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-
-import io.sloeber.autoBuild.api.AutoBuildProject;
-import io.sloeber.autoBuild.buildTools.api.IBuildTools;
-import io.sloeber.autoBuild.buildTools.api.IBuildToolsManager;
-import io.sloeber.autoBuild.helpers.Shared;
-
-@SuppressWarnings({ "restriction", "nls", "static-method" })
-public class CConfigurationDescriptionInvestigation {
- static int testCounter = 1;
-
- @BeforeAll
- static void beforeAll() {
- Shared.setDeleteProjects(false);
- Shared.setCloseProjects(false);
- // turn off auto building to make sure autobuild does not start a build behind our backs
- final IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceDescription workspaceDesc = workspace.getDescription();
- workspaceDesc.setAutoBuilding(false);
- }
-
- @Test
- public void testConfigDescription() {
- String projectName = "testConfigDescription";
- IBuildTools buildTools = IBuildToolsManager.getDefault().getAnyInstalledBuildTools(defaultProjectType);
- IProject testProject = AutoBuildProject.createProject(projectName, defaultProjectType, defaultNatureID, cpp_exeCodeProvider, buildTools, false, null);
- ICProjectDescription projectDesc = CoreModel.getDefault().getProjectDescription(testProject, true);
- for (ICConfigurationDescription curConf : projectDesc.getConfigurations()) {
- assertFalse( curConf instanceof CConfigurationDescriptionCache,"conf is readOnly class instance");
- assertTrue( curConf instanceof CConfigurationDescription,"conf is of a unknown class instance");
- ICFolderDescription orgDescription = curConf.getRootFolderDescription();
- curConf.setDescription("A nice description");
- ICFolderDescription newDescription = curConf.getRootFolderDescription();
- }
- }
-
-}
diff --git a/io.sloeber.autoBuild.ui/.classpath b/io.sloeber.autoBuild.ui/.classpath
index 3628e3368..35386b94b 100644
--- a/io.sloeber.autoBuild.ui/.classpath
+++ b/io.sloeber.autoBuild.ui/.classpath
@@ -1,6 +1,6 @@
-
+
diff --git a/io.sloeber.autoBuild.ui/.settings/org.eclipse.jdt.core.prefs b/io.sloeber.autoBuild.ui/.settings/org.eclipse.jdt.core.prefs
index 62ef3488c..23fa13b17 100644
--- a/io.sloeber.autoBuild.ui/.settings/org.eclipse.jdt.core.prefs
+++ b/io.sloeber.autoBuild.ui/.settings/org.eclipse.jdt.core.prefs
@@ -1,9 +1,9 @@
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
-org.eclipse.jdt.core.compiler.compliance=17
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
+org.eclipse.jdt.core.compiler.compliance=21
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=17
+org.eclipse.jdt.core.compiler.source=21
diff --git a/io.sloeber.autoBuild.ui/META-INF/MANIFEST.MF b/io.sloeber.autoBuild.ui/META-INF/MANIFEST.MF
index 00fec2362..60e7d1c63 100644
--- a/io.sloeber.autoBuild.ui/META-INF/MANIFEST.MF
+++ b/io.sloeber.autoBuild.ui/META-INF/MANIFEST.MF
@@ -17,7 +17,7 @@ Require-Bundle: org.eclipse.tools.templates.ui,
org.eclipse.core.filesystem,
io.sloeber.autoBuild;bundle-version="4.4.1",
org.eclipse.tools.templates.core;bundle-version="2.0.0"
-Bundle-RequiredExecutionEnvironment: JavaSE-17
+Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-Vendor: Sloeber.io
Bundle-ActivationPolicy: lazy
Bundle-Activator: io.sloeber.autoBuild.ui.internal.Activator
diff --git a/io.sloeber.autoBuild.ui/build.properties b/io.sloeber.autoBuild.ui/build.properties
index 0f364769b..b89543b23 100644
--- a/io.sloeber.autoBuild.ui/build.properties
+++ b/io.sloeber.autoBuild.ui/build.properties
@@ -5,5 +5,6 @@ bin.includes = .,\
plugin.properties,\
META-INF/,\
OSGI-INF/,\
- OSGI-INF/l10n/bundle.properties
+ OSGI-INF/l10n/bundle.properties,\
+ icons/
jars.compile.order = .
diff --git a/io.sloeber.autoBuild.ui/src/io/sloeber/autoBuild/ui/tabs/ToolSettingsTab.java b/io.sloeber.autoBuild.ui/src/io/sloeber/autoBuild/ui/tabs/ToolSettingsTab.java
index 8b955e28a..09bd26406 100644
--- a/io.sloeber.autoBuild.ui/src/io/sloeber/autoBuild/ui/tabs/ToolSettingsTab.java
+++ b/io.sloeber.autoBuild.ui/src/io/sloeber/autoBuild/ui/tabs/ToolSettingsTab.java
@@ -216,7 +216,7 @@ public void controlResized(ControlEvent e) {
} else {
//the line below is only here for development so I know there will only be resources
//TODO remove the line below after evaluation this never ever happens
- System.err.println("Element should be resource " + pageElement);
+ System.err.println("Element should be resource " + pageElement); //$NON-NLS-1$
}
setValues();
@@ -280,17 +280,6 @@ protected void updateTipText(String name, String tip) {
tipText.update();
}
- /* (non-Javadoc)
- * Method resetTipText
- * @since 7.0
- */
- private void resetTipText() {
- if (tipText == null) {
- return;
- }
- tipText.setText(Messages.ToolSettingsTab_0);
- tipText.update();
- }
/* (non-Javadoc)
* Method displayOptionsForCategory
@@ -411,7 +400,7 @@ public void modifyText(ModifyEvent e) {
}
}
- Label label = stringField.getLabelControl(mySettingsPageContainer);
+ //Label label = stringField.getLabelControl(mySettingsPageContainer);
Text text = stringField.getTextControl(mySettingsPageContainer);
text.setText(optionValue);
// if(pageHasToolTipBox)
diff --git a/io.sloeber.autoBuild/.classpath b/io.sloeber.autoBuild/.classpath
index 065ac06e1..e54fbc930 100644
--- a/io.sloeber.autoBuild/.classpath
+++ b/io.sloeber.autoBuild/.classpath
@@ -2,6 +2,6 @@
-
+
diff --git a/io.sloeber.autoBuild/.settings/org.eclipse.jdt.core.prefs b/io.sloeber.autoBuild/.settings/org.eclipse.jdt.core.prefs
index 62ef3488c..23fa13b17 100644
--- a/io.sloeber.autoBuild/.settings/org.eclipse.jdt.core.prefs
+++ b/io.sloeber.autoBuild/.settings/org.eclipse.jdt.core.prefs
@@ -1,9 +1,9 @@
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
-org.eclipse.jdt.core.compiler.compliance=17
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
+org.eclipse.jdt.core.compiler.compliance=21
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=17
+org.eclipse.jdt.core.compiler.source=21
diff --git a/io.sloeber.autoBuild/META-INF/MANIFEST.MF b/io.sloeber.autoBuild/META-INF/MANIFEST.MF
index 3b583249f..341912e99 100644
--- a/io.sloeber.autoBuild/META-INF/MANIFEST.MF
+++ b/io.sloeber.autoBuild/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: Sloeber auto Build
Bundle-SymbolicName: io.sloeber.autoBuild;singleton:=true
Bundle-Version: 5.0.0.qualifier
-Bundle-RequiredExecutionEnvironment: JavaSE-17
+Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Require-Bundle: org.eclipse.cdt.core;bundle-version="7.0.0",
diff --git a/io.sloeber.autoBuild/build.properties b/io.sloeber.autoBuild/build.properties
index 9bc5fc8ce..15072b461 100644
--- a/io.sloeber.autoBuild/build.properties
+++ b/io.sloeber.autoBuild/build.properties
@@ -10,6 +10,5 @@ bin.includes = .,\
icons/
jars.compile.order = .
src.includes = schema/,\
- src/,\
template/,\
icons/
diff --git a/io.sloeber.autoBuild/plugin.xml b/io.sloeber.autoBuild/plugin.xml
index fea1e11bf..169fce6c8 100644
--- a/io.sloeber.autoBuild/plugin.xml
+++ b/io.sloeber.autoBuild/plugin.xml
@@ -2072,7 +2072,7 @@
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/api/AutoBuildCommon.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/api/AutoBuildCommon.java
index c6af150d7..5980e8dc5 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/api/AutoBuildCommon.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/api/AutoBuildCommon.java
@@ -368,7 +368,7 @@ static public String GetNiceFileName(IFolder buildPath, IFile path) {
static public String GetNiceFileName(IPath buildPath, IPath filePath) {
String ret;
if (buildPath.isPrefixOf(filePath) || buildPath.removeLastSegments(3).isPrefixOf(filePath)) {
- ret = filePath.makeRelativeTo(buildPath).toString();
+ ret = filePath.makeRelativeTo(buildPath).toOSString();
} else {
ret = filePath.toString();
}
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/api/IAutoBuildConfigurationDescription.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/api/IAutoBuildConfigurationDescription.java
index 4531a5c58..812017332 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/api/IAutoBuildConfigurationDescription.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/api/IAutoBuildConfigurationDescription.java
@@ -13,11 +13,14 @@
import org.eclipse.cdt.core.settings.model.CSourceEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+
import io.sloeber.autoBuild.buildTools.api.IBuildTools;
import io.sloeber.autoBuild.buildTools.api.IBuildToolsManager.ToolFlavour;
import io.sloeber.autoBuild.integration.AutoBuildConfigurationDescription;
@@ -31,7 +34,8 @@ public interface IAutoBuildConfigurationDescription {
public static IAutoBuildConfigurationDescription getActiveConfig(IProject project, boolean write) {
CoreModel coreModel = CoreModel.getDefault();
- ICProjectDescription projectDescription = coreModel.getProjectDescription(project, write);
+ ICProjectDescription projectDescription =coreModel.getProjectDescriptionManager().getProjectDescription(project, ICProjectDescriptionManager.GET_IF_LOADDED);
+ //ICProjectDescription projectDescription = coreModel.getProjectDescription(project, write);
return getActiveConfig(projectDescription);
}
@@ -49,7 +53,6 @@ public static IAutoBuildConfigurationDescription getConfig(ICConfigurationDescri
return null;
}
AutoBuildConfigurationDescription ret = (AutoBuildConfigurationDescription) confDesc.getConfigurationData();
- // ret.setWritable(!confDesc.isReadOnly());
return ret;
}
@@ -453,5 +456,13 @@ public static ICSourceEntry[] getResolvedSourceEntries(IAutoBuildConfigurationDe
*/
public LinkedHashMap getPostbuildSteps();
+ /***
+ * delete the build folder
+ * Not actually deletes the build folder but all the members.
+ *
+ * @param monitor
+ */
+ void deleteBuildFolder(IProgressMonitor monitor);
+
}
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/buildTools/internal/CDTBuildTools.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/buildTools/internal/CDTBuildTools.java
index d0d001d61..ce5c929d0 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/buildTools/internal/CDTBuildTools.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/buildTools/internal/CDTBuildTools.java
@@ -96,7 +96,7 @@ public String getPathExtension() {
@Override
public String getDiscoveryCommand(ToolType toolType) {
- return getToolLocation().append( getCommand(toolType)).toString() + DISCOVERY_PARAMETERS;
+ return getToolLocation().append( getCommand(toolType)).toOSString() + DISCOVERY_PARAMETERS;
}
@Override
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/buildTools/internal/MinGW32ToolsProvider.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/buildTools/internal/MinGW32ToolsProvider.java
index f43592da1..b35a7ead6 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/buildTools/internal/MinGW32ToolsProvider.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/buildTools/internal/MinGW32ToolsProvider.java
@@ -36,7 +36,7 @@ private void findTools() {
try {
myMinGWHome = org.eclipse.cdt.internal.core.MinGW.getMinGWHome();
}
- catch(@SuppressWarnings("unused") Exception e) {
+ catch( Exception e) {
//ignore as this fails in maven build due to lack of gui and as such registry
//is not available
e.printStackTrace();
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/buildTools/internal/MinGWBuildTools.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/buildTools/internal/MinGWBuildTools.java
index a14f19b1d..34e94c64d 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/buildTools/internal/MinGWBuildTools.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/buildTools/internal/MinGWBuildTools.java
@@ -92,7 +92,7 @@ public String getPathExtension() {
@Override
public String getDiscoveryCommand(ToolType toolType) {
- return getToolLocation().append( getCommand(toolType)).toString() +DISCOVERY_PARAMETERS;
+ return getToolLocation().append( getCommand(toolType)).toOSString() +DISCOVERY_PARAMETERS;
}
@Override
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/core/Messages.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/core/Messages.java
index 6e7fffddb..da0e8076f 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/core/Messages.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/core/Messages.java
@@ -20,7 +20,6 @@ public class Messages extends NLS {
public static String ManagedMakeBuilder_message_no_build;
public static String ManagedMakeBuilder_message_error;
public static String ManagedMakeBuilder_message_error_build;
- // public static String ManagedMakeBuilder_message_error_refresh;
public static String ManagedMakeBuilder_message_undefined_build_command;
public static String ManagedMakeBuilder_message_finished;
public static String ManagedMakeBuilder_message_cancelled;
@@ -122,7 +121,6 @@ public class Messages extends NLS {
public static String GeneratedMakefileBuilder_cleanSelectedFiles;
public static String FolderInfo_4;
public static String GnuLinkOutputNameProvider_0;
- public static String CommonBuilder_1;
public static String CommonBuilder_2;
public static String CommonBuilder_6;
public static String CommonBuilder_7;
@@ -140,18 +138,22 @@ public class Messages extends NLS {
public static String ResourceChangeHandler2_0;
public static String ToolInfo_0;
public static String ToolInfo_1;
- public static String AbstractBuiltinSpecsDetector_AddScannerDiscoveryMarkers;
public static String AbstractBuiltinSpecsDetector_ClearingMarkers;
public static String AbstractBuiltinSpecsDetector_DiscoverBuiltInSettingsJobName;
- public static String AbstractBuiltinSpecsDetector_RunningScannerDiscovery;
- public static String AbstractBuiltinSpecsDetector_ScannerDiscoveryMarkerLocationPreferences;
- public static String AbstractBuiltinSpecsDetector_ScannerDiscoveryMarkerLocationProperties;
public static String AbstractBuiltinSpecsDetector_ScannerDiscoveryTaskTitle;
public static String AbstractBuiltinSpecsDetector_SerializingResults;
public static String ExternalBuilderName;
public static String InternalBuilderName;
public static String InternalBuildRunner_NoNeedToRun;
+
+ public static String ScannerDiscoveryMarkerLocationPreferences;
+
+ public static String ScannerDiscoveryMarkerLocationProperties;
+
+ public static String AddScannerDiscoveryMarkers;
+
+ public static String RunningScannerDiscovery;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/core/messages.properties b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/core/messages.properties
index 0e54f6ea3..f7ec54e3c 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/core/messages.properties
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/core/messages.properties
@@ -150,7 +150,6 @@ CfgScannerConfigUtil_ErrorNotSupported=Only type {0} is supported in this method
GeneratedMakefileBuilder_cleanSelectedFiles=Cleaning Selected Files
FolderInfo_4=converter invocation failed
GnuLinkOutputNameProvider_0=tool parent must be one of configuration, toolchain, or resource configuration
-CommonBuilder_1=customized builder created for builder that does not support customization
CommonBuilder_2=request for building non active configuration for the builder that does not support this
CommonBuilder_6=Time consumed: {0} ms. \u0020
CommonBuilder_7=Info: Parallel threads used: {0}
@@ -171,17 +170,16 @@ ToolInfo_0=conversion failure
ToolInfo_1=the tool is removed
#Language settings providers messages
-AbstractBuiltinSpecsDetector_AddScannerDiscoveryMarkers=Adding Scanner Discovery markers
+AddScannerDiscoveryMarkers=Adding Scanner Discovery markers
AbstractBuiltinSpecsDetector_ClearingMarkers=Clearing markers for {0}
AbstractBuiltinSpecsDetector_DiscoverBuiltInSettingsJobName=Discover compiler built-in language settings
-AbstractBuiltinSpecsDetector_RunningScannerDiscovery=Running scanner discovery: {0}
-AbstractBuiltinSpecsDetector_ScannerDiscoveryMarkerLocationPreferences=Preferences, C++/Build/Settings/Discovery, [{0}] options
-AbstractBuiltinSpecsDetector_ScannerDiscoveryMarkerLocationProperties=Project Properties, C++ Preprocessor Include.../Providers, [{0}] options
+RunningScannerDiscovery=Running scanner discovery: {0}
+ScannerDiscoveryMarkerLocationPreferences=Preferences, C++/Build/Settings/Discovery, [{0}] options
+ScannerDiscoveryMarkerLocationProperties=Project Properties, C++ Preprocessor Include.../Providers, [{0}] options
AbstractBuiltinSpecsDetector_ScannerDiscoveryTaskTitle=CDT Scanner Discovery
AbstractBuiltinSpecsDetector_SerializingResults=Serializing results
-
ExternalBuilderName=Make builder
InternalBuilderName=Internal builder
-InternalBuildRunner_NoNeedToRun=No need to run
+InternalBuildRunner_NoNeedToRun=No need to run
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/internal/AutoBuildLanguageSettingsProvider.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/AutoBuildLanguageSettingsProvider.java
similarity index 90%
rename from io.sloeber.autoBuild/src/io/sloeber/autoBuild/internal/AutoBuildLanguageSettingsProvider.java
rename to io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/AutoBuildLanguageSettingsProvider.java
index d4cf99ea8..1c17bb1af 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/internal/AutoBuildLanguageSettingsProvider.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/AutoBuildLanguageSettingsProvider.java
@@ -12,13 +12,14 @@
* Andrew Gvozdev - initial API and implementation
*******************************************************************************/
-package io.sloeber.autoBuild.internal;
+package io.sloeber.autoBuild.extensionPoint.providers;
import static io.sloeber.autoBuild.helpers.api.AutoBuildConstants.*;
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
@@ -65,7 +66,8 @@
import io.sloeber.autoBuild.api.AutoBuildCommon;
import io.sloeber.autoBuild.api.IAutoBuildConfigurationDescription;
import io.sloeber.autoBuild.core.Activator;
-import io.sloeber.autoBuild.extensionPoint.providers.InternalBuildRunner;
+import io.sloeber.autoBuild.core.Messages;
+import io.sloeber.autoBuild.internal.AutoBuildRunnerHelper;
import io.sloeber.autoBuild.schema.api.IOption;
/**
@@ -73,9 +75,10 @@
*/
public class AutoBuildLanguageSettingsProvider extends AbstractExecutableExtensionBase
implements ILanguageSettingsBroadcastingProvider {
+ private static final boolean LOG_TO_STD_OUT =false;
- private static final String SCANNER_DISCOVERY_CONSOLE = "org.eclipse.cdt.managedbuilder.ScannerDiscoveryConsole"; //$NON-NLS-1$
- private static final String SCANNER_DISCOVERY_GLOBAL_CONSOLE = "org.eclipse.cdt.managedbuilder.ScannerDiscoveryGlobalConsole"; //$NON-NLS-1$
+ private static final String SCANNER_DISCOVERY_CONSOLE = "io.Sloeber.autoBuild.ScannerDiscoveryConsole"; //$NON-NLS-1$
+ private static final String SCANNER_DISCOVERY_GLOBAL_CONSOLE = "io.Sloeber.autoBuild.ScannerDiscoveryGlobalConsole"; //$NON-NLS-1$
private static final String DEFAULT_CONSOLE_ICON = "icons/obj16/inspect_sys.gif"; //$NON-NLS-1$
private static final String GMAKE_ERROR_PARSER_ID = "org.eclipse.cdt.core.GmakeErrorParser"; //$NON-NLS-1$
@@ -101,10 +104,10 @@ public void addMarker(IResource rc, int lineNumber, String errorDesc, int severi
@Override
public void addMarker(final ProblemMarkerInfo problemMarkerInfo) {
final String providerId = getId();
+ final String providerName=getName();
// Add markers in a job to avoid deadlocks
Job markerJob = new Job(
- // ManagedMakeMessages.getResourceString(
- "AbstractBuiltinSpecsDetector.AddScannerDiscoveryMarkers") { //$NON-NLS-1$
+ Messages.AddScannerDiscoveryMarkers) {
@Override
protected IStatus run(IProgressMonitor monitor) {
// Avoid duplicates as different languages can generate identical errors
@@ -133,14 +136,12 @@ protected IStatus run(IProgressMonitor monitor) {
marker.setAttribute(SDMarkerGenerator.ATTR_PROVIDER, providerId);
if (problemMarkerInfo.file instanceof IWorkspaceRoot) {
- String msgPreferences = // ManagedMakeMessages.getFormattedString(
- "AbstractBuiltinSpecsDetector.ScannerDiscoveryMarkerLocationPreferences";
- // , //$NON-NLS-1$ providerName);
+ String msgPreferences = MessageFormat.format(
+ Messages.ScannerDiscoveryMarkerLocationPreferences, providerName);
marker.setAttribute(IMarker.LOCATION, msgPreferences);
} else {
- String msgProperties = // ManagedMakeMessages.getFormattedString(
- "AbstractBuiltinSpecsDetector.ScannerDiscoveryMarkerLocationProperties";
- // //$NON-NLS-1$ providerName);
+ String msgProperties = MessageFormat.format(
+ Messages.ScannerDiscoveryMarkerLocationProperties, providerName);
marker.setAttribute(IMarker.LOCATION, msgProperties);
}
} catch (CoreException e) {
@@ -252,8 +253,9 @@ public List getSettingEntries(ICConfigurationDescription
if (discoveryCommand == null || discoveryCommand.isBlank()) {
return LanguageSettingsStorage.getPooledList(list);
}
+ discoveryCommand=discoveryCommand.trim();
List cachedList=myDiscoveryCache.get(discoveryCommand);
- if ( cachedList== null || cachedList.size()==0 ) {
+ if ( cachedList== null ) {
myDiscoveryCache.put(discoveryCommand, runForLanguage(languageId, discoveryCommand, autoConf,
autoConf.getProject(), new NullProgressMonitor()));
}
@@ -298,10 +300,8 @@ private List runForLanguage(String currentLanguageId, St
try (AutoBuildRunnerHelper buildRunnerHelper = new AutoBuildRunnerHelper(currentProject);) {
SubMonitor subMonitor = SubMonitor.convert(monitor,
- // ManagedMakeMessages.getFormattedString(
- "AbstractBuiltinSpecsDetector.RunningScannerDiscovery", //$NON-NLS-1$
- // getName()),
- 100);
+ MessageFormat.format(
+ Messages.RunningScannerDiscovery, getName()), 100);
IConsole console;
if (isConsoleEnabled) {
@@ -331,11 +331,12 @@ private List runForLanguage(String currentLanguageId, St
buildRunnerHelper.prepareStreams(epm, parsers, console, subMonitor.split(TICKS_OUTPUT_PARSING));
- buildRunnerHelper.greeting(// ManagedMakeMessages
- // .getFormattedString(
- "AbstractBuiltinSpecsDetector.RunningScannerDiscovery"//$NON-NLS-1$
- // , getName())
+ buildRunnerHelper.greeting(MessageFormat.format(
+ Messages.RunningScannerDiscovery , getName())
);
+ if(LOG_TO_STD_OUT) {
+ System.out.println(currentCommandResolved);
+ }
InternalBuildRunner.launchCommand(currentCommandResolved, autoConf,
monitor, buildRunnerHelper);
@@ -412,7 +413,9 @@ public void startup(ICConfigurationDescription cfgDescription, IWorkingDirectory
@Override
public boolean processLine(String line) {
- // System.out.println(line);
+ if(LOG_TO_STD_OUT) {
+ System.out.println(line);
+ }
for (Entry curMatcher : outputMatchers.entrySet()) {
Pattern pat = curMatcher.getKey();
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/AutoBuildMakeRule.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/AutoBuildMakeRule.java
index f3f1ac5cc..4635860cc 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/AutoBuildMakeRule.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/AutoBuildMakeRule.java
@@ -288,7 +288,7 @@ public String[] getRecipes(IFolder buildFolder, AutoBuildConfigurationDescriptio
IFile file = project.getWorkspace().getRoot()
.getFile(IPath.forPosix(curEntry.getValue()));
includeFiles = includeFiles + WHITESPACE + DOUBLE_QUOTE + CMD_LINE_INCLUDE_FILE
- + file.getLocation().toString() + DOUBLE_QUOTE;
+ + file.getLocation().toOSString() + DOUBLE_QUOTE;
break;
}
case ICSettingEntry.INCLUDE_PATH: {
@@ -296,11 +296,11 @@ public String[] getRecipes(IFolder buildFolder, AutoBuildConfigurationDescriptio
.getFolder(IPath.forPosix(curEntry.getValue())).getLocation();
if(path==null) {
//Log error to allow for investigation
- Activator.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "No location found for "+curEntry.getValue()));
+ Activator.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "No location found for "+curEntry.getValue())); //$NON-NLS-1$
}else {
includePath = includePath + WHITESPACE + DOUBLE_QUOTE + CMD_LINE_INCLUDE_FOLDER
- + path.toString() + DOUBLE_QUOTE;
+ + path.toOSString() + DOUBLE_QUOTE;
}
break;
}
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/BuildRunnerForMake.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/BuildRunnerForMake.java
index 75216a1e4..454f973f6 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/BuildRunnerForMake.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/BuildRunnerForMake.java
@@ -64,14 +64,8 @@ public class BuildRunnerForMake implements IBuildRunner {
@Override
public void invokeClean(int kind, IAutoBuildConfigurationDescription autoData,
IMarkerGenerator markerGenerator, IConsole console, IProgressMonitor monitor) throws CoreException {
- IFolder buildRoot = autoData.getBuildFolder();
- if(!buildRoot.exists()) {
- return ;
- }
- //Do not delete the build folder as it may be in use with other processes (like discovery)
- for(IResource curMember:buildRoot.members()) {
- curMember.delete(true, monitor);
- }
+ autoData.deleteBuildFolder(monitor);
+
//buildRoot.create(true, true, monitor);
// for now I do not run make clean due to the fact rm -f is probably not on the system path
//return invokeBuild(IncrementalProjectBuilder.CLEAN_BUILD, envp, autoData, markerGenerator, console, monitor);
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/CommonBuilder.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/CommonBuilder.java
index fe65ccd55..803b63b32 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/CommonBuilder.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/CommonBuilder.java
@@ -311,6 +311,8 @@ private static Set getConfigsToBuild(IProject
cfgToBuild.add((AutoBuildConfigurationDescription) IAutoBuildConfigurationDescription
.getActiveConfig(project, false));
}
+ //remove null configurations that may have been added
+ cfgToBuild.remove(null);
return cfgToBuild;
}
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/InternalBuildRunner.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/InternalBuildRunner.java
index 3cbd65702..3f88bc866 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/InternalBuildRunner.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/InternalBuildRunner.java
@@ -44,7 +44,6 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -86,16 +85,7 @@ private static void createFolder(IFolder folder, boolean force, boolean local, I
@Override
public void invokeClean(int kind, IAutoBuildConfigurationDescription autoData, IMarkerGenerator markerGenerator,
IConsole console, IProgressMonitor monitor) throws CoreException {
- IFolder buildRoot = autoData.getBuildFolder();
- if(!buildRoot.exists()) {
- return ;
- }
- //Do not delete the build folder as it may be in use with other processes (like discovery)
- for(IResource curMember:buildRoot.members()) {
- curMember.delete(true, monitor);
- }
-// buildRoot.delete(true, monitor);
-// buildRoot.create(true, true, monitor);
+ autoData.deleteBuildFolder(monitor);
return ;
}
@@ -144,6 +134,7 @@ public boolean invokeBuild(int kind, String targetName, IAutoBuildConfigurationD
epm.deferDeDuplication();
int sequenceID = -1;
boolean lastSequenceID = true;
+ myHasBuildError = false;
// Run preBuildStep if existing
LinkedHashMap preBuildSteps = autoData.getPrebuildSteps();
@@ -156,13 +147,14 @@ public boolean invokeBuild(int kind, String targetName, IAutoBuildConfigurationD
}
buildRunnerHelper.toConsole(command);
if (launchCommand(command, autoData, monitor, buildRunnerHelper) != 0) {
+ myHasBuildError = true;
if (autoData.stopOnFirstBuildError()) {
return false;
}
}
}
- myHasBuildError = false;
+
do {
sequenceID++;
lastSequenceID = true;
@@ -227,35 +219,36 @@ public boolean invokeBuild(int kind, String targetName, IAutoBuildConfigurationD
lastSequenceID = true;
}
} while (!(lastSequenceID || myHasBuildError));
- // Run postBuildStep if existing
- LinkedHashMap postBuildSteps = autoData.getPostbuildSteps();
- for (Entry step:postBuildSteps.entrySet()) {
- String announcement = step.getKey();
- String command = step.getValue();
+ // Run postBuildStep if existing and no error
+ if (!myHasBuildError) {
+ LinkedHashMap postBuildSteps = autoData.getPostbuildSteps();
+ for (Entry step : postBuildSteps.entrySet()) {
+ String announcement = step.getKey();
+ String command = step.getValue();
- if (!announcement.isEmpty()) {
- buildRunnerHelper.toConsole(announcement);
- }
- buildRunnerHelper.toConsole(command);
- if (launchCommand(command, autoData, monitor, buildRunnerHelper) != 0) {
- if (autoData.stopOnFirstBuildError()) {
- return false;
+ if (!announcement.isEmpty()) {
+ buildRunnerHelper.toConsole(announcement);
+ }
+ buildRunnerHelper.toConsole(command);
+ if (launchCommand(command, autoData, monitor, buildRunnerHelper) != 0) {
+ if (autoData.stopOnFirstBuildError()) {
+ return false;
+ }
}
}
- }
-
- String postBuildStep = autoData.getPostbuildStep();
- postBuildStep = resolve(postBuildStep, EMPTY_STRING, WHITESPACE, autoData);
- if (!postBuildStep.isEmpty()) {
- String announcement = autoData.getPostBuildAnouncement();
- if (!announcement.isEmpty()) {
- buildRunnerHelper.toConsole(announcement);
- }
- buildRunnerHelper.toConsole(postBuildStep);
- if (launchCommand(postBuildStep, autoData, monitor, buildRunnerHelper) != 0) {
- return false;
+ String postBuildStep = autoData.getPostbuildStep();
+ postBuildStep = resolve(postBuildStep, EMPTY_STRING, WHITESPACE, autoData);
+ if (!postBuildStep.isEmpty()) {
+ String announcement = autoData.getPostBuildAnouncement();
+ if (!announcement.isEmpty()) {
+ buildRunnerHelper.toConsole(announcement);
+ }
+ buildRunnerHelper.toConsole(postBuildStep);
+ if (launchCommand(postBuildStep, autoData, monitor, buildRunnerHelper) != 0) {
+ return false;
+ }
}
}
}
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/MakefileGenerator.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/MakefileGenerator.java
index 08af9ed28..3c751d5d9 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/MakefileGenerator.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/extensionPoint/providers/MakefileGenerator.java
@@ -6,6 +6,7 @@
import java.text.MessageFormat;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@@ -309,29 +310,7 @@ protected StringBuffer topMakeGetRMCommand(Set myDependencyMacros) {
return (buffer.append(NEWLINE));
}
- protected String topMakeGetPreBuildStep() {
- String prebuildStep = myAutoBuildConfData.getPrebuildStep();
- // JABA issue927 adding recipe.hooks.sketch.prebuild.NUMBER.pattern as cdt
- // prebuild command if needed
- // ICConfigurationDescription confDesc =
- // ManagedBuildManager.getDescriptionForConfiguration(config);
- // String sketchPrebuild =
- // io.sloeber.core.common.Common.getBuildEnvironmentVariable(confDesc,
- // "sloeber.prebuild",
- // new String(), false);
- String sketchPrebuild = getVariableValue("sloeber.prebuild", EMPTY_STRING, true, myAutoBuildConfData); //$NON-NLS-1$
- if (!sketchPrebuild.isEmpty()) {
- if (!prebuildStep.isEmpty()) {
- prebuildStep = prebuildStep + NEWLINE+TAB + sketchPrebuild;
- } else {
- prebuildStep = sketchPrebuild;
- }
- }
- // end off JABA issue927
- // try to resolve the build macros in the prebuild step
- prebuildStep = resolve(prebuildStep, EMPTY_STRING, WHITESPACE, myAutoBuildConfData);
- return prebuildStep.trim();
- }
+
protected StringBuffer topMakeGetIncludeDependencies() {
StringBuffer buffer = new StringBuffer();
@@ -339,22 +318,32 @@ protected StringBuffer topMakeGetIncludeDependencies() {
// Add the comment for the "All" target
buffer.append(COMMENT_START).append(MakefileGenerator_comment_build_alltarget).append(NEWLINE);
- String prebuildStep = topMakeGetPreBuildStep();
- String postbuildStep = resolve(myAutoBuildConfData.getPostbuildStep(), EMPTY_STRING, WHITESPACE,
- myAutoBuildConfData);
- if (prebuildStep.isBlank() && postbuildStep.isBlank()) {
+ LinkedHashMap prebuildSteps = myAutoBuildConfData.getPrebuildSteps();
+ LinkedHashMap postbuildSteps = myAutoBuildConfData.getPostbuildSteps();
+ if (prebuildSteps.size()== 0 && postbuildSteps.size()==0) {
buffer.append(TARGET_ALL).append(COLON).append(WHITESPACE).append(MAINBUILD).append(NEWLINE);
} else {
+ // add prebuild announce data
+ String preannouncebuildStep = myAutoBuildConfData.getPreBuildAnouncement();
+ if (preannouncebuildStep.length() > 0) {
+ buffer.append(TAB).append(DASH).append(AT_SYMBOL).append(escapedEcho(preannouncebuildStep));
+ }
+ // Add the prebuild recipes
buffer.append(TARGET_ALL).append(COLON).append(NEWLINE);
- if (!prebuildStep.isBlank()) {
- buffer.append(TAB).append(MAKE).append(WHITESPACE).append(NO_PRINT_DIR).append(WHITESPACE)
- .append(PREBUILD).append(NEWLINE);
+ for (String curRecipe : prebuildSteps.values()) {
+ buffer.append(TAB).append(WHITESPACE).append(curRecipe).append(NEWLINE);
}
+ // Add the make all command
buffer.append(TAB).append(MAKE).append(WHITESPACE).append(NO_PRINT_DIR).append(WHITESPACE).append(MAINBUILD)
.append(NEWLINE);
- if (!postbuildStep.isBlank()) {
- buffer.append(TAB).append(MAKE).append(WHITESPACE).append(NO_PRINT_DIR).append(WHITESPACE)
- .append(POSTBUILD).append(NEWLINE);
+ // add postbuild announce data
+ String postannouncebuildStep = myAutoBuildConfData.getPostBuildAnouncement();
+ if (postannouncebuildStep.length() > 0) {
+ buffer.append(TAB).append(DASH).append(AT_SYMBOL).append(escapedEcho(postannouncebuildStep));
+ }
+ // Add the postbuild recipes
+ for (String curRecipe : postbuildSteps.values()) {
+ buffer.append(TAB).append(WHITESPACE).append(curRecipe).append(NEWLINE);
}
}
@@ -396,31 +385,31 @@ protected StringBuffer topMakeGetTargets() {
}
buffer.append(NEWLINE).append(NEWLINE);
- String prebuildStep = topMakeGetPreBuildStep();
- if (prebuildStep.length() > 0) {
-
- String preannouncebuildStep = myAutoBuildConfData.getPreBuildAnouncement();
- buffer.append(PREBUILD).append(COLON).append(NEWLINE);
- if (preannouncebuildStep.length() > 0) {
- buffer.append(TAB).append(DASH).append(AT_SYMBOL).append(escapedEcho(preannouncebuildStep));
- }
- buffer.append(TAB).append(DASH).append(prebuildStep).append(NEWLINE);
- buffer.append(TAB).append(DASH).append(AT_SYMBOL).append(ECHO_BLANK_LINE).append(NEWLINE);
- }
+// String prebuildStep = topMakeGetPreBuildStep();
+// if (prebuildStep.length() > 0) {
+//
+// String preannouncebuildStep = myAutoBuildConfData.getPreBuildAnouncement();
+// buffer.append(PREBUILD).append(COLON).append(NEWLINE);
+// if (preannouncebuildStep.length() > 0) {
+// buffer.append(TAB).append(DASH).append(AT_SYMBOL).append(escapedEcho(preannouncebuildStep));
+// }
+// buffer.append(TAB).append(DASH).append(prebuildStep).append(NEWLINE);
+// buffer.append(TAB).append(DASH).append(AT_SYMBOL).append(ECHO_BLANK_LINE).append(NEWLINE);
+// }
- String postbuildStep = myAutoBuildConfData.getPostbuildStep();
- postbuildStep = resolve(postbuildStep, EMPTY_STRING, WHITESPACE, myAutoBuildConfData);
- postbuildStep = postbuildStep.trim();
- // Add the postbuild step, if specified
- if (postbuildStep.length() > 0) {
- String postannouncebuildStep = myAutoBuildConfData.getPostBuildAnouncement();
- buffer.append(POSTBUILD).append(COLON).append(NEWLINE);
- if (postannouncebuildStep.length() > 0) {
- buffer.append(TAB).append(DASH).append(AT_SYMBOL).append(escapedEcho(postannouncebuildStep));
- }
- buffer.append(TAB).append(DASH).append(postbuildStep).append(NEWLINE);
- buffer.append(TAB).append(DASH).append(AT_SYMBOL).append(ECHO_BLANK_LINE).append(NEWLINE);
- }
+// String postbuildStep = myAutoBuildConfData.getPostbuildStep();
+// postbuildStep = resolve(postbuildStep, EMPTY_STRING, WHITESPACE, myAutoBuildConfData);
+// postbuildStep = postbuildStep.trim();
+// // Add the postbuild step, if specified
+// if (postbuildStep.length() > 0) {
+// String postannouncebuildStep = myAutoBuildConfData.getPostBuildAnouncement();
+// buffer.append(POSTBUILD).append(COLON).append(NEWLINE);
+// if (postannouncebuildStep.length() > 0) {
+// buffer.append(TAB).append(DASH).append(AT_SYMBOL).append(escapedEcho(postannouncebuildStep));
+// }
+// buffer.append(TAB).append(DASH).append(postbuildStep).append(NEWLINE);
+// buffer.append(TAB).append(DASH).append(AT_SYMBOL).append(ECHO_BLANK_LINE).append(NEWLINE);
+// }
return buffer;
}
@@ -562,34 +551,10 @@ public StringBuffer getRecipesInMakeFileStyle(IAutoBuildMakeRule makeRule) {
.append(escapedEcho(MakefileGenerator_message_start_file + WHITESPACE + OUT_MACRO));
buffer.append(TAB).append(AT_SYMBOL).append(escapedEcho(tool.getAnnouncement()));
- // // JABA add sketch.prebuild and postbuild if needed
- // //TOFIX this should not be here
- // if ("sloeber.ino".equals(fileName)) { //$NON-NLS-1$
- //
- // // String sketchPrebuild =
- // io.sloeber.core.common.Common.getBuildEnvironmentVariable(confDesc,
- // // "sloeber.sketch.prebuild", new String(), true); //$NON-NLS-1$
- // // String sketchPostBuild =
- // io.sloeber.core.common.Common.getBuildEnvironmentVariable(confDesc,
- // // "sloeber.sketch.postbuild", new String(), true); //$NON-NLS-1$
- // String sketchPrebuild = resolve("sloeber.sketch.prebuild", EMPTY_STRING,
- // WHITESPACE, autoBuildConfData);
- // String sketchPostBuild = resolve("sloeber.sketch.postbuild", EMPTY_STRING,
- // WHITESPACE,autoBuildConfData);
- // if (!sketchPrebuild.isEmpty()) {
- // buffer.append(TAB).append(sketchPrebuild);
- // }
- // buffer.append(TAB).append(buildCmd).append(NEWLINE);
- // if (!sketchPostBuild.isEmpty()) {
- // buffer.append(TAB).append(sketchPostBuild);
- // }
- // } else {
for (String resolvedCommand : makeRule.getRecipes(myBuildRoot, myAutoBuildConfData)) {
buffer.append(TAB).append(resolvedCommand);
buffer.append(NEWLINE);
}
- // }
- // // end JABA add sketch.prebuild and postbuild if needed
buffer.append(NEWLINE);
buffer.append(TAB).append(AT_SYMBOL)
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/helpers/api/AutoBuildConstants.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/helpers/api/AutoBuildConstants.java
index 439cf8a92..45556d073 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/helpers/api/AutoBuildConstants.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/helpers/api/AutoBuildConstants.java
@@ -43,6 +43,7 @@ public class AutoBuildConstants {
public static final String PROCENT = "%";
public static final String SLACH = "/";
public static final String BACKSLACH = "\\";
+ public static final String PATH_SEPERATOR=isWindows?BACKSLACH:SLACH;
public static final String FALSE = "FALSE";
public static final String TRUE = "TRUE";
public static final String COLON = ":";
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/helpers/api/KeyValueTree.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/helpers/api/KeyValueTree.java
index ce318b6b0..a2e059f3d 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/helpers/api/KeyValueTree.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/helpers/api/KeyValueTree.java
@@ -8,8 +8,6 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.TreeMap;
-
import org.apache.commons.io.FileUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildConfigurationDescription.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildConfigurationDescription.java
index 70fa7140b..8ea885d05 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildConfigurationDescription.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildConfigurationDescription.java
@@ -33,8 +33,10 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.osgi.framework.Bundle;
import io.sloeber.autoBuild.api.AutoBuildCommon;
@@ -52,7 +54,6 @@
import io.sloeber.autoBuild.schema.api.IOption;
import io.sloeber.autoBuild.schema.api.IProjectType;
import io.sloeber.autoBuild.schema.api.ITool;
-import io.sloeber.autoBuild.schema.internal.Configuration;
public class AutoBuildConfigurationDescription extends AutoBuildResourceData
implements IAutoBuildConfigurationDescription {
@@ -108,7 +109,7 @@ public class AutoBuildConfigurationDescription extends AutoBuildResourceData
private boolean myIsWritable = false;
private boolean myForceCleanBeforeBuild = false;
- public AutoBuildConfigurationDescription(Configuration config, IProject project, IBuildTools buildTools,
+ public AutoBuildConfigurationDescription(IConfiguration config, IProject project, IBuildTools buildTools,
String rootCodeFolder) {
initializeResourceData(project, rootCodeFolder, myBuildFolderString);
myBuildTools = buildTools;
@@ -532,6 +533,10 @@ public void setGenerateMakeFilesAUtomatically(boolean generateMakeFilesAUtomatic
@Override
public void setBuildFolderString(String buildFolder) {
+ //TODO is this the correct place to delete the old folder
+ if(buildFolder.equals(myBuildFolderString)) {
+ return;
+ }
checkIfWeCanWrite();
IFolder oldBuildFolder = getBuildFolder();
if (oldBuildFolder != null && oldBuildFolder.exists()) {
@@ -1125,16 +1130,33 @@ public void forceCleanBeforeBuild() {
myForceCleanBeforeBuild = true;
}
- public void forceFullBuildIfNeeded(IProgressMonitor monitor) throws CoreException {
+ public void forceFullBuildIfNeeded(IProgressMonitor monitor) {
if (myForceCleanBeforeBuild) {
myForceCleanBeforeBuild = false;
- IFolder buildFolder = getBuildFolder();
- if (buildFolder != null && buildFolder.exists()) {
- buildFolder.delete(true, monitor);
- }
-
+ deleteBuildFolder(monitor);
}
+ }
+
+ @Override
+ public void deleteBuildFolder(IProgressMonitor monitor) {
+ //Do not delete the build folder as it may be in use with other processes (like discovery)
+ IFolder buildFolder = getBuildFolder();
+ if (buildFolder != null && buildFolder.exists()) {
+ try {
+ for(IResource curMember:buildFolder.members()) {
+ try {
+ curMember.delete(true, monitor);
+ } catch (CoreException e) {
+ Activator.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ "Failed to delete member "+curMember.getName(), e)); //$NON-NLS-1$
+ }
+
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
}
private static String getSpecFile(String languageId) {
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildManager.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildManager.java
index a58c441b8..4e8f9d114 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildManager.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildManager.java
@@ -266,8 +266,8 @@ public static Set getProjectTypes(String extensionPointID, String
IProjectType projectType = AutoBuildManager.getProjectType(extensionPointID, extensionID,
element.getAttribute(ID), true);
if (projectType == null) {
- System.err.println("project not found: extensionPoint ID " + extensionPointID + " and extension ID "
- + extensionID + " and " + ID);
+ System.err.println("project not found: extensionPoint ID " + extensionPointID + " and extension ID " //$NON-NLS-1$ //$NON-NLS-2$
+ + extensionID + " and " + ID); //$NON-NLS-1$
} else {
ret.add(projectType);
}
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildProjectGenerator.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildProjectGenerator.java
index 7ce673e24..7e857377b 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildProjectGenerator.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/integration/AutoBuildProjectGenerator.java
@@ -2,6 +2,7 @@
package io.sloeber.autoBuild.integration;
import java.net.URI;
+import java.util.HashSet;
import java.util.List;
import org.eclipse.cdt.core.CCProjectNature;
@@ -30,13 +31,11 @@
import org.eclipse.tools.templates.core.IGenerator;
import io.sloeber.autoBuild.api.AutoBuildCommon;
-import io.sloeber.autoBuild.api.IAutoBuildConfigurationDescription;
import io.sloeber.autoBuild.api.ICodeProvider;
import io.sloeber.autoBuild.buildTools.api.IBuildTools;
import io.sloeber.autoBuild.core.Activator;
import io.sloeber.autoBuild.schema.api.IConfiguration;
import io.sloeber.autoBuild.schema.api.IProjectType;
-import io.sloeber.autoBuild.schema.internal.Configuration;
public class AutoBuildProjectGenerator implements IGenerator {
private URI myLocationURI = null;
@@ -63,13 +62,57 @@ public void generate(IProgressMonitor monitor) throws CoreException {
@Override
public void run(IProgressMonitor internalMonitor) throws CoreException {
+
+ ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
+ IProjectType autoBuildProjType = AutoBuildManager.getProjectType(myProjectType.getExtensionPointID(),
+ myProjectType.getExtensionID(), myProjectType.getId(), true);
+ if (autoBuildProjType == null) {
+ // project type not found can not continue
+ IStatus status = new Status(IStatus.ERROR, Activator.getId(),
+ "Did not find the projectType with " + myProjectType.getId() + " for extension ID " //$NON-NLS-1$ //$NON-NLS-2$
+ + myProjectType.getExtensionID() + " in extensionpointID " //$NON-NLS-1$
+ + myProjectType.getExtensionPointID());
+ CoreException exception = new CoreException(status);
+ throw (exception);
+ }
+ HashSet configNames = new HashSet<>();
+ myProject = root.getProject(myProjectName);
+ if (myProject.exists()) {
+ // Update the existing configurations
+ ICProjectDescription orgdesc = mngr.getProjectDescription(myProject, false);
+ for (ICConfigurationDescription curConfig : orgdesc.getConfigurations()) {
+ configNames.add(curConfig.getName());
+ }
+ myLocationURI=myProject.getLocationURI();
+ //CDT reads the .cproject file when setting the configuration for making the delta
+ //and old stuff stays in it causing problems
+ //ICProject cProject = CoreModel.getDefault().getCModel().getCProject(myProject.getName());
+ IFile CdtDotFile = myProject.getFile(".cproject"); //$NON-NLS-1$
+ if(CdtDotFile.exists()) {
+ CdtDotFile.delete(true, monitor);
+ }
+ myProject.close(monitor);
+ myProject.delete(false, true, monitor);
+
+ } else {
+ // Create new configurations based on the model configurations from the
+ // plugin.xml
+ IConfiguration[] modelConfigs = autoBuildProjType.getConfigurations();
+ for (IConfiguration iConfig : modelConfigs) {
+ configNames.add(iConfig.getName());
+ }
+ }
+
+
+
IProjectDescription description = workspace.newProjectDescription(myProjectName);
if (myLocationURI != null) {
description.setLocationURI(myLocationURI);
}
- myProject = root.getProject(myProjectName);
+
myProject.create(description, monitor);
myProject.open(monitor);
+
CProjectNature.addCNature(myProject, monitor);
if (CCProjectNature.CC_NATURE_ID.equals(myNatureID)) {
CCProjectNature.addCCNature(myProject, monitor);
@@ -77,7 +120,7 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
AutoBuildNature.addNature(myProject, monitor);
IContainer srcFolder = myProject;
- if (myCodeRootFolder!=null && !myCodeRootFolder.isBlank()) {
+ if (myCodeRootFolder != null && !myCodeRootFolder.isBlank()) {
IFolder actualFolder = myProject.getFolder(myCodeRootFolder);
srcFolder = actualFolder;
if (!srcFolder.exists()) {
@@ -90,48 +133,42 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
myProject = CCorePlugin.getDefault().createCDTProject(description, myProject, monitor);
- ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
+
ICProjectDescription des = mngr.createProjectDescription(myProject, false, true);
- IProjectType sloeberProjType = AutoBuildManager.getProjectType(myProjectType.getExtensionPointID(),
- myProjectType.getExtensionID(), myProjectType.getId(), true);
- if (sloeberProjType == null) {
- // project type not found can not continue
- IStatus status = new Status(IStatus.ERROR, Activator.getId(),
- "Did not find the projectType with " + myProjectType.getId() + " for extension ID " //$NON-NLS-1$ //$NON-NLS-2$
- + myProjectType.getExtensionID() + " in extensionpointID " //$NON-NLS-1$
- + myProjectType.getExtensionPointID());
- CoreException exception = new CoreException(status);
- throw (exception);
- }
- IConfiguration[] modelConfigs = sloeberProjType.getConfigurations();
- for (IConfiguration iConfig : modelConfigs) {
- Configuration config = (Configuration) iConfig;
+ IConfiguration defaultConfig = autoBuildProjType.getConfigurations()[0];
+
+ for (String curConfigName : configNames) {
+ IConfiguration config = autoBuildProjType.getConfiguration(curConfigName);
+ if (config == null) {
+ config = defaultConfig;
+ }
AutoBuildConfigurationDescription data = new AutoBuildConfigurationDescription(config, myProject,
myBuldTools, myCodeRootFolder);
assert (data != null);
+ data.setBuilder(data.getBuilder(myBuilderID));
ICConfigurationDescription cdtCfgDes = des
.createConfiguration(AutoBuildConfigurationDescriptionProvider.CFG_DATA_PROVIDER_ID, data);
+ cdtCfgDes.setName(curConfigName);
data.setCdtConfigurationDescription(cdtCfgDes);
- data.setBuilder(data.getBuilder(myBuilderID));
// Set the language Settings
- String[] defaultIds = iConfig.getDefaultLanguageSettingsProviderIds().toArray(new String[0]);
+ String[] defaultIds = config.getDefaultLanguageSettingsProviderIds().toArray(new String[0]);
List providers = LanguageSettingsManager
.createLanguageSettingsProviders(defaultIds);
ILanguageSettingsProvidersKeeper languageKeeper = (ILanguageSettingsProvidersKeeper) cdtCfgDes;
if (cdtCfgDes instanceof ILanguageSettingsProvidersKeeper) {
languageKeeper.setLanguageSettingProviders(providers);
}
+ AutoBuildCommon.createFolder(data.getBuildFolder());
}
if (!myNeedsMoreWork) {
des.setCdtProjectCreated();
}
+ des.setActiveConfiguration(des.getConfigurations()[0]);
+ des.setDefaultSettingConfiguration(des.getConfigurations()[0]);
mngr.setProjectDescription(myProject, des);
- for(ICConfigurationDescription curConfig:des.getConfigurations()) {
- IAutoBuildConfigurationDescription autodesc=IAutoBuildConfigurationDescription.getConfig(curConfig);
- AutoBuildCommon.createFolder( autodesc.getBuildFolder());
- }
+
}
};
try {
diff --git a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/schema/internal/Tool.java b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/schema/internal/Tool.java
index 46fb4c759..61574cf9a 100644
--- a/io.sloeber.autoBuild/src/io/sloeber/autoBuild/schema/internal/Tool.java
+++ b/io.sloeber.autoBuild/src/io/sloeber/autoBuild/schema/internal/Tool.java
@@ -562,7 +562,7 @@ public String[] getRecipes(IAutoBuildConfigurationDescription autoBuildConfData,
IPath toolPath = buildTools.getToolLocation();
if (toolPath != null && !toolPath.toString().isBlank()) {
//store the path
- toolCommandVars.put(CMD_LINE_TOOL_PATH, toolPath.toString().trim() + SLACH);
+ toolCommandVars.put(CMD_LINE_TOOL_PATH, toolPath.toOSString().trim() + PATH_SEPERATOR);
}
Map toolVariables = buildTools.getToolVariables();
if (toolVariables != null && toolVariables.size() > 0) {
diff --git a/io.sloeber.core.nl1/.classpath b/io.sloeber.core.nl1/.classpath
new file mode 100644
index 000000000..06514e04e
--- /dev/null
+++ b/io.sloeber.core.nl1/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/io.sloeber.core.nl1/.settings/org.eclipse.jdt.core.prefs b/io.sloeber.core.nl1/.settings/org.eclipse.jdt.core.prefs
index 27705a035..502263510 100644
--- a/io.sloeber.core.nl1/.settings/org.eclipse.jdt.core.prefs
+++ b/io.sloeber.core.nl1/.settings/org.eclipse.jdt.core.prefs
@@ -1,9 +1,18 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
+org.eclipse.jdt.core.compiler.compliance=21
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=21
org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false
org.eclipse.jdt.core.formatter.align_with_spaces=false
+org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
@@ -11,21 +20,24 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
-org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
+org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16
org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
@@ -117,11 +129,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
@@ -152,6 +165,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
@@ -176,13 +191,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
+org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
@@ -230,6 +249,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
@@ -266,9 +287,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
@@ -307,9 +331,13 @@ org.eclipse.jdt.core.formatter.tabulation.char=tab
org.eclipse.jdt.core.formatter.tabulation.size=4
org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true
org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
-org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
diff --git a/io.sloeber.core.nl1/META-INF/MANIFEST.MF b/io.sloeber.core.nl1/META-INF/MANIFEST.MF
index 8aad12868..b8205fddb 100644
--- a/io.sloeber.core.nl1/META-INF/MANIFEST.MF
+++ b/io.sloeber.core.nl1/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Sloeber core language pack
Bundle-SymbolicName: io.sloeber.core.nl1;singleton:=true
-Bundle-RequiredExecutionEnvironment: JavaSE-17
+Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-Version: 5.0.0.qualifier
Fragment-Host: io.sloeber.core
Bundle-Vendor: Sloeber.io
diff --git a/io.sloeber.core/.classpath b/io.sloeber.core/.classpath
index 17a441d04..478470af0 100644
--- a/io.sloeber.core/.classpath
+++ b/io.sloeber.core/.classpath
@@ -1,5 +1,7 @@
+
+
@@ -7,14 +9,11 @@
-
-
-
-
+
diff --git a/io.sloeber.core/.settings/org.eclipse.jdt.core.prefs b/io.sloeber.core/.settings/org.eclipse.jdt.core.prefs
index 96d2364f2..24e173460 100644
--- a/io.sloeber.core/.settings/org.eclipse.jdt.core.prefs
+++ b/io.sloeber.core/.settings/org.eclipse.jdt.core.prefs
@@ -10,11 +10,11 @@ org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
-org.eclipse.jdt.core.compiler.compliance=17
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
+org.eclipse.jdt.core.compiler.compliance=21
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=17
+org.eclipse.jdt.core.compiler.source=21
diff --git a/io.sloeber.core/META-INF/MANIFEST.MF b/io.sloeber.core/META-INF/MANIFEST.MF
index 1fddc2e65..c2dc81a5a 100644
--- a/io.sloeber.core/META-INF/MANIFEST.MF
+++ b/io.sloeber.core/META-INF/MANIFEST.MF
@@ -3,12 +3,11 @@ Bundle-ManifestVersion: 2
Bundle-Name: Arduino eclipse plugin
Bundle-SymbolicName: io.sloeber.core;singleton:=true
Bundle-Version: 5.0.0.qualifier
-Bundle-RequiredExecutionEnvironment: JavaSE-17
+Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-Vendor: Sloeber.io
Bundle-ActivationPolicy: lazy
Bundle-Activator: io.sloeber.core.Activator
Bundle-ClassPath: .,
- lib/jsch-0.1.55.jar,
lib/jssc-2.9.4.jar,
lib/jmdns-3.5.7.jar
Require-Bundle:
@@ -28,16 +27,12 @@ Require-Bundle:
org.eclipse.ui.intro,
io.sloeber.autoBuild,
org.eclipse.cdt.make.core,
- org.apache.commons.lang3;bundle-version="3.14.0"
+ org.apache.commons.lang3;bundle-version="3.14.0",
+ com.jcraft.jsch
Export-Package: cc.arduino.packages;x-internal:=true,
cc.arduino.packages.discoverers;x-internal:=true,
cc.arduino.packages.ssh;x-internal:=true,
- com.jcraft.jsch,
- com.jcraft.jsch.jce;uses:="com.jcraft.jsch",
- com.jcraft.jsch.jcraft;uses:="com.jcraft.jsch",
- com.jcraft.jsch.jgss;uses:="com.jcraft.jsch",
- io.sloeber.core;x-friends:="io.sloeber.tests",
- io.sloeber.core.Gson;uses:="com.google.gson,io.sloeber.core.api",
+ io.sloeber.arduinoFramework.api,
io.sloeber.core.api;
uses:="io.sloeber.core.common,
org.eclipse.debug.core.model,
@@ -48,20 +43,12 @@ Export-Package: cc.arduino.packages;x-internal:=true,
org.eclipse.cdt.core.settings.model,
org.eclipse.core.resources,
io.sloeber.core.api.Json",
- io.sloeber.core.api.Json;uses:="org.eclipse.core.runtime,com.google.gson,io.sloeber.core.api",
- io.sloeber.core.builder;x-internal:=true,
io.sloeber.core.common;x-friends:="io.sloeber.tests",
io.sloeber.core.communication;x-internal:=true,
io.sloeber.core.core;x-internal:=true,
- io.sloeber.core.eclipseIntegrations;uses:="org.eclipse.core.variables",
- io.sloeber.core.internal;x-friends:="io.sloeber.tests",
- io.sloeber.core.listeners;x-internal:=true,
- io.sloeber.core.managers;x-internal:=true,
+ io.sloeber.core.internal,
io.sloeber.core.natures;x-internal:=true,
io.sloeber.core.templates;x-internal:=true,
- io.sloeber.core.toolchain;x-internal:=true,
- io.sloeber.core.tools;x-friends:="io.sloeber.tests",
- io.sloeber.core.tools.uploaders;x-internal:=true,
io.sloeber.core.txt;x-friends:="io.sloeber.tests"
Import-Package: io.sloeber.autoBuild.schema.api,
org.apache.commons.io;version="2.13.0",
diff --git a/io.sloeber.core/build.properties b/io.sloeber.core/build.properties
index f43297fb8..8f7dd00fe 100644
--- a/io.sloeber.core/build.properties
+++ b/io.sloeber.core/build.properties
@@ -9,11 +9,11 @@ bin.includes = .,\
config/,\
OSGI-INF/,\
src/io/sloeber/core/templates/sketch.ino,\
- lib/jsch-0.1.55.jar,\
OSGI-INF/l10n/bundle.properties,\
+ icons/,\
+ launch/,\
lib/jssc-2.9.4.jar,\
lib/jmdns-3.5.7.jar,\
- icons/,\
- launch/
+ introContent.xml
jars.compile.order = .
src.includes = icons/
diff --git a/io.sloeber.core/config/pre_processing_platform_default.txt b/io.sloeber.core/config/pre_processing_platform_default.txt
index 6b47ace9d..b27b15804 100644
--- a/io.sloeber.core/config/pre_processing_platform_default.txt
+++ b/io.sloeber.core/config/pre_processing_platform_default.txt
@@ -1,7 +1,7 @@
#this file contains default/fallback/rescue values
software=ARDUINO
archive_file=arduino.ar
-archive_file_path=${build.path}/${archive_file}
+archive_file_path=${build.path}${PathDelimiter}${archive_file}
ide_version=20302
serial.port=${com_port}
diff --git a/io.sloeber.core/lib/jsch-0.1.55.jar b/io.sloeber.core/lib/jsch-0.1.55.jar
deleted file mode 100644
index 1a64e71da..000000000
Binary files a/io.sloeber.core/lib/jsch-0.1.55.jar and /dev/null differ
diff --git a/io.sloeber.core/plugin.xml b/io.sloeber.core/plugin.xml
index 8309f00e1..563c4359d 100644
--- a/io.sloeber.core/plugin.xml
+++ b/io.sloeber.core/plugin.xml
@@ -240,7 +240,6 @@
name="%tool.archiver.name"
toolType="o->ar">
diff --git a/io.sloeber.core/src/cc/arduino/packages/ssh/SSH.java b/io.sloeber.core/src/cc/arduino/packages/ssh/SSH.java
index a40272329..f6d71d517 100644
--- a/io.sloeber.core/src/cc/arduino/packages/ssh/SSH.java
+++ b/io.sloeber.core/src/cc/arduino/packages/ssh/SSH.java
@@ -43,6 +43,7 @@
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
+import io.sloeber.core.Activator;
import io.sloeber.core.Messages;
import io.sloeber.core.api.Common;
import io.sloeber.core.api.Const;
@@ -159,7 +160,7 @@ public void run() {
} catch (IOException e) {
// This is unlikely to happen, but log it nevertheless
IStatus status = new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.command_io, e);
- Common.log(status);
+ Activator.log(status);
} finally {
try {
this.fReader.close();
diff --git a/io.sloeber.core/src/cc/arduino/packages/ssh/SSHPwdSetup.java b/io.sloeber.core/src/cc/arduino/packages/ssh/SSHPwdSetup.java
index b76c126a3..b6f4251db 100644
--- a/io.sloeber.core/src/cc/arduino/packages/ssh/SSHPwdSetup.java
+++ b/io.sloeber.core/src/cc/arduino/packages/ssh/SSHPwdSetup.java
@@ -37,8 +37,8 @@
import com.jcraft.jsch.Session;
import cc.arduino.packages.BoardPort;
+import io.sloeber.core.Activator;
import io.sloeber.core.Messages;
-import io.sloeber.core.api.Common;
import io.sloeber.core.api.Const;
import io.sloeber.core.api.PasswordManager;
@@ -58,7 +58,7 @@ public Session setup(BoardPort port, JSch jSch) throws JSchException {
} else {
// The user should set the password in the project
// properties->arduino
- Common.log(
+ Activator.log(
new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.Upload_login_credentials_missing.replace(Messages.HOST_TAG, host)));
return null;
diff --git a/io.sloeber.core/src/io/sloeber/arduinoFramework/api/ArduinoInstallable.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/ArduinoInstallable.java
new file mode 100644
index 000000000..034288cdd
--- /dev/null
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/ArduinoInstallable.java
@@ -0,0 +1,34 @@
+package io.sloeber.arduinoFramework.api;
+
+import org.eclipse.core.runtime.IPath;
+
+public abstract class ArduinoInstallable {
+
+ protected String myArchiveFileName;
+ protected String myURL;
+ protected String myChecksum;
+ protected String mySize;
+ protected String myName;
+
+ abstract public IPath getInstallPath();
+
+ public String getArchiveFileName() {
+ return myArchiveFileName;
+ }
+
+ public String getUrl() {
+ return myURL;
+ }
+
+ public String getChecksum() {
+ return myChecksum;
+ }
+
+ public String getSize() {
+ return mySize;
+ }
+
+ public String getName() {
+ return myName;
+ }
+}
diff --git a/io.sloeber.core/src/io/sloeber/arduinoFramework/api/BoardDescription.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/BoardDescription.java
new file mode 100644
index 000000000..72967b065
--- /dev/null
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/BoardDescription.java
@@ -0,0 +1,1259 @@
+package io.sloeber.arduinoFramework.api;
+
+import static io.sloeber.core.Messages.*;
+import static io.sloeber.core.api.Common.*;
+import static io.sloeber.core.api.Const.*;
+import static io.sloeber.autoBuild.api.AutoBuildCommon.*;
+import static io.sloeber.autoBuild.helpers.api.AutoBuildConstants.DOT;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.StandardOpenOption;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeMap;
+import org.eclipse.cdt.core.parser.util.StringUtil;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+
+import io.sloeber.arduinoFramework.internal.ArduinoPlatformTooldDependency;
+import io.sloeber.autoBuild.api.IAutoBuildConfigurationDescription;
+import io.sloeber.autoBuild.helpers.api.KeyValueTree;
+import io.sloeber.core.Activator;
+import io.sloeber.core.Messages;
+import io.sloeber.core.api.ConfigurationPreferences;
+import io.sloeber.core.api.VersionNumber;
+import io.sloeber.core.tools.KeyValue;
+import io.sloeber.core.txt.BoardTxtFile;
+import io.sloeber.core.txt.PlatformTxtFile;
+import io.sloeber.core.txt.Programmers;
+import io.sloeber.core.txt.TxtFile;
+
+public class BoardDescription {
+ private static final String FIRST_SLOEBER_LINE = "#Sloeber created file please do not modify V1.00.test 07 "; //$NON-NLS-1$
+ private static final IEclipsePreferences myStorageNode = InstanceScope.INSTANCE.getNode(NODE_ARDUINO);
+
+ /*
+ * This is the basic info contained in the descriptor
+ */
+ private String myUploadPort = EMPTY;
+ private String myProgrammer = EMPTY;
+ private String myBoardID = EMPTY;
+ private Map myOptions = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ private File myUserSelectedBoardsTxtFile; // this is the boards.txt file selected in the gui
+ private BoardTxtFile mySloeberBoardTxtFile; // this is the actual used and loaded sloeber.boards.txt file
+
+ private String myBoardsCore = null;
+ private String myBoardsVariant = null;
+ private String myUploadTool = null;
+
+ private IArduinoPlatformVersion myReferencedPlatformVariant = null;
+ private IArduinoPlatformVersion myReferencedPlatformCore = null;
+ private IArduinoPlatformVersion myReferencedPlatformUpload = null;
+ private String myJsonURL = null;
+
+ private boolean myIsDirty = true;
+
+
+ @Override
+ public String toString() {
+ return getReferencingBoardsFile() + " \"" + getBoardName() + "\" " + getUploadPort(); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ /**
+ * Compare 2 descriptors and return true is they are equal. This method detects
+ * - OS changes - project name changes - moves of workspace - changed runtine
+ * eclipse install
+ *
+ * @param obj
+ * @return true if equal otherwise false
+ */
+ public boolean equals(BoardDescription otherBoardDescriptor) {
+ if (otherBoardDescriptor == null) {
+ return false;
+ }
+ if (!this.getUploadPort().equals(otherBoardDescriptor.getUploadPort())) {
+ return false;
+ }
+ if (!this.getProgrammer().equals(otherBoardDescriptor.getProgrammer())) {
+ return false;
+ }
+ return !needsRebuild(otherBoardDescriptor);
+ }
+
+ /**
+ * compare 2 board descriptors and return true if replacing one board descriptor
+ * with the other implies that a rebuild is needed
+ *
+ * @param otherBoardDescriptor
+ * @return
+ */
+ public boolean needsRebuild(BoardDescription otherBoardDescriptor) {
+ if (otherBoardDescriptor == null) {
+ return true;
+ }
+ if (!this.getBoardID().equals(otherBoardDescriptor.getBoardID())) {
+ return true;
+ }
+ String moddedReferencingBoardsFile = makePathVersionString(getReferencingBoardsFile());
+ String moddedOtherReferencingBoardsFile = makePathVersionString(
+ otherBoardDescriptor.getReferencingBoardsFile());
+ if (!moddedReferencingBoardsFile.equals(moddedOtherReferencingBoardsFile)) {
+ return true;
+ }
+ if (!this.getOptions().equals(otherBoardDescriptor.getOptions())) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * after construction data needs to be derived from other data. This method
+ * derives all other data and puts it in fields
+ */
+ private void calculateDerivedFields() {
+
+ myReferencedPlatformCore = null;
+ myBoardsCore = null;
+ myReferencedPlatformVariant = null;
+ myBoardsVariant = null;
+ myReferencedPlatformUpload = null;
+ myUploadTool = null;
+ setDefaultOptions();
+ // search in the board info
+ ParseSection();
+
+ }
+
+ private void ParseSection() {
+ KeyValueTree rootData = mySloeberBoardTxtFile.getData();
+ String boardID = getBoardID();
+ KeyValueTree boardData = rootData.getChild(boardID);
+
+ String core = boardData.getValue(BUILD + DOT + CORE);
+ String variant = boardData.getValue(BUILD + DOT + VARIANT);
+ String upload = boardData.getValue(UPLOAD + DOT + TOOL);
+ // also search the options
+ for (Entry curOption : this.myOptions.entrySet()) {
+ KeyValueTree curMenuData = boardData.getChild(MENU + DOT + curOption.getKey() + DOT + curOption.getValue());
+ String coreOption = curMenuData.getValue(BUILD + DOT + CORE);
+ String variantOption = curMenuData.getValue(BUILD + DOT + VARIANT);
+ String uploadOption = curMenuData.getValue(UPLOAD + DOT + TOOL);
+ if (!coreOption.isEmpty()) {
+ core = coreOption;
+ }
+ if (!variantOption.isEmpty()) {
+ variant = variantOption;
+ }
+ if (!uploadOption.isEmpty()) {
+ upload = uploadOption;
+ }
+ }
+ String architecture = getArchitecture();
+ if (core != null) {
+ String valueSplit[] = core.split(COLON);
+ if (valueSplit.length == 2) {
+ String refVendor = valueSplit[0];
+ myBoardsCore = valueSplit[1];
+ myReferencedPlatformCore = BoardsManager.getNewestInstalledPlatform(refVendor, architecture);
+ if (myReferencedPlatformCore == null) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
+ Helpers_tool_reference_missing.replace(TOOL_TAG, core)
+ .replace(FILE_TAG, getReferencingBoardsFile().toString())
+ .replace(BOARD_TAG, getBoardID())));
+ return;
+ }
+ } else if (valueSplit.length == 4) {
+ String refVendor = valueSplit[0];
+ String refArchitecture = valueSplit[1];
+ VersionNumber refVersion = new VersionNumber(valueSplit[2]);
+ myBoardsCore = valueSplit[3];
+ myReferencedPlatformCore = BoardsManager.getPlatform(refVendor, refArchitecture, refVersion);
+ if (myReferencedPlatformCore == null) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
+ Helpers_tool_reference_missing.replace(TOOL_TAG, core)
+ .replace(FILE_TAG, getReferencingBoardsFile().toString())
+ .replace(BOARD_TAG, getBoardID())));
+ return;
+ }
+ } else {
+ this.myBoardsCore = core;
+ }
+ }
+ if (variant != null) {
+ String valueSplit[] = variant.split(COLON);
+ if (valueSplit.length == 2) {
+ String refVendor = valueSplit[0];
+ myBoardsVariant = valueSplit[1];
+ myReferencedPlatformVariant = BoardsManager.getNewestInstalledPlatform(refVendor, architecture);
+ if (myReferencedPlatformVariant == null) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
+ Helpers_tool_reference_missing.replace(TOOL_TAG, variant)
+ .replace(FILE_TAG, getReferencingBoardsFile().toString())
+ .replace(BOARD_TAG, getBoardID())));
+ return;
+ }
+ } else if (valueSplit.length == 4) {
+ String refVendor = valueSplit[0];
+ String refArchitecture = valueSplit[1];
+ VersionNumber refVersion = new VersionNumber(valueSplit[2]);
+ myBoardsVariant = valueSplit[3];
+ if ("*".equals(valueSplit[2])) { //$NON-NLS-1$
+ myReferencedPlatformVariant = BoardsManager.getNewestInstalledPlatform(refVendor, refArchitecture);
+ } else {
+ myReferencedPlatformVariant = BoardsManager.getPlatform(refVendor, refArchitecture, refVersion);
+ }
+ if (myReferencedPlatformVariant == null) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
+ Helpers_tool_reference_missing.replace(TOOL_TAG, variant)
+ .replace(FILE_TAG, getReferencingBoardsFile().toString())
+ .replace(BOARD_TAG, getBoardID())));
+ return;
+ }
+ } else {
+ myBoardsVariant = variant;
+ }
+ }
+ if (upload != null) {
+ String valueSplit[] = upload.split(COLON);
+ if (valueSplit.length == 2) {
+ String refVendor = valueSplit[0];
+ myUploadTool = valueSplit[1];
+ myReferencedPlatformUpload = BoardsManager.getNewestInstalledPlatform(refVendor, architecture);
+ if (myReferencedPlatformUpload == null) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
+ Helpers_tool_reference_missing.replace(TOOL_TAG, upload)
+ .replace(FILE_TAG, getReferencingBoardsFile().toString())
+ .replace(BOARD_TAG, getBoardID())));
+ return;
+ }
+ } else if (valueSplit.length == 4) {
+ String refVendor = valueSplit[0];
+ String refArchitecture = valueSplit[1];
+ VersionNumber refVersion = new VersionNumber(valueSplit[2]);
+ myUploadTool = valueSplit[3];
+ myReferencedPlatformUpload = BoardsManager.getPlatform(refVendor, refArchitecture, refVersion);
+ if (this.myReferencedPlatformUpload == null) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
+ Helpers_tool_reference_missing.replace(TOOL_TAG, upload)
+ .replace(FILE_TAG, getReferencingBoardsFile().toString())
+ .replace(BOARD_TAG, getBoardID())));
+ return;
+ }
+ } else {
+ myUploadTool = upload;
+ }
+ }
+ }
+
+ /**
+ * make a board descriptor for each board in the board.txt file with the default
+ * options
+ *
+ * @param boardFile
+ * @return a list of board descriptors
+ */
+ public static List makeBoardDescriptors(File boardFile) {
+ BoardTxtFile txtFile = new BoardTxtFile(resolvePathEnvironmentString(boardFile));
+ List boards = new ArrayList<>();
+ List boardIDs = txtFile.getAllBoardIDs();
+ for (String curboardID : boardIDs) {
+ Map boardSection = txtFile.getSection(curboardID);
+ if (boardSection != null) {
+ if (!"true".equalsIgnoreCase(boardSection.get("hide"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ boards.add(new BoardDescription(null,boardFile, curboardID, null));
+ }
+ }
+ }
+ return boards;
+ }
+
+ /**
+ * create a board descriptor
+ *
+ * @param boardsFile
+ * @param boardID
+ * @param options
+ * if null default options are taken
+ */
+ public BoardDescription(String jsonURL,File boardsFile, String boardID, Map options) {
+
+ File expandedBoardsFile = resolvePathEnvironmentString(boardsFile);
+ if (!expandedBoardsFile.exists()) {
+ Activator.log(new Status(IStatus.ERROR, Activator.getId(), "BoardsFile " + boardsFile + " does not exist")); //$NON-NLS-1$//$NON-NLS-2$
+ return;
+ }
+ if (jsonURL != null) {
+ myJsonURL = jsonURL;
+ } else {
+ myJsonURL = BoardsManager.getjsonURLFormBoardsFile(expandedBoardsFile);
+ }
+ myBoardID = boardID;
+ myUserSelectedBoardsTxtFile = boardsFile;
+ mySloeberBoardTxtFile = new BoardTxtFile(expandedBoardsFile);
+ setDefaultOptions();
+ if (options != null) {
+ myOptions.putAll(options);
+ }
+ }
+
+ public BoardDescription() {
+ myUserSelectedBoardsTxtFile = new File(myStorageNode.get(KEY_LAST_USED_BOARDS_FILE, EMPTY));
+ if (!myUserSelectedBoardsTxtFile.exists()) {
+
+ IArduinoPlatformVersion platform = BoardsManager.getNewestInstalledPlatform( VENDOR_ARDUINO, AVR);
+ if (platform == null) {
+ platform = BoardsManager.getAnyInstalledPlatform();
+ }
+ myUserSelectedBoardsTxtFile = platform.getBoardsFile();
+ mySloeberBoardTxtFile = new BoardTxtFile(myUserSelectedBoardsTxtFile);
+ myJsonURL= BoardsManager.getjsonURLFormBoardsFile(myUserSelectedBoardsTxtFile);
+
+ if (mySloeberBoardTxtFile.getAllBoardIDs().contains(UNO)) {
+ myBoardID = UNO;
+ } else {
+ myBoardID = mySloeberBoardTxtFile.getAllBoardIDs().get(0);
+ }
+ setDefaultOptions();
+ } else {
+ mySloeberBoardTxtFile = new BoardTxtFile(myUserSelectedBoardsTxtFile);
+ myBoardID = myStorageNode.get(KEY_LAST_USED_BOARD, EMPTY);
+ myUploadPort = myStorageNode.get(KEY_LAST_USED_UPLOAD_PORT, EMPTY);
+ myProgrammer = myStorageNode.get(KEY_LAST_USED_UPLOAD_PROTOCOL, EMPTY);
+ myJsonURL = myStorageNode.get(KEY_LAST_USED_JSON_URL, EMPTY);
+ myOptions = KeyValue.makeMap(myStorageNode.get(KEY_LAST_USED_BOARD_MENU_OPTIONS, EMPTY));
+ }
+
+ }
+
+
+ public BoardDescription(BoardDescription srcObject) {
+ myUserSelectedBoardsTxtFile = srcObject.myUserSelectedBoardsTxtFile;
+ mySloeberBoardTxtFile = srcObject.mySloeberBoardTxtFile;
+ myJsonURL = srcObject.myJsonURL;
+ myBoardID = srcObject.myBoardID;
+ myUploadPort = srcObject.myUploadPort;
+ myProgrammer = srcObject.myProgrammer;
+ myUploadTool = srcObject.myUploadTool;
+ myOptions.putAll(new TreeMap<>(srcObject.myOptions));
+
+ }
+
+ public String getuploadTool() {
+ return this.myUploadTool;
+ }
+
+ /*
+ * Sets default options as follows If no option is specified take the first one
+ * if a option is specified but the value is invalid take the first one
+ *
+ * this is so because I want to provide a list of options but if the options are
+ * incomplete or invalid this method still returns a complete and valid set.
+ */
+ private void setDefaultOptions() {
+ Map allMenuIDs = this.mySloeberBoardTxtFile.getMenus();
+ for (Map.Entry curMenuID : allMenuIDs.entrySet()) {
+ String providedMenuValue = this.myOptions.get(curMenuID.getKey());
+ ArrayList menuOptions = this.mySloeberBoardTxtFile.getMenuItemIDsFromMenuID(curMenuID.getKey(),
+ getBoardID());
+ if (menuOptions.size() > 0) {
+ if (providedMenuValue == null) {
+
+ this.myOptions.put(curMenuID.getKey(), menuOptions.get(0));
+ } else if (!menuOptions.contains(providedMenuValue)) {
+ this.myOptions.put(curMenuID.getKey(), menuOptions.get(0));
+ }
+ }
+ }
+ }
+
+ private void removeInvalidMenuIDs() {
+ Set allMenuIDs = this.mySloeberBoardTxtFile.getMenus().keySet();
+ Set optionKey = new HashSet<>(myOptions.keySet());
+
+ for (String curOptionKey : optionKey) {
+ if (!allMenuIDs.contains(curOptionKey)) {
+ myOptions.remove(curOptionKey);
+ }
+ }
+ }
+
+ /**
+ * Store the selections the user made so we can reuse them when creating a new
+ * project
+ */
+ public void saveUserSelection() {
+ myStorageNode.put(KEY_LAST_USED_BOARDS_FILE, myUserSelectedBoardsTxtFile.toString());
+ myStorageNode.put(KEY_LAST_USED_BOARD, myBoardID);
+ myStorageNode.put(KEY_LAST_USED_UPLOAD_PORT, myUploadPort);
+ myStorageNode.put(KEY_LAST_USED_UPLOAD_PROTOCOL, myProgrammer);
+ myStorageNode.put(KEY_LAST_USED_JSON_URL, myJsonURL);
+ myStorageNode.put(KEY_LAST_USED_BOARD_MENU_OPTIONS, KeyValue.makeString(myOptions));
+ }
+
+ /*
+ * Returns the architecture based on the myUserSelectedBoardsTxtFile file name
+ * Caters for the packages (with version number and for the old way if the boards
+ * file does not exists returns avr
+ */
+ public String getArchitecture() {
+ if (myUserSelectedBoardsTxtFile == null) {
+ return AVR;
+ }
+ IPath platformFile = new Path(myUserSelectedBoardsTxtFile.toString().trim());
+ int index = hardwareSegmentIndex(platformFile);
+ if (index < 0) {
+ return AVR;
+ }
+ return platformFile.segment(index + 3);
+ }
+
+ /*
+ * Returns the vendor based on the myUserSelectedBoardsTxtFile file name
+ * Caters for the packages (with version number and for the old way if the boards
+ * file does not exists returns VENDOR_ARDUINO
+ */
+ public String getVendor() {
+ if (myUserSelectedBoardsTxtFile == null) {
+ return VENDOR_ARDUINO;
+ }
+ IPath platformFile = new Path(myUserSelectedBoardsTxtFile.toString().trim());
+ int index = hardwareSegmentIndex(platformFile);
+ if (index < 1) {
+ return VENDOR_ARDUINO;
+ }
+ return platformFile.segment(index + 1);
+ }
+
+ /**
+ * return the segment that contains the name packages
+ * or -1 if no such segment is found
+ * @param platformFile
+ * @return
+ */
+ private static int hardwareSegmentIndex(IPath platformFile) {
+ for (int i = 0; i < platformFile.segmentCount(); i++) {
+ if (PACKAGES_FOLDER_NAME.equals(platformFile.segment(i))) {
+ return i;
+ }
+ }
+ return -1;
+
+ }
+
+ public File getReferencingBoardsFile() {
+ return myUserSelectedBoardsTxtFile;
+ }
+
+ public String getBoardName() {
+ return this.mySloeberBoardTxtFile.getNiceNameFromID(this.myBoardID);
+ }
+
+ public String getUploadPort() {
+ return this.myUploadPort;
+ }
+
+ /**
+ * return the actual adress en,coded in the upload port example uploadport com4
+ * returns com4 uploadport = arduino.local at 199.25.25.1 returns arduino.local
+ *
+ * @return
+ */
+ public String getActualUploadPort() {
+ return myUploadPort.split(" ")[0]; //$NON-NLS-1$
+ }
+
+ public String getProgrammer() {
+ return this.myProgrammer;
+ }
+
+ /**
+ * Set the upload port like in the gui. The upload port can be a comport or a
+ * networkadress space and something else note that getuploadport returns the
+ * before space part of this method
+ *
+ * @param newUploadPort
+ */
+ public void setUploadPort(String newUploadPort) {
+ this.myUploadPort = newUploadPort;
+ }
+
+ public void setProgrammer(String newUploadProtocol) {
+ this.myProgrammer = newUploadProtocol;
+ }
+
+ public void setBoardID(String boardID) {
+ if (!boardID.equals(this.myBoardID)) {
+ this.myBoardID = boardID;
+ setDirty();
+ }
+ }
+
+ private void setDirty() {
+ myIsDirty = true;
+
+ }
+
+ public void setBoardName(String boardName) {
+ String newBoardID = this.mySloeberBoardTxtFile.getIDFromNiceName(boardName);
+ if ((newBoardID == null || this.myBoardID.equals(newBoardID))) {
+ return;
+ }
+ this.myBoardID = newBoardID;
+ setDirty();
+
+ }
+
+ public void setreferencingBoardsFile(File boardsFile) {
+ if (boardsFile == null) {
+ return;// ignore
+ }
+
+ if (!myUserSelectedBoardsTxtFile.equals(boardsFile)) {
+ myUserSelectedBoardsTxtFile = boardsFile;
+ setDirty();
+ }
+
+ /* do not remove this for optimization as workaround changes will not be captured */
+ mySloeberBoardTxtFile = new BoardTxtFile(resolvePathEnvironmentString(myUserSelectedBoardsTxtFile));
+
+ }
+
+ /**
+ * seOptions add the options to the already existing options and removes the options
+ * with an invalid menuID
+ * The enuitemID is not verified and assumed correct.
+ *
+ */
+ public void setOptions(Map options) {
+ if (options == null || options.size() == 0) {
+ return;
+ }
+ myOptions.putAll(options);
+ removeInvalidMenuIDs();
+ setDirty();
+ }
+
+ /**
+ * Returns the options for this board This reflects the options selected through
+ * the menu functionality in the boards.txt
+ *
+ * @return a map of case insensitive ordered key value pairs
+ */
+ public Map getOptions() {
+ // no update is needed as this field is only modified at construction or set
+ return this.myOptions;
+ }
+
+ private void updateWhenDirty() {
+ if (myIsDirty) {
+ calculateDerivedFields();
+ myIsDirty = false;
+ }
+ }
+
+ public String getBoardID() {
+ // no update is needed as this field is only modified at construction or set
+ return this.myBoardID;
+ }
+
+ public String[] getCompatibleBoards() {
+ return this.mySloeberBoardTxtFile.getAllSectionNames();
+ }
+
+ public String[] getUploadProtocols() {
+
+ return Programmers.getUploadProtocols(this);
+
+ }
+
+ public String[] getMenuItemNamesFromMenuID(String menuID) {
+ return this.mySloeberBoardTxtFile.getMenuItemNamesFromMenuID(menuID, this.myBoardID);
+ }
+
+ public String getMenuNameFromMenuID(String id) {
+ return this.mySloeberBoardTxtFile.getMenuNameFromID(id);
+ }
+
+ public String getMenuItemNamedFromMenuItemID(String menuItemID, String menuID) {
+ return this.mySloeberBoardTxtFile.getMenuItemNameFromMenuItemID(this.myBoardID, menuID, menuItemID);
+ }
+
+ public String getMenuItemIDFromMenuItemName(String menuItemName, String menuID) {
+ return this.mySloeberBoardTxtFile.getMenuItemIDFromMenuItemName(this.myBoardID, menuID, menuItemName);
+ }
+
+ /**
+ * provide the actual path to the variant. Use this method if you want to know
+ * where the variant is
+ *
+ * @return the path to the variant; null if no variant is needed
+ */
+ public IPath getActualVariantPath() {
+ updateWhenDirty();
+ String boardVariant = getBoardVariant();
+ if (boardVariant == null || boardVariant.isBlank()) {
+ return null;
+ }
+ if (myReferencedPlatformVariant == null) {
+ return new Path(myUserSelectedBoardsTxtFile.getParent().toString()).append(ARDUINO_VARIANTS_FOLDER_NAME)
+ .append(boardVariant);
+ }
+ return myReferencedPlatformVariant.getInstallPath().append(ARDUINO_VARIANTS_FOLDER_NAME).append(boardVariant);
+ }
+
+ private String getBoardVariant() {
+ updateWhenDirty();
+ return this.myBoardsVariant;
+ }
+
+ public IPath getActualCoreCodePath() {
+ updateWhenDirty();
+ if (myBoardsCore == null) {
+ return null;
+ }
+ IPath retPath = null;
+ if (myReferencedPlatformCore == null) {
+ retPath = getreferencingPlatformPath();
+ } else {
+ retPath = myReferencedPlatformCore.getInstallPath();
+ }
+ return retPath.append(CORES).append(myBoardsCore);
+ }
+
+ public IPath getReferencedUploadPlatformPath() {
+ updateWhenDirty();
+ if (myReferencedPlatformUpload != null) {
+ return myReferencedPlatformUpload.getInstallPath();
+ }
+ return getreferencingPlatformPath();
+ }
+
+ public PlatformTxtFile getReferencingPlatformFile() {
+ updateWhenDirty();
+ File platformFile = getreferencingPlatformPath().append(PLATFORM_FILE_NAME).toFile();
+ if (platformFile != null && platformFile.exists()) {
+ return new PlatformTxtFile(platformFile);
+ }
+ return null;
+ }
+
+ public Path getreferencingPlatformPath() {
+ try {
+ return new Path(myUserSelectedBoardsTxtFile.getParent());
+ } catch (@SuppressWarnings("unused") Exception e) {
+ return new Path(EMPTY);
+ }
+ }
+
+ public PlatformTxtFile getreferencedCorePlatformFile() {
+ updateWhenDirty();
+ if (myReferencedPlatformCore == null) {
+ return null;
+ }
+ File platformFile = myReferencedPlatformCore.getInstallPath().append(PLATFORM_FILE_NAME).toFile();
+ if (platformFile != null && platformFile.exists()) {
+ return new PlatformTxtFile(platformFile);
+ }
+ return null;
+ }
+
+ public IPath getReferencedCoreLibraryPath() {
+ updateWhenDirty();
+ if (myReferencedPlatformCore == null) {
+ return getReferencingLibraryPath();
+ }
+ return this.myReferencedPlatformCore.getInstallPath().append(ARDUINO_LIBRARY_FOLDER_NAME);
+ }
+
+ public IPath getReferencingLibraryPath() {
+ updateWhenDirty();
+ return this.getreferencingPlatformPath().append(ARDUINO_LIBRARY_FOLDER_NAME);
+ }
+
+ public String getUploadPatternKey() {
+ updateWhenDirty();
+ String upLoadTool = getuploadTool();
+ String networkPrefix = EMPTY;
+ if (isNetworkUpload()) {
+ networkPrefix = NETWORK_PREFIX;
+ }
+ return TOOLS + DOT + upLoadTool + DOT + UPLOAD + DOT + networkPrefix + PATTERN;
+ }
+
+ public IPath getreferencedCoreHardwarePath() {
+ updateWhenDirty();
+ if (myReferencedPlatformCore == null) {
+ return getreferencingPlatformPath();
+ }
+ return myReferencedPlatformCore.getInstallPath();
+ }
+
+ /*
+ * get the latest installed arduino platform with the same architecture. This is
+ * the platform to use the programmers.txt if no other programmers.txt are
+ * found.
+ */
+ public IPath getArduinoPlatformPath() {
+ updateWhenDirty();
+ IArduinoPlatform platform = BoardsManager.getPlatform(VENDOR_ARDUINO, getArchitecture());
+ if (platform == null) {
+ return null;
+ }
+ IArduinoPlatformVersion platformVersion = platform.getNewestInstalled();
+ if (platformVersion == null) {
+ return null;
+ }
+ return platformVersion.getInstallPath();
+ }
+
+ /**
+ * If the upload port contains a space everything before the first space is
+ * considered to be a dns name or ip adress.
+ *
+ * @param mComPort
+ * @return null if no space in uploadport return dns name op ipadress
+ */
+ public String getHost() {
+ String host = myUploadPort.split(" ")[0]; //$NON-NLS-1$
+ if (host.equals(myUploadPort))
+ return null;
+ return host;
+ }
+
+ /**
+ * true if this board needs a networkUpload else false
+ *
+ * @return
+ */
+ public boolean isNetworkUpload() {
+ return getHost() != null;
+ }
+
+
+ BoardDescription(TxtFile configFile, String prefix) {
+
+ KeyValueTree tree = configFile.getData();
+ KeyValueTree section = tree.getChild(prefix);
+ myProgrammer = section.getValue(KEY_SLOEBER_PROGRAMMER);
+ myBoardID = section.getValue(KEY_SLOEBER_BOARD_ID);
+ String board_txt = section.getValue(KEY_SLOEBER_BOARD_TXT);
+ myUploadPort = section.getValue(KEY_SLOEBER_UPLOAD_PORT);
+ KeyValueTree optionsTree = section.getChild(KEY_SLOEBER_MENU_SELECTION);
+ Map options = optionsTree.toKeyValues(EMPTY);
+
+ KeyValueTree boardSection = tree.getChild(BOARD);
+ myJsonURL = boardSection.getValue(JSON_URL);
+
+ myUserSelectedBoardsTxtFile = resolvePathEnvironmentString(new File(board_txt));
+ mySloeberBoardTxtFile = new BoardTxtFile(myUserSelectedBoardsTxtFile);
+ setDefaultOptions();
+ if (options != null) {
+ // Only add the valid options for this board to our options
+ myOptions.putAll(onlyKeepValidOptions(options));
+ }
+ }
+
+ /**
+ * create a BoardDescription based on the environment variables given
+ *
+ * @param envVars
+ */
+ public BoardDescription(KeyValueTree keyValues) {
+ myProgrammer = keyValues.getValue(KEY_SLOEBER_PROGRAMMER);
+ myUploadPort = keyValues.getValue(KEY_SLOEBER_UPLOAD_PORT);
+
+ KeyValueTree boardvalueTree = keyValues.getChild(KEY_BOARD);
+ myBoardID = boardvalueTree.getValue(KEY_SLOEBER_BOARD_ID);
+ String txtFile = boardvalueTree.getValue(KEY_SLOEBER_BOARD_TXT);
+
+ KeyValueTree jSonvalueTree = keyValues.getChild(KEY_JSON);
+ myJsonURL = jSonvalueTree.getValue(KEY_JSON_URL);
+
+ myUserSelectedBoardsTxtFile = resolvePathEnvironmentString(new File(txtFile));
+ mySloeberBoardTxtFile = new BoardTxtFile(myUserSelectedBoardsTxtFile);
+ KeyValueTree options = keyValues.getChild(KEY_SLOEBER_MENU_SELECTION);
+ for (KeyValueTree curOption : options.getChildren().values()) {
+ myOptions.put(curOption.getKey(), curOption.getValue());
+ }
+
+// int menuKeyLength = KEY_SLOEBER_MENU_SELECTION.length() + DOT.length();
+// for (Entry curEnvVar : envVars.entrySet()) {
+// String key = curEnvVar.getKey();
+// String value = curEnvVar.getValue();
+// switch (key) {
+// case KEY_SLOEBER_PROGRAMMER:
+// myProgrammer = value;
+// break;
+// case KEY_SLOEBER_BOARD_ID:
+// myBoardID = value;
+// break;
+// case KEY_SLOEBER_BOARD_TXT:
+// myUserSelectedBoardsTxtFile = resolvePathEnvironmentString(new File(value));
+// mySloeberBoardTxtFile = new BoardTxtFile(myUserSelectedBoardsTxtFile);
+// break;
+// case KEY_SLOEBER_UPLOAD_PORT:
+// myUploadPort = value;
+// break;
+// default:
+// if (key.startsWith(KEY_SLOEBER_MENU_SELECTION + DOT)) {
+// String cleanKey = key.substring(menuKeyLength);
+// myOptions.put(cleanKey, value);
+// }
+// }
+// }
+ }
+
+ /**
+ * get the environment variables that need to be stored in the configuration
+ * files configuration files are files needed to setup the sloeber environment
+ * for instance when openiung a project or after import of a project in the
+ * workspace
+ *
+ * @return the minimum list of environment variables to recreate the project
+ */
+ public void serialize(KeyValueTree keyValueTree) {
+ String board_txt = makePathVersionString(getReferencingBoardsFile());
+ keyValueTree.addChild(KEY_SLOEBER_PROGRAMMER, myProgrammer);
+ keyValueTree.addChild(KEY_SLOEBER_UPLOAD_PORT, myUploadPort);
+
+ KeyValueTree boardvalueTree = keyValueTree.addChild(KEY_BOARD);
+ boardvalueTree.addChild(KEY_SLOEBER_BOARD_ID, myBoardID);
+ boardvalueTree.addChild(KEY_SLOEBER_BOARD_TXT, board_txt);
+
+ KeyValueTree jSonvalueTree = keyValueTree.addChild(KEY_JSON);
+ jSonvalueTree.addChild(KEY_JSON_URL, myJsonURL);
+
+ KeyValueTree menuvalueTree = keyValueTree.addChild(KEY_SLOEBER_MENU_SELECTION);
+ for (Entry curOption : myOptions.entrySet()) {
+ menuvalueTree.addValue(curOption.getKey(), curOption.getValue());
+ }
+ }
+
+ private Map onlyKeepValidOptions(Map options) {
+ Map ret = new HashMap<>();
+
+ KeyValueTree tree = mySloeberBoardTxtFile.getData();
+ KeyValueTree boardMenuSection = tree.getChild(myBoardID + DOT + MENU);
+ if (boardMenuSection != null) {
+ for (Entry curoption : options.entrySet()) {
+ String key = curoption.getKey();
+ if (boardMenuSection.getChild(key).getKey() != null) {
+ ret.put(key, curoption.getValue());
+ }
+ }
+ }
+ return ret;
+ }
+
+ /**
+ * get the environment variables that need to be stored in version control
+ *
+ * @return the minimum list of environment variables to recreate the project
+ * from version control
+ */
+ public Map getEnvVarsVersion(String prefix) {
+ Map allVars = new TreeMap<>();
+ String board_txt = makePathVersionString(getReferencingBoardsFile());
+
+ allVars.put(prefix + KEY_SLOEBER_BOARD_ID, myBoardID);
+ allVars.put(prefix + KEY_SLOEBER_BOARD_TXT, board_txt);
+
+ for (Entry curOption : myOptions.entrySet()) {
+ allVars.put(prefix + KEY_SLOEBER_MENU_SELECTION + DOT + curOption.getKey(), curOption.getValue());
+ }
+ return allVars;
+ }
+
+ /**
+ * This method creates environment variables based on the platform.txt and
+ * boards.txt. platform.txt is processed first and then boards.txt. This way
+ * boards.txt settings can overwrite common settings in platform.txt The
+ * environment variables are only valid for the project given as parameter The
+ * project properties are used to identify the boards.txt and platform.txt as
+ * well as the board id to select the settings in the board.txt file At the end
+ * also the path variable is set
+ *
+ *
+ * To be able to quickly fix boards.txt and platform.txt problems I also added a
+ * pre and post platform and boards files that are processed before and after
+ * the arduino delivered boards.txt file.
+ *
+ * @param project
+ * the project for which the environment variables are set
+ * @param arduinoProperties
+ * the info of the selected board to set the variables for
+ */
+ public Map getEnvVars() {
+ updateWhenDirty();
+
+ TxtFile pluginPreProcessingPlatformTxt = new TxtFile(ConfigurationPreferences.getPreProcessingPlatformFile());
+ TxtFile pluginPostProcessingPlatformTxt = new TxtFile(ConfigurationPreferences.getPostProcessingPlatformFile());
+ BoardTxtFile pluginPreProcessingBoardsTxt = new BoardTxtFile(
+ ConfigurationPreferences.getPreProcessingBoardsFile());
+ BoardTxtFile pluginPostProcessingBoardsTxt = new BoardTxtFile(
+ ConfigurationPreferences.getPostProcessingBoardsFile());
+
+ Map allVars = pluginPreProcessingPlatformTxt.getAllEnvironVars(EMPTY);
+ allVars.putAll(pluginPreProcessingBoardsTxt.getBoardEnvironVars(getBoardID()));
+
+ String architecture = getArchitecture();
+ IPath coreHardwarePath = getreferencedCoreHardwarePath();
+ allVars.put(ENV_KEY_BUILD_ARCH, architecture.toUpperCase());
+ allVars.put(ENV_KEY_RUNTIME_HARDWARE_PATH, getreferencingPlatformPath().removeLastSegments(1).toOSString());
+ allVars.put(ENV_KEY_BUILD_SYSTEM_PATH, coreHardwarePath.append(SYSTEM).toOSString());
+ allVars.put(ENV_KEY_RUNTIME_PLATFORM_PATH, getreferencingPlatformPath().toOSString());
+ // ide_version is defined in pre_processing_platform_default.txt
+ allVars.put(ENV_KEY_RUNTIME_IDE_VERSION, makeEnvironmentVar("ide_version")); //$NON-NLS-1$
+ allVars.put(ENV_KEY_RUNTIME_IDE_PATH, makeEnvironmentVar(SLOEBER_HOME));
+ if (isWindows) {
+ allVars.put(ENV_KEY_RUNTIME_OS, "windows"); //$NON-NLS-1$
+ }
+ if (isLinux) {
+ allVars.put(ENV_KEY_RUNTIME_OS, "linux"); //$NON-NLS-1$
+ }
+ if (isMac) {
+ allVars.put(ENV_KEY_RUNTIME_OS, "macosx"); //$NON-NLS-1$
+ }
+ allVars.put(ENV_KEY_ID, getBoardID());
+ allVars.put(ENV_KEY_BUILD_FQBN, getBoardFQBN());
+
+ allVars.put(ENV_KEY_SERIAL_PORT, getActualUploadPort());
+ allVars.put(ENV_KEY_SERIAL_DOT_PORT, getActualUploadPort());
+
+ allVars.put(ENV_KEY_SERIAL_PORT_FILE, getActualUploadPort().replace("/dev/", EMPTY)); //$NON-NLS-1$
+ // if actual core path is osstring regression test issue555 willl fail teensy
+ // stuff
+ allVars.put(ENV_KEY_BUILD_ACTUAL_CORE_PATH, getActualCoreCodePath().toOSString());
+ IPath variantPath = getActualVariantPath();
+ if (variantPath != null) {
+ allVars.put(ENV_KEY_BUILD_VARIANT_PATH, variantPath.toOSString());
+ } else {// teensy does not use variant
+ allVars.put(ENV_KEY_BUILD_VARIANT_PATH, EMPTY);
+ }
+
+ PlatformTxtFile referencedPlatfromFile = getreferencedCorePlatformFile();
+ // process the platform file referenced by the boards.txt
+ if (referencedPlatfromFile != null) {
+ allVars.putAll(referencedPlatfromFile.getAllEnvironVars());
+ }
+ PlatformTxtFile referencingPlatfromFile = getReferencingPlatformFile();
+ // process the platform file next to the selected boards.txt
+ if (referencingPlatfromFile != null) {
+ allVars.putAll(referencingPlatfromFile.getAllEnvironVars());
+ }
+
+ // put in the installed tools info
+ try {
+ allVars.putAll(getEnVarPlatformInfo());
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, Messages.BoardDescription_0, e));
+ }
+
+ // boards settings not coming from menu selections
+ allVars.putAll(mySloeberBoardTxtFile.getBoardEnvironVars(getBoardID()));
+
+ // board settings from menu selections
+ Map options = getOptions();
+ KeyValueTree rootData = mySloeberBoardTxtFile.getData();
+ KeyValueTree menuData = rootData.getChild(getBoardID() + DOT + MENU);
+ for (Entry curOption : options.entrySet()) {
+ String menuID = curOption.getKey();
+ String SelectedMenuItemID = curOption.getValue();
+ KeyValueTree curSelectedMenuItem = menuData.getChild(menuID + DOT + SelectedMenuItemID);
+ allVars.putAll(curSelectedMenuItem.toKeyValues(EMPTY));
+ }
+
+ // This moved last. See github issue 1410
+ Programmers localProgrammers[] = Programmers.fromBoards(this);
+ String programmer = getProgrammer();
+ for (Programmers curProgrammer : localProgrammers) {
+ String programmerID = curProgrammer.getIDFromNiceName(programmer);
+ if (programmerID != null) {
+ allVars.putAll(curProgrammer.getAllEnvironVars(programmerID));
+ }
+ }
+
+ // add the stuff that comes with the plugin that is marked as post
+ allVars.putAll(pluginPostProcessingPlatformTxt.getAllEnvironVars(EMPTY));
+ allVars.putAll(pluginPostProcessingBoardsTxt.getBoardEnvironVars(getBoardID()));
+
+ // Do some coded post processing
+ allVars.putAll(getEnvVarsPostProcessing(allVars));
+ return allVars;
+
+ }
+
+ private String getBoardFQBN() {
+ String fqbn = getVendor() + COLON + getArchitecture() + COLON + getBoardID();
+ String options = EMPTY_STRING;
+ String prefix = COLON;
+ for (Entry curOption : myOptions.entrySet()) {
+ options = options + prefix + curOption.getKey() + EQUAL + curOption.getValue();
+ prefix = COMMA;
+ }
+ return fqbn + options;
+ }
+
+ private Map getEnVarPlatformInfo() throws IOException {
+ Map ret = new HashMap<>();
+
+ ret.putAll(getEnvVarPlatformFileTools(myReferencedPlatformUpload));
+ ret.putAll(getEnvVarPlatformFileTools(myReferencedPlatformVariant));
+ ret.putAll(getEnvVarPlatformFileTools(myReferencedPlatformCore));
+
+ BoardsManager.update(false);// This way we know the boardsmanager is started or we wait for the lock
+ IArduinoPlatformVersion latestArduinoPlatform = BoardsManager.getNewestInstalledPlatform(VENDOR_ARDUINO,
+ getArchitecture());
+ ret.putAll(getEnvVarPlatformFileTools(latestArduinoPlatform));
+
+ IPath referencingPlatformPath = getreferencingPlatformPath();
+ IArduinoPlatformVersion referencingPlatform = BoardsManager.getPlatform(referencingPlatformPath);
+ if (referencingPlatform == null) {
+ ret.putAll(getEnvVarPlatformFileTools(referencingPlatformPath.toFile()));
+ } else {
+ ret.putAll(getEnvVarPlatformFileTools(referencingPlatform));
+ }
+
+ if (myReferencedPlatformCore == null) {
+ // there is no referenced core so no need to do smart stuff
+ return ret;
+ }
+
+ boolean jsonBasedPlatformManagement = !ConfigurationPreferences.getUseArduinoToolSelection();
+ if (jsonBasedPlatformManagement) {
+ // overrule the Arduino IDE way of working and use the json refereced tools
+ ret.putAll(getEnvVarPlatformFileTools(referencingPlatform));
+ return ret;
+ }
+ // standard arduino IDE way
+ ret.putAll(getEnvVarPlatformFileTools(myReferencedPlatformCore));
+ return ret;
+
+ }
+
+ /**
+ * This method only returns environment variables with and without version
+ * number
+ * These are purely based on the tool dependencies
+ *
+ * @param platformVersion
+ * @return environment variables pointing to the tools used by the platform
+ * @throws IOException
+ */
+ private Map getEnvVarPlatformFileTools(IArduinoPlatformVersion platformVersion) throws IOException {
+ if (platformVersion == null) {
+ Path path = new Path(myUserSelectedBoardsTxtFile.toString());
+ File sloeberTxtFile = path.removeLastSegments(1).append(SLOEBER_TXT_FILE_NAME).toFile();
+ return getEnvVarPlatformFileTools(sloeberTxtFile);
+ }
+ File sloeberTxtFile = platformVersion.getInstallPath().append(SLOEBER_TXT_FILE_NAME).toFile();
+ deleteIfOutdated(sloeberTxtFile);
+
+ if (!sloeberTxtFile.exists()) {
+
+ String vars = FIRST_SLOEBER_LINE + NEWLINE;
+ for (ArduinoPlatformTooldDependency tool : platformVersion.getToolsDependencies()) {
+ IPath installPath = tool.getInstallPath();
+ if (installPath.toFile().exists()) {
+ String value = installPath.toOSString();
+ String keyString = ENV_KEY_RUNTIME_TOOLS + tool.getName() + tool.getVersion() + DOT_PATH;
+ vars = vars + NEWLINE + keyString + EQUAL + value;
+ keyString = ENV_KEY_RUNTIME_TOOLS + tool.getName() + '-' + tool.getVersion() + DOT_PATH;
+ vars = vars + NEWLINE + keyString + EQUAL + value;
+ keyString = ENV_KEY_RUNTIME_TOOLS + tool.getName() + DOT_PATH;
+ vars = vars + NEWLINE + keyString + EQUAL + value;
+ }
+ }
+ Files.write(sloeberTxtFile.toPath(), vars.getBytes(), StandardOpenOption.TRUNCATE_EXISTING,
+ StandardOpenOption.CREATE);
+ }
+
+ return getEnvVarPlatformFileTools(sloeberTxtFile);
+ }
+
+ private static Map getEnvVarPlatformFileTools(File sloeberTxtFile) {
+ if (sloeberTxtFile == null || (!sloeberTxtFile.exists())) {
+ return new HashMap<>();
+ }
+ TxtFile sloeberTxt = new TxtFile(sloeberTxtFile);
+ return sloeberTxt.getAllEnvironVars(EMPTY);
+ }
+
+ /**
+ * If the sloeber.txt variant exists delete it if it is outdated
+ *
+ * @param tmpFile
+ */
+ private static void deleteIfOutdated(File tmpFile) {
+ if (tmpFile.exists()) {
+ // delete if outdated
+ String firstLine = null;
+ try (BufferedReader Buff = new BufferedReader(new FileReader(tmpFile));) {
+ firstLine = Buff.readLine().trim();
+ } catch (@SuppressWarnings("unused") Exception e) {
+ // ignore and delete the file
+ }
+ if (!FIRST_SLOEBER_LINE.trim().equals(firstLine)) {
+ tmpFile.delete();
+ }
+ }
+ }
+
+ /**
+ * Following post processing is done
+ *
+ *
+ * The handling of the upload variables is done differently in arduino
+ * than in Sloeber. This is taken care of here. for example the output of this
+ * input
+ * tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose}
+ * is changed as if it were the output of this input
+ * tools.avrdude.upload.pattern="{tools.avrdude.cmd.path}"
+ * "-C{tools.avrdude.config.path}" {tools.avrdude.upload.verbose}
+ *
+ * if a programmer is selected different from default some extra actions
+ * are done here so no special code is needed to handle programmers
+ *
+ * The build path for the core is {build.path}/core/core in sloeber
+ * where it is {build.path}/core/ in arduino world and used to be {build.path}/
+ * This only gives problems in the link command as sometimes there are hardcoded
+ * links to some sys files so ${build.path}/core/sys* ${build.path}/sys* is
+ * replaced with ${build.path}/core/core/sys*
+ *
+ * @param contribEnv
+ * @param confDesc
+ * @param boardsDescriptor
+ */
+ private static Map getEnvVarsPostProcessing(Map vars) {
+
+ Map extraVars = new HashMap<>();
+
+ ArrayList objcopyCommand = new ArrayList<>();
+ for (Entry curVariable : vars.entrySet()) {
+ String name = curVariable.getKey();
+ String value = curVariable.getValue();
+ if (name.startsWith(RECIPE_OBJCOPY) && name.endsWith(".pattern") && !value.isEmpty()) { //$NON-NLS-1$
+ objcopyCommand.add(makeEnvironmentVar(name));
+ }
+ }
+ Collections.sort(objcopyCommand);
+ extraVars.put(SLOEBER_OBJCOPY, StringUtil.join(objcopyCommand, NEWLINE));
+
+ // add -relax for mega boards; the arduino ide way
+ String buildMCU = vars.get(ENV_KEY_BUILD_MCU);
+ if ("atmega2560".equalsIgnoreCase(buildMCU)) { //$NON-NLS-1$
+ String c_elf_flags = vars.get(ENV_KEY_BUILD_COMPILER_C_ELF_FLAGS);
+ extraVars.put(ENV_KEY_BUILD_COMPILER_C_ELF_FLAGS, c_elf_flags + ",--relax"); //$NON-NLS-1$
+ }
+ return extraVars;
+ }
+
+ public LinkedHashMap getHookSteps(LinkedHashSet hookNames,IAutoBuildConfigurationDescription autoData) {
+ LinkedHashMap hookSteps = new LinkedHashMap<>();
+ KeyValueTree keyValueTree = KeyValueTree.createRoot();
+
+ PlatformTxtFile referencedPlatfromFile = getreferencedCorePlatformFile();
+ // process the platform file referenced by the boards.txt
+ if (referencedPlatfromFile != null) {
+ try {
+ keyValueTree.mergeFile(referencedPlatfromFile.getLoadedFile());
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ PlatformTxtFile referencingPlatfromFile = getReferencingPlatformFile();
+ // process the platform file next to the selected boards.txt
+ if (referencingPlatfromFile != null) {
+ try {
+ keyValueTree.mergeFile(referencingPlatfromFile.getLoadedFile());
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ KeyValueTree hooks = keyValueTree.getChild(RECIPE).getChild(HOOKS);
+ for (String hookName : hookNames) {
+ hooks = hooks.getChild(hookName);
+ }
+
+ // Try to find the nums from 1 to 10 in order
+ // that is 01 1 02 2
+
+ for (int hoookNum = 1; hoookNum < 10; hoookNum++) {
+ boolean exists = false;
+ for (int numDigits = 1; numDigits <= 2; numDigits++) {
+ String formatter = "%0" + Integer.toString(numDigits) + "d"; //$NON-NLS-1$ //$NON-NLS-2$
+ String curKey = String.format(formatter, Integer.valueOf(hoookNum));
+ KeyValueTree curHook = hooks.getChild(curKey).getChild(PATTERN);
+ if (curHook.getValue() != null) {
+ String cmd = resolve(curHook.getValue(), EMPTY_STRING, WHITESPACE, autoData);
+ hookSteps.put(curKey, cmd);
+ exists = true;
+ }
+ }
+ if (!exists) {
+ break;
+ }
+ }
+ return hookSteps;
+ }
+
+ public boolean isValid() {
+ if (!myUserSelectedBoardsTxtFile.exists()) {
+ return false;
+ }
+ File boardsFile = mySloeberBoardTxtFile.getLoadedFile();
+ if (boardsFile == null) {
+ return false;
+ }
+ return boardsFile.exists();
+ }
+
+ public void reloadTxtFile() {
+ mySloeberBoardTxtFile.reloadTxtFile();
+
+ }
+
+ public Map getAllMenus() {
+ return mySloeberBoardTxtFile.getMenus();
+ }
+
+ public boolean isSSHUpload() {
+ if (!isNetworkUpload()) {
+ return false;
+ }
+ // This is a hardcoded fix. Not sure how to do better
+ return myBoardID.equals("yun"); //$NON-NLS-1$
+ }
+
+ public String getDefaultValueIDFromMenu(String menuID) {
+ return this.mySloeberBoardTxtFile.getDefaultValueIDFromMenu(getBoardID(), menuID);
+ }
+
+ public String getDefaultValueNameFromMenu(String menuID) {
+ return this.mySloeberBoardTxtFile.getDefaultValueNameFromMenu(getBoardID(), menuID);
+ }
+
+ public boolean isPrivate() {
+ return !sloeberHomePath.isPrefixOf(new Path(myUserSelectedBoardsTxtFile.toString()));
+ }
+}
diff --git a/io.sloeber.core/src/io/sloeber/arduinoFramework/api/BoardsManager.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/BoardsManager.java
new file mode 100644
index 000000000..bbf3e406b
--- /dev/null
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/BoardsManager.java
@@ -0,0 +1,929 @@
+package io.sloeber.arduinoFramework.api;
+
+import static io.sloeber.core.Messages.*;
+import static io.sloeber.core.api.Common.*;
+import static io.sloeber.core.api.ConfigurationPreferences.*;
+import static io.sloeber.core.api.Const.*;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import com.google.gson.Gson;
+
+import io.sloeber.arduinoFramework.internal.ArduinoPlatformPackageIndex;
+import io.sloeber.arduinoFramework.internal.ArduinoPlatformTool;
+import io.sloeber.arduinoFramework.internal.ArduinoPlatformToolVersion;
+import io.sloeber.arduinoFramework.internal.ArduinoPlatformTooldDependency;
+import io.sloeber.core.Activator;
+import io.sloeber.core.Messages;
+import io.sloeber.core.api.ConfigurationPreferences;
+import io.sloeber.core.api.Defaults;
+import io.sloeber.core.api.VersionNumber;
+import io.sloeber.core.common.InstancePreferences;
+import io.sloeber.core.managers.InstallProgress;
+import io.sloeber.core.tools.MyMultiStatus;
+import io.sloeber.core.tools.PackageManager;
+import io.sloeber.core.txt.WorkAround;
+
+/**
+ * This class groups both boards installed by the hardware manager and boards
+ * installed locally.
+ *
+ * @author jantje
+ *
+ */
+public class BoardsManager {
+ private static final String THIRD_PARTY_URL_FILE = "sloeber_third_party_url.txt"; //$NON-NLS-1$
+
+ private static Set packageIndices = new HashSet<>();
+ private static Set myPackageURLs = new HashSet<>();
+ private static boolean myHasbeenLogged = false;
+ private static boolean envVarsNeedUpdating = true;// reset global variables at startup
+
+ private static HashMap myWorkbenchEnvironmentVariables = new HashMap<>();
+
+ private static boolean myIsDirty = true;
+
+ private static boolean myIsUpdating =false;
+
+ static {
+ getPersistentPackageURLList();
+ }
+
+ public static boolean isReady() {
+ return !(myIsDirty || myIsUpdating || envVarsNeedUpdating);
+ }
+
+ /**
+ * Gets the board description based on the information provided. If
+ * jsonFileName="local" the board is assumed not to be installed by the boards
+ * manager. Otherwise the boardsmanager is queried to find the board descriptor.
+ * In this case the latest installed board will be returned
+ *
+ * @param jsonURL equals to "local" or the name of the json file used by
+ * the boards manager to install the boards
+ * @param packageName if jsonFileName equals "local" the filename of the
+ * boards.txt containing the boards. otherwise the name of
+ * the package containing the board
+ * @param architectureID ignored if jsonFileName equals "local" otherwise the
+ * architecture name of the platform containing the board
+ * (this assumes the architecture is the unique id for the
+ * platform)
+ * @param boardID the id of the board in the boards.txt file
+ * @param options the options to specify the board (the menu named on the
+ * boards.txt file) or null for defaults
+ * @return The class BoardDescriptor or null
+ */
+ static public BoardDescription getBoardDescription(String jsonURL, String packageName, String architectureID,
+ String boardID, Map options) {
+ if (LOCAL.equals(jsonURL)) {
+ return new BoardDescription(jsonURL,new File(packageName), boardID, options);
+ }
+ update(false);
+ return getNewestBoardIDFromBoardsManager(jsonURL, packageName, architectureID, boardID, options);
+ }
+
+ static private BoardDescription getNewestBoardIDFromBoardsManager(String jsonURL, String packageName,
+ String architectureID, String boardID, Map options) {
+
+ IArduinoPackage thePackage = getPackage(jsonURL, packageName);
+ if (thePackage == null) {
+ System.err.println("failed to find package:" + packageName); //$NON-NLS-1$
+ return null;
+ }
+ IArduinoPlatform platform = thePackage.getPlatform(architectureID);
+ if (platform == null) {
+ System.err.println("failed to find architecture ID " + architectureID + " in package:" + packageName); //$NON-NLS-1$ //$NON-NLS-2$
+ return null;
+ }
+ IArduinoPlatformVersion platformVersion = platform.getNewestVersion();
+ java.io.File boardsFile = platformVersion.getBoardsFile();
+ BoardDescription boardid = new BoardDescription(jsonURL,boardsFile, boardID, options);
+
+ return boardid;
+ }
+
+ public static void addPackageURLs(Collection packageUrlsToAdd) {
+ Set newList = new HashSet<>();
+ newList.addAll(myPackageURLs);
+ newList.addAll(packageUrlsToAdd);
+ setPackageURLs(newList);
+// HashSet originalJsonUrls = new HashSet<>(Arrays.asList(getJsonURLList()));
+// packageUrlsToAdd.addAll(originalJsonUrls);
+//
+// setJsonURLs(packageUrlsToAdd);
+// downloadJsons( forceDownload);
+// readJsons();
+ }
+
+ public static void setPackageURLs(Collection packageUrls) {
+ Set orgList = new HashSet<>();
+ orgList.addAll(myPackageURLs);
+ myPackageURLs.clear();
+ myPackageURLs.addAll(packageUrls);
+ if (!orgList.equals(myPackageURLs)) {
+ myIsDirty = true;
+
+ IPath myThirdPartyURLStoragePath = getThirdPartyURLStoragePath();
+ try {
+ if (myThirdPartyURLStoragePath != null) {
+ Files.write(myThirdPartyURLStoragePath.toPath(), myPackageURLs,
+ Charset.forName(StandardCharsets.UTF_8.name()));
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+//
+// if (!isReady()) {
+// Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
+// return;
+// }
+// setJsonURLs(packageUrls);
+// downloadJsons( forceDownload);
+// readJsons();
+ }
+
+ /**
+ * installs a subset of the latest platforms It skips the first
+ * platforms And stops at platforms. To install the 5 first latest
+ * platforms installsubsetOfLatestPlatforms(0,5)
+ *
+ * @param fromIndex the platforms at the start to skip
+ * @param toIndex the platforms after this platform are skipped
+ */
+ public static void installsubsetOfLatestPlatforms(int fromIndex, int toIndex) {
+ String DEPRECATED = "DEPRECATED"; //$NON-NLS-1$
+ if (myIsDirty) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
+ return;
+ }
+
+ synchronized (packageIndices) {
+ int currPlatformIndex = 1;
+ NullProgressMonitor monitor = new NullProgressMonitor();
+ List allPackages = getPackages();
+ for (IArduinoPackage curPackage : allPackages) {
+ Collection latestPlatforms = curPackage.getPlatforms();
+ for (IArduinoPlatform curPlatform : latestPlatforms) {
+ if (!curPlatform.getName().toUpperCase().contains(DEPRECATED)) {
+ if (currPlatformIndex > fromIndex) {
+ IArduinoPlatformVersion latestPlatformVersion = curPlatform.getNewestVersion();
+ if (!latestPlatformVersion.getName().toUpperCase().contains(DEPRECATED)) {
+ install(latestPlatformVersion, monitor);
+ } else {
+ System.out.println("skipping platform " + latestPlatformVersion.toString()); //$NON-NLS-1$
+ }
+ }
+ if (currPlatformIndex++ > toIndex) {
+ return;
+ }
+ } else {
+ System.out.println("skipping platform " + curPlatform.toString()); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Install all the latest platforms Assumes there are less than 100000 platforms
+ */
+ public static void installAllLatestPlatforms() {
+ installsubsetOfLatestPlatforms(0, 100000);
+ }
+
+ public static void installLatestPlatform(String JasonName, String packagerName, String architectureName) {
+ if (myIsDirty) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
+ return;
+ }
+ internalInstallLatestPlatform( JasonName, packagerName, architectureName);
+ }
+
+ private static void internalInstallLatestPlatform(String JasonName, String packagerName, String architectureName) {
+ synchronized (packageIndices) {
+ IArduinoPackage curPackage = getPackage(JasonName, packagerName);
+ if (curPackage != null) {
+ IArduinoPlatform curPlatform = curPackage.getPlatform(architectureName);
+ if (curPlatform != null) {
+ IArduinoPlatformVersion curPlatformVersion = curPlatform.getNewestVersion();
+ if (curPlatformVersion != null) {
+ NullProgressMonitor monitor = new NullProgressMonitor();
+ install(curPlatformVersion, monitor);
+ return;
+ }
+ }
+ }
+ }
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
+ "failed to find " + JasonName + " " + packagerName + " " + architectureName)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ private static IStatus install(IArduinoPlatformVersion platformVersion, IProgressMonitor monitor) {
+ boolean forceDownload = false;
+ // Check if we're installed already
+ if (platformVersion.isInstalled()) {
+ System.out.println("reusing platform " + platformVersion.toString()); //$NON-NLS-1$
+ return Status.OK_STATUS;
+ }
+
+ envVarsNeedUpdating = true;
+
+ // Download platform archive
+ System.out.println("start installing platform " + platformVersion.toString()); //$NON-NLS-1$
+
+ MyMultiStatus mstatus = new MyMultiStatus("Failed to install " + platformVersion.getName()); //$NON-NLS-1$
+ mstatus.addErrors(PackageManager.downloadAndInstall(platformVersion, forceDownload, monitor));
+ if (!mstatus.isOK()) {
+ // no use installing tools when the boards failed installing
+ return mstatus;
+ }
+
+ // keep a copy of the json file used at install
+ File packageFile = platformVersion.getParent().getParent().getPackageIndex().getJsonFile();
+ File copyToFile = platformVersion.getInstallPath().append(packageFile.getName()).toFile();
+ try {
+ Files.copy(packageFile.toPath(), copyToFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ IArduinoPackage referencingPkg = platformVersion.getParent().getParent();
+ for (ArduinoPlatformTooldDependency toolDependency : platformVersion.getToolsDependencies()) {
+ ArduinoPlatformToolVersion tool = referencingPkg.getTool(toolDependency.getName(),
+ toolDependency.getVersion());
+ if (tool == null) {
+ // this is a tool provided by another platform
+ // and the referencing platform does not specify the installable info
+ // This means the package file of the referencing platform needs to be provided
+ IArduinoPackage pkg = getPackageByProvider(toolDependency.getPackager());
+ if (pkg != null) {
+ tool = pkg.getTool(toolDependency.getName(), toolDependency.getVersion());
+ }
+ }
+ if (tool == null) {
+ mstatus.add(new Status(IStatus.ERROR, Activator.getId(),
+ Messages.Tool_no_valid_system.replace(Messages.KEY_TAG, toolDependency.getName())));
+ } else if (!tool.isInstalled()) {
+ ArduinoInstallable installable = tool.getInstallable();
+ if (installable != null) {
+ monitor.setTaskName(InstallProgress.getRandomMessage());
+ mstatus.addErrors(PackageManager.downloadAndInstall(installable, forceDownload, monitor));
+ }
+ }
+ }
+
+ WorkAround.applyKnownWorkArounds(platformVersion);
+
+ System.out.println("done installing platform " + platformVersion.toString()); //$NON-NLS-1$
+ return mstatus;
+ }
+
+ public static void addPrivateHardwarePath(String newHardwarePath) {
+ if (newHardwarePath == null) {
+ return;
+ }
+ String currentPaths[] = InstancePreferences.getPrivateHardwarePaths();
+ String newPaths[] = new String[currentPaths.length + 1];
+ for (int i = 0; i < currentPaths.length; i++) {
+ if (currentPaths[i].equals(newHardwarePath)) {
+ return;
+ }
+ newPaths[i] = currentPaths[i];
+ }
+ newPaths[currentPaths.length] = newHardwarePath;
+ InstancePreferences.setPrivateHardwarePaths(newPaths);
+ }
+
+ /**
+ * Searches for all boards.txt files from the hardware folders and the boards
+ * manager
+ *
+ * @return all the boards.txt files with full path and in a case insensitive
+ * order
+ */
+ public static File[] getAllBoardsFiles() {
+ update(false);
+ String hardwareFolders[] = getHardwarePaths();
+
+ TreeSet boardFiles = new TreeSet<>();
+ for (String CurFolder : hardwareFolders) {
+ searchFiles(new File(CurFolder), boardFiles, BOARDS_FILE_NAME, 6);
+ }
+ if (boardFiles.size() == 0) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
+ Helpers_No_boards_txt_found.replace(FILE_TAG, String.join("\n", hardwareFolders)), null)); //$NON-NLS-1$
+ return null;
+ }
+ return boardFiles.toArray(new File[boardFiles.size()]);
+ }
+
+ private static void searchFiles(File folder, TreeSet Hardwarelists, String Filename, int depth) {
+ if (depth > 0) {
+ File[] a = folder.listFiles();
+ if (a == null) {
+ if (!myHasbeenLogged) {
+ Activator.log(new Status(IStatus.INFO, CORE_PLUGIN_ID,
+ Helpers_Error_The_folder_is_empty.replace(FOLDER_TAG, folder.toString()), null));
+ myHasbeenLogged = true;
+ }
+ return;
+ }
+ for (File f : a) {
+ if (f.isDirectory()) {
+ // ignore folders named tools
+ if (!f.getName().equals(TOOLS)) {
+ searchFiles(f, Hardwarelists, Filename, depth - 1);
+ }
+ } else if (f.getName().equals(Filename)) {
+ Hardwarelists.add(f);
+ }
+ }
+ }
+ }
+
+ /**
+ * Gets all the folders that can contain hardware
+ *
+ * @return a list of all the folder locations that can contain hardware
+ */
+ private static String[] getHardwarePaths() {
+ return (InstancePreferences.getPrivateHardwarePathsString() + File.pathSeparator
+ + ConfigurationPreferences.getInstallationPathPackages()).split(File.pathSeparator);
+ }
+
+ public static IStatus updatePlatforms(List platformsToInstall,
+ List platformsToRemove, IProgressMonitor monitor, MultiStatus status) {
+ if (myIsDirty) {
+ status.add(new Status(IStatus.ERROR, CORE_PLUGIN_ID, BoardsManagerIsBussy, null));
+ return status;
+ }
+// //TODO updating the jsons after selecting what to install seems dangerous to me; check to delete
+// if (!ConfigurationPreferences.getUpdateJasonFilesFlag()) {
+// downloadJsons( true);
+// readJsons();
+// }
+ try {
+ synchronized (packageIndices) {
+ for (IArduinoPlatformVersion curPlatform : platformsToRemove) {
+ status.add(uninstall(curPlatform));
+ }
+ for (IArduinoPlatformVersion curPlatform : platformsToInstall) {
+ status.add(install(curPlatform, monitor));
+ }
+ }
+ } catch (@SuppressWarnings("unused") Exception e) {
+ // do nothing
+ }
+ return status;
+ }
+
+ private static IStatus uninstall(IArduinoPlatformVersion curPlatform) {
+ if (!curPlatform.isInstalled()) {
+ return Status.OK_STATUS;
+ }
+
+ IPath installFolder = curPlatform.getInstallPath();
+ try {
+ deleteDirectory(installFolder);
+ envVarsNeedUpdating = true;
+ } catch (IOException e) {
+ return new Status(IStatus.ERROR, Activator.getId(), "Failed to remove folder" + installFolder.toOSString(), //$NON-NLS-1$
+ e);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+// public static TreeMap getAllmenus() {
+// update(false);
+// TreeMap ret = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+// File[] boardFiles = getAllBoardsFiles();
+// for (File curBoardFile : boardFiles) {
+// BoardTxtFile txtFile = new BoardTxtFile(curBoardFile);
+// ret.putAll(txtFile.getMenus());
+// }
+// return ret;
+// }
+
+ public static void setPrivateHardwarePaths(String[] hardWarePaths) {
+ InstancePreferences.setPrivateHardwarePaths(hardWarePaths);
+ }
+
+ public static String getPrivateHardwarePathsString() {
+ return InstancePreferences.getPrivateHardwarePathsString();
+ }
+
+ /**
+ * Download the json files from the internet If the file has already been
+ * downloaded it will only be downloaded again when forceDownload is true
+ *
+ * If the file exists and the download fails the original file will not be
+ * deleted.
+ *
+ * @param forceDownload if true all the json files will be replaced with new
+ * versions
+ */
+ private static void downloadJsons(boolean forceDownload) {
+ String[] jsonUrls = getJsonURLList();
+ for (String jsonUrl : jsonUrls) {
+ if (!jsonUrl.trim().isEmpty()) // skip empty lines
+ downloadJson(jsonUrl, forceDownload);
+ }
+ }
+
+ private static void downloadJson(String jsonUrl, boolean forceDownload) {
+ File jsonFile = getLocalFileName(jsonUrl, true);
+ if (jsonFile == null) {
+ return;
+ }
+ File jsonTmpFile = new File(jsonFile.toString() + ".new"); //$NON-NLS-1$
+ File jsonOldFile = new File(jsonFile.toString() + ".prev"); //$NON-NLS-1$
+ if (!jsonFile.exists() || forceDownload) {
+ jsonFile.getParentFile().mkdirs();
+ try {
+ if (jsonTmpFile.exists()) {
+ jsonTmpFile.delete();
+ }
+ PackageManager.mySafeCopy(new URL(jsonUrl.trim()), jsonTmpFile, false);
+ if (jsonOldFile.exists()) {
+ jsonOldFile.delete();
+ }
+ jsonFile.renameTo(jsonOldFile);
+ jsonTmpFile.renameTo(jsonFile);
+ } catch (IOException e) {
+ Activator.log(new Status(IStatus.ERROR, Activator.getId(), "Unable to download " + jsonUrl, e)); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * This method takes all the json boards file urls and downloads them and parses
+ * them for usage in the boards manager
+ *
+ * @param url the url of the file to download and load
+ * @param forceDownload set true if you want to download the file even if it is
+ * already available locally
+ */
+ private static void readJsons() {
+ LibraryManager.flushIndices();
+ packageIndices.clear();
+
+ String[] jsonUrls = getJsonURLList();
+ for (String jsonUrl : jsonUrls) {
+ if (!jsonUrl.isBlank()) {// skip empty lines
+ File jsonFile = getLocalFileName(jsonUrl, true);
+ if (jsonFile == null) {
+ return;
+ }
+ if (jsonFile.exists()) {
+ if (jsonFile.getName().toLowerCase().startsWith("package_")) { //$NON-NLS-1$
+ loadPackageJson(jsonUrl, jsonFile);
+ } else if (jsonFile.getName().toLowerCase().startsWith("library_")) { //$NON-NLS-1$
+ LibraryManager.loadJson(jsonFile);
+ } else {
+ Activator.log(new Status(IStatus.ERROR, Activator.getId(),
+ "json files should start with \"package_\" or \"library_\" " + jsonUrl //$NON-NLS-1$
+ + " is ignored")); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+
+ static private void loadPackageJson(String url, File jsonFile) {
+ try (Reader reader = new FileReader(jsonFile)) {
+ ArduinoPlatformPackageIndex index = new Gson().fromJson(reader, ArduinoPlatformPackageIndex.class);
+ index.setPackageFile(jsonFile);
+ index.setURL(url);
+ packageIndices.add(index);
+ } catch (Exception e) {
+ Activator.log(new Status(IStatus.ERROR, Activator.getId(),
+ Manager_Failed_to_parse.replace(FILE_TAG, jsonFile.getAbsolutePath()), e));
+ jsonFile.delete();// Delete the file so it stops damaging
+ }
+ }
+
+ /**
+ * convert a web url to a local file name. The local file name is the cache of
+ * the web
+ *
+ * @param url url of the file we want a local cache
+ * @return the file that represents the file that is the local cache. the file
+ * itself may not exists. If the url is malformed return null;
+ * @throws MalformedURLException
+ */
+ private static File getLocalFileName(String url, boolean show_error) {
+ URL packageUrl;
+ try {
+ packageUrl = new URL(url.trim());
+ } catch (MalformedURLException e) {
+ if (show_error) {
+ Activator.log(new Status(IStatus.ERROR, Activator.getId(), "Malformed url " + url, e)); //$NON-NLS-1$
+ }
+ return null;
+ }
+ if ("file".equals(packageUrl.getProtocol())) { //$NON-NLS-1$
+ String tst = packageUrl.getFile();
+ File file = new File(tst);
+ String localFileName = file.getName();
+ java.nio.file.Path packagePath = Paths
+ .get(ConfigurationPreferences.getInstallationPath().append(localFileName).toString());
+ return packagePath.toFile();
+ }
+ String localFileName = Paths.get(packageUrl.getPath()).getFileName().toString();
+ java.nio.file.Path packagePath = Paths
+ .get(ConfigurationPreferences.getInstallationPath().append(localFileName).toString());
+ return packagePath.toFile();
+ }
+
+ public static String[] getDefaultJsonURLs() {
+ return Defaults.DEFAULT_JSON_URLS;
+ }
+
+ public static String[] getJsonURLList() {
+ return myPackageURLs.toArray(new String[myPackageURLs.size()]);
+ }
+
+ private static void getPersistentPackageURLList() {
+ myPackageURLs.clear();
+ IPath myThirdPartyURLStoragePath = getThirdPartyURLStoragePath();
+ try {
+ if (myThirdPartyURLStoragePath != null && myThirdPartyURLStoragePath.toFile().exists()) {
+ List thirdPartyURLs = Files.readAllLines(myThirdPartyURLStoragePath.toPath(),
+ Charset.forName(StandardCharsets.UTF_8.name()));
+ if (thirdPartyURLs.size() > 0) {
+ myPackageURLs.addAll(thirdPartyURLs);
+ return;
+ }
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ // The new way of storing the thirdparty urls's failed
+ // try the Sloeber V3 way for downwards compatibility
+ String[] sloeberV4Storage = getString("Manager jsons", EMPTY_STRING).replace("\r", new String()).split("\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (sloeberV4Storage.length > 3) {
+ myPackageURLs.addAll(Arrays.asList(sloeberV4Storage));
+ return;
+ }
+ // Everything failed; This is probably a new install; return the defaults;
+ myPackageURLs.addAll(Arrays.asList(Defaults.DEFAULT_JSON_URLS));
+
+ }
+
+ private static IPath getThirdPartyURLStoragePath() {
+ return sloeberHomePath.append(SLOEBER_HOME_SUB_FOLDER).append(THIRD_PARTY_URL_FILE);
+ }
+
+ public static void removeAllInstalledPlatforms() {
+ if (myIsDirty) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
+ return;
+ }
+ try {
+ synchronized (packageIndices) {
+ deleteDirectory(ConfigurationPreferences.getInstallationPathPackages());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static IPath getInstallationPath() {
+ return ConfigurationPreferences.getInstallationPath();
+ }
+
+ /**
+ * If something has been installed or deinstalled update the global variables
+ * with references to the installed stuff this to support platforms that do not
+ * explicitly define tools or platform dependencies Like private hardware
+ */
+ public static Map getEnvironmentVariables() {
+ update(false);
+ return myWorkbenchEnvironmentVariables;
+ }
+
+ private static Map getEnvVarPlatformFileTools(IArduinoPlatformVersion platformVersion) {
+ HashMap vars = new HashMap<>();
+ IArduinoPackage pkg = platformVersion.getParent().getParent();
+ for (ArduinoPlatformTooldDependency tool : platformVersion.getToolsDependencies()) {
+ ArduinoPlatformTool theTool = pkg.getTool(tool.getName());
+ if (theTool == null) {
+ System.err.println("Did not find " + tool.getName() + " in package with ID " + pkg.getID()); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ vars.putAll(theTool.getEnvVars(null));
+ }
+ }
+ return vars;
+ }
+
+ /**
+ * given a vendor and a architecture provide the newest installed platform
+ * version
+ *
+ * @param vendor
+ * @param architecture
+ * @return the found platformVersion or null if none found
+ */
+ public static IArduinoPlatformVersion getNewestInstalledPlatform(String vendor, String architecture) {
+ IArduinoPlatform platform = getPlatform(vendor, architecture);
+ if (platform == null) {
+ return null;
+ }
+ return platform.getNewestInstalled();
+ }
+
+ // Below is what used to be the internal package manager class
+
+ public static List getPackageIndices() {
+ update(false);
+ return new LinkedList<>(packageIndices);
+ }
+
+// public static List getPlatforms() {
+// List platforms = new ArrayList<>();
+// for (IArduinoPlatformPackageIndex index : getPackageIndices()) {
+// for (IArduinoPackage pkg : index.getPackages()) {
+// platforms.addAll(pkg.getPlatforms());
+// }
+// }
+// return platforms;
+// }
+
+ public static IArduinoPlatform getPlatform( String vendor, String architecture) {
+ if (myIsDirty) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
+ return null;
+ }
+ for (IArduinoPlatformPackageIndex index : packageIndices) {
+ IArduinoPackage pkg = index.getPackage(vendor);
+ if (pkg != null) {
+ IArduinoPlatform platform = pkg.getPlatform(architecture);
+ if (platform != null) {
+ return platform;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Given a platform.txt file find the platform in the platform manager
+ *
+ * @param platformTxt
+ * @return the found platform otherwise null
+ */
+ public static IArduinoPlatformVersion getPlatform(IPath platformPath) {
+ if (myIsDirty) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
+ return null;
+ }
+ for (IArduinoPlatformPackageIndex index : packageIndices) {
+ for (IArduinoPackage pkg : index.getPackages()) {
+ for (IArduinoPlatform curPlatform : pkg.getPlatforms()) {
+ if (platformPath
+ .matchingFirstSegments(curPlatform.getInstallPath()) > (platformPath.segmentCount() - 2))
+
+ for (IArduinoPlatformVersion curPlatformVersion : curPlatform.getVersions()) {
+ if (curPlatformVersion.getInstallPath().equals(platformPath)) {
+ return curPlatformVersion;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+// static public List getInstalledPlatforms() {
+// List platforms = new ArrayList<>();
+// for (IArduinoPlatformPackageIndex index : getPackageIndices()) {
+// for (IArduinoPackage pkg : index.getPackages()) {
+// platforms.addAll(pkg.getInstalledPlatforms());
+// }
+// }
+// return platforms;
+// }
+
+ /**
+ * Get any installed platform version This can be used in case of error
+ * conditions where any platform is better than null
+ *
+ * @return a platform or null if no platforms are installed
+ */
+ static public IArduinoPlatformVersion getAnyInstalledPlatform() {
+ if (myIsDirty) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
+ return null;
+ }
+ for (IArduinoPlatformPackageIndex index : packageIndices) {
+ for (IArduinoPackage pkg : index.getPackages()) {
+ for (IArduinoPlatformVersion platformVersion : pkg.getInstalledPlatforms()) {
+ return platformVersion;
+ }
+ }
+ }
+ return null;
+ }
+
+ static private boolean areThereInstalledBoards() {
+ for (IArduinoPlatformPackageIndex index : packageIndices) {
+ for (IArduinoPackage pkg : index.getPackages()) {
+ if (pkg.isInstalled()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ static public List getPackages() {
+ List packages = new ArrayList<>();
+ if (myIsDirty) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
+ return packages;
+ }
+
+ for (IArduinoPlatformPackageIndex index : packageIndices) {
+ packages.addAll(index.getPackages());
+ }
+
+ return packages;
+ }
+
+ static private IArduinoPackage getPackage(String jasonURL, String packageName) {
+ for (IArduinoPlatformPackageIndex index : packageIndices) {
+ if (index.getJsonURL().equals(jasonURL)) {
+ return index.getPackage(packageName);
+ }
+ }
+ return null;
+ }
+
+// static public IArduinoPackage getPackage(String packageName) {
+// for (IArduinoPlatformPackageIndex index : getPackageIndices()) {
+// IArduinoPackage pkg = index.getPackage(packageName);
+// if (pkg != null) {
+// return pkg;
+// }
+// }
+// return null;
+// }
+
+ /**
+ * Remove all packages that have a more recent version
+ */
+ public static void onlyKeepLatestPlatforms() {
+ if (myIsDirty) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
+ return;
+ }
+ synchronized (packageIndices) {
+ List allPackages = getPackages();
+ for (IArduinoPackage curPackage : allPackages) {
+ onlyKeepLatestPlatforms(curPackage);
+ }
+ }
+ }
+
+ private static void onlyKeepLatestPlatforms(IArduinoPackage curPackage) {
+ for (IArduinoPlatform curplatform : curPackage.getPlatforms()) {
+ IArduinoPlatformVersion newestVersion = null;
+ for (IArduinoPlatformVersion curVersion : curplatform.getVersions()) {
+ if (curVersion.isInstalled()) {
+ if (newestVersion == null) {
+ newestVersion = curVersion;
+ } else {
+ if (newestVersion.getVersion().compareTo(curVersion.getVersion()) > 0) {
+ uninstall(curVersion);
+ } else {
+ uninstall(newestVersion);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static IArduinoPlatformVersion getPlatform( String vendor, String architecture, VersionNumber refVersion) {
+ IArduinoPlatform platform = getPlatform(vendor, architecture);
+ if (platform != null) {
+ return platform.getVersion(refVersion);
+ }
+ return null;
+ }
+
+ public static IArduinoPackage getPackageByProvider(String packager) {
+ if (myIsDirty) {
+ Activator.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
+ return null;
+ }
+ for (IArduinoPlatformPackageIndex index : packageIndices) {
+ for (IArduinoPackage pkg : index.getPackages()) {
+ if (packager.equals(pkg.getID())) {
+ return pkg;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * If there are changes to the package url's this method will process these
+ * changes
+ *
+ * If there are no boards installed this methoid will install the latest arduino
+ * avr boards
+ *
+ * @param reloadFromInternet if true the downloaded the package files will be
+ * replaced with a newer download (if download
+ * succeeded)
+ */
+ public static void update(boolean reloadFromInternet) {
+ synchronized (packageIndices) {
+ myIsUpdating =true;
+ if (myIsDirty || reloadFromInternet) {
+ downloadJsons(reloadFromInternet);
+ readJsons();
+ if(reloadFromInternet) {
+ ConfigurationPreferences.setLatestUpdateTime(Instant.now());
+ }
+
+ }
+
+ if (!areThereInstalledBoards()) {
+ internalInstallLatestPlatform(Defaults.DEFAULT_INSTALL_JSON, Defaults.DEFAULT_INSTALL_MAINTAINER,
+ Defaults.DEFAULT_INSTALL_ARCHITECTURE);
+ }
+
+ myIsDirty = false;
+
+ if (envVarsNeedUpdating) {
+ myWorkbenchEnvironmentVariables.clear();
+ IArduinoPlatformVersion latestAvrPlatform = getNewestInstalledPlatform(VENDOR_ARDUINO, AVR);
+ IArduinoPlatformVersion latestSamdPlatform = getNewestInstalledPlatform(VENDOR_ARDUINO, SAMD);
+ IArduinoPlatformVersion latestSamPlatform = getNewestInstalledPlatform(VENDOR_ARDUINO, SAM);
+
+ if (latestSamdPlatform != null) {
+ myWorkbenchEnvironmentVariables.putAll(getEnvVarPlatformFileTools(latestSamdPlatform));
+ }
+ if (latestSamPlatform != null) {
+ myWorkbenchEnvironmentVariables.putAll(getEnvVarPlatformFileTools(latestSamPlatform));
+ }
+ if (latestAvrPlatform != null) {
+ myWorkbenchEnvironmentVariables.putAll(getEnvVarPlatformFileTools(latestAvrPlatform));
+ }
+ envVarsNeedUpdating = false;
+ }
+ }
+ myIsUpdating=false;
+ }
+
+ public static String getjsonURLFormBoardsFile(File boardsFile) {
+ File expandedBoardsFile = resolvePathEnvironmentString(boardsFile);
+ String ret=null;
+ for (IArduinoPlatformPackageIndex index : packageIndices) {
+ ret=index.getJsonURL();
+ for (IArduinoPackage pkg : index.getPackages()) {
+ for (IArduinoPlatformVersion platformVersion : pkg.getInstalledPlatforms()) {
+
+ if(platformVersion.getBoardsFile().equals(expandedBoardsFile)) {
+ return ret;
+ }
+ }
+ }
+ }
+ return ret;
+ }
+
+}
diff --git a/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoLibrary.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoLibrary.java
new file mode 100644
index 000000000..c2f7c703e
--- /dev/null
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoLibrary.java
@@ -0,0 +1,53 @@
+package io.sloeber.arduinoFramework.api;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+
+import io.sloeber.core.api.VersionNumber;
+
+public abstract class IArduinoLibrary extends Node implements Comparable{
+
+ public abstract Collection getVersions();
+
+ public abstract String getAuthor();
+
+ public abstract String getMaintainer();
+
+ public abstract String getWebsite();
+
+ public abstract String getCategory();
+
+ public abstract List getArchitectures();
+
+ public abstract List getTypes();
+
+ /**
+ * Get the newest version of this library
+ *
+ * @return the newest version of this library
+ */
+ public abstract IArduinoLibraryVersion getNewestVersion();
+
+ /**
+ * Get the version that is installed
+ * If no version is installed return NULL
+ *
+ * @return
+ */
+ public abstract IArduinoLibraryVersion getInstalledVersion();
+
+ /**
+ * checks if a version of this library is installed.
+ *
+ * @return true if a version is installed. false in case no version is installed
+ */
+ public abstract boolean isInstalled();
+
+
+ public abstract IArduinoLibraryVersion getVersion(VersionNumber versionNumber);
+
+ public abstract IPath getInstallPath();
+
+}
\ No newline at end of file
diff --git a/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoLibraryIndex.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoLibraryIndex.java
new file mode 100644
index 000000000..fac54de7b
--- /dev/null
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoLibraryIndex.java
@@ -0,0 +1,31 @@
+package io.sloeber.arduinoFramework.api;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+
+public interface IArduinoLibraryIndex extends Comparable{
+
+ /**
+ * given a library name provide the library
+ *
+ * @param libraryName
+ * @return the library or null if not found
+ */
+ IArduinoLibrary getLibrary(String libraryName);
+
+ /**
+ * get all the latest versions of all the libraries provided that can be
+ * installed but are not yet installed To do so I find all latest libraries and
+ * I remove the once that are installed.
+ *
+ * @return
+ */
+ Map getLatestInstallableLibraries(Set libNames);
+
+ Collection getLibraries();
+
+ String getID();
+
+}
\ No newline at end of file
diff --git a/io.sloeber.core/src/io/sloeber/core/api/IArduinoLibraryVersion.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoLibraryVersion.java
similarity index 60%
rename from io.sloeber.core/src/io/sloeber/core/api/IArduinoLibraryVersion.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoLibraryVersion.java
index c91d08d7d..368e4df2c 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/IArduinoLibraryVersion.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoLibraryVersion.java
@@ -1,8 +1,12 @@
-package io.sloeber.core.api;
+package io.sloeber.arduinoFramework.api;
+
+import java.util.List;
import org.eclipse.core.runtime.IPath;
-public interface IArduinoLibraryVersion {
+import io.sloeber.core.api.VersionNumber;
+
+public interface IArduinoLibraryVersion extends Comparable{
String getName();
@@ -39,5 +43,21 @@ public interface IArduinoLibraryVersion {
public boolean equals(IArduinoLibraryVersion other);
+ IArduinoLibrary getLibrary();
+
+ VersionNumber getVersion();
+
+ boolean isInstalled();
+
+ List getArchitectures();
+
+ String getParagraph();
+
+ String getSentence();
+
+ String getMaintainer();
+
+ String getAuthor();
+
}
diff --git a/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoPackage.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoPackage.java
new file mode 100644
index 000000000..47dc56f5c
--- /dev/null
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoPackage.java
@@ -0,0 +1,67 @@
+package io.sloeber.arduinoFramework.api;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+
+import io.sloeber.arduinoFramework.internal.ArduinoPlatformTool;
+import io.sloeber.arduinoFramework.internal.ArduinoPlatformToolVersion;
+import io.sloeber.core.api.VersionNumber;
+
+public interface IArduinoPackage extends Comparable{
+
+ IArduinoPlatformPackageIndex getPackageIndex();
+
+ String getMaintainer();
+
+ String getWebsiteURL();
+
+ String getEmail();
+
+ String getHelp();
+
+ Collection getPlatforms();
+
+ /**
+ * This method looks up the installed platforms So if you have 2 arduino avr
+ * platform versions installed you will get back 2.
+ *
+ * @return all the installed platforms
+ */
+ List getInstalledPlatforms();
+
+ /**
+ * get tyhe platform based on the platform ID
+ * The platform ID is the architecture
+ *
+ * @param platformID
+ * @return return the platfiorm or null if not found
+ */
+ IArduinoPlatform getPlatform(String platformID);
+
+ Collection getTools();
+
+ ArduinoPlatformToolVersion getTool(String toolName, VersionNumber version);
+
+ ArduinoPlatformTool getTool(String toolName);
+
+ ArduinoPlatformToolVersion getNewestInstalled(String toolName);
+
+ boolean isInstalled();
+
+ /**
+ * Is any version of the platform installed
+ *
+ * @param platformName
+ * @return if a platform with this name is installed
+ */
+ boolean isAVersionOfThisPlatformInstalled(String platformName);
+
+ String getID();
+
+ IPath getInstallPath();
+
+ String getName();
+
+}
\ No newline at end of file
diff --git a/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoPlatform.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoPlatform.java
new file mode 100644
index 000000000..069682e0f
--- /dev/null
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoPlatform.java
@@ -0,0 +1,42 @@
+package io.sloeber.arduinoFramework.api;
+
+import java.util.Collection;
+
+import org.eclipse.core.runtime.IPath;
+
+import io.sloeber.core.api.VersionNumber;
+
+public interface IArduinoPlatform extends Comparable{
+
+ boolean isInstalled();
+
+ IPath getInstallPath();
+
+ /**
+ * Get the newest version of this platform
+ *
+ * @return the newest version of this platform
+ */
+ IArduinoPlatformVersion getNewestVersion();
+
+ Collection getVersions();
+
+ IArduinoPlatformVersion getVersion(VersionNumber refVersion);
+
+ /**
+ * return the installed version with the newest version number
+ * Null if no version is installed
+ *
+ * @return
+ */
+ IArduinoPlatformVersion getNewestInstalled();
+
+ String getName();
+
+ String getArchitecture();
+
+ IArduinoPackage getParent();
+
+ String getID();
+
+}
\ No newline at end of file
diff --git a/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoPlatformPackageIndex.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoPlatformPackageIndex.java
new file mode 100644
index 000000000..250c17262
--- /dev/null
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoPlatformPackageIndex.java
@@ -0,0 +1,23 @@
+package io.sloeber.arduinoFramework.api;
+
+import java.io.File;
+import java.util.List;
+
+
+public interface IArduinoPlatformPackageIndex {
+
+ List getPackages();
+
+ IArduinoPackage getPackage(String packageName);
+
+ File getJsonFile();
+
+ boolean isInstalled();
+
+ String getID();
+
+ String getName();
+
+ String getJsonURL();
+
+}
\ No newline at end of file
diff --git a/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoPlatformVersion.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoPlatformVersion.java
new file mode 100644
index 000000000..3b84efc1a
--- /dev/null
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoPlatformVersion.java
@@ -0,0 +1,34 @@
+package io.sloeber.arduinoFramework.api;
+
+import java.io.File;
+import java.util.List;
+
+import io.sloeber.arduinoFramework.internal.ArduinoPlatformTooldDependency;
+import io.sloeber.core.api.VersionNumber;
+
+public abstract class IArduinoPlatformVersion extends ArduinoInstallable implements Comparable{
+
+ public abstract IArduinoPlatform getParent();
+
+ public abstract String getArchitecture();
+
+ public abstract VersionNumber getVersion();
+
+ public abstract String getCategory();
+
+ public abstract List getToolsDependencies();
+
+ public abstract boolean isInstalled();
+
+ public abstract File getBoardsFile();
+
+ public abstract File getPlatformFile();
+
+ public abstract List getBoardNames();
+
+ public abstract String getID();
+
+ public abstract String getConcattenatedBoardNames();
+
+
+}
\ No newline at end of file
diff --git a/io.sloeber.core/src/io/sloeber/core/api/IExample.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IExample.java
similarity index 88%
rename from io.sloeber.core/src/io/sloeber/core/api/IExample.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/api/IExample.java
index f38712c82..407256353 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/IExample.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/IExample.java
@@ -1,4 +1,4 @@
-package io.sloeber.core.api;
+package io.sloeber.arduinoFramework.api;
import java.util.Collection;
diff --git a/io.sloeber.core/src/io/sloeber/core/api/LibraryManager.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/LibraryManager.java
similarity index 70%
rename from io.sloeber.core/src/io/sloeber/core/api/LibraryManager.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/api/LibraryManager.java
index 95ab3ad93..455cffb20 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/LibraryManager.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/LibraryManager.java
@@ -1,4 +1,4 @@
-package io.sloeber.core.api;
+package io.sloeber.arduinoFramework.api;
import static io.sloeber.core.Messages.*;
import static io.sloeber.core.api.Common.*;
@@ -18,6 +18,7 @@
import java.util.TreeMap;
import java.util.TreeSet;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -28,14 +29,16 @@
import com.google.gson.Gson;
+import io.sloeber.arduinoFramework.internal.ArduinoLibraryIndex;
+import io.sloeber.arduinoFramework.internal.ArduinoLibraryVersion;
import io.sloeber.core.Activator;
-import io.sloeber.core.api.Json.ArduinoLibrary;
-import io.sloeber.core.api.Json.ArduinoLibraryIndex;
-import io.sloeber.core.api.Json.ArduinoLibraryVersion;
+import io.sloeber.core.api.ConfigurationPreferences;
+import io.sloeber.core.api.Defaults;
+import io.sloeber.core.api.IInstallLibraryHandler;
import io.sloeber.core.common.InstancePreferences;
import io.sloeber.core.core.DefaultInstallHandler;
import io.sloeber.core.internal.ArduinoHardwareLibrary;
-import io.sloeber.core.internal.ArduinoPrivateLibraryVersion;
+import io.sloeber.core.internal.ArduinoPrivateHardwareLibraryVersion;
import io.sloeber.core.internal.Example;
import io.sloeber.core.tools.FileModifiers;
import io.sloeber.core.tools.PackageManager;
@@ -55,10 +58,10 @@ public class LibraryManager {
private static final Set IGNORE_FILES = new HashSet<>(Arrays.asList(DOT, DOT + DOT));
private static final Set CODE_EXTENSIONS = new HashSet<>(Arrays.asList("h", "cpp")); //$NON-NLS-1$ //$NON-NLS-2$
- static private List libraryIndices;
+ static private List libraryIndices;
private static IInstallLibraryHandler myInstallLibraryHandler = new DefaultInstallHandler();
- static public List getLibraryIndices() {
+ static public List getLibraryIndices() {
if (libraryIndices == null) {
BoardsManager.getPackageIndices();
}
@@ -84,19 +87,23 @@ public static String getPrivateLibraryPathsString() {
return InstancePreferences.getPrivateLibraryPathsString();
}
+ public static String[] getPrivateLibraryPaths() {
+ return InstancePreferences.getPrivateLibraryPaths();
+ }
+
public static void setPrivateLibraryPaths(String[] libraryPaths) {
InstancePreferences.setPrivateLibraryPaths(libraryPaths);
}
public static void InstallDefaultLibraries(IProgressMonitor monitor) {
- for (ArduinoLibraryIndex libindex : libraryIndices) {
+ for (IArduinoLibraryIndex libindex : libraryIndices) {
for (String libraryName : Defaults.DEFAULT_INSTALLED_LIBRARIES) {
- ArduinoLibrary toInstalLib = libindex.getLibrary(libraryName);
+ IArduinoLibrary toInstalLib = libindex.getLibrary(libraryName);
if (toInstalLib != null) {
- ArduinoLibraryVersion toInstalLibVersion = toInstalLib.getNewestVersion();
- ArduinoLibraryVersion instaledLibVersion = toInstalLib.getInstalledVersion();
+ IArduinoLibraryVersion toInstalLibVersion = toInstalLib.getNewestVersion();
+ IArduinoLibraryVersion instaledLibVersion = toInstalLib.getInstalledVersion();
if (toInstalLibVersion != null) {
if (toInstalLibVersion != instaledLibVersion) {
if (instaledLibVersion != null) {
@@ -112,11 +119,11 @@ public static void InstallDefaultLibraries(IProgressMonitor monitor) {
static public void loadJson(File jsonFile) {
try (Reader reader = new FileReader(jsonFile)) {
- ArduinoLibraryIndex index = new Gson().fromJson(reader, ArduinoLibraryIndex.class);
- index.setJsonFile(jsonFile);
+ IArduinoLibraryIndex index = new Gson().fromJson(reader, ArduinoLibraryIndex.class);
+ ((ArduinoLibraryIndex)index).setJsonFile(jsonFile);
libraryIndices.add(index);
} catch (Exception e) {
- Common.log(new Status(IStatus.ERROR, Activator.getId(),
+ Activator.log(new Status(IStatus.ERROR, Activator.getId(),
Manager_Failed_to_parse.replace(FILE_TAG, jsonFile.getAbsolutePath()), e));
jsonFile.delete();// Delete the file so it stops damaging
}
@@ -139,6 +146,7 @@ public static void installLibrary(String libName) {
}
}
+
public static IStatus install(IArduinoLibraryVersion inLib, IProgressMonitor monitor) {
if (!(inLib instanceof ArduinoLibraryVersion)) {
return Status.error("Trying to install a library that is not a installable library" + inLib.getName()); //$NON-NLS-1$
@@ -162,7 +170,7 @@ public static IStatus install(IArduinoLibraryVersion inLib, IProgressMonitor mon
* @param monitor
* @return Status.OK_STATUS if delete is successful otherwise IStatus.ERROR
*/
- public static IStatus unInstall(ArduinoLibraryVersion lib, IProgressMonitor monitor) {
+ public static IStatus unInstall(IArduinoLibraryVersion lib, IProgressMonitor monitor) {
if (!lib.isInstalled()) {
return Status.OK_STATUS;
}
@@ -171,7 +179,7 @@ public static IStatus unInstall(ArduinoLibraryVersion lib, IProgressMonitor moni
deleteDirectory(lib.getInstallPath().removeLastSegments(1));
} catch (IOException e) {
return new Status(IStatus.ERROR, Activator.getId(),
- "Failed to remove folder" + lib.getInstallPath().toString(), //$NON-NLS-1$
+ "Failed to remove folder" + lib.getInstallPath().toOSString(), //$NON-NLS-1$
e);
}
@@ -186,16 +194,16 @@ public static IStatus unInstall(ArduinoLibraryVersion lib, IProgressMonitor moni
* @param category
*/
public static void installAllLatestLibraries() {
- List libraryIndices1 = getLibraryIndices();
- for (ArduinoLibraryIndex libraryIndex : libraryIndices1) {
- for (ArduinoLibrary curLib : libraryIndex.getLibraries()) {
+ List libraryIndices1 = getLibraryIndices();
+ for (IArduinoLibraryIndex libraryIndex : libraryIndices1) {
+ for (IArduinoLibrary curLib : libraryIndex.getLibraries()) {
String curLibName = curLib.getNodeName();
String[] skipArray = { "Base64", "Add others if needed" }; //$NON-NLS-1$ //$NON-NLS-2$
List skipList = Arrays.asList(skipArray);
if (!skipList.contains(curLibName)) {
- ArduinoLibraryVersion latestLibVersion = curLib.getNewestVersion();
+ IArduinoLibraryVersion latestLibVersion = curLib.getNewestVersion();
if (!latestLibVersion.isInstalled()) {
- ArduinoLibraryVersion installedLibVersion = curLib.getInstalledVersion();
+ IArduinoLibraryVersion installedLibVersion = curLib.getInstalledVersion();
if (installedLibVersion != null) {
unInstall(installedLibVersion, null);
}
@@ -221,7 +229,7 @@ public static void unInstallAllLibs() {
public static Map getLatestInstallableLibraries(Set libnames) {
Set remainingLibNames = new TreeSet<>(libnames);
Map ret = new HashMap<>();
- for (ArduinoLibraryIndex libraryIndex : libraryIndices) {
+ for (IArduinoLibraryIndex libraryIndex : libraryIndices) {
ret.putAll(libraryIndex.getLatestInstallableLibraries(remainingLibNames));
remainingLibNames.removeAll(ret.keySet());
}
@@ -261,7 +269,7 @@ public static TreeMap getExamplesLibrary(BoardDescription boar
Map installedLibs = getLibrariesAll(boardDescriptor);
for (IArduinoLibraryVersion curLib : installedLibs.values()) {
- examples.putAll(getExamplesFromFolder(curLib, curLib.getExamplePath().toFile(), 2));
+ examples.putAll(getExamplesFromFolder(curLib, curLib.getExamplePath().toFile(), 3));
}
return examples;
@@ -320,17 +328,28 @@ public static TreeMap getExamplesFromIDE() {
return examples;
}
- public static IStatus updateLibraries(Set toUnInstallLibs,
- Set toInstallLibs, IProgressMonitor monitor, MultiStatus status) {
- for (ArduinoLibraryVersion curLib : toUnInstallLibs) {
+ public static IStatus updateLibraries(Set toUnInstallLibs,
+ Set toInstallLibs, IProgressMonitor monitor, MultiStatus status) {
+ for (IArduinoLibraryVersion curLib : toUnInstallLibs) {
status.add(unInstall(curLib, monitor));
}
- for (ArduinoLibraryVersion curLib : toInstallLibs) {
+ for (IArduinoLibraryVersion curLib : toInstallLibs) {
status.add(install(curLib, monitor));
}
return status;
}
+ /**
+ * A convenience (and downward compatibility method of
+ * getLibrariesAll(BoardDescription boardDescriptor, true) {
+ *
+ * @param confDesc can be null
+ * @return A map of FQN IArduinoLibraryVersion
+ */
+ public static TreeMap getLibrariesAll(BoardDescription boardDescriptor) {
+ return getLibrariesAll( boardDescriptor, true);
+ }
+
/**
* Given a sloeber configuration provide all the libraries that can be used by
* this sketch This boils down to all libraries maintained by the Library
@@ -338,36 +357,41 @@ public static IStatus updateLibraries(Set toUnInstallLibs
* provided by the personal libraries
*
* @param confDesc can be null
- * @return
+ * @return if keyIsFQN is true: A map of FQN IArduinoLibraryVersion
+ * if keyIsFQN is false: A map of location IArduinoLibraryVersion
*/
- public static TreeMap getLibrariesAll(BoardDescription boardDescriptor) {
+ public static TreeMap getLibrariesAll(BoardDescription boardDescriptor, boolean keyIsFQN) {
TreeMap libraries = new TreeMap<>();
- libraries.putAll(getLibrariesdManaged());
- libraries.putAll(getLibrariesPrivate());
+ libraries.putAll(getLibrariesdManaged(keyIsFQN));
+ libraries.putAll(getLibrariesPrivate(keyIsFQN));
if (boardDescriptor != null) {
- libraries.putAll(getLibrariesHarware(boardDescriptor));
+ libraries.putAll(getLibrariesHarware(boardDescriptor,keyIsFQN));
}
return libraries;
}
- private static Map getLibrariesdManaged() {
+ private static Map getLibrariesdManaged(boolean keyIsFQN) {
Map ret = new HashMap<>();
- for (ArduinoLibraryIndex libindex : libraryIndices) {
- for (ArduinoLibrary curLib : libindex.getLibraries()) {
+ for (IArduinoLibraryIndex libindex : libraryIndices) {
+ for (IArduinoLibrary curLib : libindex.getLibraries()) {
IArduinoLibraryVersion instVersion = curLib.getInstalledVersion();
if (instVersion != null) {
- ret.put(instVersion.getFQN().toPortableString(), instVersion);
+ if (keyIsFQN) {
+ ret.put(instVersion.getFQN().toPortableString(), instVersion);
+ } else {
+ ret.put(instVersion.getInstallPath().toPortableString(), instVersion);
+ }
}
}
}
return ret;
}
- private static Map getLibrariesPrivate() {
+ private static Map getLibrariesPrivate(boolean keyIsFQN) {
Map ret = new HashMap<>();
String privateLibPaths[] = InstancePreferences.getPrivateLibraryPaths();
for (String curLibPath : privateLibPaths) {
- ret.putAll(getLibrariesFromFolder(new Path(curLibPath), 2, false,true));
+ ret.putAll(getLibrariesFromFolder(new Path(curLibPath), 2, false,true,keyIsFQN));
}
return ret;
@@ -377,12 +401,13 @@ private static Map getLibrariesPrivate() {
* for a given folder return all subfolders
*
* @param ipath the folder you want the subfolders off
+ * @param keyIsFQN
* @return The subfolders of the ipath folder. May contain empty values. This
* method returns a key value pair of key equals foldername and value
* equals full path.
*/
private static Map getLibrariesFromFolder(IPath ipath, int depth,
- boolean isHardwareLib,boolean isPrivate) {
+ boolean isHardwareLib,boolean isPrivate, boolean keyIsFQN) {
if (ConfigurationPreferences.getInstallationPathLibraries().isPrefixOf(ipath)) {
System.err.println("The method findAllPrivateLibs should not be called on Library manager installed libs"); //$NON-NLS-1$
}
@@ -401,13 +426,9 @@ private static Map getLibrariesFromFolder(IPath
}
String fileExt = (new Path(curChild)).getFileExtension();
if (LIBRARY_INDICATION_FILES.contains(curChild) || CODE_EXTENSIONS.contains(fileExt)) {
- if (isHardwareLib) {
- IArduinoLibraryVersion retVersion = new ArduinoHardwareLibrary(ipath);
- ret.put(retVersion.getFQN().toPortableString(), retVersion);
- } else {
- IArduinoLibraryVersion retVersion = new ArduinoPrivateLibraryVersion(ipath);
- ret.put(retVersion.getFQN().toPortableString(), retVersion);
- }
+ IArduinoLibraryVersion retVersion = isHardwareLib?new ArduinoHardwareLibrary(ipath):new ArduinoPrivateHardwareLibraryVersion(ipath);
+ String key=keyIsFQN?retVersion.getFQN().toPortableString():retVersion.getInstallPath().toPortableString();
+ ret.put(key, retVersion);
return ret;
}
@@ -421,7 +442,7 @@ private static Map getLibrariesFromFolder(IPath
IPath LibPath = ipath.append(curFolder);
File LibPathFile = LibPath.toFile();
if (LibPathFile.isDirectory() && !LibPathFile.isHidden()) {
- ret.putAll(getLibrariesFromFolder(LibPath, depth - 1, isHardwareLib,isPrivate));
+ ret.putAll(getLibrariesFromFolder(LibPath, depth - 1, isHardwareLib,isPrivate,keyIsFQN));
}
}
return ret;
@@ -431,23 +452,81 @@ private static Map getLibrariesFromFolder(IPath
* Searches all the hardware dependent libraries of a project. If this is a
* board referencing a core then the libraries of the referenced core are added
* as well
+ * @param keyIsFQN
*
* @param project the project to find all hardware libraries for
* @return all the library folder names. May contain empty values.
*/
- private static Map getLibrariesHarware(BoardDescription boardDescriptor) {
+ public static Map getLibrariesHarware(BoardDescription boardDescriptor, boolean keyIsFQN) {
Map ret = new HashMap<>();
// first add the referenced
IPath libPath = boardDescriptor.getReferencedCoreLibraryPath();
if (libPath != null) {
- ret.putAll(getLibrariesFromFolder(libPath, 1, true,boardDescriptor.isPrivate()));
+ ret.putAll(getLibrariesFromFolder(libPath, 1, true,boardDescriptor.isPrivate(),keyIsFQN));
}
// then add the referencing
libPath = boardDescriptor.getReferencingLibraryPath();
if (libPath != null) {
- ret.putAll(getLibrariesFromFolder(libPath, 1, true,boardDescriptor.isPrivate()));
+ ret.putAll(getLibrariesFromFolder(libPath, 1, true,boardDescriptor.isPrivate(),keyIsFQN));
}
return ret;
}
+ public static IArduinoLibraryVersion getLibraryVersionFromLocation(IFolder libFolder,BoardDescription boardDescriptor) {
+ if (boardDescriptor != null) {
+ IPath libPath=boardDescriptor.getReferencedCoreLibraryPath();
+ if(libPath!=null && libPath.isPrefixOf(libFolder.getLocation())) {
+ return getLibrariesHarware(boardDescriptor,false).get(libFolder.getLocation().toPortableString());
+ }
+ }
+
+ if(ConfigurationPreferences.getInstallationPathLibraries().isPrefixOf(libFolder.getLocation())) {
+ return getLibrariesdManaged(false).get(libFolder.getLocation().toPortableString());
+ }
+
+ return getLibrariesPrivate(false).get(libFolder.getLocation().toPortableString());
+ }
+
+ public static IArduinoLibraryVersion getLibraryVersionFromFQN(String FQNLibName, BoardDescription boardDescriptor) {
+ String[] fqnParts = FQNLibName.split(SLACH);
+ if (fqnParts.length < 3) {
+ return null;
+ }
+ if (!SLOEBER_LIBRARY_FQN.equals(fqnParts[0])) {
+ // this is not a library
+ return null;
+ }
+ if (MANAGED.equals(fqnParts[1])) {
+ if (BOARD.equals(fqnParts[2])) {
+ if (boardDescriptor == null) {
+ return null;
+ }
+ return getLibrariesHarware(boardDescriptor,true).get(FQNLibName);
+ }
+ return getLibrariesdManaged(true).get(FQNLibName);
+ }
+ if (PRIVATE.equals(fqnParts[1])) {
+ return getLibrariesPrivate(true).get(FQNLibName);
+ }
+ return null;
+ }
+
+ /**
+ * Remove a lib based on the name of the lib
+ *
+ * @param libName the name of the lib
+ * @return true if the lib has been removed or was not found
+ * false if the lib was found and the removal failed.
+ */
+ public static boolean uninstallLibrary(String libName) {
+ Map installedLibs=getLibrariesAll(null);
+ IPath libFQN=ArduinoLibraryVersion.calculateFQN(libName);
+ IArduinoLibraryVersion libVersion = installedLibs.get(libFQN.toString());
+ if(libVersion==null) {
+ return true;
+
+ }
+ return unInstall(libVersion, new NullProgressMonitor()).isOK();
+ }
+
}
\ No newline at end of file
diff --git a/io.sloeber.core/src/io/sloeber/core/api/Json/Node.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/Node.java
similarity index 86%
rename from io.sloeber.core/src/io/sloeber/core/api/Json/Node.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/api/Node.java
index cfa59b309..0f751d806 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/Json/Node.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/api/Node.java
@@ -1,4 +1,4 @@
-package io.sloeber.core.api.Json;
+package io.sloeber.arduinoFramework.api;
public abstract class Node {
public boolean hasChildren() {
diff --git a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoLibrary.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoLibrary.java
similarity index 74%
rename from io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoLibrary.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoLibrary.java
index 8978a8f99..cadd31988 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoLibrary.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoLibrary.java
@@ -1,9 +1,10 @@
-package io.sloeber.core.api.Json;
+package io.sloeber.arduinoFramework.internal;
-import static io.sloeber.core.Gson.GsonConverter.*;
+import static io.sloeber.arduinoFramework.internal.GsonConverter.*;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
import java.util.TreeMap;
@@ -13,6 +14,9 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
+import io.sloeber.arduinoFramework.api.IArduinoLibrary;
+import io.sloeber.arduinoFramework.api.IArduinoLibraryVersion;
+import io.sloeber.arduinoFramework.api.Node;
import io.sloeber.core.api.ConfigurationPreferences;
import io.sloeber.core.api.VersionNumber;
@@ -23,7 +27,7 @@
*
*/
-public class ArduinoLibrary extends Node implements Comparable {
+public class ArduinoLibrary extends IArduinoLibrary {
private String name;
private TreeMap versions = new TreeMap<>(Collections.reverseOrder());
@@ -50,15 +54,18 @@ protected void addVersion(JsonElement json) {
versions.put(versionNumber, new ArduinoLibraryVersion(jsonObject, this));
}
- public Collection getVersions() {
- return versions.values();
+ @Override
+ public Collection getVersions() {
+ return new LinkedList<>(versions.values());
}
- public String getAuthor() {
+ @Override
+ public String getAuthor() {
return getNewestVersion().getAuthor();
}
- public String getMaintainer() {
+ @Override
+ public String getMaintainer() {
return getNewestVersion().getMaintainer();
}
@@ -70,19 +77,23 @@ public String getParagraph() {
return getNewestVersion().getParagraph();
}
- public String getWebsite() {
+ @Override
+ public String getWebsite() {
return getNewestVersion().getWebsite();
}
- public String getCategory() {
+ @Override
+ public String getCategory() {
return getNewestVersion().getCategory();
}
- public List getArchitectures() {
+ @Override
+ public List getArchitectures() {
return getNewestVersion().getArchitectures();
}
- public List getTypes() {
+ @Override
+ public List getTypes() {
return getNewestVersion().getTypes();
}
@@ -95,7 +106,8 @@ public String getUrl() {
*
* @return the newest version of this library
*/
- public ArduinoLibraryVersion getNewestVersion() {
+ @Override
+ public ArduinoLibraryVersion getNewestVersion() {
return versions.firstEntry().getValue();
}
@@ -105,7 +117,8 @@ public ArduinoLibraryVersion getNewestVersion() {
*
* @return
*/
- public ArduinoLibraryVersion getInstalledVersion() {
+ @Override
+ public ArduinoLibraryVersion getInstalledVersion() {
for (ArduinoLibraryVersion curVersion : versions.values()) {
if (curVersion.isInstalled()) {
return curVersion;
@@ -119,12 +132,13 @@ public ArduinoLibraryVersion getInstalledVersion() {
*
* @return true if a version is installed. false in case no version is installed
*/
- public boolean isInstalled() {
+ @Override
+ public boolean isInstalled() {
return getInstalledVersion() != null;
}
@Override
- public int compareTo(ArduinoLibrary other) {
+ public int compareTo(IArduinoLibrary other) {
return getID().compareTo(other.getID());
}
@@ -149,11 +163,13 @@ public String getID() {
return name;
}
- public IPath getInstallPath() {
+ @Override
+ public IPath getInstallPath() {
return ConfigurationPreferences.getInstallationPathLibraries().append(this.name.replace(' ', '_'));
}
- public ArduinoLibraryVersion getVersion(VersionNumber versionNumber) {
+ @Override
+ public ArduinoLibraryVersion getVersion(VersionNumber versionNumber) {
return versions.get(versionNumber);
}
diff --git a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoLibraryIndex.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoLibraryIndex.java
similarity index 75%
rename from io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoLibraryIndex.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoLibraryIndex.java
index c9540ccc5..66a123793 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoLibraryIndex.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoLibraryIndex.java
@@ -1,11 +1,12 @@
-package io.sloeber.core.api.Json;
+package io.sloeber.arduinoFramework.internal;
-import static io.sloeber.core.Gson.GsonConverter.*;
+import static io.sloeber.arduinoFramework.internal.GsonConverter.*;
import java.io.File;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -17,6 +18,11 @@
import com.google.gson.JsonParseException;
import com.google.gson.annotations.JsonAdapter;
+import io.sloeber.arduinoFramework.api.IArduinoLibrary;
+import io.sloeber.arduinoFramework.api.IArduinoLibraryIndex;
+import io.sloeber.arduinoFramework.api.IArduinoLibraryVersion;
+import io.sloeber.arduinoFramework.api.Node;
+
/**
* This class represents a json file that references libraries
*
@@ -25,7 +31,7 @@
*/
@JsonAdapter(ArduinoLibraryIndex.class)
public class ArduinoLibraryIndex extends Node
- implements Comparable, JsonDeserializer {
+ implements JsonDeserializer, IArduinoLibraryIndex {
private TreeMap libraries = new TreeMap<>();
private transient File jsonFile;
@@ -35,11 +41,12 @@ public void setJsonFile(File packageFile) {
/**
* given a library name provide the library
- *
+ *
* @param libraryName
* @return the library or null if not found
*/
- public ArduinoLibrary getLibrary(String libraryName) {
+ @Override
+ public IArduinoLibrary getLibrary(String libraryName) {
return libraries.get(libraryName);
}
@@ -50,12 +57,13 @@ public ArduinoLibrary getLibrary(String libraryName) {
*
* @return
*/
- public Map getLatestInstallableLibraries(Set libNames) {
- Map ret = new HashMap<>();
+ @Override
+ public Map getLatestInstallableLibraries(Set libNames) {
+ Map ret = new HashMap<>();
if (libNames.isEmpty()) {
return ret;
}
- for (ArduinoLibrary curLibrary : libraries.values()) {
+ for (IArduinoLibrary curLibrary : libraries.values()) {
if (libNames.contains(curLibrary.getNodeName())) {
if (!curLibrary.isInstalled()) {
ret.put(curLibrary.getNodeName(), curLibrary.getNewestVersion());
@@ -111,12 +119,13 @@ public String getID() {
}
@Override
- public int compareTo(ArduinoLibraryIndex o) {
+ public int compareTo(IArduinoLibraryIndex o) {
return getID().compareTo(o.getID());
}
- public Collection getLibraries() {
- return libraries.values();
+ @Override
+ public Collection getLibraries() {
+ return new LinkedList<> (libraries.values());
}
}
diff --git a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoLibraryVersion.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoLibraryVersion.java
similarity index 86%
rename from io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoLibraryVersion.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoLibraryVersion.java
index 82a176a18..1d7ca727b 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoLibraryVersion.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoLibraryVersion.java
@@ -1,6 +1,6 @@
-package io.sloeber.core.api.Json;
+package io.sloeber.arduinoFramework.internal;
-import static io.sloeber.core.Gson.GsonConverter.*;
+import static io.sloeber.arduinoFramework.internal.GsonConverter.*;
import static io.sloeber.core.api.Const.*;
import java.util.ArrayList;
@@ -13,7 +13,9 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
-import io.sloeber.core.api.IArduinoLibraryVersion;
+import io.sloeber.arduinoFramework.api.IArduinoLibrary;
+import io.sloeber.arduinoFramework.api.IArduinoLibraryVersion;
+import io.sloeber.arduinoFramework.api.Node;
import io.sloeber.core.api.VersionNumber;
/**
@@ -23,7 +25,7 @@
*
*/
-public class ArduinoLibraryVersion extends Node implements IArduinoLibraryVersion, Comparable {
+public class ArduinoLibraryVersion extends Node implements IArduinoLibraryVersion {
private String name;
private VersionNumber version;
@@ -65,29 +67,34 @@ public ArduinoLibraryVersion(JsonElement json, ArduinoLibrary arduinoLibrary) {
archiveFileName = getSafeString(jsonObject, "archiveFileName");
size = jsonObject.get("size").getAsInt();
checksum = getSafeString(jsonObject, "checksum");
- calculateFQN();
+ myFQN=calculateFQN(getName());
} catch (Exception e) {
throw new JsonParseException("failed to parse json " + e.getMessage(),e);
}
}
+ @Override
public VersionNumber getVersion() {
return version;
}
+ @Override
public String getAuthor() {
return author;
}
+ @Override
public String getMaintainer() {
return maintainer;
}
+ @Override
public String getSentence() {
return sentence;
}
+ @Override
public String getParagraph() {
return paragraph;
}
@@ -100,6 +107,7 @@ public String getCategory() {
return category;
}
+ @Override
public List getArchitectures() {
return architectures;
}
@@ -124,12 +132,13 @@ public String getChecksum() {
return checksum;
}
+ @Override
public boolean isInstalled() {
return getInstallPath().toFile().exists();
}
@Override
- public int compareTo(ArduinoLibraryVersion other) {
+ public int compareTo(IArduinoLibraryVersion other) {
if (other == null) {
return 1;
}
@@ -142,7 +151,8 @@ public int compareTo(ArduinoLibraryVersion other) {
return version.toString().compareTo(other.getVersion().toString());
}
- public ArduinoLibrary getLibrary() {
+ @Override
+ public IArduinoLibrary getLibrary() {
return myParent;
}
@@ -195,9 +205,8 @@ public IPath getExamplePath() {
return getInstallPath().append(EXAMPLES_FOLDER);
}
- private void calculateFQN() {
- myFQN= Path.fromPortableString(SLOEBER_LIBRARY_FQN);
- myFQN=myFQN.append(MANAGED).append(getName());
+ static public IPath calculateFQN(String libName) {
+ return Path.fromPortableString(SLOEBER_LIBRARY_FQN).append(MANAGED).append(libName);
}
@Override
diff --git a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPackage.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPackage.java
similarity index 72%
rename from io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPackage.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPackage.java
index 962ddeceb..c2d97d652 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPackage.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPackage.java
@@ -5,9 +5,9 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package io.sloeber.core.api.Json;
+package io.sloeber.arduinoFramework.internal;
-import static io.sloeber.core.Gson.GsonConverter.*;
+import static io.sloeber.arduinoFramework.internal.GsonConverter.*;
import java.util.Collection;
import java.util.LinkedList;
@@ -20,11 +20,14 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
-import io.sloeber.core.api.BoardsManager;
+import io.sloeber.arduinoFramework.api.IArduinoPackage;
+import io.sloeber.arduinoFramework.api.IArduinoPlatform;
+import io.sloeber.arduinoFramework.api.IArduinoPlatformVersion;
+import io.sloeber.arduinoFramework.api.Node;
import io.sloeber.core.api.ConfigurationPreferences;
import io.sloeber.core.api.VersionNumber;
-public class ArduinoPackage extends Node implements Comparable {
+public class ArduinoPackage extends Node implements IArduinoPackage {
private String name;
private String maintainer;
@@ -75,7 +78,8 @@ public ArduinoPackage(JsonElement json, ArduinoPlatformPackageIndex packageIndex
}
}
- public ArduinoPlatformPackageIndex getPackageIndex() {
+ @Override
+ public ArduinoPlatformPackageIndex getPackageIndex() {
return myParent;
}
@@ -84,24 +88,29 @@ public String getNodeName() {
return name;
}
- public String getMaintainer() {
+ @Override
+ public String getMaintainer() {
return maintainer;
}
- public String getWebsiteURL() {
+ @Override
+ public String getWebsiteURL() {
return websiteURL;
}
- public String getEmail() {
+ @Override
+ public String getEmail() {
return email;
}
- public String getHelp() {
+ @Override
+ public String getHelp() {
return helpOnline;
}
- public Collection getPlatforms() {
- return platforms.values();
+ @Override
+ public Collection getPlatforms() {
+ return new LinkedList<>( platforms.values());
}
/**
@@ -110,10 +119,11 @@ public Collection getPlatforms() {
*
* @return all the installed platforms
*/
- public List getInstalledPlatforms() {
- List platformMap = new LinkedList<>();
+ @Override
+ public List getInstalledPlatforms() {
+ List platformMap = new LinkedList<>();
for (ArduinoPlatform platform : platforms.values()) {
- for (ArduinoPlatformVersion platformVersion : platform.getVersions()) {
+ for (IArduinoPlatformVersion platformVersion : platform.getVersions()) {
if (platformVersion.isInstalled()) {
platformMap.add(platformVersion);
}
@@ -129,15 +139,18 @@ public List getInstalledPlatforms() {
* @param platformID
* @return return the platfiorm or null if not found
*/
- public ArduinoPlatform getPlatform(String platformID) {
+ @Override
+ public IArduinoPlatform getPlatform(String platformID) {
return platforms.get(platformID);
}
- public Collection getTools() {
+ @Override
+ public Collection getTools() {
return tools.values();
}
- public ArduinoPlatformToolVersion getTool(String toolName, VersionNumber version) {
+ @Override
+ public ArduinoPlatformToolVersion getTool(String toolName, VersionNumber version) {
ArduinoPlatformTool tool = tools.get(toolName);
if (tool == null) {
return null;
@@ -145,11 +158,13 @@ public ArduinoPlatformToolVersion getTool(String toolName, VersionNumber version
return tool.getVersion(version);
}
- public ArduinoPlatformTool getTool(String toolName) {
+ @Override
+ public ArduinoPlatformTool getTool(String toolName) {
return tools.get(toolName);
}
- public ArduinoPlatformToolVersion getNewestInstalled(String toolName) {
+ @Override
+ public ArduinoPlatformToolVersion getNewestInstalled(String toolName) {
ArduinoPlatformTool tool = tools.get(toolName);
if (tool == null) {
return null;
@@ -171,31 +186,15 @@ public int hashCode() {
}
@Override
- public int compareTo(ArduinoPackage other) {
- return this.name.compareTo(other.name);
+ public int compareTo(IArduinoPackage other) {
+ return this.name.compareTo(other.getName());
}
- public void onlyKeepLatestPlatforms() {
- for (ArduinoPlatform curplatform : platforms.values()) {
- ArduinoPlatformVersion newestVersion = null;
- for (ArduinoPlatformVersion curVersion : curplatform.getVersions()) {
- if (curVersion.isInstalled()) {
- if (newestVersion == null) {
- newestVersion = curVersion;
- } else {
- if (newestVersion.getVersion().compareTo(curVersion.getVersion()) > 0) {
- BoardsManager.uninstall(curVersion, null);
- } else {
- BoardsManager.uninstall(newestVersion, null);
- }
- }
- }
- }
- }
- }
- public boolean isInstalled() {
- for (ArduinoPlatform platform : platforms.values()) {
+
+ @Override
+ public boolean isInstalled() {
+ for (IArduinoPlatform platform : platforms.values()) {
if (platform.isInstalled()) {
return true;
}
@@ -209,7 +208,8 @@ public boolean isInstalled() {
* @param platformName
* @return if a platform with this name is installed
*/
- public boolean isAVersionOfThisPlatformInstalled(String platformName) {
+ @Override
+ public boolean isAVersionOfThisPlatformInstalled(String platformName) {
for (ArduinoPlatform platform : this.platforms.values()) {
if (platform.getName().equals(platformName)) {
if (platform.isInstalled()) {
@@ -225,7 +225,8 @@ public String getID() {
return name;
}
- public IPath getInstallPath() {
+ @Override
+ public IPath getInstallPath() {
return ConfigurationPreferences.getInstallationPathPackages().append(getID());
}
@@ -239,4 +240,9 @@ public Node getParent() {
return myParent;
}
+ @Override
+ public String getName() {
+ return name;
+ }
+
}
diff --git a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatform.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatform.java
similarity index 67%
rename from io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatform.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatform.java
index b97a3a21d..867e6fad0 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatform.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatform.java
@@ -5,13 +5,14 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package io.sloeber.core.api.Json;
+package io.sloeber.arduinoFramework.internal;
-import static io.sloeber.core.Gson.GsonConverter.*;
+import static io.sloeber.arduinoFramework.internal.GsonConverter.*;
import static io.sloeber.core.api.Const.*;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedList;
import java.util.TreeMap;
import org.eclipse.core.runtime.IPath;
@@ -20,14 +21,17 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
+import io.sloeber.arduinoFramework.api.IArduinoPackage;
+import io.sloeber.arduinoFramework.api.IArduinoPlatform;
+import io.sloeber.arduinoFramework.api.IArduinoPlatformVersion;
import io.sloeber.core.api.Const;
import io.sloeber.core.api.VersionNumber;
-public class ArduinoPlatform implements Comparable {
+public class ArduinoPlatform implements IArduinoPlatform {
private String name;
private String architecture;
- private TreeMap myVersions = new TreeMap<>(Collections.reverseOrder());
+ private TreeMap myVersions = new TreeMap<>(Collections.reverseOrder());
private ArduinoPackage myParent;
@@ -50,20 +54,24 @@ protected void addVersion(JsonElement json) {
myVersions.put(version.getVersion(), version);
}
- public ArduinoPackage getParent() {
+ @Override
+ public IArduinoPackage getParent() {
return this.myParent;
}
- public String getName() {
+ @Override
+ public String getName() {
return this.name;
}
- public String getArchitecture() {
+ @Override
+ public String getArchitecture() {
return architecture;
}
- public boolean isInstalled() {
- for (ArduinoPlatformVersion curPlatformVersion : myVersions.values()) {
+ @Override
+ public boolean isInstalled() {
+ for (IArduinoPlatformVersion curPlatformVersion : myVersions.values()) {
if (curPlatformVersion.isInstalled()) {
return true;
}
@@ -71,16 +79,18 @@ public boolean isInstalled() {
return false;
}
- public IPath getInstallPath() {
+ @Override
+ public IPath getInstallPath() {
return myParent.getInstallPath().append(Const.ARDUINO_HARDWARE_FOLDER_NAME).append(getID());
}
- public String getID() {
+ @Override
+ public String getID() {
return architecture;
}
@Override
- public int compareTo(ArduinoPlatform o) {
+ public int compareTo(IArduinoPlatform o) {
return name.compareTo(o.getName());
}
@@ -89,15 +99,18 @@ public int compareTo(ArduinoPlatform o) {
*
* @return the newest version of this platform
*/
- public ArduinoPlatformVersion getNewestVersion() {
+ @Override
+ public IArduinoPlatformVersion getNewestVersion() {
return myVersions.firstEntry().getValue();
}
- public Collection getVersions() {
- return myVersions.values();
+ @Override
+ public Collection getVersions() {
+ return new LinkedList<>(myVersions.values());
}
- public ArduinoPlatformVersion getVersion(VersionNumber refVersion) {
+ @Override
+ public IArduinoPlatformVersion getVersion(VersionNumber refVersion) {
return myVersions.get(refVersion);
}
@@ -107,8 +120,9 @@ public ArduinoPlatformVersion getVersion(VersionNumber refVersion) {
*
* @return
*/
- public ArduinoPlatformVersion getNewestInstalled() {
- for (ArduinoPlatformVersion curVersion : myVersions.values()) {
+ @Override
+ public IArduinoPlatformVersion getNewestInstalled() {
+ for (IArduinoPlatformVersion curVersion : myVersions.values()) {
if (curVersion.isInstalled()) {
return curVersion;
}
diff --git a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformPackageIndex.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformPackageIndex.java
similarity index 76%
rename from io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformPackageIndex.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformPackageIndex.java
index df34bcdae..719d0f057 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformPackageIndex.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformPackageIndex.java
@@ -5,11 +5,12 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package io.sloeber.core.api.Json;
+package io.sloeber.arduinoFramework.internal;
import java.io.File;
import java.lang.reflect.Type;
import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
import com.google.gson.JsonDeserializationContext;
@@ -19,19 +20,27 @@
import com.google.gson.JsonParseException;
import com.google.gson.annotations.JsonAdapter;
+import io.sloeber.arduinoFramework.api.IArduinoPackage;
+import io.sloeber.arduinoFramework.api.IArduinoPlatformPackageIndex;
+import io.sloeber.arduinoFramework.api.Node;
+
@JsonAdapter(ArduinoPlatformPackageIndex.class)
public class ArduinoPlatformPackageIndex extends Node
- implements Comparable, JsonDeserializer {
+ implements Comparable, JsonDeserializer, IArduinoPlatformPackageIndex {
private List myPackages = new ArrayList<>();
private transient File myJsonFile;
- public List getPackages() {
- return myPackages;
+ private String myURL;
+
+ @Override
+ public List getPackages() {
+ return new LinkedList<>(myPackages);
}
- public ArduinoPackage getPackage(String packageName) {
+ @Override
+ public IArduinoPackage getPackage(String packageName) {
for (ArduinoPackage pkg : myPackages) {
if (pkg.getNodeName().equals(packageName)) {
return pkg;
@@ -44,7 +53,8 @@ public void setPackageFile(File packageFile) {
myJsonFile = packageFile;
}
- public File getJsonFile() {
+ @Override
+ public File getJsonFile() {
return myJsonFile;
}
@@ -76,8 +86,9 @@ public ArduinoPlatformPackageIndex deserialize(JsonElement json, Type arg1, Json
}
- public boolean isInstalled() {
- for (ArduinoPackage pkg : myPackages) {
+ @Override
+ public boolean isInstalled() {
+ for (IArduinoPackage pkg : myPackages) {
if (pkg.isInstalled()) {
return true;
}
@@ -105,4 +116,19 @@ public int compareTo(ArduinoPlatformPackageIndex o) {
return getID().compareTo(o.getID());
}
+ @Override
+ public String getName() {
+ return getNodeName();
+ }
+
+ @Override
+ public String getJsonURL() {
+ return myURL;
+ }
+
+ public void setURL(String url) {
+ myURL=url;
+
+ }
+
}
diff --git a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformTool.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformTool.java
similarity index 93%
rename from io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformTool.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformTool.java
index c7bbfc249..7faae3d13 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformTool.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformTool.java
@@ -5,9 +5,9 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package io.sloeber.core.api.Json;
+package io.sloeber.arduinoFramework.internal;
-import static io.sloeber.core.Gson.GsonConverter.*;
+import static io.sloeber.arduinoFramework.internal.GsonConverter.*;
import static io.sloeber.core.api.Const.*;
import java.util.Collection;
@@ -21,6 +21,8 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
+import io.sloeber.arduinoFramework.api.IArduinoPackage;
+import io.sloeber.arduinoFramework.api.Node;
import io.sloeber.core.api.VersionNumber;
public class ArduinoPlatformTool extends Node {
@@ -48,7 +50,7 @@ protected void addVersion(JsonElement json) {
myVersions.put(version.getVersion(), version);
}
- public ArduinoPackage getPackage() {
+ public IArduinoPackage getPackage() {
return myParentPackage;
}
diff --git a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformToolVersion.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformToolVersion.java
similarity index 88%
rename from io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformToolVersion.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformToolVersion.java
index 23467bb57..2bea7630c 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformToolVersion.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformToolVersion.java
@@ -5,9 +5,9 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package io.sloeber.core.api.Json;
+package io.sloeber.arduinoFramework.internal;
-import static io.sloeber.core.Gson.GsonConverter.*;
+import static io.sloeber.arduinoFramework.internal.GsonConverter.*;
import static io.sloeber.core.api.Const.*;
import java.util.ArrayList;
@@ -20,6 +20,11 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
+import io.sloeber.arduinoFramework.api.ArduinoInstallable;
+import io.sloeber.arduinoFramework.api.IArduinoPackage;
+import io.sloeber.arduinoFramework.api.IArduinoPlatform;
+import io.sloeber.arduinoFramework.api.IArduinoPlatformVersion;
+import io.sloeber.arduinoFramework.api.Node;
import io.sloeber.core.api.VersionNumber;
public class ArduinoPlatformToolVersion extends Node {
@@ -82,9 +87,9 @@ public IPath getInstallPath() {
if (myInstallPath != null) {
return myInstallPath;
}
- ArduinoPackage pkg = myParentTool.getPackage();
- for (ArduinoPlatform curPlatform : pkg.getPlatforms()) {
- for (ArduinoPlatformVersion curplatformVersion : curPlatform.getVersions()) {
+ IArduinoPackage pkg = myParentTool.getPackage();
+ for (IArduinoPlatform curPlatform : pkg.getPlatforms()) {
+ for (IArduinoPlatformVersion curplatformVersion : curPlatform.getVersions()) {
for (ArduinoPlatformTooldDependency curTooldependency : curplatformVersion.getToolsDependencies()) {
if (curTooldependency.getName().equals(myParentTool.getNodeName())
&& curTooldependency.getVersion().compareTo(myVersion) == 0) {
diff --git a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformTooldDependency.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformTooldDependency.java
similarity index 78%
rename from io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformTooldDependency.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformTooldDependency.java
index 9d69a4a28..e335eda84 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformTooldDependency.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformTooldDependency.java
@@ -1,6 +1,6 @@
-package io.sloeber.core.api.Json;
+package io.sloeber.arduinoFramework.internal;
-import static io.sloeber.core.Gson.GsonConverter.*;
+import static io.sloeber.arduinoFramework.internal.GsonConverter.*;
import static io.sloeber.core.api.Const.*;
import org.eclipse.core.runtime.IPath;
@@ -9,6 +9,7 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
+import io.sloeber.arduinoFramework.api.IArduinoPlatformVersion;
import io.sloeber.core.api.ConfigurationPreferences;
import io.sloeber.core.api.VersionNumber;
@@ -18,10 +19,10 @@ public class ArduinoPlatformTooldDependency {
private String myPackager;
private VersionNumber myVersion;
- private transient ArduinoPlatformVersion myParentPlatform;
+ private transient IArduinoPlatformVersion myParentPlatform;
@SuppressWarnings("nls")
- public ArduinoPlatformTooldDependency(JsonElement json, ArduinoPlatformVersion arduinoPlatformVersion) {
+ public ArduinoPlatformTooldDependency(JsonElement json, IArduinoPlatformVersion arduinoPlatformVersion) {
myParentPlatform = arduinoPlatformVersion;
JsonObject jsonObject = json.getAsJsonObject();
try {
diff --git a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformVersion.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformVersion.java
similarity index 50%
rename from io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformVersion.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformVersion.java
index 7aed2b055..c69bbb8ee 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinoPlatformVersion.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoPlatformVersion.java
@@ -5,14 +5,13 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package io.sloeber.core.api.Json;
+package io.sloeber.arduinoFramework.internal;
-import static io.sloeber.core.Gson.GsonConverter.*;
+import static io.sloeber.arduinoFramework.internal.GsonConverter.*;
import static io.sloeber.core.api.Const.*;
import java.io.File;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.eclipse.core.runtime.IPath;
@@ -21,16 +20,17 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
+import io.sloeber.arduinoFramework.api.IArduinoPlatformVersion;
import io.sloeber.core.api.VersionNumber;
-public class ArduinoPlatformVersion extends ArduinoInstallable implements Comparable {
+public class ArduinoPlatformVersion extends IArduinoPlatformVersion {
- private String architecture;
- private VersionNumber version;
- private String category;
+ private String myArchitecture;
+ private VersionNumber myVersion;
+ private String myCategory;
- private List boards = new ArrayList<>();
- private List toolsDependencies = new ArrayList<>();;
+ private List myBoards = new ArrayList<>();
+ private List myToolDependencies = new ArrayList<>();
private ArduinoPlatform myParent;
@@ -40,20 +40,20 @@ public ArduinoPlatformVersion(JsonElement json, ArduinoPlatform parent) {
JsonObject jsonObject = json.getAsJsonObject();
try {
- name = getSafeString(jsonObject, "name");
- architecture = getSafeString(jsonObject, "architecture");
- version = getSafeVersion(jsonObject, "version");
- category = getSafeString(jsonObject, "category");
- url = getSafeString(jsonObject, "url");
- archiveFileName = getSafeString(jsonObject, "archiveFileName");
- checksum = getSafeString(jsonObject, "checksum");
- size = getSafeString(jsonObject, "size");
+ myName = getSafeString(jsonObject, "name");
+ myArchitecture = getSafeString(jsonObject, "architecture");
+ myVersion = getSafeVersion(jsonObject, "version");
+ myCategory = getSafeString(jsonObject, "category");
+ myURL = getSafeString(jsonObject, "url");
+ myArchiveFileName = getSafeString(jsonObject, "archiveFileName");
+ myChecksum = getSafeString(jsonObject, "checksum");
+ mySize = getSafeString(jsonObject, "size");
for (JsonElement curElement : jsonObject.get("boards").getAsJsonArray()) {
- boards.add(getSafeString(curElement.getAsJsonObject(), "name"));
+ myBoards.add(getSafeString(curElement.getAsJsonObject(), "name"));
}
if (jsonObject.get("toolsDependencies") != null) {
for (JsonElement curElement : jsonObject.get("toolsDependencies").getAsJsonArray()) {
- toolsDependencies.add(new ArduinoPlatformTooldDependency(curElement, this));
+ myToolDependencies.add(new ArduinoPlatformTooldDependency(curElement, this));
}
}
} catch (Exception e) {
@@ -61,56 +61,59 @@ public ArduinoPlatformVersion(JsonElement json, ArduinoPlatform parent) {
}
}
- public ArduinoPlatform getParent() {
+ @Override
+ public ArduinoPlatform getParent() {
return myParent;
}
- public String getArchitecture() {
- return architecture;
+ @Override
+ public String getArchitecture() {
+ return myArchitecture;
}
- public VersionNumber getVersion() {
- return version;
+ @Override
+ public VersionNumber getVersion() {
+ return myVersion;
}
- public String getCategory() {
- return category;
+ @Override
+ public String getCategory() {
+ return myCategory;
}
- public List getToolsDependencies() {
- return toolsDependencies;
+ @Override
+ public List getToolsDependencies() {
+ return myToolDependencies;
}
- public boolean isInstalled() {
+ @Override
+ public boolean isInstalled() {
return getBoardsFile().exists();
}
- public File getBoardsFile() {
+ @Override
+ public File getBoardsFile() {
return getInstallPath().append(BOARDS_FILE_NAME).toFile();
}
- public File getPlatformFile() {
+ @Override
+ public File getPlatformFile() {
return getInstallPath().append(PLATFORM_FILE_NAME).toFile();
}
@Override
public IPath getInstallPath() {
- return getParent().getInstallPath().append(this.version.toString());
+ return getParent().getInstallPath().append(this.myVersion.toString());
}
- public List getIncludePath() {
- IPath installPath = getInstallPath();
- return Arrays.asList(installPath.append("cores/{build.core}"), //$NON-NLS-1$
- installPath.append(ARDUINO_VARIANTS_FOLDER_NAME + "/{build.variant}")); //$NON-NLS-1$
- }
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((this.name == null) ? 0 : this.name.hashCode());
+ result = prime * result + ((this.myName == null) ? 0 : this.myName.hashCode());
result = prime * result + ((this.myParent == null) ? 0 : this.myParent.hashCode());
- result = prime * result + ((this.version == null) ? 0 : this.version.hashCode());
+ result = prime * result + ((this.myVersion == null) ? 0 : this.myVersion.hashCode());
return result;
}
@@ -123,44 +126,47 @@ public boolean equals(Object obj) {
if (getClass() != obj.getClass())
return false;
ArduinoPlatformVersion other = (ArduinoPlatformVersion) obj;
- if (this.name == null) {
- if (other.name != null)
+ if (this.myName == null) {
+ if (other.myName != null)
return false;
- } else if (!this.name.equals(other.name))
+ } else if (!this.myName.equals(other.myName))
return false;
if (this.myParent == null) {
if (other.myParent != null)
return false;
} else if (!this.myParent.equals(other.myParent))
return false;
- if (this.version == null) {
- if (other.version != null)
+ if (this.myVersion == null) {
+ if (other.myVersion != null)
return false;
- } else if (!this.version.equals(other.version))
+ } else if (!this.myVersion.equals(other.myVersion))
return false;
return true;
}
- public List getBoardNames() {
- return boards;
+ @Override
+ public List getBoardNames() {
+ return myBoards;
}
- public String getID() {
- return version.toString();
+ @Override
+ public String getID() {
+ return myVersion.toString();
}
- public String getConcattenatedBoardNames() {
+ @Override
+ public String getConcattenatedBoardNames() {
return String.join("\n", getBoardNames()); //$NON-NLS-1$
}
@Override
- public int compareTo(ArduinoPlatformVersion o) {
- return name.compareTo(o.getName());
+ public int compareTo(IArduinoPlatformVersion o) {
+ return myName.compareTo(o.getName());
}
@Override
public String toString() {
- return name + SPACE + architecture + '(' + version + ')';
+ return myName + SPACE + myArchitecture + '(' + myVersion + ')';
}
}
diff --git a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinpPlatformToolSystem.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinpPlatformToolSystem.java
similarity index 89%
rename from io.sloeber.core/src/io/sloeber/core/api/Json/ArduinpPlatformToolSystem.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinpPlatformToolSystem.java
index 58b675bff..92ac3feec 100644
--- a/io.sloeber.core/src/io/sloeber/core/api/Json/ArduinpPlatformToolSystem.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinpPlatformToolSystem.java
@@ -5,9 +5,9 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package io.sloeber.core.api.Json;
+package io.sloeber.arduinoFramework.internal;
-import static io.sloeber.core.Gson.GsonConverter.*;
+import static io.sloeber.arduinoFramework.internal.GsonConverter.*;
import org.eclipse.core.runtime.IPath;
@@ -15,6 +15,8 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
+import io.sloeber.arduinoFramework.api.ArduinoInstallable;
+
public class ArduinpPlatformToolSystem extends ArduinoInstallable {
private transient ArduinoPlatformToolVersion myParent;
@@ -27,10 +29,10 @@ public ArduinpPlatformToolSystem(JsonElement json, ArduinoPlatformToolVersion to
try {
host = getSafeString(jsonObject, "host");
- archiveFileName = getSafeString(jsonObject, "archiveFileName");
- url = getSafeString(jsonObject, "url");
- checksum = getSafeString(jsonObject, "checksum");
- size = getSafeString(jsonObject, "size");
+ myArchiveFileName = getSafeString(jsonObject, "archiveFileName");
+ myURL = getSafeString(jsonObject, "url");
+ myChecksum = getSafeString(jsonObject, "checksum");
+ mySize = getSafeString(jsonObject, "size");
} catch (Exception e) {
throw new JsonParseException("failed to parse Tool json " + e.getMessage(),e);
}
diff --git a/io.sloeber.core/src/io/sloeber/core/Gson/GsonConverter.java b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/GsonConverter.java
similarity index 93%
rename from io.sloeber.core/src/io/sloeber/core/Gson/GsonConverter.java
rename to io.sloeber.core/src/io/sloeber/arduinoFramework/internal/GsonConverter.java
index 7f797bf60..af022007a 100644
--- a/io.sloeber.core/src/io/sloeber/core/Gson/GsonConverter.java
+++ b/io.sloeber.core/src/io/sloeber/arduinoFramework/internal/GsonConverter.java
@@ -1,4 +1,4 @@
-package io.sloeber.core.Gson;
+package io.sloeber.arduinoFramework.internal;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
diff --git a/io.sloeber.core/src/io/sloeber/core/Activator.java b/io.sloeber.core/src/io/sloeber/core/Activator.java
index afa7859e7..f9000e3c2 100644
--- a/io.sloeber.core/src/io/sloeber/core/Activator.java
+++ b/io.sloeber.core/src/io/sloeber/core/Activator.java
@@ -8,6 +8,8 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.time.Duration;
+import java.time.Instant;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
@@ -29,16 +31,19 @@
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.ui.statushandlers.StatusManager;
import org.osgi.framework.BundleContext;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
import cc.arduino.packages.discoverers.SloeberNetworkDiscovery;
-import io.sloeber.core.api.BoardsManager;
-import io.sloeber.core.api.Common;
+import io.sloeber.arduinoFramework.api.BoardsManager;
+import io.sloeber.arduinoFramework.api.LibraryManager;
import io.sloeber.core.api.ConfigurationPreferences;
+import io.sloeber.core.api.Defaults;
import io.sloeber.core.common.InstancePreferences;
import io.sloeber.core.listeners.ConfigurationChangeListener;
+import io.sloeber.core.listeners.IndexerController;
import io.sloeber.core.listeners.IndexerListener;
import io.sloeber.core.tools.PackageManager;
@@ -168,7 +173,7 @@ private static void testKnownIssues() {
if (!errorString.isEmpty()) {
errorString += "\n\nSloeber might still function but if you get strange results you know where to look.\n";
errorString += "Do not create an issue if you see this!!!";
- Common.log(new Status(IStatus.ERROR, PLUGIN_ID, errorString));
+ log(new Status(IStatus.ERROR, Activator.getId(), errorString));
}
}
@@ -190,8 +195,9 @@ private static void registerListeners() {
CCorePlugin.getIndexManager().addIndexChangeListener(myindexerListener);
CCorePlugin.getIndexManager().addIndexerStateListener(myindexerListener);
CoreModel singCoreModel = CoreModel.getDefault();
+ IndexerController.registerIndexerController();
- singCoreModel.addCProjectDescriptionListener(myConfigurationChangeListener,CProjectDescriptionEvent.ABOUT_TO_APPLY);
+ singCoreModel.addCProjectDescriptionListener(myConfigurationChangeListener,CProjectDescriptionEvent.ABOUT_TO_APPLY|CProjectDescriptionEvent.APPLIED);
@@ -202,6 +208,7 @@ private static void unRegisterListeners() {
CCorePlugin.getIndexManager().removeIndexChangeListener(myindexerListener);
CoreModel singCoreModel = CoreModel.getDefault();
singCoreModel.removeCProjectDescriptionListener(myConfigurationChangeListener);
+ IndexerController.unRegisterIndexerController();
@@ -215,13 +222,12 @@ private static void initializeImportantVariables() {
try {
workspace.setDescription(workspaceDesc);
} catch (CoreException e) {
- Common.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, e.getMessage(), e));
+ log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, e.getMessage(), e));
}
// Make sure some important variables are being initialized
InstancePreferences.setPrivateLibraryPaths(InstancePreferences.getPrivateLibraryPaths());
InstancePreferences.setPrivateHardwarePaths(InstancePreferences.getPrivateHardwarePaths());
InstancePreferences.setAutomaticallyImportLibraries(InstancePreferences.getAutomaticallyImportLibraries());
- BoardsManager.setJsonURLs(BoardsManager.getJsonURLs());
}
private void runPluginCoreStartInstantiatorJob() {
@@ -259,7 +265,7 @@ protected IStatus run(IProgressMonitor monitor) {
installOtherStuff();
- BoardsManager.startup_Pluging(monitor);
+ startup_BoardsManager(monitor);
monitor.setTaskName("Done!");
if (InstancePreferences.useBonjour()) {
@@ -295,7 +301,7 @@ public void stop(BundleContext context) throws Exception {
* the io.sloeber.core.managers and io.sloeber.core.managers.ui to work.
*/
public static String getId() {
- return PLUGIN_ID;
+ return "io.sloeber.core";
}
/**
@@ -382,7 +388,7 @@ private static void addFileAssociations() {
ctbin.addFileSpec("ino", IContentTypeSettings.FILE_EXTENSION_SPEC);
ctbin.addFileSpec("pde", IContentTypeSettings.FILE_EXTENSION_SPEC);
} catch (CoreException e) {
- Common.log(new Status(IStatus.WARNING, Activator.getId(),
+ log(new Status(IStatus.WARNING, Activator.getId(),
"Failed to add *.ino and *.pde as file extensions.", e));
}
@@ -405,6 +411,7 @@ private static void installOtherStuff() {
if (localMakePath.append(MAKE_EXE).toFile().exists()) {
if (!localMakePath.append(SH_EXE).toFile().exists()) {
try {
+ //Sloeber needs the make that also contains sh.exe
deleteDirectory(localMakePath);
} catch (IOException e) {
// should not happen
@@ -414,16 +421,79 @@ private static void installOtherStuff() {
}
if (!localMakePath.append(MAKE_EXE).toFile().exists()) {
IProgressMonitor monitor = new NullProgressMonitor();
- Common.log(PackageManager.downloadAndInstall(MAKE_URL, MAKE_ZIP, localMakePath, false, monitor));
+ log(PackageManager.downloadAndInstall(MAKE_URL, MAKE_ZIP, localMakePath, false, monitor));
}
// Install awk if needed
IPath localAwkPath = ConfigurationPreferences.getAwkPath();
if (!localAwkPath.append(AWK_EXE).toFile().exists()) {
IProgressMonitor monitor = new NullProgressMonitor();
- Common.log(PackageManager.downloadAndInstall(AWK_URL, AWK_ZIP, localAwkPath, false, monitor));
+ log(PackageManager.downloadAndInstall(AWK_URL, AWK_ZIP, localAwkPath, false, monitor));
}
}
}
+
+ /**
+ * Logs the status information if status is OK then nothing happens
+ *
+ * @param status
+ * the status information to log
+ */
+ public static void log(IStatus status) {
+ switch (status.getSeverity()) {
+ case IStatus.OK: {
+ break;
+ }
+ case IStatus.ERROR: {
+ int style = StatusManager.LOG | StatusManager.SHOW | StatusManager.BLOCK;
+ StatusManager stMan = StatusManager.getManager();
+ stMan.handle(status, style);
+ break;
+ }
+ case SLOEBER_STATUS_DEBUG:
+ // break;//remove break to add debugging
+ default:
+ Activator.getDefault().getLog().log(status);
+ }
+ }
+
+ /**
+ * Loads all stuff needed and if this is the first time downloads the avr boards
+ * and needed tools
+ *
+ * @param monitor
+ */
+ private static synchronized void startup_BoardsManager(IProgressMonitor monitor) {
+ //ConfigurationPreferences.getUpdateJasonFilesFlag();
+ Instant currentTime=Instant.now();
+ Instant latestUpdate= ConfigurationPreferences.getLatestJsonUpdateTime();
+ Duration requestedDelay=ConfigurationPreferences.getJsonUpdateDelay();
+ Instant nextUpdate=latestUpdate.plus(requestedDelay);
+ boolean needsUpdate = nextUpdate.isBefore(currentTime);
+
+// long latestUpdate= getLatestUpdateTime();
+// long requestedDelay=getUpdateDelay();
+// long currentTime= System.currentTimeMillis();
+// boolean needsUpdate = currentTime>(requestedDelay+latestUpdate);
+ if(needsUpdate) {
+ BoardsManager.update(true );
+ }else {
+ BoardsManager.update(false );
+ }
+
+ if (!LibraryManager.libsAreInstalled()) {
+ LibraryManager.InstallDefaultLibraries(monitor);
+ }
+ IPath examplesPath = ConfigurationPreferences.getInstallationPathExamples();
+ if (!examplesPath.toFile().exists()) {// examples are not installed
+ // Download arduino IDE example programs
+ Activator.log(PackageManager.downloadAndInstall(Defaults.EXAMPLES_URL, Defaults.EXAMPLE_PACKAGE, examplesPath,
+ false, monitor));
+ }
+
+
+ }
+
+
}
diff --git a/io.sloeber.core/src/io/sloeber/core/Messages.java b/io.sloeber.core/src/io/sloeber/core/Messages.java
index dc4651099..c3d9dce54 100644
--- a/io.sloeber.core/src/io/sloeber/core/Messages.java
+++ b/io.sloeber.core/src/io/sloeber/core/Messages.java
@@ -39,7 +39,8 @@ public class Messages extends NLS {
public static String ArduinoSerial_unable_to_open_serial_port;
public static String ArduinoSerial_Using_1200bps_touch;
public static String ArduinoSerial_Using_comport;
- public static String Boards_Failed_to_read_boards;
+ public static String BoardDescription_0;
+ public static String Boards_Failed_to_read_boards;
public static String Boards_Get_menu_item_name_from_id_did_not_find;
public static String Boards_menu_ID_not_found;
public static String Boards_menu_name_not_found;
@@ -108,15 +109,13 @@ public class Messages extends NLS {
public static String CompileDescription_CustomDebugLevel;
public static String CompileDescription_OptimizedForDebug;
public static String CompileDescription_OptimizedForRelease;
- public static String CompileDescription_SizeArduinoWay;
- public static String CompileDescription_SizeAVRAlternative;
- public static String CompileDescription_SizeCustom;
- public static String CompileDescription_SizeRawResult;
public static String CompileDescription_WarningsAll;
public static String CompileDescription_WarningsCustom;
public static String CompileDescription_WarningsDefault;
public static String CompileDescription_WarningsMore;
public static String CompileDescription_WarningsNone;
+ public static String SloeberConfiguration_Failed_Modify_config_rename;
+ public static String SloeberProject_Project_is_null;
static {
// initialize resource bundle
diff --git a/io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java b/io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java
deleted file mode 100644
index 039955cfe..000000000
--- a/io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java
+++ /dev/null
@@ -1,1138 +0,0 @@
-package io.sloeber.core.api;
-
-import static io.sloeber.core.Messages.*;
-import static io.sloeber.core.api.Common.*;
-import static io.sloeber.core.api.Const.*;
-import static io.sloeber.autoBuild.api.AutoBuildCommon.*;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeMap;
-import org.eclipse.cdt.core.parser.util.StringUtil;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-
-import io.sloeber.autoBuild.api.IAutoBuildConfigurationDescription;
-import io.sloeber.autoBuild.helpers.api.KeyValueTree;
-import io.sloeber.core.api.Json.ArduinoPlatform;
-import io.sloeber.core.api.Json.ArduinoPlatformTooldDependency;
-import io.sloeber.core.api.Json.ArduinoPlatformVersion;
-import io.sloeber.core.tools.KeyValue;
-import io.sloeber.core.txt.BoardTxtFile;
-import io.sloeber.core.txt.PlatformTxtFile;
-import io.sloeber.core.txt.Programmers;
-import io.sloeber.core.txt.TxtFile;
-
-public class BoardDescription {
- private static final IEclipsePreferences myStorageNode = InstanceScope.INSTANCE.getNode(NODE_ARDUINO);
-
- /*
- * This is the basic info contained in the descriptor
- */
- private String myUploadPort = EMPTY;
- private String myProgrammer = EMPTY;
- private String myBoardID = EMPTY;
- private Map myOptions = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
- private File myUserSelectedBoardsTxtFile; //this is the boards.txt file selected in the gui
- private BoardTxtFile mySloeberBoardTxtFile; // this is the actual used and loaded sloeber.boards.txt file
-
- private String myBoardsCore = null;
- private String myBoardsVariant = null;
- private String myUploadTool = null;
-
- private ArduinoPlatformVersion myReferencedPlatformVariant = null;
- private ArduinoPlatformVersion myReferencedPlatformCore = null;
- private ArduinoPlatformVersion myReferencedPlatformUpload = null;
-
- private boolean isDirty = true;
-
- @Override
- public String toString() {
- return getReferencingBoardsFile() + " \"" + getBoardName() + "\" " + getUploadPort(); //$NON-NLS-1$//$NON-NLS-2$
- }
-
- /**
- * Compare 2 descriptors and return true is they are equal. This method detects
- * - OS changes - project name changes - moves of workspace - changed runtine
- * eclipse install
- *
- * @param obj
- * @return true if equal otherwise false
- */
- public boolean equals(BoardDescription otherBoardDescriptor) {
- if (otherBoardDescriptor == null) {
- return false;
- }
- if (!this.getUploadPort().equals(otherBoardDescriptor.getUploadPort())) {
- return false;
- }
- if (!this.getProgrammer().equals(otherBoardDescriptor.getProgrammer())) {
- return false;
- }
- return !needsRebuild(otherBoardDescriptor);
- }
-
- /**
- * compare 2 board descriptors and return true if replacing one board descriptor
- * with the other implies that a rebuild is needed
- *
- * @param otherBoardDescriptor
- * @return
- */
- public boolean needsRebuild(BoardDescription otherBoardDescriptor) {
- if (otherBoardDescriptor == null) {
- return true;
- }
- if (!this.getBoardID().equals(otherBoardDescriptor.getBoardID())) {
- return true;
- }
- String moddedReferencingBoardsFile = makePathVersionString(getReferencingBoardsFile());
- String moddedOtherReferencingBoardsFile = makePathVersionString(
- otherBoardDescriptor.getReferencingBoardsFile());
- if (!moddedReferencingBoardsFile.equals(moddedOtherReferencingBoardsFile)) {
- return true;
- }
- if (!this.getOptions().equals(otherBoardDescriptor.getOptions())) {
- return true;
- }
- return false;
- }
-
- /**
- * after construction data needs to be derived from other data. This method
- * derives all other data and puts it in fields
- */
- private void calculateDerivedFields() {
-
- myReferencedPlatformCore = null;
- myBoardsCore = null;
- myReferencedPlatformVariant = null;
- myBoardsVariant = null;
- myReferencedPlatformUpload = null;
- myUploadTool = null;
- setDefaultOptions();
- // search in the board info
- ParseSection();
-
- }
-
- private void ParseSection() {
- KeyValueTree rootData = mySloeberBoardTxtFile.getData();
- String boardID = getBoardID();
- KeyValueTree boardData = rootData.getChild(boardID);
-
- String core = boardData.getValue(BUILD + DOT + CORE);
- String variant = boardData.getValue(BUILD + DOT + VARIANT);
- String upload = boardData.getValue(UPLOAD + DOT + TOOL);
- // also search the options
- for (Entry curOption : this.myOptions.entrySet()) {
- KeyValueTree curMenuData = boardData.getChild(MENU + DOT + curOption.getKey() + DOT + curOption.getValue());
- String coreOption = curMenuData.getValue(BUILD + DOT + CORE);
- String variantOption = curMenuData.getValue(BUILD + DOT + VARIANT);
- String uploadOption = curMenuData.getValue(UPLOAD + DOT + TOOL);
- if (!coreOption.isEmpty()) {
- core = coreOption;
- }
- if (!variantOption.isEmpty()) {
- variant = variantOption;
- }
- if (!uploadOption.isEmpty()) {
- upload = uploadOption;
- }
- }
- String architecture = getArchitecture();
- if (core != null) {
- String valueSplit[] = core.split(COLON);
- if (valueSplit.length == 2) {
- String refVendor = valueSplit[0];
- myBoardsCore = valueSplit[1];
- myReferencedPlatformCore = BoardsManager.getNewestInstalledPlatform(refVendor, architecture);
- if (myReferencedPlatformCore == null) {
- Common.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
- Helpers_tool_reference_missing.replace(TOOL_TAG, core)
- .replace(FILE_TAG, getReferencingBoardsFile().toString())
- .replace(BOARD_TAG, getBoardID())));
- return;
- }
- } else if (valueSplit.length == 4) {
- String refVendor = valueSplit[0];
- String refArchitecture = valueSplit[1];
- VersionNumber refVersion = new VersionNumber(valueSplit[2]);
- myBoardsCore = valueSplit[3];
- myReferencedPlatformCore = BoardsManager.getPlatform(refVendor, refArchitecture, refVersion);
- if (myReferencedPlatformCore == null) {
- Common.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
- Helpers_tool_reference_missing.replace(TOOL_TAG, core)
- .replace(FILE_TAG, getReferencingBoardsFile().toString())
- .replace(BOARD_TAG, getBoardID())));
- return;
- }
- } else {
- this.myBoardsCore = core;
- }
- }
- if (variant != null) {
- String valueSplit[] = variant.split(COLON);
- if (valueSplit.length == 2) {
- String refVendor = valueSplit[0];
- myBoardsVariant = valueSplit[1];
- myReferencedPlatformVariant = BoardsManager.getNewestInstalledPlatform(refVendor, architecture);
- if (myReferencedPlatformVariant == null) {
- Common.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
- Helpers_tool_reference_missing.replace(TOOL_TAG, variant)
- .replace(FILE_TAG, getReferencingBoardsFile().toString())
- .replace(BOARD_TAG, getBoardID())));
- return;
- }
- } else if (valueSplit.length == 4) {
- String refVendor = valueSplit[0];
- String refArchitecture = valueSplit[1];
- VersionNumber refVersion = new VersionNumber(valueSplit[2]);
- myBoardsVariant = valueSplit[3];
- if ("*".equals(valueSplit[2])) { //$NON-NLS-1$
- myReferencedPlatformVariant = BoardsManager.getNewestInstalledPlatform(refVendor, refArchitecture);
- } else {
- myReferencedPlatformVariant = BoardsManager.getPlatform(refVendor, refArchitecture, refVersion);
- }
- if (myReferencedPlatformVariant == null) {
- Common.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
- Helpers_tool_reference_missing.replace(TOOL_TAG, variant)
- .replace(FILE_TAG, getReferencingBoardsFile().toString())
- .replace(BOARD_TAG, getBoardID())));
- return;
- }
- } else {
- myBoardsVariant = variant;
- }
- }
- if (upload != null) {
- String valueSplit[] = upload.split(COLON);
- if (valueSplit.length == 2) {
- String refVendor = valueSplit[0];
- myUploadTool = valueSplit[1];
- myReferencedPlatformUpload = BoardsManager.getNewestInstalledPlatform(refVendor, architecture);
- if (myReferencedPlatformUpload == null) {
- Common.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
- Helpers_tool_reference_missing.replace(TOOL_TAG, upload)
- .replace(FILE_TAG, getReferencingBoardsFile().toString())
- .replace(BOARD_TAG, getBoardID())));
- return;
- }
- } else if (valueSplit.length == 4) {
- String refVendor = valueSplit[0];
- String refArchitecture = valueSplit[1];
- VersionNumber refVersion = new VersionNumber(valueSplit[2]);
- myUploadTool = valueSplit[3];
- myReferencedPlatformUpload = BoardsManager.getPlatform(refVendor, refArchitecture, refVersion);
- if (this.myReferencedPlatformUpload == null) {
- Common.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID,
- Helpers_tool_reference_missing.replace(TOOL_TAG, upload)
- .replace(FILE_TAG, getReferencingBoardsFile().toString())
- .replace(BOARD_TAG, getBoardID())));
- return;
- }
- } else {
- myUploadTool = upload;
- }
- }
- }
-
- /**
- * make a board descriptor for each board in the board.txt file with the default
- * options
- *
- * @param boardFile
- * @return a list of board descriptors
- */
- public static List makeBoardDescriptors(File boardFile) {
- BoardTxtFile txtFile = new BoardTxtFile(resolvePathEnvironmentString(boardFile));
- List boards = new ArrayList<>();
- List boardIDs = txtFile.getAllBoardIDs();
- for (String curboardID : boardIDs) {
- Map boardSection = txtFile.getSection(curboardID);
- if (boardSection != null) {
- if (!"true".equalsIgnoreCase(boardSection.get("hide"))) { //$NON-NLS-1$ //$NON-NLS-2$
- boards.add(new BoardDescription(boardFile, curboardID, null));
- }
- }
- }
- return boards;
- }
-
- /**
- * create a board descriptor
- *
- * @param boardsFile
- * @param boardID
- * @param options
- * if null default options are taken
- */
- BoardDescription(File boardsFile, String boardID, Map options) {
- myBoardID = boardID;
- myUserSelectedBoardsTxtFile = boardsFile;
- mySloeberBoardTxtFile = new BoardTxtFile(resolvePathEnvironmentString(myUserSelectedBoardsTxtFile));
- setDefaultOptions();
- if (options != null) {
- myOptions.putAll(options);
- }
- }
-
- public BoardDescription() {
- myUserSelectedBoardsTxtFile = new File(myStorageNode.get(KEY_LAST_USED_BOARDS_FILE, EMPTY));
- if (!myUserSelectedBoardsTxtFile.exists()) {
-
- ArduinoPlatformVersion platform = BoardsManager.getNewestInstalledPlatform(VENDOR_ARDUINO, AVR);
- if (platform == null) {
- List platforms = BoardsManager.getInstalledPlatforms();
- //If you crash on the next line no platform have been installed
- platform = platforms.get(0);
- }
- myUserSelectedBoardsTxtFile = platform.getBoardsFile();
- mySloeberBoardTxtFile = new BoardTxtFile(myUserSelectedBoardsTxtFile);
-
- if (mySloeberBoardTxtFile.getAllBoardIDs().contains(UNO)) {
- myBoardID = UNO;
- } else {
- myBoardID = mySloeberBoardTxtFile.getAllBoardIDs().get(0);
- }
- } else {
- mySloeberBoardTxtFile = new BoardTxtFile(myUserSelectedBoardsTxtFile);
- myBoardID = myStorageNode.get(KEY_LAST_USED_BOARD, EMPTY);
- myUploadPort = myStorageNode.get(KEY_LAST_USED_UPLOAD_PORT, EMPTY);
- myProgrammer = myStorageNode.get(KEY_LAST_USED_UPLOAD_PROTOCOL, EMPTY);
- myOptions = KeyValue.makeMap(myStorageNode.get(KEY_LAST_USED_BOARD_MENU_OPTIONS, EMPTY));
- }
-
- }
-
- public BoardDescription(BoardDescription srcObject) {
- myUserSelectedBoardsTxtFile = srcObject.myUserSelectedBoardsTxtFile;
- mySloeberBoardTxtFile = srcObject.mySloeberBoardTxtFile;
- myBoardID = srcObject.myBoardID;
- myUploadPort = srcObject.myUploadPort;
- myProgrammer = srcObject.myProgrammer;
- myUploadTool = srcObject.myUploadTool;
- myOptions.putAll( new TreeMap<>(srcObject.myOptions));
-
- }
-
- public String getuploadTool() {
- return this.myUploadTool;
- }
-
- /*
- * Sets default options as follows If no option is specified take the first one
- * if a option is specified but the value is invalid take the first one
- *
- * this is so because I want to provide a list of options but if the options are
- * incomplete or invalid this method still returns a complete and valid set.
- */
- private void setDefaultOptions() {
- Map allMenuIDs = this.mySloeberBoardTxtFile.getMenus();
- for (Map.Entry curMenuID : allMenuIDs.entrySet()) {
- String providedMenuValue = this.myOptions.get(curMenuID.getKey());
- ArrayList menuOptions = this.mySloeberBoardTxtFile.getMenuItemIDsFromMenuID(curMenuID.getKey(),
- getBoardID());
- if (menuOptions.size() > 0) {
- if (providedMenuValue == null) {
-
- this.myOptions.put(curMenuID.getKey(), menuOptions.get(0));
- } else if (!menuOptions.contains(providedMenuValue)) {
- this.myOptions.put(curMenuID.getKey(), menuOptions.get(0));
- }
- }
- }
- }
-
- private void removeInvalidMenuIDs() {
- Set allMenuIDs = this.mySloeberBoardTxtFile.getMenus().keySet();
- Set optionKey=new HashSet<>(myOptions.keySet());
-
- for ( String curOptionKey : optionKey) {
- if(!allMenuIDs.contains(curOptionKey)) {
- myOptions.remove(curOptionKey);
- }
- }
- }
-
- /**
- * Store the selections the user made so we can reuse them when creating a new
- * project
- */
- public void saveUserSelection() {
- myStorageNode.put(KEY_LAST_USED_BOARDS_FILE, getReferencingBoardsFile().toString());
- myStorageNode.put(KEY_LAST_USED_BOARD, this.myBoardID);
- myStorageNode.put(KEY_LAST_USED_UPLOAD_PORT, this.myUploadPort);
- myStorageNode.put(KEY_LAST_USED_UPLOAD_PROTOCOL, this.myProgrammer);
- myStorageNode.put(KEY_LAST_USED_BOARD_MENU_OPTIONS, KeyValue.makeString(this.myOptions));
- }
-
- public String getArchitecture() {
- return mySloeberBoardTxtFile.getArchitecture();
- }
-
- public String getVendor() {
- return mySloeberBoardTxtFile.getVendor();
- }
-
- public File getReferencingBoardsFile() {
- return myUserSelectedBoardsTxtFile;
- }
-
- public String getBoardName() {
- return this.mySloeberBoardTxtFile.getNiceNameFromID(this.myBoardID);
- }
-
- public String getUploadPort() {
- return this.myUploadPort;
- }
-
- /**
- * return the actual adress en,coded in the upload port example uploadport com4
- * returns com4 uploadport = arduino.local at 199.25.25.1 returns arduino.local
- *
- * @return
- */
- public String getActualUploadPort() {
- return myUploadPort.split(" ")[0]; //$NON-NLS-1$
- }
-
- public String getProgrammer() {
- return this.myProgrammer;
- }
-
- /**
- * Set the upload port like in the gui. The upload port can be a comport or a
- * networkadress space and something else note that getuploadport returns the
- * before space part of this method
- *
- * @param newUploadPort
- */
- public void setUploadPort(String newUploadPort) {
- this.myUploadPort = newUploadPort;
- }
-
- public void setProgrammer(String newUploadProtocol) {
- this.myProgrammer = newUploadProtocol;
- }
-
- public void setBoardID(String boardID) {
- if (!boardID.equals(this.myBoardID)) {
- this.myBoardID = boardID;
- setDirty();
- }
- }
-
- private void setDirty() {
- isDirty = true;
-
- }
-
- public void setBoardName(String boardName) {
- String newBoardID = this.mySloeberBoardTxtFile.getIDFromNiceName(boardName);
- if ((newBoardID == null || this.myBoardID.equals(newBoardID))) {
- return;
- }
- this.myBoardID = newBoardID;
- setDirty();
-
- }
-
- public void setreferencingBoardsFile(File boardsFile) {
- if (boardsFile == null) {
- return;// ignore
- }
-
- if (!myUserSelectedBoardsTxtFile.equals(boardsFile)) {
- myUserSelectedBoardsTxtFile = boardsFile;
- setDirty();
- }
-
- /* do not remove this for optimization as workaround changes will not be captured */
- mySloeberBoardTxtFile = new BoardTxtFile(resolvePathEnvironmentString(myUserSelectedBoardsTxtFile));
-
- }
- /**
- * seOptions add the options to the already existing options and removes the options
- * with an invalid menuID
- * The enuitemID is not verified and assumed correct.
- *
- */
- public void setOptions(Map options) {
- if (options == null || options.size()==0) {
- return;
- }
- myOptions.putAll(options);
- removeInvalidMenuIDs();
- setDirty();
- }
-
- /**
- * Returns the options for this board This reflects the options selected through
- * the menu functionality in the boards.txt
- *
- * @return a map of case insensitive ordered key value pairs
- */
- public Map getOptions() {
- // no update is needed as this field is only modified at construction or set
- return this.myOptions;
- }
-
- private void updateWhenDirty() {
- if (isDirty) {
- calculateDerivedFields();
- isDirty = false;
- }
- }
-
- public String getBoardID() {
- // no update is needed as this field is only modified at construction or set
- return this.myBoardID;
- }
-
- public String[] getCompatibleBoards() {
- return this.mySloeberBoardTxtFile.getAllSectionNames();
- }
-
- public String[] getUploadProtocols() {
-
- return Programmers.getUploadProtocols(this);
-
- }
-
- public String[] getMenuItemNamesFromMenuID(String menuID) {
- return this.mySloeberBoardTxtFile.getMenuItemNamesFromMenuID(menuID, this.myBoardID);
- }
-
-
- public String getMenuNameFromMenuID(String id) {
- return this.mySloeberBoardTxtFile.getMenuNameFromID(id);
- }
-
- public String getMenuItemNamedFromMenuItemID(String menuItemID, String menuID) {
- return this.mySloeberBoardTxtFile.getMenuItemNameFromMenuItemID(this.myBoardID, menuID, menuItemID);
- }
-
- public String getMenuItemIDFromMenuItemName(String menuItemName, String menuID) {
- return this.mySloeberBoardTxtFile.getMenuItemIDFromMenuItemName(this.myBoardID, menuID, menuItemName);
- }
-
- /**
- * provide the actual path to the variant. Use this method if you want to know
- * where the variant is
- *
- * @return the path to the variant; null if no variant is needed
- */
- public IPath getActualVariantPath() {
- updateWhenDirty();
- String boardVariant = getBoardVariant();
- if (boardVariant == null || boardVariant.isBlank()) {
- return null;
- }
- if (myReferencedPlatformVariant == null) {
- return new Path(myUserSelectedBoardsTxtFile.getParent().toString()).append(ARDUINO_VARIANTS_FOLDER_NAME)
- .append(boardVariant);
- }
- return myReferencedPlatformVariant.getInstallPath().append(ARDUINO_VARIANTS_FOLDER_NAME).append(boardVariant);
- }
-
- private String getBoardVariant() {
- updateWhenDirty();
- return this.myBoardsVariant;
- }
-
- public IPath getActualCoreCodePath() {
- updateWhenDirty();
- if (myBoardsCore == null) {
- return null;
- }
- IPath retPath = null;
- if (myReferencedPlatformCore == null) {
- retPath = getreferencingPlatformPath();
- } else {
- retPath = myReferencedPlatformCore.getInstallPath();
- }
- return retPath.append(CORES).append(myBoardsCore);
- }
-
- public IPath getReferencedUploadPlatformPath() {
- updateWhenDirty();
- if (myReferencedPlatformUpload != null) {
- return myReferencedPlatformUpload.getInstallPath();
- }
- return getreferencingPlatformPath();
- }
-
- public PlatformTxtFile getReferencingPlatformFile() {
- updateWhenDirty();
- File platformFile = getreferencingPlatformPath().append(PLATFORM_FILE_NAME).toFile();
- if (platformFile != null && platformFile.exists()) {
- return new PlatformTxtFile(platformFile);
- }
- return null;
- }
-
- public Path getreferencingPlatformPath() {
- try {
- return new Path(myUserSelectedBoardsTxtFile.getParent());
- } catch (@SuppressWarnings("unused") Exception e) {
- return new Path(EMPTY);
- }
- }
-
- public PlatformTxtFile getreferencedCorePlatformFile() {
- updateWhenDirty();
- if (myReferencedPlatformCore == null) {
- return null;
- }
- File platformFile = myReferencedPlatformCore.getInstallPath().append(PLATFORM_FILE_NAME).toFile();
- if (platformFile != null && platformFile.exists()) {
- return new PlatformTxtFile(platformFile);
- }
- return null;
- }
-
- public IPath getReferencedCoreLibraryPath() {
- updateWhenDirty();
- if (myReferencedPlatformCore == null) {
- return null;
- }
- return this.myReferencedPlatformCore.getInstallPath().append(ARDUINO_LIBRARY_FOLDER_NAME);
- }
-
- public IPath getReferencingLibraryPath() {
- updateWhenDirty();
- return this.getreferencingPlatformPath().append(ARDUINO_LIBRARY_FOLDER_NAME);
- }
-
- public String getUploadPatternKey() {
- updateWhenDirty();
- String upLoadTool = getuploadTool();
- String networkPrefix = EMPTY;
- if (isNetworkUpload()) {
- networkPrefix = NETWORK_PREFIX;
- }
- return TOOLS + DOT + upLoadTool + DOT + UPLOAD + DOT + networkPrefix + PATTERN;
- }
-
- public IPath getreferencedCoreHardwarePath() {
- updateWhenDirty();
- if (myReferencedPlatformCore == null) {
- return getreferencingPlatformPath();
- }
- return myReferencedPlatformCore.getInstallPath();
- }
-
- /*
- * get the latest installed arduino platform with the same architecture. This is
- * the platform to use the programmers.txt if no other programmers.txt are
- * found.
- */
- public IPath getArduinoPlatformPath() {
- updateWhenDirty();
- ArduinoPlatform platform = BoardsManager.getPlatform(VENDOR_ARDUINO, getArchitecture());
- if (platform == null) {
- return null;
- }
- ArduinoPlatformVersion platformVersion = platform.getNewestInstalled();
- if (platformVersion == null) {
- return null;
- }
- return platformVersion.getInstallPath();
- }
-
- /**
- * If the upload port contains a space everything before the first space is
- * considered to be a dns name or ip adress.
- *
- * @param mComPort
- * @return null if no space in uploadport return dns name op ipadress
- */
- public String getHost() {
- String host = myUploadPort.split(" ")[0]; //$NON-NLS-1$
- if (host.equals(myUploadPort))
- return null;
- return host;
- }
-
- /**
- * true if this board needs a networkUpload else false
- *
- * @return
- */
- public boolean isNetworkUpload() {
- return getHost() != null;
- }
-
- protected BoardDescription(File boardsFile, String boardID) {
- myBoardID = boardID;
- myUserSelectedBoardsTxtFile = boardsFile;
- mySloeberBoardTxtFile = new BoardTxtFile(myUserSelectedBoardsTxtFile);
- setDefaultOptions();
- calculateDerivedFields();
- }
-
- BoardDescription(TxtFile configFile, String prefix) {
-
- KeyValueTree tree = configFile.getData();
- KeyValueTree section = tree.getChild(prefix);
- myProgrammer = section.getValue(KEY_SLOEBER_PROGRAMMER);
- myBoardID = section.getValue(KEY_SLOEBER_BOARD_ID);
- String board_txt = section.getValue(KEY_SLOEBER_BOARD_TXT);
- myUploadPort = section.getValue(KEY_SLOEBER_UPLOAD_PORT);
- KeyValueTree optionsTree = section.getChild(KEY_SLOEBER_MENU_SELECTION);
- Map options = optionsTree.toKeyValues(EMPTY);
-
- myUserSelectedBoardsTxtFile = resolvePathEnvironmentString(new File(board_txt));
- mySloeberBoardTxtFile = new BoardTxtFile(myUserSelectedBoardsTxtFile);
- setDefaultOptions();
- if (options != null) {
- // Only add the valid options for this board to our options
- myOptions.putAll(onlyKeepValidOptions(options));
- }
- }
-
- /**
- * create a BoardDescription based on the environment variables given
- *
- * @param envVars
- */
- public BoardDescription(Map envVars) {
- int menuKeyLength = KEY_SLOEBER_MENU_SELECTION.length() + DOT.length();
- for (Entry curEnvVar : envVars.entrySet()) {
- String key = curEnvVar.getKey();
- String value = curEnvVar.getValue();
- switch (key) {
- case KEY_SLOEBER_PROGRAMMER:
- myProgrammer = value;
- break;
- case KEY_SLOEBER_BOARD_ID:
- myBoardID = value;
- break;
- case KEY_SLOEBER_BOARD_TXT:
- myUserSelectedBoardsTxtFile = resolvePathEnvironmentString(new File(value));
- mySloeberBoardTxtFile = new BoardTxtFile(myUserSelectedBoardsTxtFile);
- break;
- case KEY_SLOEBER_UPLOAD_PORT:
- myUploadPort = value;
- break;
- default:
- if (key.startsWith(KEY_SLOEBER_MENU_SELECTION + DOT)) {
- String cleanKey = key.substring(menuKeyLength);
- myOptions.put(cleanKey, value);
- }
- }
- }
- }
-
- /**
- * get the environment variables that need to be stored in the configuration
- * files configuration files are files needed to setup the sloeber environment
- * for instance when openiung a project or after import of a project in the
- * workspace
- *
- * @return the minimum list of environment variables to recreate the project
- */
- public Map getEnvVarsConfig() {
- Map allVars = new TreeMap<>();
- String board_txt = makePathVersionString(getReferencingBoardsFile());
-
- allVars.put(KEY_SLOEBER_PROGRAMMER, myProgrammer);
- allVars.put(KEY_SLOEBER_BOARD_ID, myBoardID);
- allVars.put(KEY_SLOEBER_BOARD_TXT, board_txt);
- allVars.put(KEY_SLOEBER_UPLOAD_PORT, myUploadPort);
-
- for (Entry curOption : myOptions.entrySet()) {
- allVars.put(KEY_SLOEBER_MENU_SELECTION + DOT + curOption.getKey(), curOption.getValue());
- }
- return allVars;
- }
-
- private Map onlyKeepValidOptions(Map options) {
- Map ret = new HashMap<>();
-
- KeyValueTree tree = mySloeberBoardTxtFile.getData();
- KeyValueTree boardMenuSection = tree.getChild(myBoardID + DOT + MENU);
- if (boardMenuSection != null) {
- for (Entry curoption : options.entrySet()) {
- String key = curoption.getKey();
- if (boardMenuSection.getChild(key).getKey() != null) {
- ret.put(key, curoption.getValue());
- }
- }
- }
- return ret;
- }
-
- /**
- * get the environment variables that need to be stored in version control
- *
- * @return the minimum list of environment variables to recreate the project
- * from version control
- */
- public Map getEnvVarsVersion(String prefix) {
- Map allVars = new TreeMap<>();
- String board_txt = makePathVersionString(getReferencingBoardsFile());
-
- allVars.put(prefix + KEY_SLOEBER_BOARD_ID, myBoardID);
- allVars.put(prefix + KEY_SLOEBER_BOARD_TXT, board_txt);
-
- for (Entry curOption : myOptions.entrySet()) {
- allVars.put(prefix + KEY_SLOEBER_MENU_SELECTION + DOT + curOption.getKey(), curOption.getValue());
- }
- return allVars;
- }
-
- /**
- * This method creates environment variables based on the platform.txt and
- * boards.txt. platform.txt is processed first and then boards.txt. This way
- * boards.txt settings can overwrite common settings in platform.txt The
- * environment variables are only valid for the project given as parameter The
- * project properties are used to identify the boards.txt and platform.txt as
- * well as the board id to select the settings in the board.txt file At the end
- * also the path variable is set
- *
- *
- * To be able to quickly fix boards.txt and platform.txt problems I also added a
- * pre and post platform and boards files that are processed before and after
- * the arduino delivered boards.txt file.
- *
- * @param project
- * the project for which the environment variables are set
- * @param arduinoProperties
- * the info of the selected board to set the variables for
- */
- public Map getEnvVars() {
- updateWhenDirty();
-
- TxtFile pluginPreProcessingPlatformTxt = new TxtFile(ConfigurationPreferences.getPreProcessingPlatformFile());
- TxtFile pluginPostProcessingPlatformTxt = new TxtFile(ConfigurationPreferences.getPostProcessingPlatformFile());
- BoardTxtFile pluginPreProcessingBoardsTxt = new BoardTxtFile(
- ConfigurationPreferences.getPreProcessingBoardsFile());
- BoardTxtFile pluginPostProcessingBoardsTxt = new BoardTxtFile(
- ConfigurationPreferences.getPostProcessingBoardsFile());
-
- Map allVars = pluginPreProcessingPlatformTxt.getAllEnvironVars(EMPTY);
- allVars.putAll(pluginPreProcessingBoardsTxt.getBoardEnvironVars(getBoardID()));
-
- String architecture = getArchitecture();
- IPath coreHardwarePath = getreferencedCoreHardwarePath();
- allVars.put(ENV_KEY_BUILD_ARCH, architecture.toUpperCase());
- allVars.put(ENV_KEY_RUNTIME_HARDWARE_PATH, getreferencingPlatformPath().removeLastSegments(1).toOSString());
- allVars.put(ENV_KEY_BUILD_SYSTEM_PATH, coreHardwarePath.append(SYSTEM).toOSString());
- allVars.put(ENV_KEY_RUNTIME_PLATFORM_PATH, getreferencingPlatformPath().toOSString());
- //ide_version is defined in pre_processing_platform_default.txt
- allVars.put(ENV_KEY_RUNTIME_IDE_VERSION, makeEnvironmentVar("ide_version")); //$NON-NLS-1$
- allVars.put(ENV_KEY_RUNTIME_IDE_PATH, makeEnvironmentVar(SLOEBER_HOME));
- if(isWindows) {
- allVars.put(ENV_KEY_RUNTIME_OS, "windows"); //$NON-NLS-1$
- }
- if(isLinux) {
- allVars.put(ENV_KEY_RUNTIME_OS, "linux"); //$NON-NLS-1$
- }
- if(isMac) {
- allVars.put(ENV_KEY_RUNTIME_OS, "macosx"); //$NON-NLS-1$
- }
- allVars.put(ENV_KEY_ID,getBoardID());
- allVars.put(ENV_KEY_BUILD_FQBN,getBoardFQBN());
-
- allVars.put(ENV_KEY_SERIAL_PORT, getActualUploadPort());
- allVars.put(ENV_KEY_SERIAL_DOT_PORT, getActualUploadPort());
-
- allVars.put(ENV_KEY_SERIAL_PORT_FILE, getActualUploadPort().replace("/dev/", EMPTY)); //$NON-NLS-1$
- // if actual core path is osstring regression test issue555 willl fail teensy
- // stuff
- allVars.put(ENV_KEY_BUILD_ACTUAL_CORE_PATH, getActualCoreCodePath().toString());
- IPath variantPath = getActualVariantPath();
- if (variantPath != null) {
- allVars.put(ENV_KEY_BUILD_VARIANT_PATH, variantPath.toOSString());
- } else {// teensy does not use variant
- allVars.put(ENV_KEY_BUILD_VARIANT_PATH, EMPTY);
- }
-
- PlatformTxtFile referencedPlatfromFile = getreferencedCorePlatformFile();
- // process the platform file referenced by the boards.txt
- if (referencedPlatfromFile != null) {
- allVars.putAll(referencedPlatfromFile.getAllEnvironVars());
- }
- PlatformTxtFile referencingPlatfromFile = getReferencingPlatformFile();
- // process the platform file next to the selected boards.txt
- if (referencingPlatfromFile != null) {
- allVars.putAll(referencingPlatfromFile.getAllEnvironVars());
- }
-
- // put in the installed tools info
- allVars.putAll(getEnVarPlatformInfo());
-
- // boards settings not coming from menu selections
- allVars.putAll(mySloeberBoardTxtFile.getBoardEnvironVars(getBoardID()));
-
- // board settings from menu selections
- Map options = getOptions();
- KeyValueTree rootData = mySloeberBoardTxtFile.getData();
- KeyValueTree menuData = rootData.getChild(getBoardID() + DOT + MENU);
- for (Entry curOption : options.entrySet()) {
- String menuID = curOption.getKey();
- String SelectedMenuItemID = curOption.getValue();
- KeyValueTree curSelectedMenuItem = menuData.getChild(menuID + DOT + SelectedMenuItemID);
- allVars.putAll(curSelectedMenuItem.toKeyValues(EMPTY));
- }
-
- //This moved last. See github issue 1410
- Programmers localProgrammers[] = Programmers.fromBoards(this);
- String programmer = getProgrammer();
- for (Programmers curProgrammer : localProgrammers) {
- String programmerID = curProgrammer.getIDFromNiceName(programmer);
- if (programmerID != null) {
- allVars.putAll(curProgrammer.getAllEnvironVars(programmerID));
- }
- }
-
- // add the stuff that comes with the plugin that is marked as post
- allVars.putAll(pluginPostProcessingPlatformTxt.getAllEnvironVars(EMPTY));
- allVars.putAll(pluginPostProcessingBoardsTxt.getBoardEnvironVars(getBoardID()));
-
- // Do some coded post processing
- allVars.putAll(getEnvVarsPostProcessing(allVars));
- return allVars;
-
- }
-
- private String getBoardFQBN() {
- String fqbn=getVendor()+COLON+getArchitecture()+COLON+getBoardID();
- String options=EMPTY_STRING;
- String prefix=COLON;
- for(Entry curOption:myOptions.entrySet()){
- options=options+prefix+curOption.getKey()+EQUAL+curOption.getValue();
- prefix=COMMA;
- }
- return fqbn+options;
- }
-
- private Map getEnVarPlatformInfo() {
- Map ret = new HashMap<>();
-
- if (myReferencedPlatformUpload != null) {
- ret.putAll(getEnvVarPlatformFileTools(myReferencedPlatformUpload));
- }
- if (myReferencedPlatformVariant != null) {
- ret.putAll(getEnvVarPlatformFileTools(myReferencedPlatformVariant));
- }
-
- if (myReferencedPlatformCore != null) {
- ret.putAll(getEnvVarPlatformFileTools(myReferencedPlatformCore));
- }
-
- IPath referencingPlatformPath = getreferencingPlatformPath();
- ArduinoPlatformVersion referencingPlatform = BoardsManager.getPlatform(referencingPlatformPath);
-
- if (referencingPlatform == null) {
- // This is the case for private hardware
- //there is no need to specify tool path as they do not use them
- return ret;
- }
- ArduinoPlatformVersion latestArduinoPlatform = BoardsManager.getNewestInstalledPlatform(Const.VENDOR_ARDUINO,
- referencingPlatform.getArchitecture());
- if (latestArduinoPlatform != null) {
- ret.putAll(getEnvVarPlatformFileTools(latestArduinoPlatform));
- }
-
- if (myReferencedPlatformCore == null) {
- //there is no referenced core so no need to do smart stuff
- ret.putAll(getEnvVarPlatformFileTools(referencingPlatform));
- return ret;
- }
-
- boolean jsonBasedPlatformManagement = !Preferences.getUseArduinoToolSelection();
- if (jsonBasedPlatformManagement) {
- // overrule the Arduino IDE way of working and use the json refereced tools
- ret.putAll(getEnvVarPlatformFileTools(referencingPlatform));
- return ret;
- }
- // standard arduino IDE way
- ret.putAll(getEnvVarPlatformFileTools(referencingPlatform));
- ret.putAll(getEnvVarPlatformFileTools(myReferencedPlatformCore));
- return ret;
-
- }
-
- /**
- * This method only returns environment variables with and without version
- * number
- * These are purely based on the tool dependencies
- *
- * @param platformVersion
- * @return environment variables pointing to the tools used by the platform
- */
- private static Map getEnvVarPlatformFileTools(ArduinoPlatformVersion platformVersion) {
- HashMap vars = new HashMap<>();
- for (ArduinoPlatformTooldDependency tool : platformVersion.getToolsDependencies()) {
- IPath installPath = tool.getInstallPath();
- if (installPath.toFile().exists()) {
- String value = installPath.toOSString();
- String keyString = ENV_KEY_RUNTIME_TOOLS + tool.getName() + tool.getVersion() + DOT_PATH;
- vars.put(keyString, value);
- keyString = ENV_KEY_RUNTIME_TOOLS + tool.getName() + '-' + tool.getVersion() + DOT_PATH;
- vars.put(keyString, value);
- keyString = ENV_KEY_RUNTIME_TOOLS + tool.getName() + DOT_PATH;
- vars.put(keyString, value);
- }
- }
- return vars;
- }
-
- /**
- * Following post processing is done
- *
- *
- * The handling of the upload variables is done differently in arduino
- * than in Sloeber. This is taken care of here. for example the output of this
- * input
- * tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose}
- * is changed as if it were the output of this input
- * tools.avrdude.upload.pattern="{tools.avrdude.cmd.path}"
- * "-C{tools.avrdude.config.path}" {tools.avrdude.upload.verbose}
- *
- * if a programmer is selected different from default some extra actions
- * are done here so no special code is needed to handle programmers
- *
- * The build path for the core is {build.path}/core/core in sloeber
- * where it is {build.path}/core/ in arduino world and used to be {build.path}/
- * This only gives problems in the link command as sometimes there are hardcoded
- * links to some sys files so ${build.path}/core/sys* ${build.path}/sys* is
- * replaced with ${build.path}/core/core/sys*
- *
- * @param contribEnv
- * @param confDesc
- * @param boardsDescriptor
- */
- private static Map getEnvVarsPostProcessing(Map