blob: 36b5af75d66b6476dd189898d3d690fe5e1f19b8 [file] [log] [blame]
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package testsharder
import (
"go.fuchsia.dev/fuchsia/tools/build"
)
// AddImageDeps selects and adds the subset of images needed by a shard to
// that shard's list of dependencies.
func AddImageDeps(s *Shard, images []build.Image, pave bool) {
imageDeps := []string{"images.json"}
for _, image := range images {
if isUsedForTesting(s, image, pave) {
imageDeps = append(imageDeps, image.Path)
}
}
s.AddDeps(imageDeps)
}
func isUsedForTesting(s *Shard, image build.Image, pave bool) bool {
if s.Env.IsEmu {
// This provisions the images used by EMU targets in botanist:
// https://cs.opensource.google/fuchsia/fuchsia/+/master:tools/botanist/target/qemu.go?q=zbi_zircon
return image.Name == "qemu-kernel" || image.Name == "storage-full" || image.Name == "zircon-a"
}
return (pave && len(image.PaveArgs) != 0) || (!pave && len(image.NetbootArgs) != 0)
}