From eef28700d937698b1c49e4c567963960afba7bfe Mon Sep 17 00:00:00 2001 From: gholdys Date: Sat, 22 Jul 2017 22:39:38 +0200 Subject: [PATCH] Fixed issues #26 and #27 --- .../importer/ArduinoBuilderRunner.java | 20 +++++++++++-------- .../importer/ChipKitBoardConfigNavigator.java | 14 ++++++++++--- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/com/microchip/mplab/nbide/embedded/chipkit/importer/ArduinoBuilderRunner.java b/src/com/microchip/mplab/nbide/embedded/chipkit/importer/ArduinoBuilderRunner.java index 5257ca7..88ae543 100644 --- a/src/com/microchip/mplab/nbide/embedded/chipkit/importer/ArduinoBuilderRunner.java +++ b/src/com/microchip/mplab/nbide/embedded/chipkit/importer/ArduinoBuilderRunner.java @@ -236,14 +236,18 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { Path dependencyFilePath = Paths.get( path ); // TODO: If the "path" string does not represent a path then it probably contains error information. Find a way to handle it. if ( Files.exists( dependencyFilePath ) ) { - LOGGER.info( "Dependency path:" + dependencyFilePath ); - Path relativeDependencyPath = librariesDir.relativize(dependencyFilePath.normalize()); - String libraryName = relativeDependencyPath.getName(0).toString(); - Path libraryPath = librariesDir.resolve(libraryName); - if ( !allLibraries.contains(libraryPath) ) { - LOGGER.info("Found library path: " + libraryPath); - allLibraries.add(libraryPath); - ret.add(libraryPath); + LOGGER.info( "Dependency path: " + dependencyFilePath ); + if ( dependencyFilePath.startsWith( librariesDir ) ) { + Path relativeDependencyPath = librariesDir.relativize(dependencyFilePath.normalize()); + String libraryName = relativeDependencyPath.getName(0).toString(); + Path libraryPath = librariesDir.resolve(libraryName); + if ( !allLibraries.contains(libraryPath) ) { + LOGGER.info("Found library path: " + libraryPath); + allLibraries.add(libraryPath); + ret.add(libraryPath); + } + } else { + LOGGER.info( "Ignoring dependency file path:" + dependencyFilePath ); } } } diff --git a/src/com/microchip/mplab/nbide/embedded/chipkit/importer/ChipKitBoardConfigNavigator.java b/src/com/microchip/mplab/nbide/embedded/chipkit/importer/ChipKitBoardConfigNavigator.java index 1acd331..3576f5c 100644 --- a/src/com/microchip/mplab/nbide/embedded/chipkit/importer/ChipKitBoardConfigNavigator.java +++ b/src/com/microchip/mplab/nbide/embedded/chipkit/importer/ChipKitBoardConfigNavigator.java @@ -49,8 +49,13 @@ public class ChipKitBoardConfigNavigator { public static List findChipKitHardwareDirectories( ArduinoConfig arduinoPathResolver ) throws IOException { - final Path settingsPath = arduinoPathResolver.getSettingsPath(); + Path settingsPath = arduinoPathResolver.getSettingsPath(); + if ( settingsPath == null ) { + LOGGER.severe( "Failed to find the Arduino settings directory!" ); + throw new FileNotFoundException("Failed to find the Arduino settings directory!"); + } + // Find all paths containing a "platform.txt" file LOGGER.log(Level.INFO, "Searching for platform files in {0}", settingsPath); FileFinder finder = new FileFinder(PLATFORM_FILENAME); @@ -65,8 +70,8 @@ public static List findChipKitHardwareDirectories( ArduinoConfig arduinoPa if ( chipkitPlatformPaths.size() > 0 ) { LOGGER.log(Level.INFO, "Found {0} platform path(s): {1}", new Object[]{chipkitPlatformPaths.size(), chipkitPlatformPaths}); } else { - LOGGER.severe("Failed to find any chipKIT platform file!"); - throw new FileNotFoundException("Failed to find any chipKIT platform file!"); + LOGGER.severe("Failed to find chipKIT platform files!"); + throw new FileNotFoundException("Failed to find chipKIT platform files!"); } return chipkitPlatformPaths; @@ -122,6 +127,9 @@ public String getFullyQualifiedBoardName( String boardId ) throws IOException { // FQBN arduino:avr:nano - [vendor folder name]:[architecture folder name]:[boardId]. // TODO: Implement proper Vendor/Architecture resolution int chipkitIndex = findChipKitPathIndex(chipKitHardwarePath); + if ( chipkitIndex == -1 ) { + throw new RuntimeException("Failed to find chipKIT hardware directory!"); + } String chipkitCoreName = chipKitHardwarePath.getName(chipkitIndex).toString(); return chipkitCoreName + ":pic32:" + boardId; }