utils

package
v2.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2025 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddWestFilesToCbuild added in v2.12.0

func AddWestFilesToCbuild(westInfo WestBuildInfo) error

func AppendFileToGroup added in v2.12.0

func AppendFileToGroup(fileTree *[]Filetree, group, file string)

func AppendUnique

func AppendUnique[T comparable](slice []T, elems ...T) []T

func ComparePaths added in v2.5.0

func ComparePaths(path1, path2 string) (bool, error)

checks if two paths are equivalent

func Contains

func Contains[T comparable](slice []T, elem T) bool

func CreateContext

func CreateContext(contextItem ContextItem) (context string)

func DeleteAll added in v2.7.0

func DeleteAll(path string, excludeFilePatterns []string) error

DeleteAll removes everything under path except files whose base name matches any of the provided glob patterns. If patterns is empty, it just calls os.RemoveAll.

func ExecuteCommand added in v2.5.0

func ExecuteCommand(program string, args ...string) (string, string, error)

This exclusive function returns the standard output and standard error as strings

func FileExists added in v2.5.0

func FileExists(filePath string) (bool, error)

func FormatTime added in v2.4.0

func FormatTime(time time.Duration) string

func GetDefaultCmsisPackRoot

func GetDefaultCmsisPackRoot() (root string)

func GetExecutablePath

func GetExecutablePath() (string, error)

func GetInstalledExePath

func GetInstalledExePath(exeName string) (path string, err error)

func GetModule added in v2.12.0

func GetModule(file string, modules []Module) string

func GetOutDir added in v2.7.0

func GetOutDir(cbuildIdxFile string, context string) (string, error)

func GetParentFolder added in v2.9.0

func GetParentFolder(path string) (string, error)

func GetTargetSetProjectContexts added in v2.12.0

func GetTargetSetProjectContexts(csolutionFile string, selectedTargetSet string) []string

func GetTmpDir added in v2.7.0

func GetTmpDir(csolutionFile string, outputDir string) (string, error)

func GetYamlNodeByKey added in v2.12.0

func GetYamlNodeByKey(node *yaml.Node, key string) *yaml.Node

func IsWildcardPattern

func IsWildcardPattern(str string) bool

func LogStdMsg added in v2.4.0

func LogStdMsg(msg string)

func MatchString

func MatchString(str string, pattern string) (bool, error)

func NormalizePath

func NormalizePath(path string) string

func ParseAndFetchToolchainInfo added in v2.8.0

func ParseAndFetchToolchainInfo(toolchainFile string) string

func ParseYAMLFile added in v2.7.0

func ParseYAMLFile(filePath string, out interface{}) error

func PrintSeparator added in v2.5.0

func PrintSeparator(delimiter string, length int)

func RemoveDuplicates added in v2.5.0

func RemoveDuplicates(input []string) []string

func ResolveContexts

func ResolveContexts(allContext []string, contextFilters []string) ([]string, error)

func SetExample added in v2.9.0

func SetExample(name string)

func SetYamlNodeByKey added in v2.12.0

func SetYamlNodeByKey(base *yaml.Node, node *yaml.Node, key string)

func ToRegEx

func ToRegEx(str string) string

Types

type Cbuild added in v2.7.0

type Cbuild struct {
	Build struct {
		OutputDirs struct {
			Intdir string `yaml:"intdir"`
			Outdir string `yaml:"outdir"`
		} `yaml:"output-dirs"`
	} `yaml:"build"`
}

func ParseCbuildFile added in v2.7.0

func ParseCbuildFile(cbuildFile string) (Cbuild, error)

type CbuildIndex

type CbuildIndex struct {
	BuildIdx struct {
		GeneratedBy string `yaml:"generated-by"`
		Cdefault    string `yaml:"cdefault"`
		Csolution   string `yaml:"csolution"`
		TmpDir      string `yaml:"tmpdir"`
		Cprojects   []struct {
			Cproject string `yaml:"cproject"`
		} `yaml:"cprojects"`
		Licenses interface{} `yaml:"licenses"`
		Cbuilds  []struct {
			Cbuild        string `yaml:"cbuild"`
			West          bool   `yaml:"west"`
			Project       string `yaml:"project"`
			Configuration string `yaml:"configuration"`
			Rebuild       bool   `yaml:"rebuild"`
			Messages      struct {
				Warnings []string `yaml:"warnings"`
				Info     []string `yaml:"info"`
			} `yaml:"messages"`
		} `yaml:"cbuilds"`
		Executes  []interface{} `yaml:"executes"`
		Rebuild   bool          `yaml:"rebuild"`
		ImageOnly bool          `yaml:"image-only"`
	} `yaml:"build-idx"`
}

