8000 Use default FQBN options when missing by cmaglie · Pull Request #53 · arduino/arduino-cli · GitHub
[go: up one dir, main page]

Skip to content

Use default FQBN options when missing #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use default FQBN options when missing
Fix #23
  • Loading branch information
cmaglie committed Oct 3, 2018
commit b7307b872f9fd533f12e1f0cd1afef1b9ba7f259
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 24 additions & 14 deletions arduino/cores/board.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(optionValue)
optionsConf := optionMenu.SubTree(userValue)
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
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions vendor/github.com/arduino/go-properties-orderedmap/properties.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0