diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2021-07-20 09:51:49 +0000 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2021-07-20 13:39:45 +0200 |
| commit | 1d0d9801861138705e655de691d7bb9c8b3aac4b (patch) | |
| tree | dd34c41d4d900e7aed2df6b2f90f6b3cdc612797 /pkg/build/gvisor.go | |
| parent | 2fe31df39f956886ef214b5b028362964aa07a53 (diff) | |
pkg/build: modify builder interface
Modify the `builder` interface in such a way that build method also
returns a struct containing extra information about the build process.
This allows to fetch compiler ID from individual builders. Also, this
makes the `signer` interface obsolete, as this information can also go
into that structure.
Diffstat (limited to 'pkg/build/gvisor.go')
| -rw-r--r-- | pkg/build/gvisor.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/pkg/build/gvisor.go b/pkg/build/gvisor.go index 0925a7b7c..d1fafdf77 100644 --- a/pkg/build/gvisor.go +++ b/pkg/build/gvisor.go @@ -19,7 +19,7 @@ type gvisor struct{} var bazelTargetPath = regexp.MustCompile(`(?sm:.*^)\s*Outputs: \[(.*)\](?sm:$.*)`) -func (gvisor gvisor) build(params Params) error { +func (gvisor gvisor) build(params Params) (ImageDetails, error) { if params.Compiler == "" { params.Compiler = "bazel" } @@ -67,7 +67,7 @@ func (gvisor gvisor) build(params Params) error { // on the first build after bazel/deps update. Also other gvisor instances running // on the same machine contribute to longer build times. if _, err := osutil.RunCmd(60*time.Minute, params.KernelDir, params.Compiler, buildArgs...); err != nil { - return err + return ImageDetails{}, err } // Find out a path to the runsc binary. @@ -76,20 +76,20 @@ func (gvisor gvisor) build(params Params) error { log.Logf(0, "bazel: %v", aqueryArgs) out, err := osutil.RunCmd(time.Minute, params.KernelDir, params.Compiler, aqueryArgs...) if err != nil { - return err + return ImageDetails{}, err } match := bazelTargetPath.FindSubmatch(out) if match == nil { - return fmt.Errorf("failed to find the runsc binary") + return ImageDetails{}, fmt.Errorf("failed to find the runsc binary") } outBinary := filepath.Join(params.KernelDir, filepath.FromSlash(string(match[1]))) if err := osutil.CopyFile(outBinary, filepath.Join(params.OutputDir, "image")); err != nil { - return err + return ImageDetails{}, err } sysTarget := targets.Get(params.TargetOS, params.TargetArch) - return osutil.CopyFile(outBinary, filepath.Join(params.OutputDir, "obj", sysTarget.KernelObject)) + return ImageDetails{}, osutil.CopyFile(outBinary, filepath.Join(params.OutputDir, "obj", sysTarget.KernelObject)) } func (gvisor) clean(kernelDir, targetArch string) error { |