func ParseCbuildIndexFile

func ParseCbuildIndexFile(cbuildIndexFile string) (CbuildIndex, error)

Wrapper functions for specific types

type CbuildSet

type CbuildSet struct {
	ContextSet struct {
		GeneratedBy string `yaml:"generated-by"`
		Contexts    []struct {
			Context string `yaml:"context"`
		} `yaml:"contexts"`
		Compiler string `yaml:"compiler"`
	} `yaml:"cbuild-set"`
}

func ParseCbuildSetFile

func ParseCbuildSetFile(cbuildSetFile string) (CbuildSet, error)

type CompileCommands added in v2.12.0

type CompileCommands struct {
	Directory string `json:"directory"`
	File      string `json:"file"`
	Output    string `json:"output"`
	Command   string `json:"command"`
}

Compile Commands

func ParseCompileCommandsFile added in v2.12.0

func ParseCompileCommandsFile(compileCommandsFile string) ([]CompileCommands, error)

type Configurations

type Configurations struct {
	BinPath string
	EtcPath string
	BinExtn string
}

func GetInstallConfigs

func GetInstallConfigs() (configs Configurations, err error)

type ContextItem

type ContextItem struct {
	ProjectName string
	BuildType   string
	TargetType  string
}

func ParseContext

func ParseContext(context string) (item ContextItem, err error)

type Csolution added in v2.7.0

type Csolution struct {
	Solution struct {
		TargetTypes []struct {
			Type      string `yaml:"type"`
			TargetSet []struct {
				Set    string `yaml:"set"`
				Images []struct {
					ProjectContext string `yaml:"project-context"`
				} `yaml:"images"`
			} `yaml:"target-set"`
		} `yaml:"target-types"`
		OutputDirs struct {
			Tmpdir string `yaml:"tmpdir"`
		} `yaml:"output-dirs"`
	} `yaml:"solution"`
}

func ParseCsolutionFile added in v2.7.0

func ParseCsolutionFile(csolutionFile string) (Csolution, error)

type EnvVars

type EnvVars struct {
	PackRoot     string
	CompilerRoot string
	BuildRoot    string
}

func UpdateEnvVars

func UpdateEnvVars(binPath string, etcPath string) (env EnvVars)

type Filetree added in v2.12.0

type Filetree struct {
	Group string
	Files []string
}

West Groups

type Module added in v2.12.0

type Module struct {
	Name  string
	Path  string
	CMake string
}

West Modules

func ParseModules added in v2.12.0

func ParseModules(filePath string) ([]Module, error)

type PerformanceTracker added in v2.9.0

type PerformanceTracker struct{}

PerformanceTracker is a no-op stub version used in normal mode to resolve build errors

func GetTrackerInstance added in v2.9.0

func GetTrackerInstance(outputPath string) *PerformanceTracker

func (*PerformanceTracker) SaveResults added in v2.9.0

func (pt *PerformanceTracker) SaveResults() error

func (*PerformanceTracker) StartTracking added in v2.9.0

func (pt *PerformanceTracker) StartTracking(tool string, args string)

func (*PerformanceTracker) StopTracking added in v2.9.0

func (pt *PerformanceTracker) StopTracking()

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

func (Runner) ExecuteCommand

func (r Runner) ExecuteCommand(program string, quiet bool, args ...string) (string, error)

func (*Runner) Write

func (r *Runner) Write(bytes []byte) (n int, err error)

type RunnerInterface

type RunnerInterface interface {
	ExecuteCommand(program string, quiet bool, args ...string) (output string, err error)
}

type WestBuildInfo added in v2.12.0

type WestBuildInfo struct {
	App        string
	Board      string
	OutDir     string
	Compiler   string
	Cbuild     string
	CbuildData Cbuild
}

West Build Info

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL