• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2021 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
16load(":cc_library_common.bzl", "create_cc_prebuilt_library_info")
17
18def _cc_prebuilt_library_shared_impl(ctx):
19    lib = ctx.file.shared_library
20    files = ctx.attr.shared_library.files if lib != None else None
21    cc_toolchain = find_cpp_toolchain(ctx)
22    feature_configuration = cc_common.configure_features(
23        ctx = ctx,
24        cc_toolchain = cc_toolchain,
25    )
26    cc_info = create_cc_prebuilt_library_info(
27        ctx,
28        cc_common.create_library_to_link(
29            actions = ctx.actions,
30            dynamic_library = lib,
31            feature_configuration = feature_configuration,
32            cc_toolchain = cc_toolchain,
33        ) if lib != None else None,
34    )
35    return [DefaultInfo(files = files), cc_info]
36
37cc_prebuilt_library_shared = rule(
38    implementation = _cc_prebuilt_library_shared_impl,
39    attrs = dict(
40        shared_library = attr.label(
41            providers = [CcInfo],
42            allow_single_file = True,
43        ),
44        export_includes = attr.string_list(),
45        export_system_includes = attr.string_list(),
46    ),
47    toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
48    fragments = ["cpp"],
49    provides = [CcInfo],
50)
51