Skip to content

Commit

Permalink
Add pdb_file and def_file output groups to cc_shared_library
Browse files Browse the repository at this point in the history
This matches `cc_binary`'s behavior at https://github.com/bazelbuild/bazel/blob/d738910e83427d394526cbdfc8ac665027dd9196/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl#L828-L832

Fixes #21602

Closes #21900.

PiperOrigin-RevId: 626309605
Change-Id: I58683eaa2eedd590746e51df8c97833527c409f4
  • Loading branch information
fmeum authored and Copybara-Service committed Apr 19, 2024
1 parent 7979dd6 commit f2eb91a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ def _cc_shared_library_impl(ctx):
additional_inputs = []
additional_outputs = []
link_variables = {}
additional_output_groups = {}

pdb_file = None
if cc_common.is_enabled(feature_configuration = feature_configuration, feature_name = "generate_pdb_file"):
Expand All @@ -694,6 +695,7 @@ def _cc_shared_library_impl(ctx):
else:
pdb_file = ctx.actions.declare_file(ctx.label.name + ".pdb")
additional_outputs.append(pdb_file)
additional_output_groups["pdb_file"] = depset([pdb_file])

if cc_common.is_enabled(feature_configuration = feature_configuration, feature_name = "targets_windows"):
object_files = []
Expand All @@ -711,6 +713,7 @@ def _cc_shared_library_impl(ctx):
generated_def_file = None
if def_parser != None:
generated_def_file = cc_helper.generate_def_file(ctx, def_parser, object_files, ctx.label.name)
additional_output_groups["def_file"] = depset([generated_def_file])
custom_win_def_file = ctx.file.win_def_file
win_def_file = cc_helper.get_windows_def_file_for_linking(ctx, custom_win_def_file, generated_def_file, feature_configuration)
link_variables["def_file_path"] = win_def_file.path
Expand Down Expand Up @@ -786,6 +789,7 @@ def _cc_shared_library_impl(ctx):
OutputGroupInfo(
main_shared_library_output = depset(library),
interface_library = depset(interface_library),
**additional_output_groups
),
CcSharedLibraryInfo(
dynamic_deps = merged_cc_shared_library_info,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ def _pdb_test_impl(env, target):
matching.contains("foo_so.pdb"),
])

pdb_short_path = [f.short_path for f in target_action.outputs.to_list() if "foo_so.pdb" in f.basename]
env.expect.that_target(target).output_group("pdb_file").contains_exactly(pdb_short_path)

def _pdb_test_macro(name, target):
analysis_test(
name = name,
Expand Down

0 comments on commit f2eb91a

Please sign in to comment.