blob: e83d4e85e327571f6b5f1e0d50f7aee830990f65 [file]
# 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/fidl/toolchain.gni")
# Exposes a `fidlgen_tests` variable describing all the available libraries to
# test fidlgen_banjo.
# Single-file libraries.
_simple_libraries = [
{
name = "alias"
backends = [ "c" ]
},
{
name = "alignment"
backends = [
"c",
"rust",
]
},
{
name = "api"
backends = [ "c" ]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "attributes"
backends = [
"c",
"rust",
]
},
# Note: badtypes verifies that the banjo parser correctly fails.
{
name = "binary"
backends = [ "c" ]
},
{
name = "buffer"
backends = [
"c",
"cpp",
]
},
{
name = "callback"
backends = [
"c",
"cpp",
"cpp_internal",
]
deps = [
":callback2",
"//zircon/vdso/zx",
]
},
{
name = "callback2"
backends = [
"c",
"cpp",
"cpp_internal",
]
},
{
name = "constants"
backends = [ "c" ]
},
{
name = "empty"
backends = [
"c",
"cpp",
"cpp_internal",
"rust",
]
},
{
name = "enums"
backends = [
"c",
"rust",
]
},
{
name = "example0"
backends = [
"c",
"rust",
]
},
{
name = "example1"
backends = [
"c",
"rust",
]
},
{
name = "example2"
backends = [
"c",
"rust",
]
},
{
name = "example3"
backends = [
"c",
"rust",
]
},
{
name = "example4"
backends = [
"c",
"cpp",
"cpp_internal",
"rust",
]
},
{
name = "example6"
backends = [
"c",
"cpp",
"cpp_internal",
"rust",
]
},
{
name = "example7"
backends = [
"c",
"cpp",
"cpp_internal",
"rust",
]
},
{
name = "example8"
backends = [
"c",
"rust",
]
},
{
name = "example9"
backends = [
"c",
"cpp",
"cpp_internal",
"rust",
]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "fidlhandle"
backends = [ "c" ]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "handles"
backends = [
"c",
"cpp",
"cpp_internal",
]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "interface"
backends = [
"c",
"cpp",
"cpp_internal",
"cpp_mock",
]
deps = [ "//zircon/vdso/zx" ]
},
# Note: libraryparts is omitted as FIDL supports libraries across multiple files.
{
name = "order"
backends = [ "c" ]
},
{
name = "order1"
backends = [ "c" ]
},
{
name = "order2"
backends = [ "c" ]
},
{
name = "order3"
backends = [ "c" ]
},
{
name = "order4"
backends = [ "c" ]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "order5"
backends = [ "c" ]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "order6"
backends = [ "c" ]
deps = [ ":order7" ]
},
{
name = "order7"
backends = []
},
# Note: parameterattributes is an AST-only test, the tested feature is supported by FIDL.
{
name = "passcallback"
backends = [
"c",
"cpp_mock",
]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "point"
backends = [
"c",
"rust",
]
},
{
name = "preservenames"
backends = [ "c" ]
},
{
name = "protocolarray"
backends = [
"c",
"cpp",
"cpp_internal",
"cpp_mock",
]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "protocolbase"
backends = [
"c",
"cpp",
"cpp_internal",
"cpp_mock",
]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "protocolhandle"
backends = [
"c",
"cpp",
"cpp_internal",
"cpp_mock",
]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "protocolothertypes"
backends = [
"c",
"cpp",
"cpp_internal",
"cpp_mock",
]
},
{
name = "protocolprimitive"
backends = [
"c",
"cpp",
"cpp_internal",
"cpp_mock",
]
},
{
name = "protocolvector"
backends = [
"c",
"cpp",
"cpp_internal",
"cpp_mock",
]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "references"
backends = [
"c",
"cpp",
]
},
{
name = "rustderive"
backends = [ "rust" ]
},
{
name = "simple"
backends = [
"c",
"cpp",
"cpp_internal",
"rust",
]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "tables"
backends = [
"c",
"rust",
]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "types"
backends = [
"c",
"rust",
]
deps = [ "//zircon/vdso/zx" ]
},
{
name = "union"
backends = [ "c" ]
},
{
name = "view"
backends = [
"c",
"cpp",
"cpp_internal",
"rust",
]
deps = [ ":point" ]
},
]
_base_label = "//src/devices/tools/fidlgen_banjo/tests"
_fidl_label = "$_base_label/fidl"
_fidl_gen_dir =
get_label_info("$_fidl_label:something($fidl_toolchain)", "target_gen_dir")
fidlgen_tests = []
_enabled_libraries = []
foreach(lib, _simple_libraries) {
if (!defined(lib.disabled) || !lib.disabled) {
_enabled_libraries += [ lib ]
}
}
foreach(lib, _enabled_libraries) {
_name = lib.name
fidlgen_tests += [
{
# Nickname.
name = _name
# fidl() target name.
target = _name
# FIDL library name.
library_name = "banjo.examples.$_name"
# Label for the fidl_library target generating the IR.
dep = "$_fidl_label:$_name($fidl_toolchain)"
# List of source files.
sources = [ "$_name.test.fidl" ]
# List of library dependencies.
deps = []
if (defined(lib.deps)) {
deps += lib.deps
}
# Path to the generated IR in the output directory.
ir = "$_fidl_gen_dir/$_name.fidl.json"
# List of golden files.
goldens = []
if (lib.backends + [ "c" ] - [ "c" ] != lib.backends) {
goldens += [ "$_base_label/c/$_name.h" ]
}
if (lib.backends + [ "cpp" ] - [ "cpp" ] != lib.backends) {
goldens += [ "$_base_label/cpp/$_name.h" ]
}
if (lib.backends + [ "cpp_internal" ] - [ "cpp_internal" ] !=
lib.backends) {
goldens += [ "$_base_label/cpp/$_name-internal.h" ]
}
if (lib.backends + [ "cpp_mock" ] - [ "cpp_mock" ] != lib.backends) {
goldens += [ "$_base_label/cpp/mock-$_name.h" ]
}
if (lib.backends + [ "rust" ] - [ "rust" ] != lib.backends) {
goldens += [ "$_base_label/rust/$_name.rs" ]
}
},
]
}