Skip to content

Commit

Permalink
Add --verbose flag to enable toolchain's verbose output
Browse files Browse the repository at this point in the history
  • Loading branch information
brondani authored Nov 9, 2022
1 parent ad3619e commit 0820672
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This utility allows embedded developers to orchestrate the build of CPRJ project
## Usage

```bash
cbuild: Build Invocation 0.11.0-dev0 (C) 2022 ARM
cbuild: Build Invocation 1.3.0 (C) 2022 ARM

Usage:
cbuild <project.cprj> [flags]
Expand All @@ -29,5 +29,6 @@ Flags:
-s, --schema Check *.cprj file against CPRJ.xsd schema
-t, --target string Optional CMake target name
-u, --update string Generate *.cprj file for reproducing current build
-v, --version Print version
-v, --verbose Enable verbose messages from toolchain builds
-V, --version Print version
```
3 changes: 3 additions & 0 deletions cmd/cbuild/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func NewRootCmd() *cobra.Command {
jobs, _ := cmd.Flags().GetInt("jobs")
quiet, _ := cmd.Flags().GetBool("quiet")
debug, _ := cmd.Flags().GetBool("debug")
verbose, _ := cmd.Flags().GetBool("verbose")
clean, _ := cmd.Flags().GetBool("clean")
schema, _ := cmd.Flags().GetBool("schema")
packs, _ := cmd.Flags().GetBool("packs")
Expand All @@ -103,6 +104,7 @@ func NewRootCmd() *cobra.Command {
Jobs: jobs,
Quiet: quiet,
Debug: debug,
Verbose: verbose,
Clean: clean,
Schema: schema,
Packs: packs,
Expand All @@ -120,6 +122,7 @@ func NewRootCmd() *cobra.Command {
rootCmd.Flags().BoolP("help", "h", false, "Print usage")
rootCmd.Flags().BoolP("quiet", "q", false, "Suppress output messages except build invocations")
rootCmd.Flags().BoolP("debug", "d", false, "Enable debug messages")
rootCmd.Flags().BoolP("verbose", "v", false, "Enable verbose messages from toolchain builds")
rootCmd.Flags().BoolP("clean", "c", false, "Remove intermediate and output directories")
rootCmd.Flags().BoolP("schema", "s", false, "Check *.cprj file against CPRJ.xsd schema")
rootCmd.Flags().BoolP("packs", "p", false, "Download missing software packs with cpackget")
Expand Down
4 changes: 4 additions & 0 deletions pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Options struct {
Jobs int
Quiet bool
Debug bool
Verbose bool
Clean bool
Schema bool
Packs bool
Expand Down Expand Up @@ -349,6 +350,9 @@ func (b Builder) Build() error {
if b.Options.Target != "" {
args = append(args, "--target", b.Options.Target)
}
if b.Options.Debug || b.Options.Verbose {
args = append(args, "--verbose")
}
err = b.Runner.ExecuteCommand(vars.cmakeBin, false, args...)
if err != nil {
log.Error("error executing 'cmake' build")
Expand Down
7 changes: 7 additions & 0 deletions pkg/builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,13 @@ func TestBuild(t *testing.T) {
assert.Nil(err)
})

t.Run("test build verbose", func(t *testing.T) {
b.Options.Debug = false
b.Options.Verbose = true
err := b.Build()
assert.Nil(err)
})

t.Run("test build clean target", func(t *testing.T) {
b.Options.Target = "clean"
err := b.Build()
Expand Down

0 comments on commit 0820672

Please sign in to comment.