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
15"""cc_library_headers is a headers only cc library."""
16
17load(":cc_constants.bzl", "constants")
18load(":cc_library_common.bzl", "check_absolute_include_dirs_disabled", "create_ccinfo_for_includes")
19
20def _cc_headers_impl(ctx):
21    check_absolute_include_dirs_disabled(
22        ctx.label.package,
23        ctx.attr.export_absolute_includes,
24    )
25
26    return [
27        create_ccinfo_for_includes(
28            ctx,
29            hdrs = ctx.files.hdrs,
30            includes = ctx.attr.export_includes,
31            absolute_includes = ctx.attr.export_absolute_includes,
32            system_includes = ctx.attr.export_system_includes,
33            deps = ctx.attr.deps,
34        ),
35        cc_common.CcSharedLibraryHintInfo(
36            attributes = [],
37        ),
38    ]
39
40cc_library_headers = rule(
41    implementation = _cc_headers_impl,
42    attrs = {
43        "export_absolute_includes": attr.string_list(doc = "List of exec-root relative or absolute search paths for headers, usually passed with -I"),
44        "export_includes": attr.string_list(doc = "Package-relative list of search paths for headers, usually passed with -I"),
45        "export_system_includes": attr.string_list(doc = "Package-relative list of search paths for headers, usually passed with -isystem"),
46        "deps": attr.label_list(doc = "Re-propagates the includes obtained from these dependencies.", providers = [CcInfo]),
47        "hdrs": attr.label_list(doc = "Header files.", allow_files = constants.hdr_dot_exts),
48        "min_sdk_version": attr.string(),
49        "sdk_version": attr.string(),
50    },
51    fragments = ["cpp"],
52    provides = [CcInfo, cc_common.CcSharedLibraryHintInfo],
53    doc = "A library that contains c/c++ headers which are imported by other targets.",
54)
55