| # 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. | 
 |  | 
 | import("//build/fidl/fidl.gni") | 
 | import("//build/test.gni") | 
 | import("//build/testing/environments.gni") | 
 | import("//src/sys/build/components.gni") | 
 | import("//third_party/protobuf/proto_library.gni") | 
 |  | 
 | static_library("fidl_codec") { | 
 |   friend = [ ":tests" ] | 
 |  | 
 |   public = [ | 
 |     "builtin_semantic.h", | 
 |     "display_handle.h", | 
 |     "display_options.h", | 
 |     "encoder.h", | 
 |     "json_visitor.h", | 
 |     "library_loader.h", | 
 |     "logger.h", | 
 |     "memory_helpers.h", | 
 |     "message_decoder.h", | 
 |     "printer.h", | 
 |     "proto_value.h", | 
 |     "semantic.h", | 
 |     "semantic_parser.h", | 
 |     "status.h", | 
 |     "type_visitor.h", | 
 |     "visitor.h", | 
 |     "wire_object.h", | 
 |     "wire_parser.h", | 
 |     "wire_types.h", | 
 |   ] | 
 |  | 
 |   sources = [ | 
 |     "builtin_semantic.cc", | 
 |     "display_handle.cc", | 
 |     "encoder.cc", | 
 |     "library_loader.cc", | 
 |     "logger.cc", | 
 |     "message_decoder.cc", | 
 |     "printer.cc", | 
 |     "proto_value.cc", | 
 |     "semantic.cc", | 
 |     "semantic_parser.cc", | 
 |     "status.cc", | 
 |     "wire_object.cc", | 
 |     "wire_parser.cc", | 
 |     "wire_types.cc", | 
 |   ] | 
 |  | 
 |   public_deps = [ "//src/lib/fxl" ] | 
 |   deps = [ | 
 |     ":value_proto", | 
 |     "//zircon/public/lib/fidl_base", | 
 |     "//zircon/system/public", | 
 |  | 
 |     # TODO(fxbug.dev/57392): Move it back to //third_party once unification completes. | 
 |     "//zircon/third_party/rapidjson", | 
 |   ] | 
 |  | 
 |   # TODO(fxbug.dev/58162): delete the below and fix compiler warnings | 
 |   configs += [ "//build/config:Wno-conversion" ] | 
 | } | 
 |  | 
 | proto_library("value_proto") { | 
 |   proto_in_dir = "//" | 
 |  | 
 |   sources = [ "//src/lib/fidl_codec/proto/value.proto" ] | 
 |  | 
 |   generate_python = false | 
 |  | 
 |   deps = [ "//third_party/protobuf:protobuf_full" ] | 
 | } | 
 |  | 
 | executable("fidl_codec_test_bin") { | 
 |   testonly = true | 
 |   sources = [ | 
 |     "builtin_semantic_test.cc", | 
 |     "dispatcher_test.cc", | 
 |     "library_loader_test.cc", | 
 |     "message_decoder_test.cc", | 
 |     "printer_test.cc", | 
 |     "proto_test.cc", | 
 |     "semantic_parser_test.cc", | 
 |     "wire_object_test.cc", | 
 |     "wire_parser_test.cc", | 
 |     "wire_types_test.cc", | 
 |   ] | 
 |  | 
 |   deps = [ | 
 |     ":fidl", | 
 |     ":fidl_codec", | 
 |     ":json_for_test", | 
 |     ":list_for_test", | 
 |     ":value_proto", | 
 |     "//sdk/fidl/fuchsia.sys", | 
 |     "//sdk/lib/fidl/cpp:test_support", | 
 |     "//sdk/lib/fidl/cpp/test", | 
 |     "//src/lib/fxl/test:gtest_main", | 
 |     "//third_party/googletest:gmock", | 
 |     "//third_party/googletest:gtest", | 
 |     "//zircon/system/ulib/async-loop:async-loop-cpp", | 
 |     "//zircon/system/ulib/async-loop:async-loop-default", | 
 |  | 
 |     # TODO(fxbug.dev/57392): Move it back to //third_party once unification completes. | 
 |     "//zircon/third_party/rapidjson", | 
 |   ] | 
 | } | 
 |  | 
 | fuchsia_unittest_package("fidl-codec-tests") { | 
 |   deps = [ ":fidl_codec_test_bin" ] | 
 |   executable_path = "bin/fidl_codec_test_bin" | 
 | } | 
 |  | 
 | group("tests") { | 
 |   testonly = true | 
 |  | 
 |   deps = [ ":fidl-codec-tests" ] | 
 | } | 
 |  | 
 | action("json_for_test") { | 
 |   deps = [ | 
 |     ":fidl($fidl_toolchain)", | 
 |     ":fidl-composed($fidl_toolchain)", | 
 |     ":fidl-sys($fidl_toolchain)", | 
 |     "//sdk/fidl/fuchsia.io", | 
 |     "//sdk/fidl/fuchsia.sys", | 
 |     "//sdk/lib/fidl/cpp/test:frobinator", | 
 |   ] | 
 |   outputs = [ "$target_gen_dir/library_loader_test_data.h" ] | 
 |   script = "generate_test_includes.sh" | 
 |   args = [ | 
 |     rebase_path(target_gen_dir, root_build_dir) + "/library_loader_test_data.h", | 
 |     "FidlcodecExamples", | 
 |     rebase_path(root_build_dir) + | 
 |         "/fidling/gen/sdk/lib/fidl/cpp/test/frobinator.fidl.json", | 
 |     rebase_path(root_build_dir) + | 
 |         "/fidling/gen/sdk/fidl/fuchsia.io/fuchsia.io.fidl.json", | 
 |     rebase_path(root_build_dir) + | 
 |         "/fidling/gen/src/lib/fidl_codec/fidl.fidl.json", | 
 |     rebase_path(root_build_dir) + | 
 |         "/fidling/gen/src/lib/fidl_codec/fidl-composed.fidl.json", | 
 |     rebase_path(root_build_dir) + | 
 |         "/fidling/gen/src/lib/fidl_codec/fidl-sys.fidl.json", | 
 |   ] | 
 | } | 
 |  | 
 | action("list_for_test") { | 
 |   testonly = true | 
 |   deps = [ "//sdk:core_fidl_json" ] | 
 |   outputs = [ "$target_gen_dir/list_test_data.h" ] | 
 |   script = "generate_test_includes.sh" | 
 |   args = [ | 
 |     rebase_path(target_gen_dir, root_build_dir) + "/list_test_data.h", | 
 |     "SdkExamples", | 
 |     "-content", | 
 |     rebase_path(root_build_dir) + "/gen/sdk/core.fidl_json.txt", | 
 |   ] | 
 | } | 
 |  | 
 | fidl("fidl") { | 
 |   name = "test.fidlcodec.examples" | 
 |  | 
 |   sources = [ | 
 |     "testdata/empty.test.fidl", | 
 |     "testdata/reserved_member.test.fidl", | 
 |     "testdata/types.test.fidl", | 
 |     "testdata/xunionmigration.fidl", | 
 |   ] | 
 |  | 
 |   public_deps = [ "//zircon/vdso/zx" ] | 
 | } | 
 |  | 
 | fidl("fidl-composed") { | 
 |   name = "test.fidlcodec.composedinto" | 
 |  | 
 |   sources = [ "testdata/composed_into.test.fidl" ] | 
 |  | 
 |   public_deps = [ ":fidl" ] | 
 | } | 
 |  | 
 | fidl("fidl-sys") { | 
 |   name = "test.fidlcodec.sys" | 
 |  | 
 |   sources = [ "testdata/sys.test.fidl" ] | 
 |  | 
 |   public_deps = [ "//zircon/vdso/zx" ] | 
 | } |