Search in sources :

Example 1 with MyMultiStatus

use of io.sloeber.core.tools.MyMultiStatus in project arduino-eclipse-plugin by Sloeber.

the class InternalPackageManager method startup_Pluging.

/**
 * Loads all stuff needed and if this is the first time downloads the avr boards
 * and needed tools
 *
 * @param monitor
 */
public static void startup_Pluging(IProgressMonitor monitor) {
    loadJsons(ConfigurationPreferences.getUpdateJasonFilesFlag());
    List<Board> allBoards = getInstalledBoards();
    if (!LibraryManager.libsAreInstalled()) {
        LibraryManager.InstallDefaultLibraries(monitor);
    }
    if (allBoards.isEmpty()) {
        // If boards are installed do nothing
        // $NON-NLS-1$
        MyMultiStatus mstatus = new MyMultiStatus("Failed to configer Sloeber");
        // Download sample programs
        mstatus.addErrors(downloadAndInstall(Defaults.EXAMPLES_URL, Defaults.EXAMPLE_PACKAGE, ConfigurationPreferences.getInstallationPathExamples(), false, monitor));
        if (mstatus.isOK()) {
            // if successfully installed the examples: add the boards
            Package pkg = getPackageIndices().get(0).getPackages().get(0);
            if (pkg != null) {
                ArduinoPlatform platform = pkg.getLatestPlatform(Defaults.PLATFORM_NAME, false);
                if (platform == null) {
                    ArduinoPlatform[] platformList = new ArduinoPlatform[pkg.getLatestPlatforms().size()];
                    pkg.getLatestPlatforms().toArray(platformList);
                    platform = platformList[0];
                }
                if (platform != null) {
                    mstatus.addErrors(downloadAndInstall(platform, false, monitor));
                }
            }
        }
        if (!mstatus.isOK()) {
            StatusManager stMan = StatusManager.getManager();
            stMan.handle(mstatus, StatusManager.LOG | StatusManager.SHOW | StatusManager.BLOCK);
        }
    }
    myIsReady = true;
}
Also used : StatusManager(org.eclipse.ui.statushandlers.StatusManager) MyMultiStatus(io.sloeber.core.tools.MyMultiStatus)

Example 2 with MyMultiStatus

use of io.sloeber.core.tools.MyMultiStatus in project arduino-eclipse-plugin by Sloeber.

the class InternalPackageManager method downloadAndInstall.

/**
 * Given a platform description in a json file download and install all needed
 * stuff. All stuff is including all tools and core files and hardware specific
 * libraries. That is (on windows) inclusive the make.exe
 *
 * @param platform
 * @param monitor
 * @param object
 * @return
 */
public static IStatus downloadAndInstall(ArduinoPlatform platform, boolean forceDownload, IProgressMonitor monitor) {
    // $NON-NLS-1$
    MyMultiStatus mstatus = new MyMultiStatus("Failed to install " + platform.getName());
    mstatus.addErrors(downloadAndInstall(platform.getUrl(), platform.getArchiveFileName(), platform.getInstallPath(), forceDownload, monitor));
    if (!mstatus.isOK()) {
        // no use going on installing tools if the boards failed installing
        return mstatus;
    }
    if (platform.getToolsDependencies() != null) {
        for (ToolDependency tool : platform.getToolsDependencies()) {
            monitor.setTaskName(InstallProgress.getRandomMessage());
            mstatus.addErrors(tool.install(monitor));
        }
    }
    // On Windows install make
    if (SystemUtils.IS_OS_WINDOWS) {
        IPath localMakePath = ConfigurationPreferences.getMakePath();
        if (!ConfigurationPreferences.getMakePath().append("make.exe").toFile().exists()) {
            // $NON-NLS-1$
            mstatus.addErrors(downloadAndInstall(// $NON-NLS-1$ //$NON-NLS-2$
            "https://eclipse.baeyens.it/download/make.zip", // $NON-NLS-1$ //$NON-NLS-2$
            "make.zip", // $NON-NLS-1$ //$NON-NLS-2$
            localMakePath, forceDownload, monitor));
        }
    }
    // replace -DARDUINO_BOARD="{build.board}" with -DARDUINO_BOARD="\"{build.board}\""
    if (SystemUtils.IS_OS_WINDOWS) {
        if ("esp8266".equals(platform.getArchitecture()) && "esp8266".equals(platform.getName())) {
            FileModifiers.replaceInFile(platform.getPlatformFile(), false, "-DARDUINO_BOARD=\"{build.board}\"", "-DARDUINO_BOARD=\"\\\"{build.board}\\\"\"");
        }
    }
    return mstatus;
}
Also used : IPath(org.eclipse.core.runtime.IPath) MyMultiStatus(io.sloeber.core.tools.MyMultiStatus)

Example 3 with MyMultiStatus

use of io.sloeber.core.tools.MyMultiStatus 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)

Aggregations

MyMultiStatus (io.sloeber.core.tools.MyMultiStatus)3 ArduinoInstallable (io.sloeber.core.api.Json.ArduinoInstallable)1 ArduinoPackage (io.sloeber.core.api.Json.ArduinoPackage)1 ArduinoPlatformToolVersion (io.sloeber.core.api.Json.ArduinoPlatformToolVersion)1 ArduinoPlatformTooldDependency (io.sloeber.core.api.Json.ArduinoPlatformTooldDependency)1 BoardTxtFile (io.sloeber.core.txt.BoardTxtFile)1 File (java.io.File)1 IOException (java.io.IOException)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 Status (org.eclipse.core.runtime.Status)1 StatusManager (org.eclipse.ui.statushandlers.StatusManager)1