Skip to content

Commit fafce8a

Browse files
committed

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

cc/common/cc_helper.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def _libraries_from_linking_context(linking_context):
6868
def _is_valid_shared_library_name(shared_library_name):
6969
if (shared_library_name.endswith(".so") or
7070
shared_library_name.endswith(".dll") or
71+
shared_library_name.endswith(".pyd") or
7172
shared_library_name.endswith(".dylib") or
7273
shared_library_name.endswith(".wasm")):
7374
return True
@@ -512,7 +513,7 @@ def _get_toolchain_global_make_variables(cc_toolchain):
512513
result["CROSSTOOLTOP"] = cc_toolchain._crosstool_top_path
513514
return result
514515

515-
_SHARED_LIBRARY_EXTENSIONS = ["so", "dll", "dylib", "wasm"]
516+
_SHARED_LIBRARY_EXTENSIONS = ["so", "dll", "pyd", "dylib", "wasm"]
516517

517518
def _is_valid_shared_library_artifact(shared_library):
518519
if (shared_library.extension in _SHARED_LIBRARY_EXTENSIONS):

cc/common/cc_helper_internal.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ _ARCHIVE = [".a", ".lib"]
9696
_PIC_ARCHIVE = [".pic.a"]
9797
_ALWAYSLINK_LIBRARY = [".lo"]
9898
_ALWAYSLINK_PIC_LIBRARY = [".pic.lo"]
99-
_SHARED_LIBRARY = [".so", ".dylib", ".dll", ".wasm"]
99+
_SHARED_LIBRARY = [".so", ".dylib", ".dll", ".pyd", ".wasm"]
100100
_INTERFACE_SHARED_LIBRARY = [".ifso", ".tbd", ".lib", ".dll.a"]
101101
_OBJECT_FILE = [".o", ".obj"]
102102
_PIC_OBJECT_FILE = [".pic.o"]
@@ -170,7 +170,7 @@ _ArtifactCategoryInfo, _unused_new_aci = provider(
170170
_artifact_categories = [
171171
_ArtifactCategoryInfo("STATIC_LIBRARY", "lib", ".a", ".lib"),
172172
_ArtifactCategoryInfo("ALWAYSLINK_STATIC_LIBRARY", "lib", ".lo", ".lo.lib"),
173-
_ArtifactCategoryInfo("DYNAMIC_LIBRARY", "lib", ".so", ".dylib", ".dll", ".wasm"),
173+
_ArtifactCategoryInfo("DYNAMIC_LIBRARY", "lib", ".so", ".dylib", ".dll", ".pyd", ".wasm"),
174174
_ArtifactCategoryInfo("EXECUTABLE", "", "", ".exe", ".wasm"),
175175
_ArtifactCategoryInfo("INTERFACE_LIBRARY", "lib", ".ifso", ".tbd", ".if.lib", ".lib"),
176176
_ArtifactCategoryInfo("PIC_FILE", "", ".pic"),

cc/private/link/create_libraries_to_link_values.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,12 @@ def _add_dynamic_library_to_link(
286286
# -l:libfoo.so.1 -> libfoo.so.1
287287
has_compatible_name = (
288288
name.startswith("lib") or
289-
(not name.endswith(".so") and not name.endswith(".dylib") and not name.endswith(".dll"))
289+
(not name.endswith(".so") and not name.endswith(".dylib") and \
290+
not name.endswith(".dll") and not name.endswith(".pyd"))
290291
)
291292
if shared_library and has_compatible_name:
292293
lib_name = name.removeprefix("lib").removesuffix(".so").removesuffix(".dylib") \
293-
.removesuffix(".dll")
294+
.removesuffix(".dll").removesuffix(".pyd")
294295
libraries_to_link_values.append(
295296
_NamedLibraryInfo(
296297
type = _TYPE.DYNAMIC_LIBRARY,

cc/private/rules_impl/cc_binary.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def _create_transitive_linking_actions(
331331
# entries during linking process.
332332
for libs in precompiled_files[:]:
333333
for artifact in libs:
334-
if _matches([".so", ".dylib", ".dll", ".ifso", ".tbd", ".lib", ".dll.a"], artifact.basename) or cc_helper.is_valid_shared_library_artifact(artifact):
334+
if _matches([".so", ".dylib", ".dll", ".pyd", ".ifso", ".tbd", ".lib", ".dll.a"], artifact.basename) or cc_helper.is_valid_shared_library_artifact(artifact):
335335
library_to_link = cc_common.create_library_to_link(
336336
actions = ctx.actions,
337337
feature_configuration = feature_configuration,
@@ -477,7 +477,7 @@ def cc_binary_impl(ctx, additional_linkopts, force_linkstatic = False):
477477
# the target name.
478478
# This is no longer necessary, the toolchain can figure out the correct file extensions.
479479
target_name = ctx.label.name
480-
has_legacy_link_shared_name = _is_link_shared(ctx) and (_matches([".so", ".dylib", ".dll"], target_name) or cc_helper.is_valid_shared_library_name(target_name))
480+
has_legacy_link_shared_name = _is_link_shared(ctx) and (_matches([".so", ".dylib", ".dll", ".pyd"], target_name) or cc_helper.is_valid_shared_library_name(target_name))
481481
binary = None
482482
is_dbg_build = (cc_toolchain._cpp_configuration.compilation_mode() == "dbg")
483483
if has_legacy_link_shared_name:

cc/private/toolchain/windows_cc_toolchain_config.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ def _impl(ctx):
120120
prefix = "",
121121
extension = ".dll",
122122
),
123+
artifact_name_pattern(
124+
category_name = "dynamic_library",
125+
prefix = "",
126+
extension = ".pyd",
127+
),
123128
artifact_name_pattern(
124129
category_name = "interface_library",
125130
prefix = "",

0 commit comments

Comments
 (0)