Commit 4431be4d authored by Cristian Maglie's avatar Cristian Maglie

Renamed 'folder' to 'directory'

Fix #106
parent 1b8bf633
......@@ -15,7 +15,7 @@
"types",
"utils"
]
revision = "2f39b7080c6220c43fa49ab0b378e3af4cf99ee6"
revision = "b8512dfa8616122c6a471e56295f58420775d965"
source = "github.com/bcmi-labs/arduino-builder"
[[projects]]
......
......@@ -45,14 +45,14 @@ import (
func (pm *PackageManager) LoadHardware(config *configs.Configuration) error {
dirs, err := config.HardwareDirectories()
if err != nil {
return fmt.Errorf("getting hardware folder: %s", err)
return fmt.Errorf("getting hardware directory: %s", err)
}
if err := pm.LoadHardwareFromDirectories(dirs); err != nil {
return err
}
dirs, err = configs.BundleToolsDirectories()
if err != nil {
return fmt.Errorf("getting hardware folder: %s", err)
return fmt.Errorf("getting hardware directory: %s", err)
}
return pm.LoadToolsFromBundleDirectories(dirs)
}
......@@ -78,10 +78,10 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
if isDir, err := path.IsDir(); err != nil {
return fmt.Errorf("reading %s stat info: %s", path, err)
} else if !isDir {
return fmt.Errorf("%s is not a folder", path)
return fmt.Errorf("%s is not a directory", path)
}
// Scan subfolders.
// Scan subdirs
files, err := path.ReadDir()
if err != nil {
return fmt.Errorf("reading %s directory: %s", path, err)
......@@ -90,9 +90,9 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
for _, packagerPath := range files {
packager := packagerPath.Base()
// First exclude all "tools" folders
// First exclude all "tools" directory
if packager == "tools" {
pm.Log.Infof("Excluding folder: %s", packagerPath)
pm.Log.Infof("Excluding directory: %s", packagerPath)
continue
}
......@@ -102,7 +102,7 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
return fmt.Errorf("following possible symlink %s: %s", path, err)
}
// There are two possible package folder structures:
// There are two possible package directory structures:
// - PACKAGER/ARCHITECTURE-1/boards.txt... (ex: arduino/avr/...)
// PACKAGER/ARCHITECTURE-2/boards.txt... (ex: arduino/sam/...)
// PACKAGER/ARCHITECTURE-3/boards.txt... (ex: arduino/samd/...)
......@@ -111,11 +111,11 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
// PACKAGER/hardware/ARCHITECTURE-2/VERSION/boards.txt... (ex: arduino/hardware/sam/1.6.6/...)
// PACKAGER/hardware/ARCHITECTURE-3/VERSION/boards.txt... (ex: arduino/hardware/samd/1.6.12/...)
// PACKAGER/tools/... (ex: arduino/tools/...)
// in the latter case we just move into "hardware" folder and continue
// in the latter case we just move into "hardware" directory and continue
var architectureParentPath *paths.Path
hardwareSubdirPath := packagerPath.Join("hardware") // ex: .arduino15/packages/arduino/hardware
if isDir, _ := hardwareSubdirPath.IsDir(); isDir {
// we found the "hardware" folder move down into that
// we found the "hardware" directory move down into that
architectureParentPath = hardwareSubdirPath // ex: .arduino15/packages/arduino/
} else if isDir, _ := packagerPath.IsDir(); isDir {
// we are already at the correct level
......@@ -130,7 +130,7 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
return fmt.Errorf("loading package %s: %s", packager, err)
}
// Check if we have tools to load, the folder structure is as follows:
// Check if we have tools to load, the directory structure is as follows:
// - PACKAGER/tools/TOOL-NAME/TOOL-VERSION/... (ex: arduino/tools/bossac/1.7.0/...)
toolsSubdirPath := packagerPath.Join("tools")
if isDir, _ := toolsSubdirPath.IsDir(); isDir {
......@@ -146,18 +146,12 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
// loadPlatforms load plaftorms from the specified directory assuming that they belongs
// to the targetPackage object passed as parameter.
func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageFolder *paths.Path) error {
pm.Log.Infof("Loading package %s from: %s", targetPackage.Name, packageFolder)
func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir *paths.Path) error {
pm.Log.Infof("Loading package %s from: %s", targetPackage.Name, packageDir)
// packagePlatformTxt, err := properties.SafeLoad(filepath.Join(folder, constants.FILE_PLATFORM_TXT))
// if err != nil {
// return err
// }
// targetPackage.Properties.Merge(packagePlatformTxt)
files, err := packageFolder.ReadDir()
files, err := packageDir.ReadDir()
if err != nil {
return fmt.Errorf("reading directory %s: %s", packageFolder, err)
return fmt.Errorf("reading directory %s: %s", packageDir, err)
}
for _, file := range files {
......@@ -166,12 +160,12 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageFol
architecure == "platform.txt" { // TODO: Check if this "platform.txt" condition should be here....
continue
}
platformPath := packageFolder.Join(architecure)
platformPath := packageDir.Join(architecure)
if isDir, _ := platformPath.IsDir(); !isDir {
continue
}
// There are two possible platform folder structures:
// There are two possible platform directory structures:
// - ARCHITECTURE/boards.txt
// - ARCHITECTURE/VERSION/boards.txt
// We identify them by checking where is the bords.txt file
......@@ -202,7 +196,7 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageFol
} else /* !exist */ {
// case: ARCHITECTURE/VERSION/boards.txt
// let's dive into VERSION folders
// let's dive into VERSION directories
platform := targetPackage.GetOrCreatePlatform(architecure)
versionDirs, err := platformPath.ReadDir()
......@@ -332,7 +326,6 @@ func (pm *PackageManager) loadToolReleasesFromTool(tool *cores.Tool, toolPath *p
version := versionPath.Base()
if toolReleasePath, err := versionPath.Abs(); err == nil {
release := tool.GetOrCreateRelease(version)
// TODO: Make Folder a *paths.Path
release.InstallDir = toolReleasePath
pm.Log.WithField("tool", release).Infof("Loaded tool")
} else {
......@@ -358,7 +351,7 @@ func (pm *PackageManager) LoadToolsFromBundleDirectory(toolsPath *paths.Path) er
// We scan toolsPath content to find a "builtin_tools_versions.txt", if such file exists
// then the all the tools are available in the same directory, mixed together, and their
// name and version are written in the "builtin_tools_versions.txt" file.
// If no "builtin_tools_versions.txt" is found, then the folder structure is the classic
// If no "builtin_tools_versions.txt" is found, then the directory structure is the classic
// TOOLSPATH/TOOL-NAME/TOOL-VERSION and it will be parsed as such and associated to an
// "unnamed" packager.
......
......@@ -372,7 +372,7 @@ func (pm *PackageManager) FindToolsRequiredForBoard(board *cores.Board) ([]*core
foundTools := map[string]*cores.ToolRelease{}
// a Platform may not specify required tools (because it's a platform that comes from a
// sketchbook/hardware folder without a package_index.json) then add all available tools
// sketchbook/hardware dir without a package_index.json) then add all available tools
for _, targetPackage := range pm.packages.Packages {
for _, tool := range targetPackage.Tools {
rel := tool.GetLatestInstalled()
......
......@@ -38,9 +38,9 @@ import (
type LibraryLayout uint16
const (
// FlatLayout is a library without a `src` folder
// FlatLayout is a library without a `src` directory
FlatLayout LibraryLayout = 1 << iota
// RecursiveLayout is a library with `src` folder (that allows recursive build)
// RecursiveLayout is a library with `src` directory (that allows recursive build)
RecursiveLayout
)
......
......@@ -58,7 +58,7 @@ func (lm *LibrariesManager) Install(indexLibrary *librariesindex.Release) (*path
libsDir := lm.getSketchbookLibrariesDir()
if libsDir == nil {
return nil, fmt.Errorf("sketchbook folder not set")
return nil, fmt.Errorf("sketchbook directory not set")
}
libPath := libsDir.Join(utils.SanitizeName(indexLibrary.Library.Name))
......
......@@ -143,7 +143,7 @@ func (sc *LibrariesManager) AddLibrariesDir(path *paths.Path, location libraries
})
}
// AddPlatformReleaseLibrariesDir add the libraries folder in the
// AddPlatformReleaseLibrariesDir add the libraries directory in the
// specified PlatformRelease to the list of directories to scan when
// searching for libraries.
func (sc *LibrariesManager) AddPlatformReleaseLibrariesDir(plaftormRelease *cores.PlatformRelease, location libraries.LibraryLocation) {
......@@ -186,20 +186,20 @@ func (sc *LibrariesManager) getSketchbookLibrariesDir() *paths.Path {
// LoadLibrariesFromDir loads all libraries in the given directory. Returns
// nil if the directory doesn't exists.
func (sc *LibrariesManager) LoadLibrariesFromDir(librariesDir *LibrariesDir) error {
subFolders, err := librariesDir.Path.ReadDir()
subDirs, err := librariesDir.Path.ReadDir()
if os.IsNotExist(err) {
return nil
}
if err != nil {
return fmt.Errorf("reading dir %s: %s", librariesDir.Path, err)
}
subFolders.FilterDirs()
subFolders.FilterOutHiddenFiles()
subDirs.FilterDirs()
subDirs.FilterOutHiddenFiles()
for _, subFolder := range subFolders {
library, err := libraries.Load(subFolder, librariesDir.Location)
for _, subDir := range subDirs {
library, err := libraries.Load(subDir, librariesDir.Location)
if err != nil {
return fmt.Errorf("loading library from %s: %s", subFolder, err)
return fmt.Errorf("loading library from %s: %s", subDir, err)
}
library.ContainerPlatform = librariesDir.PlatformRelease
alternatives, ok := sc.Libraries[library.Name]
......
......@@ -32,17 +32,17 @@ package libraries
// Lint produce warnings about the formal correctness of a Library
func (l *Library) Lint() ([]string, error) {
// TODO: check for spurious folders
// subFolders, err := ioutil.ReadDir(libraryFolder)
// TODO: check for spurious dirs
// subDirs, err := ioutil.ReadDir(libraryDir)
// if err != nil {
// return nil, fmt.Errorf("reading dir %s: %s", libraryFolder, err)
// return nil, fmt.Errorf("reading dir %s: %s", libraryDir, err)
// }
// for _, subFolder := range subFolders {
// if utils.IsSCCSOrHiddenFile(subFolder) {
// if !utils.IsSCCSFile(subFolder) && utils.IsHiddenFile(subFolder) {
// for _, subDir := range subDirs {
// if utils.IsSCCSOrHiddenFile(subDir) {
// if !utils.IsSCCSFile(subDir) && utils.IsHiddenFile(subDir) {
// logger.Fprintln(os.Stdout, "warn",
// "WARNING: Spurious {0} folder in '{1}' library",
// filepath.Base(subFolder.Name()), libProperties["name"])
// "WARNING: Spurious {0} directory in '{1}' library",
// filepath.Base(subDir.Name()), libProperties["name"])
// }
// }
// }
......
......@@ -37,7 +37,7 @@ import (
properties "github.com/arduino/go-properties-map"
)
// Load loads a library from the given folder
// Load loads a library from the given LibraryLocation
func Load(libDir *paths.Path, location LibraryLocation) (*Library, error) {
if exist, _ := libDir.Join("library.properties").Exist(); exist {
return makeNewLibrary(libDir, location)
......@@ -45,15 +45,15 @@ func Load(libDir *paths.Path, location LibraryLocation) (*Library, error) {
return makeLegacyLibrary(libDir, location)
}
func addUtilityFolder(library *Library) {
func addUtilityDirectory(library *Library) {
utilitySourcePath := library.InstallDir.Join("utility")
if isDir, _ := utilitySourcePath.IsDir(); isDir {
library.UtilityDir = utilitySourcePath
}
}
func makeNewLibrary(libraryFolder *paths.Path, location LibraryLocation) (*Library, error) {
libProperties, err := properties.Load(libraryFolder.Join("library.properties").String())
func makeNewLibrary(libraryDir *paths.Path, location LibraryLocation) (*Library, error) {
libProperties, err := properties.Load(libraryDir.Join("library.properties").String())
if err != nil {
return nil, fmt.Errorf("loading library.properties: %s", err)
}
......@@ -70,14 +70,14 @@ func makeNewLibrary(libraryFolder *paths.Path, location LibraryLocation) (*Libra
library := &Library{}
library.Location = location
library.InstallDir = libraryFolder
if exist, _ := libraryFolder.Join("src").Exist(); exist {
library.InstallDir = libraryDir
if exist, _ := libraryDir.Join("src").Exist(); exist {
library.Layout = RecursiveLayout
library.SourceDir = libraryFolder.Join("src")
library.SourceDir = libraryDir.Join("src")
} else {
library.Layout = FlatLayout
library.SourceDir = libraryFolder
addUtilityFolder(library)
library.SourceDir = libraryDir
addUtilityDirectory(library)
}
if libProperties["architectures"] == "" {
......@@ -99,7 +99,7 @@ func makeNewLibrary(libraryFolder *paths.Path, location LibraryLocation) (*Libra
}
library.License = libProperties["license"]
library.Name = libraryFolder.Base()
library.Name = libraryDir.Base()
library.RealName = strings.TrimSpace(libProperties["name"])
library.Version = strings.TrimSpace(libProperties["version"])
library.Author = strings.TrimSpace(libProperties["author"])
......@@ -126,6 +126,6 @@ func makeLegacyLibrary(path *paths.Path, location LibraryLocation) (*Library, er
Architectures: []string{"*"},
IsLegacy: true,
}
addUtilityFolder(library)
addUtilityDirectory(library)
return library, nil
}
......@@ -9,13 +9,13 @@ import (
)
// Install installs the resource in three steps:
// - the archive is unpacked in a temporary subfolder of tempPath
// - there should be only one root folder in the unpacked content
// - the only root folder is moved/renamed to/as the destination directory
// - the archive is unpacked in a temporary subdir of tempPath
// - there should be only one root dir in the unpacked content
// - the only root dir is moved/renamed to/as the destination directory
// Note that tempPath and destDir must be on the same filesystem partition
// otherwise the last step will fail.
func (release *DownloadResource) Install(downloadDir, tempPath, destDir *paths.Path) error {
// Create a temporary folder to extract package
// Create a temporary dir to extract package
if err := tempPath.MkdirAll(); err != nil {
return fmt.Errorf("creating temp dir for extraction: %s", err)
}
......
......@@ -54,7 +54,10 @@ const (
ErrNoConfigFile
ErrBadCall
ErrNetwork
ErrCoreConfig // Represents an error in the cli core config, for example some basic files shipped with the installation are missing, or cannot create or get basic folder vital for the CLI to work.
// ErrCoreConfig represents an error in the cli core config, for example some basic
// files shipped with the installation are missing, or cannot create or get basic
// directories vital for the CLI to work.
ErrCoreConfig
ErrBadArgument
Version = "0.1.0-alpha.preview"
......
......@@ -285,7 +285,7 @@ func TestCoreDownload(t *testing.T) {
defer makeTempDataDir(t)()
defer makeTempSketchbookDir(t)()
// Set staging folder to a temporary folder
// Set staging dir to a temporary dir
tmp, err := ioutil.TempDir(os.TempDir(), "test")
require.NoError(t, err, "making temporary staging dir")
defer os.RemoveAll(tmp)
......
......@@ -65,8 +65,8 @@ func InitCommand() *cobra.Command {
command.Flags().StringVarP(&flags.fqbn, "fqbn", "b", "", "Fully Qualified Board Name, e.g.: arduino:avr:uno")
command.Flags().BoolVar(&flags.showProperties, "show-properties", false, "Show all build properties used instead of compiling.")
command.Flags().BoolVar(&flags.preprocess, "preprocess", false, "Print preprocessed code to stdout instead of compiling.")
command.Flags().StringVar(&flags.buildCachePath, "build-cache-path", "", "Builds of 'core.a' are saved into this folder to be cached and reused.")
command.Flags().StringVar(&flags.buildPath, "build-path", "", "Folder where to save compiled files. If omitted, a folder will be created in the temporary folder specified by your OS.")
command.Flags().StringVar(&flags.buildCachePath, "build-cache-path", "", "Builds of 'core.a' are saved into this path to be cached and reused.")
command.Flags().StringVar(&flags.buildPath, "build-path", "", "Path where to save compiled files. If omitted, a directory will be created in the default temporary path of your OS.")
command.Flags().StringSliceVar(&flags.buildProperties, "build-properties", []string{}, "List of custom build properties separated by commas. Or can be used multiple times for multiple properties.")
command.Flags().StringVar(&flags.warnings, "warnings", "none", `Optional, can be "none", "default", "more" and "all". Defaults to "none". Used to tell gcc which warning level to use (-W flag).`)
command.Flags().BoolVarP(&flags.verbose, "verbose", "v", false, "Optional, turns on verbose mode.")
......@@ -79,8 +79,8 @@ var flags struct {
fqbn string // Fully Qualified Board Name, e.g.: arduino:avr:uno.
showProperties bool // Show all build preferences used instead of compiling.
preprocess bool // Print preprocessed code to stdout.
buildCachePath string // Builds of 'core.a' are saved into this folder to be cached and reused.
buildPath string // Folder where to save compiled files.
buildCachePath string // Builds of 'core.a' are saved into this path to be cached and reused.
buildPath string // Path where to save compiled files.
buildProperties []string // List of custom build properties separated by commas. Or can be used multiple times for multiple properties.
warnings string // Used to tell gcc which warning level to use.
verbose bool // Turns on verbose mode.
......@@ -171,28 +171,28 @@ func run(cmd *cobra.Command, args []string) {
ctx.SketchLocation = paths.New(sketch.FullPath)
// FIXME: This will be redundant when arduino-builder will be part of the cli
if packagesFolder, err := commands.Config.HardwareDirectories(); err == nil {
ctx.HardwareFolders = packagesFolder
if packagesDir, err := commands.Config.HardwareDirectories(); err == nil {
ctx.HardwareDirs = packagesDir
} else {
formatter.PrintError(err, "Cannot get hardware directories.")
os.Exit(commands.ErrCoreConfig)
}
if toolsFolder, err := configs.BundleToolsDirectories(); err == nil {
ctx.ToolsFolders = toolsFolder
if toolsDir, err := configs.BundleToolsDirectories(); err == nil {
ctx.ToolsDirs = toolsDir
} else {
formatter.PrintError(err, "Cannot get bundled tools directories.")
os.Exit(commands.ErrCoreConfig)
}
ctx.OtherLibrariesFolders = paths.NewPathList()
ctx.OtherLibrariesFolders.Add(commands.Config.LibrariesDir())
ctx.OtherLibrariesDirs = paths.NewPathList()
ctx.OtherLibrariesDirs.Add(commands.Config.LibrariesDir())
if flags.buildPath != "" {
ctx.BuildPath = paths.New(flags.buildPath)
err = ctx.BuildPath.MkdirAll()
if err != nil {
formatter.PrintError(err, "Cannot create the build folder.")
formatter.PrintError(err, "Cannot create the build directory.")
os.Exit(commands.ErrBadCall)
}
}
......@@ -216,7 +216,7 @@ func run(cmd *cobra.Command, args []string) {
ctx.BuildCachePath = paths.New(flags.buildCachePath)
err = ctx.BuildCachePath.MkdirAll()
if err != nil {
formatter.PrintError(err, "Cannot create the build cache folder.")
formatter.PrintError(err, "Cannot create the build cache directory.")
os.Exit(commands.ErrBadCall)
}
}
......@@ -239,7 +239,7 @@ func run(cmd *cobra.Command, args []string) {
sort.Strings(pathVariants)
ideHardwarePath := lastIdeSubProperties[pathVariants[len(pathVariants)-1]]
ideLibrariesPath := filepath.Join(filepath.Dir(ideHardwarePath), "libraries")
ctx.BuiltInLibrariesFolders = paths.NewPathList(ideLibrariesPath)
ctx.BuiltInLibrariesDirs = paths.NewPathList(ideLibrariesPath)
}
if flags.showProperties {
......@@ -261,7 +261,7 @@ func run(cmd *cobra.Command, args []string) {
// FIXME: Make a function to produce a better name...
fqbn = strings.Replace(fqbn, ":", ".", -1)
// Copy .hex file to sketch folder
// Copy .hex file to sketch directory
srcHex := paths.New(outputPath)
dstHex := paths.New(sketch.FullPath).Join(sketch.Name + "." + fqbn + ext)
logrus.WithField("from", srcHex).WithField("to", dstHex).Print("copying sketch build output")
......@@ -270,7 +270,7 @@ func run(cmd *cobra.Command, args []string) {
os.Exit(commands.ErrGeneric)
}
// Copy .elf file to sketch folder
// Copy .elf file to sketch directory
srcElf := paths.New(outputPath[:len(outputPath)-3] + "elf")
dstElf := paths.New(sketch.FullPath).Join(sketch.Name + "." + fqbn + ".elf")
logrus.WithField("from", srcElf).WithField("to", dstElf).Print("copying sketch build output")
......
......@@ -60,7 +60,7 @@ void loop() {
func runNewCommand(cmd *cobra.Command, args []string) {
sketchDir := commands.Config.SketchbookDir.Join(args[0])
if err := sketchDir.Mkdir(); err != nil {
formatter.PrintError(err, "Could not create sketch folder.")
formatter.PrintError(err, "Could not create sketch directory.")
os.Exit(commands.ErrGeneric)
}
......
......@@ -139,7 +139,7 @@ func runSyncCommand(cmd *cobra.Command, args []string) {
}
logrus.Info("Finding local sketches")
sketchMap := sketches.Find(sketchbook.String(), "libraries") // Exclude libraries folder.
sketchMap := sketches.Find(sketchbook.String(), "libraries") // Exclude libraries dirs.
logrus.Info("Finding online sketches")
client := createClient.New(nil)
......@@ -353,13 +353,13 @@ func pullSketch(sketch *createClient.ArduinoCreateSketch, sketchbook *paths.Path
return err
}
sketchFolder, err := sketchbook.MkTempDir(fmt.Sprintf("%s-temp", *sketch.Name))
sketchDir, err := sketchbook.MkTempDir(fmt.Sprintf("%s-temp", *sketch.Name))
if err != nil {
return err
}
defer sketchFolder.RemoveAll()
defer sketchDir.RemoveAll()
destFolder := sketchbook.Join(*sketch.Name)
destDir := sketchbook.Join(*sketch.Name)
for _, file := range append(r.Files, sketch.Ino) {
path := findPathOf(*sketch.Name, *file.Path)
......@@ -389,18 +389,18 @@ func pullSketch(sketch *createClient.ArduinoCreateSketch, sketchbook *paths.Path
return err
}
destFile := sketchFolder.Join(path)
destFile := sketchDir.Join(path)
err = destFile.WriteFile(decodedData)
if err != nil {
return errors.New("Copy of a file of the downloaded sketch failed, sync failed.")
}
}
if err := destFolder.RemoveAll(); err != nil {
if err := destDir.RemoveAll(); err != nil {
return err
}
err = sketchFolder.Rename(destFolder)
err = sketchDir.Rename(destDir)
if err != nil {
return err
}
......
......@@ -57,15 +57,15 @@ func InitCommand() *cobra.Command {
func run(cmd *cobra.Command, args []string) {
logrus.Info("Executing `arduino validate`")
packagesFolder := commands.Config.PackagesDir().String()
err := filepath.Walk(packagesFolder, func(path string, info os.FileInfo, err error) error {
packagesDir := commands.Config.PackagesDir().String()
err := filepath.Walk(packagesDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
return nil
}
relativePath, err := filepath.Rel(packagesFolder, path)
relativePath, err := filepath.Rel(packagesDir, path)
if err != nil {
return err
}
......
......@@ -45,7 +45,7 @@ type ProcessResult struct {
// String returns a string representation of the object.
// EXAMPLE:
// ToolName - ErrorText: Error explaining why failed
// ToolName - StatusText: PATH = /path/to/result/folder
// ToolName - StatusText: PATH = /path/to/result/dir
func (lr ProcessResult) String() string {
ret := lr.ItemName
if lr.Status != "" {
......
......@@ -55,23 +55,23 @@ func getDefaultArduinoDataDir() (*paths.Path, error) {
if err != nil {
return nil, fmt.Errorf("retrieving user home dir: %s", err)
}
arduinoDataFolder := paths.New(usr.HomeDir)
arduinoDataDir := paths.New(usr.HomeDir)
switch runtime.GOOS {
case "linux":
arduinoDataFolder = arduinoDataFolder.Join(".arduino15")
arduinoDataDir = arduinoDataDir.Join(".arduino15")
case "darwin":
arduinoDataFolder = arduinoDataFolder.Join("Library", "arduino15")
arduinoDataDir = arduinoDataDir.Join("Library", "arduino15")
case "windows":
localAppDataPath, err := win32.GetLocalAppDataFolder()
if err != nil {
return nil, fmt.Errorf("getting LocalAppData path: %s", err)
}
arduinoDataFolder = paths.New(localAppDataPath).Join("Arduino15")
arduinoDataDir = paths.New(localAppDataPath).Join("Arduino15")
default:
return nil, fmt.Errorf("unsupported OS: %s", runtime.GOOS)
}
return arduinoDataFolder, nil
return arduinoDataDir, nil
}
func getDefaultSketchbookDir() (*paths.Path, error) {
......
......@@ -41,9 +41,9 @@ func (config *Configuration) HardwareDirectories() (paths.PathList, error) {
res := paths.PathList{}
if IsBundledInDesktopIDE() {
bundledHardwareFolder := filepath.Join(*arduinoIDEDirectory, "hardware")
if info, err := os.Stat(bundledHardwareFolder); err == nil && info.IsDir() {
res.Add(paths.New(bundledHardwareFolder))
bundledHardwareDir := filepath.Join(*arduinoIDEDirectory, "hardware")
if info, err := os.Stat(bundledHardwareDir); err == nil && info.IsDir() {
res.Add(paths.New(bundledHardwareDir))
}
}
......@@ -65,9 +65,9 @@ func BundleToolsDirectories() (paths.PathList, error) {
res := paths.PathList{}
if IsBundledInDesktopIDE() {
bundledToolsFolder := filepath.Join(*arduinoIDEDirectory, "hardware", "tools")
if info, err := os.Stat(bundledToolsFolder); err == nil && info.IsDir() {
res = append(res, paths.New(bundledToolsFolder))
bundledToolsDir := filepath.Join(*arduinoIDEDirectory, "hardware", "tools")
if info, err := os.Stat(bundledToolsDir); err == nil && info.IsDir() {
res = append(res, paths.New(bundledToolsDir))
}
}
......
......@@ -43,7 +43,7 @@ type yamlConfig struct {
ProxyType string `yaml:"proxy_type"`
ProxyManualConfig *yamlProxyConfig `yaml:"manual_configs,omitempty"`
SketchbookPath string `yaml:"sketchbook_path,omitempty"`
ArduinoDataFolder string `yaml:"arduino_data,omitempty"`
ArduinoDataDir string `yaml:"arduino_data,omitempty"`
BoardsManager *yamlBoardsManagerConfig `yaml:"board_manager"`
}
......@@ -72,8 +72,8 @@ func (config *Configuration) LoadFromYAML(path *paths.Path) error {
return err
}
if ret.ArduinoDataFolder != "" {
config.DataDir = paths.New(ret.ArduinoDataFolder)
if ret.ArduinoDataDir != "" {
config.DataDir = paths.New(ret.ArduinoDataDir)
}
if ret.SketchbookPath != "" {
config.SketchbookDir = paths.New(ret.SketchbookPath)
......@@ -106,7 +106,7 @@ func (config *Configuration) SerializeToYAML() ([]byte, error) {
c.SketchbookPath = config.SketchbookDir.String()
}
if config.DataDir != nil {
c.ArduinoDataFolder = config.DataDir.String()
c.ArduinoDataDir = config.DataDir.String()
}
c.ProxyType = ProxyType
if ProxyType == "manual" {
......
......@@ -39,7 +39,7 @@ type HardwareLoader struct{}
func (s *HardwareLoader) Run(ctx *types.Context) error {
pm := packagemanager.NewPackageManager(nil, nil, nil, nil)
if err := pm.LoadHardwareFromDirectories(ctx.HardwareFolders); err != nil {
if err := pm.LoadHardwareFromDirectories(ctx.HardwareDirs); err != nil {
return i18n.WrapError(err)
}
ctx.PackageManager = pm
......
......@@ -46,7 +46,7 @@ func (s *LibrariesLoader) Run(ctx *types.Context) error {
lm := librariesmanager.NewLibraryManager(nil, nil)
ctx.LibrariesManager = lm
builtInLibrariesFolders := ctx.BuiltInLibrariesFolders
builtInLibrariesFolders := ctx.BuiltInLibrariesDirs
if err := builtInLibrariesFolders.ToAbs(); err != nil {
return i18n.WrapError(err)
}
......@@ -64,7 +64,7 @@ func (s *LibrariesLoader) Run(ctx *types.Context) error {
}
lm.AddPlatformReleaseLibrariesDir(platform, libraries.PlatformBuiltIn)
librariesFolders := ctx.OtherLibrariesFolders
librariesFolders := ctx.OtherLibrariesDirs
if err := librariesFolders.ToAbs(); err != nil {
return i18n.WrapError(err)
}
......
......@@ -45,7 +45,7 @@ import (
type PlatformKeysRewriteLoader struct{}
func (s *PlatformKeysRewriteLoader) Run(ctx *types.Context) error {
folders := ctx.HardwareFolders
folders := ctx.HardwareDirs
platformKeysRewriteTxtPath, err := findPlatformKeysRewriteTxt(folders)
if err != nil {
......
......@@ -48,19 +48,19 @@ func (s *ToolsLoader) Run(ctx *types.Context) error {
folders := paths.NewPathList()
builtinFolders := paths.NewPathList()
if ctx.BuiltInToolsFolders != nil || len(ctx.BuiltInLibrariesFolders) == 0 {
folders = ctx.ToolsFolders
builtinFolders = ctx.BuiltInToolsFolders
if ctx.BuiltInToolsDirs != nil || len(ctx.BuiltInLibrariesDirs) == 0 {
folders = ctx.ToolsDirs
builtinFolders = ctx.BuiltInToolsDirs
} else {
// Auto-detect built-in tools folders (for arduino-builder backward compatibility)
// this is a deprecated feature and will be removed in the future
builtinHardwareFolder, err := ctx.BuiltInLibrariesFolders[0].Join("..").Abs()
builtinHardwareFolder, err := ctx.BuiltInLibrariesDirs[0].Join("..").Abs()
if err != nil {
fmt.Println("Error detecting ")
}
for _, folder := range ctx.ToolsFolders {
for _, folder := range ctx.ToolsDirs {
if !strings.Contains(folder.String(), builtinHardwareFolder.String()) { // TODO: make a function to check for subfolders
folders = append(folders, folder)
} else {
......
......@@ -23,16 +23,16 @@ type ProgressStruct struct {
// Context structure
type Context struct {
// Build options
HardwareFolders paths.PathList
ToolsFolders paths.PathList
BuiltInToolsFolders paths.PathList
BuiltInLibrariesFolders paths.PathList
OtherLibrariesFolders paths.PathList
SketchLocation *paths.Path
WatchedLocations paths.PathList
ArduinoAPIVersion string
FQBN *cores.FQBN
CodeCompleteAt string
HardwareDirs paths.PathList
ToolsDirs paths.PathList
BuiltInToolsDirs paths.PathList
BuiltInLibrariesDirs paths.PathList
OtherLibrariesDirs paths.PathList
SketchLocation *paths.Path
WatchedLocations paths.PathList
ArduinoAPIVersion string
FQBN *cores.FQBN
CodeCompleteAt string
// Build options are serialized here
BuildOptionsJson string
......@@ -115,10 +115,10 @@ type Context struct {
func (ctx *Context) ExtractBuildOptions() properties.Map {
opts := make(properties.Map)
opts["hardwareFolders"] = strings.Join(ctx.HardwareFolders.AsStrings(), ",")
opts["toolsFolders"] = strings.Join(ctx.ToolsFolders.AsStrings(), ",")
opts["builtInLibrariesFolders"] = strings.Join(ctx.BuiltInLibrariesFolders.AsStrings(), ",")
opts["otherLibrariesFolders"] = strings.Join(ctx.OtherLibrariesFolders.AsStrings(), ",")
opts["hardwareFolders"] = strings.Join(ctx.HardwareDirs.AsStrings(), ",")
opts["toolsFolders"] = strings.Join(ctx.ToolsDirs.AsStrings(), ",")
opts["builtInLibrariesFolders"] = strings.Join(ctx.BuiltInLibrariesDirs.AsStrings(), ",")
opts["otherLibrariesFolders"] = strings.Join(ctx.OtherLibrariesDirs.AsStrings(), ",")
opts["sketchLocation"] = ctx.SketchLocation.String()
var additionalFilesRelative []string
if ctx.Sketch != nil {
......@@ -139,10 +139,10 @@ func (ctx *Context) ExtractBuildOptions() properties.Map {
}
func (ctx *Context) InjectBuildOptions(opts properties.Map) {
ctx.HardwareFolders = paths.NewPathList(strings.Split(opts["hardwareFolders"], ",")...)
ctx.ToolsFolders = paths.NewPathList(strings.Split(opts["toolsFolders"], ",")...)
ctx.BuiltInLibrariesFolders = paths.NewPathList(strings.Split(opts["builtInLibrariesFolders"], ",")...)
ctx.OtherLibrariesFolders = paths.NewPathList(strings.Split(opts["otherLibrariesFolders"], ",")...)
ctx.HardwareDirs = paths.NewPathList(strings.Split(opts["hardwareFolders"], ",")...)
ctx.ToolsDirs = paths.NewPathList(strings.Split(opts["toolsFolders"], ",")...)
ctx.BuiltInLibrariesDirs = paths.NewPathList(strings.Split(opts["builtInLibrariesFolders"], ",")...)
ctx.OtherLibrariesDirs = paths.NewPathList(strings.Split(opts["otherLibrariesFolders"], ",")...)
ctx.SketchLocation = paths.New(opts["sketchLocation"])
fqbn, err := cores.ParseFQBN(opts["fqbn"])
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment