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 {
if
err
:=
pm
.
LoadHardwareFromDirectories
(
dirs
);
err
!=
nil
{
return
err
}
dirs
,
err
=
config
s
.
BundleToolsDirectories
()
dirs
,
err
=
config
.
BundleToolsDirectories
()
if
err
!=
nil
{
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
Config
.
DownloadsDir
())
// Add IDE builtin libraries dir
if
bundledLibsDir
:=
configs
.
IDEBundledLibrariesDir
();
bundledLibsDir
!=
nil
{
if
bundledLibsDir
:=
Config
.
IDEBundledLibrariesDir
();
bundledLibsDir
!=
nil
{
lm
.
AddLibrariesDir
(
bundledLibsDir
,
libraries
.
IDEBuiltIn
)
}
...
...
commands/compile/compile.go
View file @
4f935b80
...
...
@@ -31,7 +31,6 @@ import (
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/core"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/configs"
"github.com/arduino/go-paths-helper"
properties
"github.com/arduino/go-properties-map"
"github.com/sirupsen/logrus"
...
...
@@ -163,7 +162,7 @@ func run(cmd *cobra.Command, args []string) {
os
.
Exit
(
commands
.
ErrCoreConfig
)
}
if
toolsDir
,
err
:=
co
nfigs
.
BundleToolsDirectories
();
err
==
nil
{
if
toolsDir
,
err
:=
co
mmands
.
Config
.
BundleToolsDirectories
();
err
==
nil
{
ctx
.
ToolsDirs
=
toolsDir
}
else
{
formatter
.
PrintError
(
err
,
"Cannot get bundled tools directories."
)
...
...
commands/root/root.go
View file @
4f935b80
...
...
@@ -114,7 +114,7 @@ func initConfigs() {
if
err
:=
commands
.
Config
.
LoadFromYAML
(
commands
.
Config
.
ConfigFile
);
err
!=
nil
{
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"
)
err
:=
commands
.
Config
.
LoadFromDesktopIDEPreferences
()
if
err
!=
nil
{
...
...
configs/configuration.go
View file @
4f935b80
...
...
@@ -34,6 +34,14 @@ type Configuration struct {
// SketchbookDir represents the current root of the sketchbooks tree (defaulted to `$HOME/Arduino`).
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
...
...
configs/hardware_directories.go
View file @
4f935b80
...
...
@@ -18,9 +18,6 @@
package
configs
import
(
"os"
"path/filepath"
"github.com/arduino/go-paths-helper"
)
...
...
@@ -28,10 +25,10 @@ import (
func
(
config
*
Configuration
)
HardwareDirectories
()
(
paths
.
PathList
,
error
)
{
res
:=
paths
.
PathList
{}
if
IsBundledInDesktopIDE
()
{
bundledHardwareDir
:=
filepath
.
Join
(
*
arduinoIDEDirectory
,
"hardware"
)
if
info
,
err
:=
os
.
Stat
(
bundledHardwareDir
);
err
==
nil
&&
info
.
IsDir
()
{
res
.
Add
(
paths
.
New
(
bundledHardwareDir
)
)
if
config
.
IsBundledInDesktopIDE
()
{
bundledHardwareDir
:=
config
.
ArduinoIDEDirectory
.
Join
(
"hardware"
)
if
bundledHardwareDir
.
IsDir
()
{
res
.
Add
(
bundledHardwareDir
)
}
}
...
...
@@ -47,13 +44,13 @@ func (config *Configuration) HardwareDirectories() (paths.PathList, error) {
}
// BundleToolsDirectories returns all paths that may contains bundled-tools.
func
BundleToolsDirectories
()
(
paths
.
PathList
,
error
)
{
func
(
config
*
Configuration
)
BundleToolsDirectories
()
(
paths
.
PathList
,
error
)
{
res
:=
paths
.
PathList
{}
if
IsBundledInDesktopIDE
()
{
bundledToolsDir
:=
filepath
.
Join
(
*
arduinoIDEDirectory
,
"hardware"
,
"tools"
)
if
info
,
err
:=
os
.
Stat
(
bundledToolsDir
);
err
==
nil
&&
info
.
IsDir
()
{
res
=
append
(
res
,
paths
.
New
(
bundledToolsDir
)
)
if
config
.
IsBundledInDesktopIDE
()
{
bundledToolsDir
:=
config
.
ArduinoIDEDirectory
.
Join
(
"hardware"
,
"tools"
)
if
bundledToolsDir
.
IsDir
()
{
res
=
append
(
res
,
bundledToolsDir
)
}
}
...
...
configs/preferences_txt_serializer.go
View file @
4f935b80
...
...
@@ -21,7 +21,6 @@ import (
"errors"
"net/url"
"os"
"path/filepath"
"strings"
"github.com/arduino/go-paths-helper"
...
...
@@ -30,15 +29,14 @@ import (
"github.com/sirupsen/logrus"
)
var
arduinoIDEDirectory
*
string
// IsBundledInDesktopIDE returns true if the CLI is bundled with the Arduino IDE.
func
IsBundledInDesktopIDE
()
bool
{
if
arduinoIDEDirectory
!=
nil
{
return
*
arduinoIDEDirectory
!=
""
func
(
config
*
Configuration
)
IsBundledInDesktopIDE
()
bool
{
if
config
.
IDEBundledCheckResult
!=
nil
{
return
*
config
.
IDEBundledCheckResult
}
empty
:=
""
arduinoIDEDirectory
=
&
empty
res
:=
false
config
.
IDEBundledCheckResult
=
&
res
logrus
.
Info
(
"Checking if CLI is Bundled into the IDE"
)
executable
,
err
:=
os
.
Executable
()
...
...
@@ -46,25 +44,27 @@ func IsBundledInDesktopIDE() bool {
logrus
.
WithError
(
err
)
.
Warn
(
"Cannot get executable path"
)
return
false
}
executable
,
err
=
filepath
.
EvalSymlinks
(
executable
)
if
err
!=
nil
{
logrus
.
WithError
(
err
)
.
Warn
(
"Cannot get executable path
(symlinks error)
"
)
executable
Path
:=
paths
.
New
(
executable
)
if
err
:=
executablePath
.
FollowSymLink
();
err
!=
nil
{
logrus
.
WithError
(
err
)
.
Warn
(
"Cannot get executable path"
)
return
false
}
ideDir
:=
filepath
.
Dir
(
executable
)
ideDir
:=
executablePath
.
Parent
(
)
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
{
filePath
:=
filepath
.
Join
(
ideDir
,
test
)
_
,
err
:=
os
.
Stat
(
filePath
)
if
!
os
.
IsNotExist
(
err
)
{
arduinoIDEDirectory
=
&
ideDir
break
if
!
ideDir
.
Join
(
test
)
.
Exist
()
{
return
false
}
}
return
*
arduinoIDEDirectory
!=
""
config
.
ArduinoIDEDirectory
=
ideDir
res
=
true
return
true
}
// LoadFromDesktopIDEPreferences loads the config from the Desktop IDE preferences.txt file
...
...
@@ -127,9 +127,9 @@ func proxyConfigsFromIDEPrefs(props properties.Map) error {
// IDEBundledLibrariesDir returns the libraries directory bundled in
// the Arduino IDE. If there is no Arduino IDE or the directory doesn't
// exists then nil is returned
func
IDEBundledLibrariesDir
()
*
paths
.
Path
{
if
IsBundledInDesktopIDE
()
{
libDir
:=
paths
.
New
(
*
arduinoIDEDirectory
,
"libraries"
)
func
(
config
*
Configuration
)
IDEBundledLibrariesDir
()
*
paths
.
Path
{
if
config
.
IsBundledInDesktopIDE
()
{
libDir
:=
config
.
ArduinoIDEDirectory
.
Join
(
"libraries"
)
if
libDir
.
IsDir
()
{
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