Skip to content
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

Call optionally cbuild2cmake instead of cbuildgen #167

Merged
merged 7 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 7 additions & 5 deletions cmd/cbuild/commands/build/buildcprj_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Arm Limited. All rights reserved.
* Copyright (c) 2023-2024 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -8,6 +8,7 @@ package build_test

import (
"os"
"path/filepath"
"testing"

"github.com/Open-CMSIS-Pack/cbuild/v2/cmd/cbuild/commands"
Expand All @@ -16,10 +17,11 @@ import (
)

const testRoot = "../../../../test"
const testDir = "command"

func TestBuildCPRJCommand(t *testing.T) {
assert := assert.New(t)
cprjFile := testRoot + "/run/minimal.cprj"
cprjFile := filepath.Join(testRoot, testDir, "minimal.cprj")

t.Run("multiple arguments", func(t *testing.T) {
cmd := commands.NewRootCmd()
Expand All @@ -38,9 +40,9 @@ func TestBuildCPRJCommand(t *testing.T) {

func TestPreLogConfiguration(t *testing.T) {
assert := assert.New(t)
logDir := testRoot + "/run/log"
logFile := logDir + "/test.log"
cprjFile := testRoot + "/run/minimal.cprj"
logDir := filepath.Join(testRoot, testDir, "log")
logFile := filepath.Join(logDir, "test.log")
cprjFile := filepath.Join(testRoot, testDir, "minimal.cprj")

t.Run("test normal verbosity level", func(t *testing.T) {
// No quiet, No debug
Expand Down
5 changes: 3 additions & 2 deletions cmd/cbuild/commands/list/list_contexts_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
* Copyright (c) 2023 Arm Limited. All rights reserved.
* Copyright (c) 2023-2024 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/

package list_test

import (
"path/filepath"
"testing"

"github.com/Open-CMSIS-Pack/cbuild/v2/cmd/cbuild/commands"
Expand All @@ -15,7 +16,7 @@ import (

func TestListContextsCommand(t *testing.T) {
assert := assert.New(t)
csolutionFile := testRoot + "/run/TestSolution/test.csolution.yml"
csolutionFile := filepath.Join(testRoot, testDir, "TestSolution/test.csolution.yml")

t.Run("No arguments", func(t *testing.T) {
cmd := commands.NewRootCmd()
Expand Down
3 changes: 2 additions & 1 deletion cmd/cbuild/commands/list/list_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Arm Limited. All rights reserved.
* Copyright (c) 2023-2024 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -14,6 +14,7 @@ import (
)

const testRoot = "../../../../test"
const testDir = "command"

func TestListCommand(t *testing.T) {
assert := assert.New(t)
Expand Down
5 changes: 3 additions & 2 deletions cmd/cbuild/commands/list/list_toolchains_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
* Copyright (c) 2023 Arm Limited. All rights reserved.
* Copyright (c) 2023-2024 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/

package list_test

import (
"path/filepath"
"testing"

"github.com/Open-CMSIS-Pack/cbuild/v2/cmd/cbuild/commands"
Expand All @@ -15,7 +16,7 @@ import (

func TestListToolchainsCommand(t *testing.T) {
assert := assert.New(t)
csolutionFile := testRoot + "/run/TestSolution/test.csolution.yml"
csolutionFile := filepath.Join(testRoot, testDir, "TestSolution/test.csolution.yml")

t.Run("invalid flag", func(t *testing.T) {
cmd := commands.NewRootCmd()
Expand Down
45 changes: 24 additions & 21 deletions cmd/cbuild/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,29 +129,31 @@ func NewRootCmd() *cobra.Command {
toolchain, _ := cmd.Flags().GetString("toolchain")
useContextSet, _ := cmd.Flags().GetBool("context-set")
frozenPacks, _ := cmd.Flags().GetBool("frozen-packs")
useCbuild2CMake, _ := cmd.Flags().GetBool("cbuild2cmake")

options := builder.Options{
IntDir: intDir,
OutDir: outDir,
LockFile: lockFile,
LogFile: logFile,
Generator: generator,
Target: target,
Jobs: jobs,
Quiet: quiet,
Debug: debug,
Verbose: verbose,
Clean: clean,
Schema: schema,
Packs: packs,
Rebuild: rebuild,
UpdateRte: updateRte,
Contexts: contexts,
UseContextSet: useContextSet,
Load: load,
Output: output,
Toolchain: toolchain,
FrozenPacks: frozenPacks,
IntDir: intDir,
OutDir: outDir,
LockFile: lockFile,
LogFile: logFile,
Generator: generator,
Target: target,
Jobs: jobs,
Quiet: quiet,
Debug: debug,
Verbose: verbose,
Clean: clean,
Schema: schema,
Packs: packs,
Rebuild: rebuild,
UpdateRte: updateRte,
Contexts: contexts,
UseContextSet: useContextSet,
Load: load,
Output: output,
Toolchain: toolchain,
FrozenPacks: frozenPacks,
UseCbuild2CMake: useCbuild2CMake,
}

configs, err := utils.GetInstallConfigs()
Expand Down Expand Up @@ -208,6 +210,7 @@ func NewRootCmd() *cobra.Command {
rootCmd.PersistentFlags().BoolP("schema", "s", false, "Validate project input file(s) against schema")
rootCmd.PersistentFlags().StringP("log", "", "", "Save output messages in a log file")
rootCmd.PersistentFlags().StringP("toolchain", "", "", "Input toolchain to be used")
rootCmd.Flags().BoolP("cbuild2cmake", "", false, "Use cbuild2cmake")

// CPRJ specific hidden flags
rootCmd.Flags().StringP("intdir", "i", "", "Set directory for intermediate files")
Expand Down
14 changes: 8 additions & 6 deletions cmd/cbuild/commands/root_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023 Arm Limited. All rights reserved.
* Copyright (c) 2022-2024 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -8,6 +8,7 @@ package commands_test

import (
"os"
"path/filepath"
"testing"

"github.com/Open-CMSIS-Pack/cbuild/v2/cmd/cbuild/commands"
Expand All @@ -17,15 +18,16 @@ import (
)

const testRoot = "../../../test"
const testDir = "command"

func init() {
inittest.TestInitialization(testRoot)
inittest.TestInitialization(testRoot, testDir)
}

func TestCommands(t *testing.T) {
assert := assert.New(t)
cprjFile := testRoot + "/run/minimal.cprj"
csolutionFile := testRoot + "/run/test.csolution.yml"
cprjFile := filepath.Join(testRoot, testDir, "minimal.cprj")
csolutionFile := filepath.Join(testRoot, testDir, "test.csolution.yml")

t.Run("test version", func(t *testing.T) {
cmd := commands.NewRootCmd()
Expand Down Expand Up @@ -72,8 +74,8 @@ func TestCommands(t *testing.T) {

func TestPreLogConfiguration(t *testing.T) {
assert := assert.New(t)
logDir := testRoot + "/run/log"
logFile := logDir + "/test.log"
logDir := filepath.Join(testRoot, testDir, "log")
logFile := filepath.Join(logDir, "test.log")

t.Run("test normal verbosity level", func(t *testing.T) {
// No quiet, No debug
Expand Down
Loading
Loading