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
4379a60f
Commit
4379a60f
authored
Oct 03, 2018
by
Cristian Maglie
Committed by
Cristian Maglie
Oct 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use default FQBN options when missing
Fix #23
parent
fd1ed1ac
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
17 deletions
+66
-17
Gopkg.lock
Gopkg.lock
+2
-2
arduino/cores/board.go
arduino/cores/board.go
+24
-14
vendor/github.com/arduino/go-properties-orderedmap/objects.go
...or/github.com/arduino/go-properties-orderedmap/objects.go
+3
-1
vendor/github.com/arduino/go-properties-orderedmap/properties.go
...github.com/arduino/go-properties-orderedmap/properties.go
+37
-0
No files found.
Gopkg.lock
View file @
4379a60f
...
...
@@ -38,11 +38,11 @@
[[projects]]
branch = "master"
digest = "1:
4abd23fb5076a0d6b83363a5f317714e30a2971c11184bbd8a546b71f89a9cc3
"
digest = "1:
0ee4da82ad4588eec5fff9a3d2b954cfa37ee46fe6c2e6c7ee6da12111583211
"
name = "github.com/arduino/go-properties-orderedmap"
packages = ["."]
pruneopts = "UT"
revision = "
10dff422b3669aaa85870522fd0138a89fb244ca
"
revision = "
89278049acd3b807d566b8290a71e73b7c12ce3d
"
[[projects]]
branch = "master"
...
...
arduino/cores/board.go
View file @
4379a60f
...
...
@@ -62,30 +62,40 @@ func (b *Board) String() string {
// GetBuildProperties returns the build properties and the build
// platform for the Board with the configuration passed as parameter.
func
(
b
*
Board
)
GetBuildProperties
(
configs
*
properties
.
Map
)
(
*
properties
.
Map
,
error
)
{
func
(
b
*
Board
)
GetBuildProperties
(
userConfigs
*
properties
.
Map
)
(
*
properties
.
Map
,
error
)
{
// Clone user configs because they are destroyed during iteration
userConfigs
=
userConfigs
.
Clone
()
// Start with board's base properties
buildProperties
:=
b
.
Properties
.
Clone
()
// Add all sub-configurations one by one
// Add all sub-configurations one by one
(a config is: option=value)
menu
:=
b
.
Properties
.
SubTree
(
"menu"
)
for
_
,
option
:=
range
configs
.
Keys
()
{
if
option
==
""
{
return
nil
,
fmt
.
Errorf
(
"invalid empty option found"
)
}
for
_
,
option
:=
range
menu
.
FirstLevelKeys
()
{
optionMenu
:=
menu
.
SubTree
(
option
)
if
optionMenu
.
Size
()
==
0
{
return
nil
,
fmt
.
Errorf
(
"invalid option '%s'"
,
option
)
}
optionValue
:=
configs
.
Get
(
option
)
if
!
optionMenu
.
ContainsKey
(
optionValue
)
{
return
nil
,
fmt
.
Errorf
(
"invalid value '%s' for option '%s'"
,
optionValue
,
option
)
userValue
,
haveUserValue
:=
userConfigs
.
GetOk
(
option
)
if
haveUserValue
{
userConfigs
.
Remove
(
option
)
if
!
optionMenu
.
ContainsKey
(
userValue
)
{
return
nil
,
fmt
.
Errorf
(
"invalid value '%s' for option '%s'"
,
userValue
,
option
)
}
}
else
{
// apply default
userValue
=
optionMenu
.
FirstLevelKeys
()[
0
]
}
optionsConf
:=
optionMenu
.
SubTree
(
option
Value
)
optionsConf
:=
optionMenu
.
SubTree
(
user
Value
)
buildProperties
.
Merge
(
optionsConf
)
}
// Check for residual invalid options...
for
_
,
invalidOption
:=
range
userConfigs
.
Keys
()
{
if
invalidOption
==
""
{
return
nil
,
fmt
.
Errorf
(
"invalid empty option found"
)
}
return
nil
,
fmt
.
Errorf
(
"invalid option '%s'"
,
invalidOption
)
}
return
buildProperties
,
nil
}
...
...
vendor/github.com/arduino/go-properties-orderedmap/objects.go
View file @
4379a60f
...
...
@@ -30,6 +30,8 @@
package
properties
import
(
"strings"
"github.com/arduino/go-paths-helper"
)
...
...
@@ -37,7 +39,7 @@ import (
// equals to the string "true", in any other case returns false.
func
(
m
*
Map
)
GetBoolean
(
key
string
)
bool
{
value
,
ok
:=
m
.
GetOk
(
key
)
return
ok
&&
value
==
"true"
return
ok
&&
strings
.
TrimSpace
(
value
)
==
"true"
}
// SetBoolean sets the specified key to the string "true" or "false" if the value
...
...
vendor/github.com/arduino/go-properties-orderedmap/properties.go
View file @
4379a60f
...
...
@@ -291,6 +291,43 @@ func (m *Map) FirstLevelOf() map[string]*Map {
return
newMap
}
// FirstLevelKeys returns the keys in the first level of the hierarchy
// of the current Map. For example the following Map:
//
// properties.Map{
// "uno.name": "Arduino/Genuino Uno",
// "uno.upload.tool": "avrdude",
// "uno.upload.protocol": "arduino",
// "uno.upload.maximum_size": "32256",
// "diecimila.name": "Arduino Duemilanove or Diecimila",
// "diecimila.upload.tool": "avrdude",
// "diecimila.upload.protocol": "arduino",
// "diecimila.bootloader.tool": "avrdude",
// "diecimila.bootloader.low_fuses": "0xFF",
// }
//
// will produce the following result:
//
// []string{
// "uno",
// "diecimila",
// }
//
// the order of the original map is preserved
func
(
m
*
Map
)
FirstLevelKeys
()
[]
string
{
res
:=
[]
string
{}
taken
:=
map
[
string
]
bool
{}
for
_
,
k
:=
range
m
.
o
{
first
:=
strings
.
SplitN
(
k
,
"."
,
2
)[
0
]
if
taken
[
first
]
{
continue
}
taken
[
first
]
=
true
res
=
append
(
res
,
first
)
}
return
res
}
// SubTree extracts a sub Map from an existing map using the first level
// of the keys hierarchy as selector.
// For example the following Map:
...
...
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