Unverified Commit 7eae0bd2 authored by Cristian Maglie's avatar Cristian Maglie Committed by GitHub

Print `FQBN` in verbose compile output (#2134)

* Added `FQBN.Clone()` method

* Slightly increased unti-test isolation

* Added `PackageManager.NormalizeFQBN()` method.

* Print FQBN in verbose compile output
parent 5a1c2fe8
......@@ -76,6 +76,16 @@ func (fqbn *FQBN) String() string {
return res
}
// Clone returns a copy of this FQBN.
func (fqbn *FQBN) Clone() *FQBN {
return &FQBN{
Package: fqbn.Package,
PlatformArch: fqbn.PlatformArch,
BoardID: fqbn.BoardID,
Configs: fqbn.Configs.Clone(),
}
}
// Match check if the target FQBN corresponds to the receiver one.
// The core parts are checked for exact equality while board options are loosely
// matched: the set of boards options of the target must be fully contained within
......
......@@ -827,3 +827,26 @@ func (pme *Explorer) FindMonitorDependency(discovery *cores.MonitorDependency) *
return toolRelease.GetLatestInstalled()
}
}
// NormalizeFQBN return a normalized copy of the given FQBN, that is the same
// FQBN but with the unneeded or invalid options removed.
func (pme *Explorer) NormalizeFQBN(fqbn *cores.FQBN) (*cores.FQBN, error) {
_, _, board, _, _, err := pme.ResolveFQBN(fqbn)
if err != nil {
return nil, err
}
normalizedFqbn := fqbn.Clone()
for _, option := range fqbn.Configs.Keys() {
values := board.GetConfigOptionValues(option)
if values == nil || values.Size() == 0 {
normalizedFqbn.Configs.Remove(option)
continue
}
defaultValue := values.Keys()[0]
if fqbn.Configs.Get(option) == defaultValue {
normalizedFqbn.Configs.Remove(option)
}
}
return normalizedFqbn, nil
}
......@@ -36,9 +36,18 @@ func (s *TargetBoardResolver) Run(ctx *types.Context) error {
core = "arduino"
}
// select the core name in case of "package:core" format
normalizedFQBN, err := ctx.PackageManager.NormalizeFQBN(ctx.FQBN)
if err != nil {
ctx.Warn(fmt.Sprintf("Could not normalize FQBN: %s", err))
normalizedFQBN = ctx.FQBN
}
ctx.Info(fmt.Sprintf("FQBN: %s", normalizedFQBN))
core = core[strings.Index(core, ":")+1:]
ctx.Info(tr("Using board '%[1]s' from platform in folder: %[2]s", targetBoard.BoardID, targetPlatform.InstallDir))
ctx.Info(tr("Using core '%[1]s' from platform in folder: %[2]s", core, buildPlatform.InstallDir))
ctx.Info("")
}
if buildProperties.Get("build.board") == "" {
......
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