| # 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("virtual_device") { |
| sources = [ |
| "aemu.go", |
| "common.go", |
| "common_test.go", |
| "qemu.go", |
| "qemu_test.go", |
| ] |
| deps = [ |
| ":proto", |
| "//third_party/golibs:github.com/google/go-cmp", |
| "//tools/build", |
| "//tools/qemu", |
| ] |
| } |
| |
| go_test("virtual_device_test") { |
| output_name = "virtual_device_test" |
| gopackages = [ "go.fuchsia.dev/fuchsia/tools/virtual_device" ] |
| deps = [ ":virtual_device" ] |
| } |
| |
| go_library("fvd_lib") { |
| source_dir = "cmd/fvd" |
| sources = [ "main.go" ] |
| deps = [ |
| ":proto", |
| ":virtual_device", |
| "//third_party/golibs:github.com/golang/protobuf", |
| "//tools/build", |
| "//tools/lib/jsonutil", |
| ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":pb_go_diff", |
| ":virtual_device_test", |
| ] |
| } |
| |
| 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), |
| "--buildinfo_cpu", |
| target_cpu, |
| ] |
| 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 |
| } |