-
Notifications
You must be signed in to change notification settings - Fork 0
/
job.go
58 lines (49 loc) · 1.48 KB
/
job.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) 2020-2021 C4 Project
//
// This file is part of c4t.
// Licenced under the MIT licence; see `LICENSE`.
package compiler
import (
"github.com/c4-project/c4t/internal/model/service"
)
// Job represents a request to compile a list of files to a particular target given a particular compiler.
type Job struct {
// Compiler describes the compiler to use for the compilation.
Compiler *Instance
// In is the list of files to be sent to the compiler.
In []string
// Out is the file to be received from the compiler.
Out string
// Kind is the kind of file being produced by this compile.
Kind Target
}
// NewJob is a convenience constructor for compiles.
func NewJob(k Target, c *Instance, out string, in ...string) *Job {
return &Job{
Kind: k,
Compiler: c,
In: in,
Out: out,
}
}
// CompilerRun gets the job's compiler run information if present; else, nil.
func (j *Job) CompilerRun() *service.RunInfo {
if j.Compiler == nil {
return nil
}
return j.Compiler.Run
}
// SelectedOptName gets the name of this job's compiler's selected optimisation level, if present; else, "".
func (j *Job) SelectedOptName() string {
if j.Compiler == nil || j.Compiler.SelectedOpt == nil {
return ""
}
return j.Compiler.SelectedOpt.Name
}
// SelectedMOptName gets the name of this job's compiler's selected machine optimisation profile, if present; else, "".
func (j *Job) SelectedMOptName() string {
if j.Compiler == nil {
return ""
}
return j.Compiler.SelectedMOpt
}