Test allowing diamond inheritance of shared lib

This commit is contained in:
John Laxson 2021-02-09 08:56:55 -07:00
parent 40548a2974
commit 8caeb338c9
3 changed files with 59 additions and 1 deletions

View File

@ -1,6 +1,6 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") 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") load(":starlark_tests.bzl", "additional_inputs_test", "build_failure_test", "linking_suffix_test", "paths_test")
package( package(
@ -202,3 +202,13 @@ bzl_library(
srcs = ["starlark_tests.bzl"], srcs = ["starlark_tests.bzl"],
visibility = ["//visibility:private"], 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__"],
)

View File

@ -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"
]
)

View File

@ -0,0 +1,8 @@
#include <iostream>
#include "examples/test_cc_shared_library/a_suffix.h"
int main() {
std::cout << "hello " << a_suffix() << std::endl;
return 0;
}