blob: 66328e98d37d080156b9f6e6411e500bfe2fd664 [file] [log] [blame]
# Copyright 2020 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.
import("//build/go/go_binary.gni")
import("//build/go/go_library.gni")
import("//build/go/go_test.gni")
import("//build/testing/golden_file.gni")
import("//third_party/protobuf/proto_library.gni")
go_library("fvd_lib") {
source_dir = "cmd/fvd"
sources = [
"main.go",
"main_test.go",
]
deps = [
":proto",
"//third_party/golibs:github.com/golang/protobuf",
"//third_party/golibs:github.com/google/go-cmp",
"//third_party/golibs:google.golang.org/protobuf",
]
}
go_test("fvd_test") {
output_name = "fvd_test"
gopackages = [ "go.fuchsia.dev/fuchsia/tools/virtual_device/cmd/fvd" ]
deps = [ ":fvd_lib" ]
}
group("tests") {
testonly = true
deps = [
":fvd_test",
":pb_go_diff",
]
}
go_binary("fvd") {
gopackage = "go.fuchsia.dev/fuchsia/tools/virtual_device/cmd/fvd"
deps = [ ":fvd_lib" ]
}
# Generates $root_build_dir/default.fvd.
action("default") {
script = "$host_out_dir/fvd"
outputs = [ "$root_build_dir/default.fvd" ]
args = [
# images.json is built before this target even though it is not a dep.
"--images_json",
rebase_path("$root_build_dir/images.json", root_build_dir),
"--output",
rebase_path(outputs[0], root_build_dir),
"--name",
"default",
]
deps = [ ":fvd($host_toolchain)" ]
}
proto_library("proto_lib") {
sources = [ "proto/virtual_device.proto" ]
generate_cc = false
generate_go = true
generate_python = false
}
go_library("proto") {
name = "go.fuchsia.dev/fuchsia/tools/virtual_device/proto"
source_dir = "$root_gen_dir/go-proto-gen/src/tools/virtual_device/proto"
sources = [ "virtual_device.pb.go" ]
deps = [ "//third_party/golibs:github.com/golang/protobuf" ]
non_go_deps = [ ":proto_lib" ]
}
# We keep a checked-in copy of the generated .pb.go file so that regular Go
# toolchain commands work with this code. So make sure the generated file stays
# up to date with the source-of-truth .proto file.
golden_file("pb_go_diff") {
current = "$root_gen_dir/go-proto-gen/src/tools/virtual_device/proto/virtual_device.pb.go"
golden = "proto/virtual_device.pb.go"
deps = [ ":proto_lib_gen" ]
warn_on_changes = false
}