gomklib

package module
v0.0.0-...-c89b632 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: AGPL-3.0 Imports: 21 Imported by: 0

README

gomk-lib

Utilities to use with gomk.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddGraphvizExeChecks

func AddGraphvizExeChecks(m map[string][]string)

func AddPlantUMLExeChecks

func AddPlantUMLExeChecks(m map[string][]string)

func CheckExes

func CheckExes(exeToRefURLs map[string][]string) (missing map[string][]string)

func LogMissingExes

func LogMissingExes(log *slog.Logger, level slog.Level, missing map[string][]string)

func Watch

func Watch(prj *gomkore.Project, chg *gomkore.Changer) error

Types

type Dot

type Dot struct {
	Exe        string
	OutputType string
}

func (*Dot) Describe

func (dot *Dot) Describe(*gomkore.Action, *gomkore.Env) string

func (*Dot) Do

func (dot *Dot) Do(tr *gomkore.Trace, a *gomkore.Action, env *gomkore.Env) error

func (*Dot) WriteHash

func (dot *Dot) WriteHash(h hash.Hash, _ *gomkore.Action, _ *gomkore.Env) (bool, error)

type GoDefaultGoals

type GoDefaultGoals struct {
	Generate  gomk.GoalEd
	VulnCheck gomk.GoalEd
	Test      gomk.GoalEd
	DotSVG    gomk.GoalEd
}

type GoModule

type GoModule struct {
	Trace *gomkore.Trace
	Env   *gomkore.Env

	Clean    bool
	DryRun   bool
	WriteDot bool
	NoTest   bool
	Watch    bool

	ExeChecks []func(map[string][]string)
	// contains filtered or unexported fields
}
Example
build := GoModule{Env: gomkore.DefaultEnv(nil)} // Set out own Env…
// …to discard stdout that breaks Go test Example output
build.Env.Out = nil

build.Flags() // Register and parse some useful flags

// The project, name is taken from current working directory
prj := gomkore.NewProject("testdata/prj")

// Now, edit project for this project's specifics
err := gomk.Edit(prj, func(prj gomk.ProjectEd) {
	// Some goals: generate, govulncheck, test
	goAls := build.DefaultGolas(prj)

	prj.Goal(mkfs.File("yacmd")).
		By(build.GoBuild(), goAls.Test, prj.Goal(mkfs.DirList{Dir: "cmd/yacmd"}))
})
if err != nil {
	log.Fatal(err)
}

// Now, go for it…
err = build.Make(prj)
if err != nil {
	log.Fatal(err)
}

fmt.Println("DONE") // just for Go test Example
Output:

DONE

func (*GoModule) DefaultGolas

func (m *GoModule) DefaultGolas(prj gomk.ProjectEd) (gs GoDefaultGoals)

func (*GoModule) DotGoals

func (m *GoModule) DotGoals(prj gomk.ProjectEd) (dotSVG gomk.GoalEd)

func (*GoModule) Flags

func (m *GoModule) Flags()

func (*GoModule) GoBuild

func (m *GoModule) GoBuild() *gomk.GoBuild

func (*GoModule) GoGenerate

func (m *GoModule) GoGenerate() *gomk.GoGenerate

func (*GoModule) GoTest

func (m *GoModule) GoTest() *gomk.GoTest

func (*GoModule) GoVulncheck

func (m *GoModule) GoVulncheck() *GoVulncheck

func (*GoModule) Make

func (m *GoModule) Make(prj *gomkore.Project) error

type GoVulncheck

type GoVulncheck struct {
	Version  string
	CWD      string
	Tags     []string
	Patterns []string
}

func (*GoVulncheck) Describe

func (gvc *GoVulncheck) Describe(a *gomkore.Action, _ *gomkore.Env) string

func (*GoVulncheck) Do

func (gvc *GoVulncheck) Do(tr *gomkore.Trace, a *gomkore.Action, env *gomkore.Env) error

func (*GoVulncheck) WriteHash

func (*GoVulncheck) WriteHash(hash.Hash, *gomkore.Action, *gomkore.Env) (bool, error)

type PlantUML

