diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-08-18 22:04:17 -0700 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-08-18 22:04:17 -0700 |
| commit | 4e1e8035f3a8696dbf410a4576b51f68f62e6830 (patch) | |
| tree | 878c9bd42c96647ea01b6a96342e51242296ba58 /pkg | |
| parent | 7067e78fd655232314eaa3d964004ed9600e02be (diff) | |
pkg/build: update gvisor race build process
Use separate target as this is something that can be upstreamed.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/build/gvisor.go | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/pkg/build/gvisor.go b/pkg/build/gvisor.go index ea961d6ae..5628d6628 100644 --- a/pkg/build/gvisor.go +++ b/pkg/build/gvisor.go @@ -4,7 +4,6 @@ package build import ( - "fmt" "path/filepath" "strings" "time" @@ -16,42 +15,26 @@ type gvisor struct{} func (gvisor gvisor) build(targetArch, vmType, kernelDir, outputDir, compiler, userspaceDir, cmdlineFile, sysctlFile string, config []byte) error { + outBinary := "" args := []string{"build", "--verbose_failures"} if strings.Contains(" "+string(config)+" ", " -race ") { - args = append(args, "--features=race") + args = append(args, "--features=race", "//runsc:runsc-race") + outBinary = "bazel-bin/runsc/linux_amd64_static_race_stripped/runsc-race" + } else { + args = append(args, "//runsc:runsc") + outBinary = "bazel-bin/runsc/linux_amd64_pure_stripped/runsc" } - args = append(args, "runsc") + outBinary = filepath.Join(kernelDir, filepath.FromSlash(outBinary)) if _, err := osutil.RunCmd(20*time.Minute, kernelDir, compiler, args...); err != nil { return err } - if err := gvisor.copyBinary(kernelDir, outputDir); err != nil { + if err := osutil.CopyFile(outBinary, filepath.Join(outputDir, "image")); err != nil { return err } - if len(config) != 0 { - if err := osutil.WriteFile(filepath.Join(outputDir, "kernel.config"), config); err != nil { - return fmt.Errorf("failed to save kernel config: %v", err) - } - } osutil.RunCmd(10*time.Minute, kernelDir, compiler, "shutdown") return nil } -func (gvisor) copyBinary(kernelDir, outputDir string) error { - // Funny it's not possible to understand what bazel actually built... - for _, typ := range []string{ - "linux_amd64_pure_stripped", - "linux_amd64_static_stripped", - "linux_amd64_static_race_stripped", - } { - runsc := filepath.Join(kernelDir, "bazel-bin", "runsc", typ, "runsc") - if !osutil.IsExist(runsc) { - continue - } - return osutil.CopyFile(runsc, filepath.Join(outputDir, "image")) - } - return fmt.Errorf("failed to locate bazel output") -} - func (gvisor) clean(kernelDir string) error { // Let's assume that bazel always properly handles build without cleaning (until proven otherwise). return nil |
