| # 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/fidl/toolchain.gni") |
| import("//build/testing/golden_test.gni") |
| import("//build/zircon/migrated_targets.gni") |
| import("//tools/fidl/fidlc/testdata/info.gni") |
| |
| config("fidlc_config") { |
| defines = [] |
| if (defined(fidlc_deprecate_c_unions) && fidlc_deprecate_c_unions) { |
| defines += [ "FIDLC_DEPRECATE_C_UNIONS" ] |
| } |
| } |
| |
| group("headers") { |
| public_configs = [ ":headers.config" ] |
| } |
| |
| config("headers.config") { |
| include_dirs = [ "include" ] |
| } |
| |
| zx_library("fidl") { |
| host = true |
| sdk = "source" |
| sdk_headers = [] |
| sdk_migrated = true |
| sources = [ |
| "lib/c_generator.cc", |
| "lib/check.cc", |
| "lib/coded_types_generator.cc", |
| "lib/diagnostic_types.cc", |
| "lib/diagnostics_json.cc", |
| "lib/experimental_flags.cc", |
| "lib/findings_json.cc", |
| "lib/flat_ast.cc", |
| "lib/formatter.cc", |
| "lib/json_generator.cc", |
| "lib/lexer.cc", |
| "lib/linter.cc", |
| "lib/linting_tree_callbacks.cc", |
| "lib/names.cc", |
| "lib/new_syntax_conversion.cc", |
| "lib/new_syntax_converter.cc", |
| "lib/ordinals.cc", |
| "lib/parser.cc", |
| "lib/raw_ast.cc", |
| "lib/reporter.cc", |
| "lib/source_file.cc", |
| "lib/source_manager.cc", |
| "lib/source_span.cc", |
| "lib/tables_generator.cc", |
| "lib/template_string.cc", |
| "lib/tree_visitor.cc", |
| "lib/type_shape.cc", |
| "lib/utils.cc", |
| "lib/virtual_source_file.cc", |
| ] |
| public_deps = [ |
| "//sdk/lib/fit:headers", |
| "//zircon/system/ulib/cmdline:headers", |
| "//zircon/third_party/ulib/safemath", |
| ] |
| deps = [ |
| ":json_schema", |
| "//sdk/lib/fit", |
| "//zircon/system/ulib/cmdline", |
| ] |
| deps += [ "//third_party/boringssl" ] |
| |
| configs += [ ":fidlc_config" ] |
| |
| visibility = [ |
| ":fidl-format", |
| ":fidl-lint", |
| ":fidlc", |
| "//src/tests/benchmarks/fidl/fidlc:*", |
| "//zircon/system/utest/fidl-compiler:*", |
| ] |
| } |
| |
| source_set("json_schema") { |
| visibility = [ ":*" ] |
| sources = [ "$target_gen_dir/json_schema.cc" ] |
| deps = [ |
| ":gen-json-schema", |
| ":headers", |
| ] |
| } |
| |
| action("gen-json-schema") { |
| visibility = [ ":json_schema" ] |
| outputs = [ "$target_gen_dir/json_schema.cc" ] |
| sources = [ "schema.json" ] |
| script = "gen-json-schema.sh" |
| args = rebase_path(outputs, root_build_dir) + |
| rebase_path(sources, root_build_dir) |
| } |
| |
| group("host") { |
| if (current_os != "fuchsia") { |
| deps = [ ":fidlc" ] |
| } |
| } |
| |
| if (current_os != "fuchsia") { |
| zx_host_tool("fidlc") { |
| sources = [ "compiler/main.cc" ] |
| deps = [ ":fidl" ] |
| sdk_migrated = true |
| } |
| |
| zx_host_tool("fidl-format") { |
| sources = [ "formatter/main.cc" ] |
| deps = [ ":fidl" ] |
| sdk_migrated = true |
| } |
| |
| zx_host_tool("fidl-lint") { |
| sources = [ |
| "linter/command_line_options.cc", |
| "linter/main.cc", |
| ] |
| deps = [ ":fidl" ] |
| sdk_migrated = true |
| } |
| } |
| |
| if (is_host) { |
| golden_test("fidlc_golden_tests") { |
| goldens_dir = "goldens" |
| deps = [] |
| entries = [] |
| foreach(info, fidl_testdata_info) { |
| deps += [ "${info.target}($fidl_toolchain)" ] |
| entries += [ |
| { |
| golden = "${info.name}.json.golden" |
| generated = "${info.fidl_gen_dir}/${info.target_name}.fidl.json" |
| }, |
| { |
| golden = "${info.name}.tables.c.golden" |
| generated = "${info.fidl_gen_dir}/${info.target_name}.fidl.tables.c" |
| }, |
| ] |
| } |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ ":fidlc_golden_tests($host_toolchain)" ] |
| } |