CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
76 lines
2.9 KiB
Python
76 lines
2.9 KiB
Python
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
"""A macro to produce a loadable plugin library for the target OS.
|
|
|
|
This macro produces a set of platform-specific `cc_binary` rules, by appending
|
|
the platform suffix (`.dll`, `.dylib`, or `.so`) to the provided `name`. It then
|
|
connects these to a `cc_import` rule with `name` exactly and `hdrs` that can be
|
|
used by other Bazel rules to depend on the plugin library.
|
|
|
|
The `srcs` attribute for the `cc_binary` rules is `srcs + hdrs`. Other explicit
|
|
arguments are passed to all of the rules where they apply, and can be used to
|
|
configure generic aspects of all generated rules such as `testonly`. Lastly,
|
|
`kwargs` is expanded into all the `cc_binary` rules.
|
|
"""
|
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_import", "cc_library")
|
|
|
|
def cc_plugin_library(name, srcs, hdrs, include_prefix = None, strip_include_prefix = None, alwayslink = False, features = [], tags = [], testonly = False, **kwargs):
|
|
# Neither the name of the plugin binary nor tags on whether it is built are
|
|
# configurable. Instead, we build a `cc_binary` with each name and
|
|
# selectively depend on them based on platform.
|
|
#
|
|
# All-in-all, this is a pretty poor workaround. I think this is part of the
|
|
# Bazel issue: https://github.com/bazelbuild/bazel/issues/7538
|
|
so_name = name + ".so"
|
|
dll_name = name + ".dll"
|
|
dylib_name = name + ".dylib"
|
|
interface_output_name = name + "_interface_output"
|
|
import_name = name + "_import"
|
|
for impl_name in [dll_name, dylib_name, so_name]:
|
|
cc_binary(
|
|
name = impl_name,
|
|
srcs = srcs + hdrs,
|
|
linkshared = True,
|
|
linkstatic = True,
|
|
features = features,
|
|
tags = ["manual"] + tags,
|
|
testonly = testonly,
|
|
**kwargs
|
|
)
|
|
native.filegroup(
|
|
name = interface_output_name,
|
|
srcs = select({
|
|
"@platforms//os:windows": [":" + dll_name],
|
|
"@platforms//os:macos": [":" + dylib_name],
|
|
"//conditions:default": [":" + so_name],
|
|
}),
|
|
output_group = "interface_library",
|
|
)
|
|
cc_import(
|
|
name = import_name,
|
|
interface_library = ":" + interface_output_name,
|
|
shared_library = select({
|
|
"@platforms//os:windows": ":" + dll_name,
|
|
"@platforms//os:macos": ":" + dylib_name,
|
|
"//conditions:default": ":" + so_name,
|
|
}),
|
|
alwayslink = alwayslink,
|
|
features = features,
|
|
tags = tags,
|
|
testonly = testonly,
|
|
)
|
|
cc_library(
|
|
name = name,
|
|
hdrs = hdrs,
|
|
include_prefix = include_prefix,
|
|
strip_include_prefix = strip_include_prefix,
|
|
deps = [":" + import_name],
|
|
alwayslink = alwayslink,
|
|
features = features,
|
|
tags = tags,
|
|
testonly = testonly,
|
|
)
|