diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index f227fc0..c0dcbbd 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -48,9 +48,10 @@ tasks: <<: *common examples: platform: ubuntu1804 - bazel: last_downstream_green + bazel: last_green build_targets: - "//examples/test_cc_shared_library/..." + - "//examples/test_cc_shared_library/diamond_inheritance/..." build_flags: - "--experimental_cc_shared_library" - "--//examples:incompatible_link_once=True" @@ -60,3 +61,4 @@ tasks: - "--//examples:incompatible_link_once=True" test_targets: - "//examples/test_cc_shared_library/..." + - "//examples/test_cc_shared_library/diamond_inheritance/..." 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..7b83574 --- /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", + permissions = [ + "//examples/test_cc_shared_library:permissions", + ], + roots = ["//examples/test_cc_shared_library:a_suffix"], +) + +cc_shared_library( + name = "qux_so", + dynamic_deps = [":baz_so"], + permissions = [ + "//examples/test_cc_shared_library:permissions", + ], + roots = ["//examples/test_cc_shared_library:qux"], +) + +cc_shared_library( + name = "qux2_so", + dynamic_deps = [":baz_so"], + permissions = [ + "//examples/test_cc_shared_library:permissions", + ], + roots = ["//examples/test_cc_shared_library:qux2"], +) + +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; +}