mkf

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

mkf package works with makefiles.

Index

Constants

This section is empty.

Variables

View Source
var (
	AutoEditedMarkComment = `# This file was edited by ergomcutool`
	AutoEditedMarkPrefix  = "# ERGOMCUTOOL_VERSION ="
	ErrValueNotFound      = errors.New("value not found")
	ErrEntryNotFound      = errors.New("entry not found")
)

Functions

func BackupMakefile

func BackupMakefile(makefilePath string) error

BackupMakefile moves specified makefile to '_non_persistent/backups/makefile/'.

Types

type Mkf

type Mkf struct {
	// Lines are the lines read from a Makefile.
	Lines []string
	// LineEnding specifies the Makefile line endings ("\n" and "\r\n" are supported).
	LineEnding string
}

func FromFile

func FromFile(path string) (m *Mkf, err error)

FromFile reads a Makefile from the specified file. Line endings are detected automatically.

func (*Mkf) AppendString

func (m *Mkf) AppendString(s string, appendEmptyLine bool) error

AppendString is similar to AppendTextLines but it splits 's' into lines first, and then appends the lines. No whitespace characters will be removed, except '\r' and '\n'.

func (*Mkf) AppendTextLines

func (m *Mkf) AppendTextLines(textLines []string, appendEmptyLine bool) error

AppendTextLines appends a text block at the end of the makefile, but before `# *** EOF ***` line if such line exists. The text block must not contain line endings.

func (*Mkf) Bytes

func (m *Mkf) Bytes() []byte

func (*Mkf) InsertAutoEditedMark

func (m *Mkf) InsertAutoEditedMark() error

InsertAutoEditedMark inserts a mark that helps to identify if the Makefile was edited by ergomcutool.

func (*Mkf) InsertValue

func (m *Mkf) InsertValue(entryName string, values []string) error

InsertValue writes the value of the specified entry. It doesn't create the entry itself.

func (*Mkf) IsAutoEdited

func (m *Mkf) IsAutoEdited() bool

func (*Mkf) Parse

func (m *Mkf) Parse() (*ParsedMkf, error)

ParseMkf parses the internal Lines field into ParsedMkf.

func (*Mkf) ReadValue

func (m *Mkf) ReadValue(entryName string) ([]string, error)

func (*Mkf) RemoveValue

func (m *Mkf) RemoveValue(entryName string) error

RemoveValue removes the value of the specified entry. It doesn't remove the entry itself.

func (*Mkf) ReplaceValue

func (m *Mkf) ReplaceValue(entryName string, values []string) error

ReplaceValue removes the original entry value and inserts the new one.

func (*Mkf) String

func (m *Mkf) String() string

type ParsedMkf

type ParsedMkf struct {
	// IsAutoEdited is true if the Makefile has been edited by ergomcutool
	IsAutoEdited bool
	// ErgomcutoolVersion is the version of ergomcutool that edited the Makefile
	ErgomcutoolVersion string
	// Debug is 1 if the Debug mode is selected, or 0 in Release mode.
	Debug string
	// Opt contains optimization level arguments, default is -Og
	Opt string

	// BuildDir is the build directory, default is 'build'
	BuildDir string

	// CSources is a list of .c files from the Makefile,
	// the order is preserved.
	CSources []string

	// CDefs is a list of definitions from the Makefile,
	// the order is preserved.
	CDefs []string

	// CIncludes is a list of include paths from the Makefile,
	// the order is preserved.
	CIncludes []string
}

Jump to

Keyboard shortcuts

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