Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
4f935b80
Commit
4f935b80
authored
Sep 12, 2018
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rationalized configurations about IDE and bundled cores
parent
4833cf51
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
39 deletions
+43
-39
arduino/cores/packagemanager/loader.go
arduino/cores/packagemanager/loader.go
+1
-1
commands/commands.go
commands/commands.go
+1
-1
commands/compile/compile.go
commands/compile/compile.go
+1
-2
commands/root/root.go
commands/root/root.go
+1
-1
configs/configuration.go
configs/configuration.go
+8
-0
configs/hardware_directories.go
configs/hardware_directories.go
+9
-12
configs/preferences_txt_serializer.go
configs/preferences_txt_serializer.go
+22
-22
No files found.
arduino/cores/packagemanager/loader.go
View file @
4f935b80
...
@@ -39,7 +39,7 @@ func (pm *PackageManager) LoadHardware(config *configs.Configuration) error {
...
@@ -39,7 +39,7 @@ func (pm *PackageManager) LoadHardware(config *configs.Configuration) error {
if
err
:=
pm
.
LoadHardwareFromDirectories
(
dirs
);
err
!=
nil
{
if
err
:=
pm
.
LoadHardwareFromDirectories
(
dirs
);
err
!=
nil
{
return
err
return
err
}
}
dirs
,
err
=
config
s
.
BundleToolsDirectories
()
dirs
,
err
=
config
.
BundleToolsDirectories
()
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"getting hardware directory: %s"
,
err
)
return
fmt
.
Errorf
(
"getting hardware directory: %s"
,
err
)
}
}
...
...
commands/commands.go
View file @
4f935b80
...
@@ -102,7 +102,7 @@ func InitLibraryManager(pm *packagemanager.PackageManager) *librariesmanager.Lib
...
@@ -102,7 +102,7 @@ func InitLibraryManager(pm *packagemanager.PackageManager) *librariesmanager.Lib
Config
.
DownloadsDir
())
Config
.
DownloadsDir
())
// Add IDE builtin libraries dir
// Add IDE builtin libraries dir
if
bundledLibsDir
:=
configs
.
IDEBundledLibrariesDir
();
bundledLibsDir
!=
nil
{
if
bundledLibsDir
:=
Config
.
IDEBundledLibrariesDir
();
bundledLibsDir
!=
nil
{
lm
.
AddLibrariesDir
(
bundledLibsDir
,
libraries
.
IDEBuiltIn
)
lm
.
AddLibrariesDir
(
bundledLibsDir
,
libraries
.
IDEBuiltIn
)
}
}
...
...
commands/compile/compile.go
View file @
4f935b80
...
@@ -31,7 +31,6 @@ import (
...
@@ -31,7 +31,6 @@ import (
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/core"
"github.com/arduino/arduino-cli/commands/core"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/configs"
"github.com/arduino/go-paths-helper"
"github.com/arduino/go-paths-helper"
properties
"github.com/arduino/go-properties-map"
properties
"github.com/arduino/go-properties-map"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
...
@@ -163,7 +162,7 @@ func run(cmd *cobra.Command, args []string) {
...
@@ -163,7 +162,7 @@ func run(cmd *cobra.Command, args []string) {
os
.
Exit
(
commands
.
ErrCoreConfig
)
os
.
Exit
(
commands
.
ErrCoreConfig
)
}
}
if
toolsDir
,
err
:=
co
nfigs
.
BundleToolsDirectories
();
err
==
nil
{
if
toolsDir
,
err
:=
co
mmands
.
Config
.
BundleToolsDirectories
();
err
==
nil
{
ctx
.
ToolsDirs
=
toolsDir
ctx
.
ToolsDirs
=
toolsDir
}
else
{
}
else
{
formatter
.
PrintError
(
err
,
"Cannot get bundled tools directories."
)
formatter
.
PrintError
(
err
,
"Cannot get bundled tools directories."
)
...
...
commands/root/root.go
View file @
4f935b80
...
@@ -114,7 +114,7 @@ func initConfigs() {
...
@@ -114,7 +114,7 @@ func initConfigs() {
if
err
:=
commands
.
Config
.
LoadFromYAML
(
commands
.
Config
.
ConfigFile
);
err
!=
nil
{
if
err
:=
commands
.
Config
.
LoadFromYAML
(
commands
.
Config
.
ConfigFile
);
err
!=
nil
{
logrus
.
WithError
(
err
)
.
Warn
(
"Did not manage to get config file, using default configuration"
)
logrus
.
WithError
(
err
)
.
Warn
(
"Did not manage to get config file, using default configuration"
)
}
}
if
co
nfigs
.
IsBundledInDesktopIDE
()
{
if
co
mmands
.
Config
.
IsBundledInDesktopIDE
()
{
logrus
.
Info
(
"CLI is bundled into the IDE"
)
logrus
.
Info
(
"CLI is bundled into the IDE"
)
err
:=
commands
.
Config
.
LoadFromDesktopIDEPreferences
()
err
:=
commands
.
Config
.
LoadFromDesktopIDEPreferences
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
configs/configuration.go
View file @
4f935b80
...
@@ -34,6 +34,14 @@ type Configuration struct {
...
@@ -34,6 +34,14 @@ type Configuration struct {
// SketchbookDir represents the current root of the sketchbooks tree (defaulted to `$HOME/Arduino`).
// SketchbookDir represents the current root of the sketchbooks tree (defaulted to `$HOME/Arduino`).
SketchbookDir
*
paths
.
Path
SketchbookDir
*
paths
.
Path
// ArduinoIDEDirectory is the directory of the Arduino IDE if the CLI runs togheter with it.
ArduinoIDEDirectory
*
paths
.
Path
// IDEBundledCheckResult contains the result of the check to see if the CLI is bundled with the IDE:
// the field is true if the CLI is bundled with the Arduino IDE, false if the CLI is running
// standalone or nil if the detection has not been performed.
IDEBundledCheckResult
*
bool
}
}
// NewConfiguration returns a new Configuration with the default values
// NewConfiguration returns a new Configuration with the default values
...
...
configs/hardware_directories.go
View file @
4f935b80
...
@@ -18,9 +18,6 @@
...
@@ -18,9 +18,6 @@
package
configs
package
configs
import
(
import
(
"os"
"path/filepath"
"github.com/arduino/go-paths-helper"
"github.com/arduino/go-paths-helper"
)
)
...
@@ -28,10 +25,10 @@ import (
...
@@ -28,10 +25,10 @@ import (
func
(
config
*
Configuration
)
HardwareDirectories
()
(
paths
.
PathList
,
error
)
{
func
(
config
*
Configuration
)
HardwareDirectories
()
(
paths
.
PathList
,
error
)
{
res
:=
paths
.
PathList
{}
res
:=
paths
.
PathList
{}
if
IsBundledInDesktopIDE
()
{
if
config
.
IsBundledInDesktopIDE
()
{
bundledHardwareDir
:=
filepath
.
Join
(
*
arduinoIDEDirectory
,
"hardware"
)
bundledHardwareDir
:=
config
.
ArduinoIDEDirectory
.
Join
(
"hardware"
)
if
info
,
err
:=
os
.
Stat
(
bundledHardwareDir
);
err
==
nil
&&
info
.
IsDir
()
{
if
bundledHardwareDir
.
IsDir
()
{
res
.
Add
(
paths
.
New
(
bundledHardwareDir
)
)
res
.
Add
(
bundledHardwareDir
)
}
}
}
}
...
@@ -47,13 +44,13 @@ func (config *Configuration) HardwareDirectories() (paths.PathList, error) {
...
@@ -47,13 +44,13 @@ func (config *Configuration) HardwareDirectories() (paths.PathList, error) {
}
}
// BundleToolsDirectories returns all paths that may contains bundled-tools.
// BundleToolsDirectories returns all paths that may contains bundled-tools.
func
BundleToolsDirectories
()
(
paths
.
PathList
,
error
)
{
func
(
config
*
Configuration
)
BundleToolsDirectories
()
(
paths
.
PathList
,
error
)
{
res
:=
paths
.
PathList
{}
res
:=
paths
.
PathList
{}
if
IsBundledInDesktopIDE
()
{
if
config
.
IsBundledInDesktopIDE
()
{
bundledToolsDir
:=
filepath
.
Join
(
*
arduinoIDEDirectory
,
"hardware"
,
"tools"
)
bundledToolsDir
:=
config
.
ArduinoIDEDirectory
.
Join
(
"hardware"
,
"tools"
)
if
info
,
err
:=
os
.
Stat
(
bundledToolsDir
);
err
==
nil
&&
info
.
IsDir
()
{
if
bundledToolsDir
.
IsDir
()
{
res
=
append
(
res
,
paths
.
New
(
bundledToolsDir
)
)
res
=
append
(
res
,
bundledToolsDir
)
}
}
}
}
...
...
configs/preferences_txt_serializer.go
View file @
4f935b80
...
@@ -21,7 +21,6 @@ import (
...
@@ -21,7 +21,6 @@ import (
"errors"
"errors"
"net/url"
"net/url"
"os"
"os"
"path/filepath"
"strings"
"strings"
"github.com/arduino/go-paths-helper"
"github.com/arduino/go-paths-helper"
...
@@ -30,15 +29,14 @@ import (
...
@@ -30,15 +29,14 @@ import (
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
)
)
var
arduinoIDEDirectory
*
string
// IsBundledInDesktopIDE returns true if the CLI is bundled with the Arduino IDE.
// IsBundledInDesktopIDE returns true if the CLI is bundled with the Arduino IDE.
func
IsBundledInDesktopIDE
()
bool
{
func
(
config
*
Configuration
)
IsBundledInDesktopIDE
()
bool
{
if
arduinoIDEDirectory
!=
nil
{
if
config
.
IDEBundledCheckResult
!=
nil
{
return
*
arduinoIDEDirectory
!=
""
return
*
config
.
IDEBundledCheckResult
}
}
empty
:=
""
arduinoIDEDirectory
=
&
empty
res
:=
false
config
.
IDEBundledCheckResult
=
&
res
logrus
.
Info
(
"Checking if CLI is Bundled into the IDE"
)
logrus
.
Info
(
"Checking if CLI is Bundled into the IDE"
)
executable
,
err
:=
os
.
Executable
()
executable
,
err
:=
os
.
Executable
()
...
@@ -46,25 +44,27 @@ func IsBundledInDesktopIDE() bool {
...
@@ -46,25 +44,27 @@ func IsBundledInDesktopIDE() bool {
logrus
.
WithError
(
err
)
.
Warn
(
"Cannot get executable path"
)
logrus
.
WithError
(
err
)
.
Warn
(
"Cannot get executable path"
)
return
false
return
false
}
}
executable
,
err
=
filepath
.
EvalSymlinks
(
executable
)
executable
Path
:=
paths
.
New
(
executable
)
if
err
!=
nil
{
if
err
:=
executablePath
.
FollowSymLink
();
err
!=
nil
{
logrus
.
WithError
(
err
)
.
Warn
(
"Cannot get executable path
(symlinks error)
"
)
logrus
.
WithError
(
err
)
.
Warn
(
"Cannot get executable path"
)
return
false
return
false
}
}
ideDir
:=
filepath
.
Dir
(
executable
)
ideDir
:=
executablePath
.
Parent
(
)
logrus
.
Info
(
"Candidate IDE Directory: "
,
ideDir
)
logrus
.
Info
(
"Candidate IDE Directory: "
,
ideDir
)
tests
:=
[]
string
{
"tools-builder"
,
"Examples/01.Basics/Blink"
}
tests
:=
[]
string
{
"tools-builder"
,
"examples/01.Basics/Blink"
,
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
filePath
:=
filepath
.
Join
(
ideDir
,
test
)
if
!
ideDir
.
Join
(
test
)
.
Exist
()
{
_
,
err
:=
os
.
Stat
(
filePath
)
return
false
if
!
os
.
IsNotExist
(
err
)
{
arduinoIDEDirectory
=
&
ideDir
break
}
}
}
}
return
*
arduinoIDEDirectory
!=
""
config
.
ArduinoIDEDirectory
=
ideDir
res
=
true
return
true
}
}
// LoadFromDesktopIDEPreferences loads the config from the Desktop IDE preferences.txt file
// LoadFromDesktopIDEPreferences loads the config from the Desktop IDE preferences.txt file
...
@@ -127,9 +127,9 @@ func proxyConfigsFromIDEPrefs(props properties.Map) error {
...
@@ -127,9 +127,9 @@ func proxyConfigsFromIDEPrefs(props properties.Map) error {
// IDEBundledLibrariesDir returns the libraries directory bundled in
// IDEBundledLibrariesDir returns the libraries directory bundled in
// the Arduino IDE. If there is no Arduino IDE or the directory doesn't
// the Arduino IDE. If there is no Arduino IDE or the directory doesn't
// exists then nil is returned
// exists then nil is returned
func
IDEBundledLibrariesDir
()
*
paths
.
Path
{
func
(
config
*
Configuration
)
IDEBundledLibrariesDir
()
*
paths
.
Path
{
if
IsBundledInDesktopIDE
()
{
if
config
.
IsBundledInDesktopIDE
()
{
libDir
:=
paths
.
New
(
*
arduinoIDEDirectory
,
"libraries"
)
libDir
:=
config
.
ArduinoIDEDirectory
.
Join
(
"libraries"
)
if
libDir
.
IsDir
()
{
if
libDir
.
IsDir
()
{
return
libDir
return
libDir
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment