| # 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/compiled_action.gni") |
| import("//build/host.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//build/rust/rustc_test.gni") |
| import("//build/testing/golden_files.gni") |
| import("//tools/fidl/fidlc/testdata/info.gni") |
| |
| if (is_host) { |
| copy("fidldoc_copy_config") { |
| sources = [ "src/fidldoc.config.json" ] |
| outputs = [ "${host_tools_dir}/fidldoc.config.json" ] |
| } |
| |
| fidl_testdata_info_filtered = [] |
| foreach(info, fidl_testdata_info) { |
| if (info.denylist + [ "fidldoc" ] - [ "fidldoc" ] == info.denylist) { |
| fidl_testdata_info_filtered += [ info ] |
| } |
| } |
| |
| compiled_action("generate_goldens") { |
| testonly = true |
| tool = "//build/bazel/host:bazel_root_host_tools.fidldoc" |
| tool_output_name = "fidldoc" |
| deps = [ ":fidldoc_copy_config" ] |
| sources = [] |
| inputs = [ "${host_tools_dir}/fidldoc.config.json" ] |
| args = [ |
| "--silent", |
| "--config", |
| rebase_path("${host_tools_dir}/fidldoc.config.json", root_build_dir), |
| "--out", |
| rebase_path("${target_gen_dir}/goldens", root_build_dir), |
| ] |
| outputs = [ |
| "$target_gen_dir/goldens/_toc.yaml", |
| "$target_gen_dir/goldens/README.md", |
| "$target_gen_dir/goldens/style.css", |
| ] |
| foreach(info, fidl_testdata_info_filtered) { |
| deps += [ "${info.target}($fidl_toolchain)" ] |
| json_ir = "${info.fidl_gen_dir}/${info.target_name}.fidl.json" |
| sources += [ json_ir ] |
| args += [ rebase_path(json_ir, root_build_dir) ] |
| outputs += [ "$target_gen_dir/goldens/${info.library}/README.md" ] |
| } |
| } |
| |
| golden_files("fidldoc_golden_tests") { |
| testonly = true |
| deps = [ ":generate_goldens" ] |
| comparisons = [ |
| { |
| golden = "goldens/_toc.yaml.golden" |
| candidate = "$target_gen_dir/goldens/_toc.yaml" |
| }, |
| { |
| golden = "goldens/README.md.golden" |
| candidate = "$target_gen_dir/goldens/README.md" |
| }, |
| { |
| golden = "goldens/style.css.golden" |
| candidate = "$target_gen_dir/goldens/style.css" |
| }, |
| ] |
| foreach(info, fidl_testdata_info_filtered) { |
| comparisons += [ |
| { |
| golden = "goldens/${info.name}.md.golden" |
| candidate = "$target_gen_dir/goldens/${info.library}/README.md" |
| }, |
| ] |
| } |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":fidldoc_bin_test($host_toolchain)", |
| ":fidldoc_golden_tests($host_toolchain)", |
| ] |
| } |
| |
| ## BAZEL2GN SENTINEL - DO NOT EDIT BELOW THIS LINE ## |
| # |
| # ________ _________ ________ ________ |
| # |\ ____\|\___ ___\\ __ \|\ __ \ |
| # \ \ \___|\|___ \ \_\ \ \|\ \ \ \|\ \ |
| # \ \_____ \ \ \ \ \ \ \\\ \ \ ____\ |
| # \|____|\ \ \ \ \ \ \ \\\ \ \ \___| |
| # ____\_\ \ \ \__\ \ \_______\ \__\ |
| # |\_________\ \|__| \|_______|\|__| |
| # \|_________| |
| # |
| # |
| # AUTO-GENERATED - DO NOT EDIT |
| # |
| # The targets below are auto-generated based on the targets defined in the |
| # BUILD.bazel file from the same directory. If you made changes to targets in |
| # Bazel, instead of editing this file manually, run: |
| # |
| # > fx bazel2gn |
| # |
| # Please do NOT edit this file directly. Instead, edit the BUILD.bazel file and |
| # rerun bazel2gn. |
| |
| import("//build/tools/bazel2gn/bazel_migration.gni") |
| |
| # A self-verification target for generated content in this file. |
| if (is_host) { |
| verify_bazel2gn("verify_bazel2gn") { |
| } |
| } |
| |
| common_sources = [ |
| "src/fidljson.rs", |
| "src/main.rs", |
| "src/templates/markdown/mod.rs", |
| "src/templates/mod.rs", |
| ] |
| |
| # To avoid "Assignment had no effect" from GN. |
| # It's possible this variable is only used in if conditions (e.g. is_host). |
| not_needed([ "common_sources" ]) |
| |
| common_compile_data = [ |
| "src/templates/markdown/partials/header.hbs", |
| "src/templates/markdown/partials/types/filename.hbs", |
| "src/templates/markdown/library.hbs", |
| "src/templates/markdown/partials/header_dir.hbs", |
| "src/templates/markdown/partials/declarations/tables.hbs", |
| "src/templates/markdown/partials/declarations/enums.hbs", |
| "src/templates/markdown/partials/declarations/constants.hbs", |
| "src/templates/markdown/partials/declarations/aliases.hbs", |
| "src/templates/markdown/partials/declarations/protocols.hbs", |
| "src/templates/markdown/partials/types/doc.hbs", |
| "src/templates/markdown/partials/declarations/bits.hbs", |
| "src/templates/markdown/partials/declarations/unions.hbs", |
| "src/templates/markdown/partials/declarations/services.hbs", |
| "src/templates/markdown/main.hbs", |
| "src/templates/markdown/toc.hbs", |
| "src/templates/markdown/partials/types/type.hbs", |
| "src/templates/markdown/partials/declarations/structs.hbs", |
| "src/templates/markdown/style.css", |
| ] |
| |
| # To avoid "Assignment had no effect" from GN. |
| # It's possible this variable is only used in if conditions (e.g. is_host). |
| not_needed([ "common_compile_data" ]) |
| |
| common_deps = [ |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:argh", |
| "//third_party/rust_crates:handlebars", |
| "//third_party/rust_crates:heck", |
| "//third_party/rust_crates:log", |
| "//third_party/rust_crates:pulldown-cmark", |
| "//third_party/rust_crates:rayon", |
| "//third_party/rust_crates:regex", |
| "//third_party/rust_crates:serde", |
| "//third_party/rust_crates:serde_json", |
| "//third_party/rust_crates:simplelog", |
| ] |
| |
| # To avoid "Assignment had no effect" from GN. |
| # It's possible this variable is only used in if conditions (e.g. is_host). |
| not_needed([ "common_deps" ]) |
| |
| if (is_host) { |
| rustc_test("fidldoc_bin_test") { |
| testonly = true |
| sources = common_sources |
| inputs = common_compile_data + [ |
| "src/templates/markdown/testdata/README.md", |
| "src/templates/markdown/testdata/_toc.yaml", |
| "src/fidldoc.config.json", |
| ] |
| source_root = "src/main.rs" |
| edition = "2024" |
| deps = common_deps + [ "//third_party/rust_crates:tempfile" ] |
| } |
| } |