Skip to content

Commit

Permalink
Streamline output when using layer detection (#216)
Browse files Browse the repository at this point in the history
Addressing partially :
Open-CMSIS-Pack/devtools#1403
  • Loading branch information
soumeh01 committed May 6, 2024
1 parent a17faad commit 689c02e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/builder/csolution/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ func (b CSolutionBuilder) formulateArgs(command []string) (args []string) {
if b.Options.FrozenPacks {
args = append(args, "--frozen-packs")
}
if b.Options.Quiet {
args = append(args, "--quiet")
}
return
}

Expand Down Expand Up @@ -192,20 +195,27 @@ func (b CSolutionBuilder) generateBuildFiles() (err error) {
}
}

// on setup command, run csolution convert command with --quiet
if b.Setup {
args = append(args, "--quiet")
}

_, err = b.runCSolution(args, false)

// Execute this code exclusively upon invocation of the 'setup' command.
// Its purpose is to update layer information within the *.cbuild-idx.yml files.
if b.Setup {
if exitError, ok := err.(*exec.ExitError); ok {
if exitError.ExitCode() == 2 {
args = []string{"list", "layers", b.InputFile, "--load=all", "--update-idx"}
args = []string{"list", "layers", b.InputFile, "--load=all", "--update-idx", "--quiet"}
for _, context := range selectedContexts {
args = append(args, "--context="+context)
}
_, listCmdErr := b.runCSolution(args, false)
if listCmdErr != nil {
err = listCmdErr
} else {
utils.LogStdMsg("To resolve undefined variables, copy the settings from cbuild-idx.yml to csolution.yml")
}
}
}
Expand Down Expand Up @@ -401,8 +411,8 @@ func (b CSolutionBuilder) buildContexts(selectedContexts []string, projBuilders
progress := fmt.Sprintf("(%s/%d)", strconv.Itoa(index+1), len(selectedContexts))
infoMsg = progress + " " + operation + " context: \"" + selectedContexts[index] + "\""
}
sep := strings.Repeat("=", len(infoMsg)+13) + "\n"
_, _ = log.StandardLogger().Out.Write([]byte(sep))
sep := strings.Repeat("=", len(infoMsg)+13)
utils.LogStdMsg(sep)
log.Info(infoMsg)

b.setBuilderOptions(&projBuilders[index], false)
Expand Down Expand Up @@ -517,7 +527,7 @@ func (b CSolutionBuilder) ListEnvironment() error {
return err
}
for _, config := range envConfigs {
_, _ = log.StandardLogger().Out.Write([]byte(config + "\n"))
utils.LogStdMsg(config)
}
return nil
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,7 @@ func RemoveVersionRange(str string) string {
}
return str
}

func LogStdMsg(msg string) {
_, _ = log.StandardLogger().Out.Write([]byte(msg + "\n"))
}

0 comments on commit 689c02e

Please sign in to comment.