Skip to content

Commit

Permalink
Make it an error to have a cc_shared_library with no deps
Browse files Browse the repository at this point in the history
A cc_shared_library with no deps doesn't provide anything on the build graph, it would be an empty shared library file.

RELNOTES:none
PiperOrigin-RevId: 508597495
Change-Id: Ied80243500b804071b88a6df5c0fc9c8bbdd0f28
  • Loading branch information
oquenchil authored and copybara-github committed Feb 10, 2023
1 parent f29db1b commit 69d43b4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ def _get_deps(ctx):
if not len(deps):
deps = ctx.attr.roots

if len(deps) == 0:
fail(
"'cc_shared_library' must have at least one dependency in 'deps' (or 'roots')",
attr = "deps",
)

return deps

def _cc_shared_library_impl(ctx):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,3 +492,9 @@ no_exporting_static_lib_test(
name = "no_exporting_static_lib_test",
target_under_test = ":lib_with_no_exporting_roots",
)

build_failure_test(
name = "shared_library_without_deps",
message = "'cc_shared_library' must have at least one dependency in 'deps' (or 'roots')",
target_under_test = "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/failing_targets:failing_with_no_deps_so",
)
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,8 @@ cc_shared_library(
],
tags = TAGS,
)

cc_shared_library(
name = "failing_with_no_deps_so",
tags = TAGS,
)

0 comments on commit 69d43b4

Please sign in to comment.