Search in sources :

Example 1 with ArduinoPackage

use of io.sloeber.core.api.Json.ArduinoPackage in project arduino-eclipse-plugin by Sloeber.

the class BoardsManager method install.

@SuppressWarnings("nls")
private static IStatus install(ArduinoPlatformVersion platformVersion, IProgressMonitor monitor) {
    boolean forceDownload = false;
    String name = platformVersion.getName();
    String architecture = platformVersion.getArchitecture();
    String version = platformVersion.getVersion().toString();
    // Check if we're installed already
    if (platformVersion.isInstalled()) {
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        System.out.println("reusing platform " + name + " " + architecture + "(" + version + ")");
        return Status.OK_STATUS;
    }
    // Download platform archive
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    System.out.println("start installing platform " + name + " " + architecture + "(" + version + ")");
    // $NON-NLS-1$
    MyMultiStatus mstatus = new MyMultiStatus("Failed to install " + platformVersion.getName());
    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();
    }
    ArduinoPackage 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
            ArduinoPackage 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);
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    System.out.println("done installing platform " + name + " " + architecture + "(" + version + ")");
    return mstatus;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) MyMultiStatus(io.sloeber.core.tools.MyMultiStatus) Status(org.eclipse.core.runtime.Status) ArduinoPlatformToolVersion(io.sloeber.core.api.Json.ArduinoPlatformToolVersion) ArduinoInstallable(io.sloeber.core.api.Json.ArduinoInstallable) ArduinoPackage(io.sloeber.core.api.Json.ArduinoPackage) ArduinoPlatformTooldDependency(io.sloeber.core.api.Json.ArduinoPlatformTooldDependency) IOException(java.io.IOException) MyMultiStatus(io.sloeber.core.tools.MyMultiStatus) BoardTxtFile(io.sloeber.core.txt.BoardTxtFile) File(java.io.File)

Example 2 with ArduinoPackage

use of io.sloeber.core.api.Json.ArduinoPackage in project arduino-eclipse-plugin by Sloeber.

the class PlatformSelectionPage method mustBeInstalled.

private boolean mustBeInstalled(ArduinoPlatform platform) {
    ArduinoPackage parentPkg = platform.getParent();
    ArduinoPlatformPackageIndex parentIndex = parentPkg.getPackageIndex();
    InstallableVersion[] inScopeVersions = myShownPlatforms.get(parentIndex.getID()).get(parentPkg.getID()).get(platform.getID());
    for (InstallableVersion version : inScopeVersions) {
        if (version.mustBeInstalled()) {
            return true;
        }
    }
    return false;
}
Also used : ArduinoPlatformPackageIndex(io.sloeber.core.api.Json.ArduinoPlatformPackageIndex) ArduinoPackage(io.sloeber.core.api.Json.ArduinoPackage)

Example 3 with ArduinoPackage

use of io.sloeber.core.api.Json.ArduinoPackage in project arduino-eclipse-plugin by Sloeber.

the class BoardsManager method getNewestBoardIDFromBoardsManager.

private static BoardDescription getNewestBoardIDFromBoardsManager(String jsonFileName, String packageName, String architectureName, String boardID, Map<String, String> options) {
    ArduinoPackage thePackage = getPackage(jsonFileName, packageName);
    if (thePackage == null) {
        // fail("failed to find package:" + this.mPackageName);
        return null;
    }
    ArduinoPlatform platform = thePackage.getPlatform(architectureName);
    if (platform == null) {
        // package:" + this.mPackageName);
        return null;
    }
    ArduinoPlatformVersion platformVersion = platform.getNewestVersion();
    java.io.File boardsFile = platformVersion.getBoardsFile();
    BoardDescription boardid = new BoardDescription(boardsFile, boardID, options);
    return boardid;
}
Also used : ArduinoPlatformVersion(io.sloeber.core.api.Json.ArduinoPlatformVersion) ArduinoPlatform(io.sloeber.core.api.Json.ArduinoPlatform) ArduinoPackage(io.sloeber.core.api.Json.ArduinoPackage) File(java.io.File)

