From 8caeb338c90cfeeb68effcbc2733cdf66c5430c2 Mon Sep 17 00:00:00 2001 From: John Laxson Date: Tue, 9 Feb 2021 08:56:55 -0700 Subject: [PATCH] Test allowing diamond inheritance of shared lib --- examples/test_cc_shared_library/BUILD | 12 +++++- .../diamond_inheritance/BUILD | 40 +++++++++++++++++++ .../diamond_inheritance/main.cc | 8 ++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 examples/test_cc_shared_library/diamond_inheritance/BUILD create mode 100644 examples/test_cc_shared_library/diamond_inheritance/main.cc diff --git a/examples/test_cc_shared_library/BUILD b/examples/test_cc_shared_library/BUILD index 5f3d03b..9c3acda 100644 --- a/examples/test_cc_shared_library/BUILD +++ b/examples/test_cc_shared_library/BUILD @@ -1,6 +1,6 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") -load("//examples:experimental_cc_shared_library.bzl", "LINKABLE_MORE_THAN_ONCE", "cc_shared_library") +load("//examples:experimental_cc_shared_library.bzl", "LINKABLE_MORE_THAN_ONCE", "cc_shared_library", "cc_shared_library_permissions") load(":starlark_tests.bzl", "additional_inputs_test", "build_failure_test", "linking_suffix_test", "paths_test") package( @@ -202,3 +202,13 @@ bzl_library( srcs = ["starlark_tests.bzl"], visibility = ["//visibility:private"], ) + +cc_shared_library_permissions( + name = "permissions", + targets = [ + "//examples/test_cc_shared_library:a_suffix", + "//examples/test_cc_shared_library:qux", + "//examples/test_cc_shared_library:qux2", + ], + visibility = ["//examples/test_cc_shared_library/diamond_inheritance:__pkg__"], +) diff --git a/examples/test_cc_shared_library/diamond_inheritance/BUILD b/examples/test_cc_shared_library/diamond_inheritance/BUILD new file mode 100644 index 0000000..10cf38d --- /dev/null +++ b/examples/test_cc_shared_library/diamond_inheritance/BUILD @@ -0,0 +1,40 @@ +load("//cc:defs.bzl", "cc_binary") +load("//examples:experimental_cc_shared_library.bzl", "cc_shared_library") + +cc_shared_library( + name = "baz_so", + roots = ["//examples/test_cc_shared_library:a_suffix"], + permissions = [ + "//examples/test_cc_shared_library:permissions", + ], +) + +cc_shared_library( + name = "qux_so", + dynamic_deps = [":baz_so"], + roots = ["//examples/test_cc_shared_library:qux"], + permissions = [ + "//examples/test_cc_shared_library:permissions", + ], +) + +cc_shared_library( + name = "qux2_so", + dynamic_deps = [":baz_so"], + roots = ["//examples/test_cc_shared_library:qux2"], + permissions = [ + "//examples/test_cc_shared_library:permissions", + ], +) + +cc_binary( + name = "diamond_inheritance", + srcs = ["main.cc"], + dynamic_deps = [ + ":qux_so", + ":qux2_so", + ], + deps = [ + "//examples/test_cc_shared_library:a_suffix" + ] +) diff --git a/examples/test_cc_shared_library/diamond_inheritance/main.cc b/examples/test_cc_shared_library/diamond_inheritance/main.cc new file mode 100644 index 0000000..18e4366 --- /dev/null +++ b/examples/test_cc_shared_library/diamond_inheritance/main.cc @@ -0,0 +1,8 @@ +#include + +#include "examples/test_cc_shared_library/a_suffix.h" + +int main() { + std::cout << "hello " << a_suffix() << std::endl; + return 0; +}