Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions elisp/elisp_cc_module.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2025 Google LLC
# Copyright 2020-2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,6 +47,10 @@ def _elisp_cc_module_impl(ctx):
local_defines = defaults.defines + ctx.attr.local_defines,
user_compile_flags = defaults.copts + ctx.attr.copts,
)

# Ensure that the library file has the expected name.
filename = ctx.label.name + config.suffix
lib = ctx.actions.declare_file(filename)
out = cc_common.link(
name = ctx.label.name,
actions = ctx.actions,
Expand All @@ -55,24 +59,13 @@ def _elisp_cc_module_impl(ctx):
compilation_outputs = objs,
linking_contexts = [info.linking_context for info in infos],
output_type = "dynamic_library",
main_output = lib,
user_link_flags = defaults.linkopts + ctx.attr.linkopts,
additional_inputs = config.additional_linker_inputs,
)
if not (out.library_to_link and out.library_to_link.dynamic_library):
fail("linking Emacs module didn’t produce a dynamic library")

# Ensure that the library file has the expected name.
filename = ctx.label.name + config.suffix
if out.library_to_link.dynamic_library.basename == filename:
lib = out.library_to_link.dynamic_library
else:
lib = ctx.actions.declare_file(filename)
ctx.actions.symlink(
output = lib,
target_file = out.library_to_link.dynamic_library,
progress_message = "Creating symbolic link " + lib.short_path,
)

# Replicate some implementation details of cc_binary to make coverage work,
# at least with llvm-cov. See
# https://github.com/bazelbuild/bazel/issues/15974.
Expand Down
Loading