Example 4 with ArduinoPackage

use of io.sloeber.core.api.Json.ArduinoPackage in project arduino-eclipse-plugin by Sloeber.

the class BoardsManager method getEnvVarPlatformFileTools.

private static Map<String, String> getEnvVarPlatformFileTools(ArduinoPlatformVersion platformVersion) {
    HashMap<String, String> vars = new HashMap<>();
    ArduinoPackage pkg = platformVersion.getParent().getParent();
    for (ArduinoPlatformTooldDependency tool : platformVersion.getToolsDependencies()) {
        ArduinoPlatformTool theTool = pkg.getTool(tool.getName());
        if (theTool == null) {
            // $NON-NLS-1$ //$NON-NLS-2$
            System.err.println("Did not find " + tool.getName() + " in package with ID " + pkg.getID());
        } else {
            vars.putAll(theTool.getEnvVars(null));
        }
    }
    return vars;
}
Also used : ArduinoPackage(io.sloeber.core.api.Json.ArduinoPackage) HashMap(java.util.HashMap) ArduinoPlatformTooldDependency(io.sloeber.core.api.Json.ArduinoPlatformTooldDependency) ArduinoPlatformTool(io.sloeber.core.api.Json.ArduinoPlatformTool)

Example 5 with ArduinoPackage

use of io.sloeber.core.api.Json.ArduinoPackage in project arduino-eclipse-plugin by Sloeber.

the class BoardsManager method installLatestPlatform.

public static void installLatestPlatform(String JasonName, String packageName, String architectureName) {
    if (!isReady()) {
        Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
        return;
    }
    envVarsNeedUpdating = true;
    ArduinoPackage curPackage = getPackage(JasonName, packageName);
    if (curPackage != null) {
        ArduinoPlatform curPlatform = curPackage.getPlatform(architectureName);
        if (curPlatform != null) {
            ArduinoPlatformVersion curPlatformVersion = curPlatform.getNewestVersion();
            if (curPlatformVersion != null) {
                NullProgressMonitor monitor = new NullProgressMonitor();
                install(curPlatformVersion, monitor);
                return;
            }
        }
    }
    Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    "failed to find " + JasonName + " " + packageName + " " + architectureName));
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) MyMultiStatus(io.sloeber.core.tools.MyMultiStatus) Status(org.eclipse.core.runtime.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ArduinoPlatformVersion(io.sloeber.core.api.Json.ArduinoPlatformVersion) ArduinoPlatform(io.sloeber.core.api.Json.ArduinoPlatform) ArduinoPackage(io.sloeber.core.api.Json.ArduinoPackage) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

ArduinoPackage (io.sloeber.core.api.Json.ArduinoPackage)9 ArduinoPlatform (io.sloeber.core.api.Json.ArduinoPlatform)6 ArduinoPlatformVersion (io.sloeber.core.api.Json.ArduinoPlatformVersion)5 MyMultiStatus (io.sloeber.core.tools.MyMultiStatus)3 IOException (java.io.IOException)3 IStatus (org.eclipse.core.runtime.IStatus)3 MultiStatus (org.eclipse.core.runtime.MultiStatus)3 Status (org.eclipse.core.runtime.Status)3 BoardDescription (io.sloeber.core.api.BoardDescription)2 ArduinoPlatformPackageIndex (io.sloeber.core.api.Json.ArduinoPlatformPackageIndex)2 ArduinoPlatformTooldDependency (io.sloeber.core.api.Json.ArduinoPlatformTooldDependency)2 File (java.io.File)2 MalformedURLException (java.net.MalformedURLException)2 LinkedList (java.util.LinkedList)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ArduinoInstallable (io.sloeber.core.api.Json.ArduinoInstallable)1 ArduinoPlatformTool (io.sloeber.core.api.Json.ArduinoPlatformTool)1 ArduinoPlatformToolVersion (io.sloeber.core.api.Json.ArduinoPlatformToolVersion)1 BoardTxtFile (io.sloeber.core.txt.BoardTxtFile)1 HashMap (java.util.HashMap)1