| # 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. |
| |
| import("//build/json/validate_json.gni") |
| |
| # Generates a virtual device specification JSON from a board definition. |
| # |
| # THIS IS A TEMPORARY IMPLEMENTATION UNTIL fxbug.dev/84738 is done. |
| # |
| template("virtual_device_specification") { |
| assert(defined(invoker.name), "Device name is required.") |
| |
| not_needed(invoker, [ "name" ]) |
| |
| schema_target = "//build/sdk/meta/virtual_device-93A41932.json" |
| |
| output = "${target_gen_dir}/virtual_device.json" |
| |
| # TODO(fxbug.dev/84738): Generate a virtual device specification. |
| copy_target = "${target_name}_copy_test_file" |
| |
| # Copy a sample virtual device specification to unblock finalization of the |
| # spec. Remove this when fxbug.dev/84738 is fixed. |
| copy(copy_target) { |
| sources = |
| [ "//src/developer/ffx/plugins/emulator/testdata/device_spec.json" ] |
| outputs = [ output ] |
| metadata = { |
| images = [ |
| { |
| label = get_label_info(":$target_name", "label_with_toolchain") |
| name = "virtual_device" |
| path = rebase_path(output, root_build_dir) |
| type = "manifest" |
| }, |
| ] |
| } |
| } |
| |
| validator_target = "${target_name}_json_validator" |
| validate_json(validator_target) { |
| visibility = [ ":*" ] |
| forward_variables_from(invoker, [ "testonly" ]) |
| data = output |
| deps = [ ":${copy_target}" ] |
| schema = schema_target |
| sources = [ |
| # Included schemata. |
| "//build/sdk/meta/common.json", |
| "//build/sdk/meta/hardware-f6f47515.json", |
| "//build/sdk/meta/virtual_device-93A41932.json", |
| ] |
| allow_comments = true |
| } |
| |
| group(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| deps = [ |
| ":${copy_target}", |
| ":${validator_target}", |
| ] |
| } |
| } |