Search in sources :

Example 1 with PlatformTxtFile

use of io.sloeber.core.txt.PlatformTxtFile in project arduino-eclipse-plugin by Sloeber.

the class BoardDescription method getreferencedCorePlatformFile.

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;
}
Also used : PlatformTxtFile(io.sloeber.core.txt.PlatformTxtFile) PlatformTxtFile(io.sloeber.core.txt.PlatformTxtFile) TxtFile(io.sloeber.core.txt.TxtFile) BoardTxtFile(io.sloeber.core.txt.BoardTxtFile) File(java.io.File)

Example 2 with PlatformTxtFile

use of io.sloeber.core.txt.PlatformTxtFile in project arduino-eclipse-plugin by Sloeber.

the class BoardDescription method getReferencingPlatformFile.

public PlatformTxtFile getReferencingPlatformFile() {
    updateWhenDirty();
    File platformFile = getreferencingPlatformPath().append(PLATFORM_FILE_NAME).toFile();
    if (platformFile != null && platformFile.exists()) {
        return new PlatformTxtFile(platformFile);
    }
    return null;
}
Also used : PlatformTxtFile(io.sloeber.core.txt.PlatformTxtFile) PlatformTxtFile(io.sloeber.core.txt.PlatformTxtFile) TxtFile(io.sloeber.core.txt.TxtFile) BoardTxtFile(io.sloeber.core.txt.BoardTxtFile) File(java.io.File)

Example 3 with PlatformTxtFile

use of io.sloeber.core.txt.PlatformTxtFile in project arduino-eclipse-plugin by Sloeber.

the class BoardDescription method getEnvVars.

/**
 * 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<String, String> 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<String, String> 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_HARDWARE_PATH, coreHardwarePath.removeLastSegments(1).toOSString());
    allVars.put(ENV_KEY_BUILD_SYSTEM_PATH, coreHardwarePath.append(SYSTEM).toOSString());
    allVars.put(ENV_KEY_PLATFORM_PATH, getreferencingPlatformPath().toOSString());
    allVars.put(ENV_KEY_SERIAL_PORT, getActualUploadPort());
    allVars.put(ENV_KEY_SERIAL_DOT_PORT, getActualUploadPort());
    // $NON-NLS-1$
    allVars.put(ENV_KEY_SERIAL_PORT_FILE, getActualUploadPort().replace("/dev/", EMPTY));
    // 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 variants
        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(myBoardTxtFile.getBoardEnvironVars(getBoardID()));
    // board settings from menu selections
    Map<String, String> options = getOptions();
    KeyValueTree rootData = myBoardTxtFile.getData();
    KeyValueTree menuData = rootData.getChild(getBoardID() + DOT + MENU);
    for (Entry<String, String> curOption : options.entrySet()) {
        String menuID = curOption.getKey();
        String SelectedMenuItemID = curOption.getValue();
        KeyValueTree curSelectedMenuItem = menuData.getChild(menuID + DOT + SelectedMenuItemID);
        allVars.putAll(curSelectedMenuItem.toKeyValues(EMPTY, false));
    }
    // 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;
}
Also used : IPath(org.eclipse.core.runtime.IPath) PlatformTxtFile(io.sloeber.core.txt.PlatformTxtFile) BoardTxtFile(io.sloeber.core.txt.BoardTxtFile) PlatformTxtFile(io.sloeber.core.txt.PlatformTxtFile) TxtFile(io.sloeber.core.txt.TxtFile) BoardTxtFile(io.sloeber.core.txt.BoardTxtFile) KeyValueTree(io.sloeber.core.txt.KeyValueTree) Programmers(io.sloeber.core.txt.Programmers)

Aggregations

BoardTxtFile (io.sloeber.core.txt.BoardTxtFile)3 PlatformTxtFile (io.sloeber.core.txt.PlatformTxtFile)3 TxtFile (io.sloeber.core.txt.TxtFile)3 File (java.io.File)2 KeyValueTree (io.sloeber.core.txt.KeyValueTree)1 Programmers (io.sloeber.core.txt.Programmers)1 IPath (org.eclipse.core.runtime.IPath)1