1// Copyright 2018 syzkaller project authors. All rights reserved. 2// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4package build 5 6import ( 7 "fmt" 8 "path/filepath" 9 "time" 10 11 "github.com/google/syzkaller/pkg/osutil" 12 "github.com/google/syzkaller/sys/targets" 13) 14 15type fuchsia struct{} 16 17func (fu fuchsia) build(targetArch, vmType, kernelDir, outputDir, compiler, userspaceDir, 18 cmdlineFile, sysctlFile string, config []byte) error { 19 sysTarget := targets.Get("fuchsia", targetArch) 20 if sysTarget == nil { 21 return fmt.Errorf("unsupported fuchsia arch %v", targetArch) 22 } 23 arch := sysTarget.KernelHeaderArch 24 if _, err := osutil.RunCmd(time.Hour, kernelDir, "scripts/fx", "clean-build", arch, 25 "--packages", "garnet/packages/products/sshd", "--variant", "asan"); err != nil { 26 return err 27 } 28 for src, dst := range map[string]string{ 29 "out/" + arch + "/images/fvm.blk": "image", 30 "out/" + arch + "/ssh-keys/id_ed25519": "key", 31 "out/build-zircon/build-" + arch + "/zircon.elf": "obj/zircon.elf", 32 "out/build-zircon/build-" + arch + "/multiboot.bin": "kernel", 33 "out/" + arch + "/fuchsia.zbi": "initrd", 34 } { 35 fullSrc := filepath.Join(kernelDir, filepath.FromSlash(src)) 36 fullDst := filepath.Join(outputDir, filepath.FromSlash(dst)) 37 if err := osutil.CopyFile(fullSrc, fullDst); err != nil { 38 return fmt.Errorf("faied to copy %v: %v", src, err) 39 } 40 } 41 return nil 42} 43 44func (fu fuchsia) clean(kernelDir string) error { 45 // We always do clean build because incremental build is frequently broken. 46 // So no need to clean separately. 47 return nil 48} 49