type PlantUML struct {
	JAR        string
	OutputType string
}

func (*PlantUML) ConvertAll

func (puml *PlantUML) ConvertAll(
	prj gomk.ProjectEd,
	src, dst mkfs.Directory,
	ignoreErrors bool,
	withOutput func([]gomk.GoalEd),
)

ConvertAll panics – but can only be used in gomk.Edit context.

func (*PlantUML) Describe

func (puml *PlantUML) Describe(*gomkore.Action, *gomkore.Env) string

func (*PlantUML) Do

func (puml *PlantUML) Do(tr *gomkore.Trace, a *gomkore.Action, env *gomkore.Env) error

1 .puml -> 1 .img => explicit by Op 1 .puml -> n .img => set Dir + files not checked 1 .puml -> 1 Dir => set Dir + files not checked 1 .puml -> n Dir => ERROR n .puml -> 1 .img => ERROR n .puml -> n .img => ??? n .puml -> 1 Dir => set Dir + files not checked * Dir -> => ERROR (may be supported later)

func (*PlantUML) OutputFiles

func (puml *PlantUML) OutputFiles(source string) (res []string, err error)
Example
puml := PlantUML{}
ofs, err := puml.OutputFiles("testdata/dias.puml")
if err != nil {
	fmt.Println(err)
	return
}
for _, of := range ofs {
	fmt.Printf("[%s]\n", of)
}
Output:

[dias.png]
[dia1.png]
[dia2.png]
[dias_001.png]

func (*PlantUML) WriteHash

func (puml *PlantUML) WriteHash(h hash.Hash, _ *gomkore.Action, _ *gomkore.Env) (bool, error)

type SlogTrace

type SlogTrace struct{ Log *slog.Logger }

func (SlogTrace) CheckGoal

func (tr SlogTrace) CheckGoal(t *gomkore.Trace, g *gomkore.Goal)

func (SlogTrace) Debug

func (tr SlogTrace) Debug(t *gomkore.Trace, msg string, args ...any)

func (SlogTrace) DoneProject

func (tr SlogTrace) DoneProject(t *gomkore.Trace, p *gomkore.Project, activity string, dt time.Duration)

func (SlogTrace) GoalNeedsActions

func (tr SlogTrace) GoalNeedsActions(t *gomkore.Trace, g *gomkore.Goal, n int)

func (SlogTrace) GoalUpToDate

func (tr SlogTrace) GoalUpToDate(t *gomkore.Trace, g *gomkore.Goal)

func (SlogTrace) Info

func (tr SlogTrace) Info(t *gomkore.Trace, msg string, args ...any)

func (SlogTrace) RemoveArtefact

func (tr SlogTrace) RemoveArtefact(t *gomkore.Trace, g *gomkore.Goal)

func (SlogTrace) RunAction

func (tr SlogTrace) RunAction(t *gomkore.Trace, a *gomkore.Action)

func (SlogTrace) RunImplicitAction

func (tr SlogTrace) RunImplicitAction(t *gomkore.Trace, _ *gomkore.Action)

func (SlogTrace) ScheduleNotPremises

func (tr SlogTrace) ScheduleNotPremises(t *gomkore.Trace, a *gomkore.Action, res *gomkore.Goal)

func (SlogTrace) ScheduleOutdated

func (tr SlogTrace) ScheduleOutdated(t *gomkore.Trace, a *gomkore.Action, res, pre *gomkore.Goal)

func (SlogTrace) SchedulePreTimeZero

func (tr SlogTrace) SchedulePreTimeZero(t *gomkore.Trace, a *gomkore.Action, res, pre *gomkore.Goal)

func (SlogTrace) ScheduleResTimeZero

func (tr SlogTrace) ScheduleResTimeZero(t *gomkore.Trace, a *gomkore.Action, res *gomkore.Goal)

func (SlogTrace) StartProject

func (tr SlogTrace) StartProject(t *gomkore.Trace, p *gomkore.Project, activity string)

func (SlogTrace) Warn

func (tr SlogTrace) Warn(t *gomkore.Trace, msg string, args ...any)

Jump to

Keyboard shortcuts

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