utils

package
v2.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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, excludeFilePattern string) error

DeleteAll removes everything under path except files whose base name matches the provided glob pattern. If pattern 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 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 GetTmpDir added in v2.7.0

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

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 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"`
			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 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 {
		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 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)
}

Jump to

Keyboard shortcuts

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