|  | # Copyright 2019 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. | 
|  |  | 
|  | ########################################## | 
|  | # Though under //zircon, this build file # | 
|  | # is meant to be used in the Fuchsia GN  # | 
|  | # build.                                 # | 
|  | # See fxbug.dev/36139.                   # | 
|  | ########################################## | 
|  |  | 
|  | assert(!defined(zx) || zx != "/", | 
|  | "This file can only be used in the Fuchsia GN build.") | 
|  |  | 
|  | import("//build/test.gni") | 
|  |  | 
|  | # The generation depends only on the source, so do it only once. | 
|  | if (current_toolchain == default_toolchain) { | 
|  | action("gen-examples") { | 
|  | visibility = [ ":examples" ] | 
|  | outputs = [ "$target_gen_dir/examples.cc" ] | 
|  | sources = [ | 
|  | # find zircon/tools/fidl/examples -type f | sed -e 's+^zircon\(.*\)$+"//zircon\1",+' | sort | 
|  | "//zircon/tools/fidl/examples/alignment.test.fidl", | 
|  | "//zircon/tools/fidl/examples/bits.test.fidl", | 
|  | "//zircon/tools/fidl/examples/empty.test.fidl", | 
|  | "//zircon/tools/fidl/examples/empty_struct.test.fidl", | 
|  | "//zircon/tools/fidl/examples/enums.test.fidl", | 
|  | "//zircon/tools/fidl/examples/errors.test.fidl", | 
|  | "//zircon/tools/fidl/examples/events.test.fidl", | 
|  | "//zircon/tools/fidl/examples/example-0.test.fidl", | 
|  | "//zircon/tools/fidl/examples/example-1.test.fidl", | 
|  | "//zircon/tools/fidl/examples/example-10.test.fidl", | 
|  | "//zircon/tools/fidl/examples/example-2.test.fidl", | 
|  | "//zircon/tools/fidl/examples/example-3.test.fidl", | 
|  | "//zircon/tools/fidl/examples/example-4.test.fidl", | 
|  | "//zircon/tools/fidl/examples/example-5.test.fidl", | 
|  | "//zircon/tools/fidl/examples/example-6.test.fidl", | 
|  | "//zircon/tools/fidl/examples/example-7.test.fidl", | 
|  | "//zircon/tools/fidl/examples/example-8.test.fidl", | 
|  | "//zircon/tools/fidl/examples/example-9.test.fidl", | 
|  | "//zircon/tools/fidl/examples/library-a/point.test.fidl", | 
|  | "//zircon/tools/fidl/examples/library-b/view.test.fidl", | 
|  | "//zircon/tools/fidl/examples/protocol-ordinals.test.fidl", | 
|  | "//zircon/tools/fidl/examples/simple.test.fidl", | 
|  | "//zircon/tools/fidl/examples/tables.test.fidl", | 
|  | "//zircon/tools/fidl/examples/test.test.fidl", | 
|  | "//zircon/tools/fidl/examples/types.test.fidl", | 
|  |  | 
|  | # manual | 
|  | "testdata/badformat.fidl.noformat", | 
|  | "testdata/doc_comments.test.fidl", | 
|  | "testdata/goodformat.test.fidl", | 
|  | ] | 
|  | script = "gen-examples.sh" | 
|  | args = rebase_path(outputs, root_build_dir) + | 
|  | rebase_path(sources, root_build_dir) | 
|  | } | 
|  |  | 
|  | action("gen-goldens") { | 
|  | visibility = [ ":goldens" ] | 
|  | outputs = [ "$target_gen_dir/goldens.cc" ] | 
|  | sources = [ | 
|  | # find zircon/tools/fidl/{testdata,goldens} -type f | sed -e 's+^zircon\(.*\)$+"//zircon\1",+' | grep -v README | grep -v regen | sort | 
|  | "//zircon/tools/fidl/goldens/bits.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/bits.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/byte_and_bytes.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/byte_and_bytes.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/constants.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/constants.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/consts.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/consts.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/doc_comments.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/doc_comments.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/empty_struct.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/empty_struct.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/enum.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/enum.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/error.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/error.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/escaping.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/escaping.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/foreign_type_in_response_used_through_compose.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/handles.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/handles.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/handles_in_types.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/handles_in_types.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/inheritance.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/inheritance.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/inheritance_with_recursive_decl.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/inheritance_with_recursive_decl.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/placement_of_attributes.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/protocol_request.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/protocol_request.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/protocols.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/protocols.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/request_flexible_envelope.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/request_flexible_envelope.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/service.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/service.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/struct.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/struct.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/struct_default_value_enum_library_reference.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/table.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/table.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/transitive_dependencies.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/transitive_dependencies_compose.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/type_aliases.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/union.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/union.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/goldens/union_sandwich.test.json.golden", | 
|  | "//zircon/tools/fidl/goldens/union_sandwich.test.tables.c.golden", | 
|  | "//zircon/tools/fidl/testdata/bits.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/byte_and_bytes.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/constants.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/consts.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/doc_comments.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/empty_struct.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/enum.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/error.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/escaping.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/foreign_type_in_response_used_through_compose/bottom.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/foreign_type_in_response_used_through_compose/middle.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/foreign_type_in_response_used_through_compose/order.txt", | 
|  | "//zircon/tools/fidl/testdata/foreign_type_in_response_used_through_compose/top.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/handles.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/handles_in_types.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/inheritance.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/inheritance_with_recursive_decl.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/placement_of_attributes/example.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/placement_of_attributes/exampleusing.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/placement_of_attributes/order.txt", | 
|  | "//zircon/tools/fidl/testdata/protocol_request.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/protocols.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/request_flexible_envelope.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/service.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/struct.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/struct_default_value_enum_library_reference/dependent.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/struct_default_value_enum_library_reference/example.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/struct_default_value_enum_library_reference/order.txt", | 
|  | "//zircon/tools/fidl/testdata/table.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/transitive_dependencies/bottom.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/transitive_dependencies/middle.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/transitive_dependencies/order.txt", | 
|  | "//zircon/tools/fidl/testdata/transitive_dependencies/top.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/transitive_dependencies_compose/bottom.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/transitive_dependencies_compose/middle.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/transitive_dependencies_compose/order.txt", | 
|  | "//zircon/tools/fidl/testdata/transitive_dependencies_compose/top.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/type_aliases/example.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/type_aliases/order.txt", | 
|  | "//zircon/tools/fidl/testdata/type_aliases/someotherlibrary.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/union.test.fidl", | 
|  | "//zircon/tools/fidl/testdata/union_sandwich.test.fidl", | 
|  | ] | 
|  | script = "gen-goldens.py" | 
|  | args = rebase_path(outputs, root_build_dir) + | 
|  | rebase_path(sources, root_build_dir) | 
|  | } | 
|  | } else { | 
|  | test("fidl-compiler") { | 
|  | if (is_fuchsia) { | 
|  | configs += [ "//build/unification/config:zircon-migrated" ] | 
|  | } | 
|  | if (is_fuchsia) { | 
|  | fdio_config = [ "//build/config/fuchsia:fdio_config" ] | 
|  | if (configs + fdio_config - fdio_config != configs) { | 
|  | configs -= fdio_config | 
|  | } | 
|  | } | 
|  | sources = [ | 
|  | "array_tests.cc", | 
|  | "attributes_tests.cc", | 
|  | "bits_tests.cc", | 
|  | "c_generator_tests.cc", | 
|  | "canonical_names_tests.cc", | 
|  | "coded_types_generator_tests.cc", | 
|  | "consts_tests.cc", | 
|  | "declaration_order_tests.cc", | 
|  | "enums_tests.cc", | 
|  | "errors_tests.cc", | 
|  | "flat_ast_tests.cc", | 
|  | "flexible_tests.cc", | 
|  | "formatter_tests.cc", | 
|  | "handle_tests.cc", | 
|  | "json_diagnostics_tests.cc", | 
|  | "json_findings_tests.cc", | 
|  | "json_generator_tests.cc", | 
|  | "lint_findings_tests.cc", | 
|  | "lint_tests.cc", | 
|  | "ordinals_tests.cc", | 
|  | "parsing_tests.cc", | 
|  | "protocol_tests.cc", | 
|  | "recoverable_compilation_tests.cc", | 
|  | "recoverable_parsing_tests.cc", | 
|  | "recursion_detector_tests.cc", | 
|  | "reporter_tests.cc", | 
|  | "resource_tests.cc", | 
|  | "resourceness_tests.cc", | 
|  | "service_tests.cc", | 
|  | "span_tests.cc", | 
|  | "strictness_tests.cc", | 
|  | "structs_tests.cc", | 
|  | "table_tests.cc", | 
|  | "tables_generator_tests.cc", | 
|  | "type_alias_tests.cc", | 
|  | "types_tests.cc", | 
|  | "typeshape_tests.cc", | 
|  | "union_tests.cc", | 
|  | "using_tests.cc", | 
|  | "utils_tests.cc", | 
|  | "virtual_source_tests.cc", | 
|  | "visitor_unittests.cc", | 
|  | ] | 
|  | deps = [ | 
|  | ":examples", | 
|  | ":goldens", | 
|  | "//third_party/boringssl", | 
|  | "//zircon/public/lib/zxtest", | 
|  | "//zircon/tools/fidl:fidl", | 
|  | ] | 
|  | } | 
|  |  | 
|  | source_set("examples") { | 
|  | gen_label = ":gen-examples($default_toolchain)" | 
|  | gen_dir = get_label_info(gen_label, "target_gen_dir") | 
|  | include_dirs = [ "." ] | 
|  | sources = [ "$gen_dir/examples.cc" ] | 
|  | deps = [ gen_label ] | 
|  | } | 
|  |  | 
|  | source_set("goldens") { | 
|  | gen_label = ":gen-goldens($default_toolchain)" | 
|  | gen_dir = get_label_info(gen_label, "target_gen_dir") | 
|  | include_dirs = [ "." ] | 
|  | sources = [ "$gen_dir/goldens.cc" ] | 
|  | deps = [ gen_label ] | 
|  | } | 
|  | } |