Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterExecDriver(name string, runner Runner)
- type Command
- type EventHandler
- type EvtTaskActivated
- type EvtTaskFinish
- type EvtTaskOutput
- type EvtTaskStart
- type ExecPlan
- func (p *ExecPlan) AddTarget(t *Target) (*Task, bool)
- func (p *ExecPlan) Execute() error
- func (p *ExecPlan) GenerateSummary() (err error)
- func (p *ExecPlan) OnEvent(handler EventHandler) *ExecPlan
- func (p *ExecPlan) Rebuild(targets ...string) *ExecPlan
- func (p *ExecPlan) Require(targets ...string) error
- func (p *ExecPlan) Skip(targets ...string) *ExecPlan
- type File
- type Project
- func (p *Project) DebugLogFile() string
- func (p *Project) Finalize() error
- func (p *Project) GetSettings(v interface{}) error
- func (p *Project) GetSettingsIn(name string, v interface{}) error
- func (p *Project) Glob(pattern string) (paths []string, err error)
- func (p *Project) Load(path string) (*File, error)
- func (p *Project) MergeSettingsFlat(flat map[string]interface{}) error
- func (p *Project) Plan() *ExecPlan
- func (p *Project) Resolve() error
- func (p *Project) SummaryFile() string
- func (p *Project) TargetNames() []string
- func (p *Project) WorkPath() string
- type Runner
- type RunnerFactory
- type Settings
- type Target
- func (t *Target) AddDep(dep *Target)
- func (t *Target) BuildWatchList() (list WatchList)
- func (t *Target) Errorf(format string, args ...interface{}) error
- func (t *Target) GetExt(v interface{}) error
- func (t *Target) GetSettings(name string, v interface{}) error
- func (t *Target) GetSettingsWithExt(name string, v interface{}) (err error)
- func (t *Target) Initialize(name string, project *Project)
- type TargetNameMap
- type Task
- func (t *Task) BuildScript() string
- func (t *Task) BuildScriptFile() (string, error)
- func (t *Task) BuildSuccessMark() error
- func (t *Task) CalcSuccessMark() bool
- func (t *Task) ClearSuccessMark() error
- func (t *Task) Duration() time.Duration
- func (t *Task) Exec(command string, args ...string) error
- func (t *Task) ExecScript() error
- func (t *Task) IsActivated() bool
- func (t *Task) LogFile() string
- func (t *Task) Name() string
- func (t *Task) Project() *Project
- func (t *Task) Runner() (Runner, error)
- func (t *Task) ScriptFile() string
- func (t *Task) SuccessMarkFile() string
- func (t *Task) Summary() map[string]interface{}
- func (t *Task) Write(p []byte) (int, error)
- func (t *Task) WriteScriptFile(script string) error
- type TaskResult
- type TaskState
- type WatchItem
- type WatchList
Constants ¶
const ( // Format is the supported format Format = "hypermake.v0" // RootFile is hmake filename sits on root RootFile = "HyperMake" // WorkFolder is the name of project WorkFolder WorkFolder = ".hmake" // SummaryFileName is the filename of summary SummaryFileName = "hmake.summary.json" // LogFileName is the filename of hmake debug log LogFileName = "hmake.debug.log" )
const (
// SettingExecDriver is the property name of exec-driver
SettingExecDriver = "exec-driver"
)
Variables ¶
var ( // DefaultExecDriver specify the default exec-driver to use DefaultExecDriver string )
var ErrUnsupportedFormat = fmt.Errorf("unsupported format")
ErrUnsupportedFormat indicates the file is not recognized
Functions ¶
func RegisterExecDriver ¶
RegisterExecDriver registers a runner
Types ¶
type EventHandler ¶
type EventHandler func(event interface{})
EventHandler receives event notifications during execution of plan
type EvtTaskActivated ¶
type EvtTaskActivated struct {
Task *Task
}
EvtTaskActivated is emitted when task is queued
type EvtTaskFinish ¶
type EvtTaskFinish struct {
Task *Task
}
EvtTaskFinish is emitted when task finishes
type EvtTaskOutput ¶
EvtTaskOutput is emitted when output is received
type EvtTaskStart ¶
type EvtTaskStart struct {
Task *Task
}
EvtTaskStart is emitted before task gets run
type ExecPlan ¶
type ExecPlan struct { // Project is the wrapped project Project *Project // Tasks are the tasks need execution Tasks map[string]*Task // Env is pre-defined environment variables Env map[string]string // WorkPath is full path to hmake state dir ProjectDir/.hmake WorkPath string // MaxConcurrency defines maximum number of tasks being executed in parallel // if it's 0, the number of CPU cores are counted MaxConcurrency int // RebuildAll force rebuild everything regardless of success mark RebuildAll bool // RebuildTargets specify targets to rebuild regardless of success mark RebuildTargets map[string]bool // SkippedTargets specify targets to be marked as Skipped SkippedTargets map[string]bool // RequiredTargets are names of targets explicitly required RequiredTargets []string // RunnerFactory specifies the custom runner factory RunnerFactory RunnerFactory // DebugLog enables logging debug info into .hmake/hmake.debug.log DebugLog bool // Dryrun will skip the actual execution of target, just return success DryRun bool // WaitingTasks are tasks in waiting state WaitingTasks map[string]*Task // QueuedTasks are tasks in Queued state QueuedTasks []*Task // RunningTasks are tasks in Running state RunningTasks map[string]*Task // FinishedTasks are tasks in finished state FinishedTasks []*Task // EventHandler handles the events during execution EventHandler EventHandler // Summary is the report of all executed targets Summary []map[string]interface{} // contains filtered or unexported fields }
ExecPlan describes the plan for execution
func NewExecPlan ¶
NewExecPlan creates an ExecPlan for a Project
func (*ExecPlan) GenerateSummary ¶
GenerateSummary dumps summary to summary file
func (*ExecPlan) OnEvent ¶
func (p *ExecPlan) OnEvent(handler EventHandler) *ExecPlan
OnEvent subscribes the events
type File ¶
type File struct { // Format indicates file format Format string `json:"format"` // Name is name of the project Name string `json:"name"` // Desc is description of the project Desc string `json:"description"` // Targets are targets defined in current file Targets map[string]*Target `json:"targets"` // Settings are properties Settings Settings `json:"settings"` // Includes are patterns for sourcing external files Includes []string `json:"includes"` // Source is the relative path to the file Source string `json:"-"` }
File defines the content of HyperMake or .hmake file
type Project ¶
type Project struct { // Name is name of the project Name string // BaseDir is the root directory of project BaseDir string // LaunchPath is relative path under BaseDir where hmake launches LaunchPath string // MasterFile is the file with everything merged MasterFile File // All loaded make files Files []*File // Tasks are built from resolved targets Targets TargetNameMap }
Project is the world view of hmake
func LoadProject ¶
LoadProject locates, resolves and finalizes project
func LoadProjectFrom ¶
LoadProjectFrom locates, resolves and finalizes project from startDir
func LocateProject ¶
LocateProject creates a project by locating the root file
func LocateProjectFrom ¶
LocateProjectFrom creates a project by locating the root file from startDir
func (*Project) DebugLogFile ¶
DebugLogFile returns the fullpath to debug log file
func (*Project) Finalize ¶
Finalize builds up the relationship between targets and settings and also verifies any cyclic dependencies
func (*Project) GetSettings ¶
GetSettings maps settings into provided variable
func (*Project) GetSettingsIn ¶
GetSettingsIn maps settings[name] into provided variable
func (*Project) MergeSettingsFlat ¶
MergeSettingsFlat merges settings from a flat key/value map
func (*Project) SummaryFile ¶
SummaryFile returns the fullpath to summary file
func (*Project) TargetNames ¶
TargetNames returns sorted target names
type RunnerFactory ¶
RunnerFactory creates a runner from a task
type Target ¶
type Target struct { Name string `json:"name"` Desc string `json:"description"` Before []string `json:"before"` After []string `json:"after"` ExecDriver string `json:"exec-driver"` Envs []string `json:"envs"` Cmds []*Command `json:"cmds"` Script string `json:"script"` Watches []string `json:"watches"` Ext map[string]interface{} `json:"*"` Project *Project `json:"-"` Source string `json:"-"` Depends TargetNameMap `json:"-"` Activates TargetNameMap `json:"-"` }
Target defines a build target
func (*Target) BuildWatchList ¶
BuildWatchList collects current state of all watched items
func (*Target) GetSettings ¶
GetSettings extracts the value from settings stack
func (*Target) GetSettingsWithExt ¶
GetSettingsWithExt extracts the value from Ext and settings stack
func (*Target) Initialize ¶
Initialize prepare fields in target
type TargetNameMap ¶
TargetNameMap is targets mapping by name
func (TargetNameMap) Add ¶
func (m TargetNameMap) Add(t *Target) error
Add adds a target to name map
func (TargetNameMap) BuildDeps ¶
func (m TargetNameMap) BuildDeps() error
BuildDeps builds direct depends and activates
func (TargetNameMap) CheckCyclicDeps ¶
func (m TargetNameMap) CheckCyclicDeps() error
CheckCyclicDeps detects cycles in depenencies
type Task ¶
type Task struct { // Plan is ExecPlan owns the task Plan *ExecPlan // Target is wrapped target Target *Target // Depends is the tasks being depended on // The task is activated when depends is empty Depends map[string]*Task // State indicates task state State TaskState // Result indicates the result of the task Result TaskResult // Error represents any error happened during execution Error error // StartTime StartTime time.Time // FinishTime FinishTime time.Time // contains filtered or unexported fields }
Task is the execution state of a target
func (*Task) BuildScript ¶
BuildScript generates script file according to cmds/script in target
func (*Task) BuildScriptFile ¶
BuildScriptFile generates the script file using default generated script
func (*Task) BuildSuccessMark ¶
BuildSuccessMark checks if the task can be skipped
func (*Task) CalcSuccessMark ¶
CalcSuccessMark calculates the watchlist digest and checks if the task can be skipped
func (*Task) ClearSuccessMark ¶
ClearSuccessMark removes the success mark
func (*Task) IsActivated ¶
IsActivated indicates the task is ready to run
func (*Task) ScriptFile ¶
ScriptFile returns the filename of script
func (*Task) SuccessMarkFile ¶
SuccessMarkFile returns the filename of success mark
func (*Task) WriteScriptFile ¶
WriteScriptFile builds the script file with provided script
type TaskResult ¶
type TaskResult int
TaskResult indicates the result of task execution
const ( Unknown TaskResult = iota Success Failure Skipped )
Task results
func (TaskResult) String ¶
func (r TaskResult) String() string
type WatchItem ¶
type WatchItem struct { // Path is relative path to the project root Path string // ModTime is the modification time of the item ModTime time.Time }
WatchItem contains information the target watches