xref: /aosp_15_r20/external/libcap/Android.bp (revision 2810ac1b38eead2603277920c78344c84ddf3aff)
1package {
2    default_applicable_licenses: ["external_libcap_license"],
3}
4
5// Added automatically by a large-scale-change that took the approach of
6// 'apply every license found to every target'. While this makes sure we respect
7// every license restriction, it may not be entirely correct.
8//
9// e.g. GPL in an MIT project might only apply to the contrib/ directory.
10//
11// Please consider splitting the single license below into multiple licenses,
12// taking care not to lose any license_kind information, and overriding the
13// default license using the 'licenses: [...]' property on targets as needed.
14//
15// For unused files, consider creating a 'fileGroup' with "//visibility:private"
16// to attach the license to, and including a comment whether the files may be
17// used in the current project.
18//
19// large-scale-change filtered out the below license kinds as false-positives:
20//   SPDX-license-identifier-GPL
21//   SPDX-license-identifier-GPL-2.0
22//   SPDX-license-identifier-LGPL
23// See: http://go/android-license-faq
24license {
25    name: "external_libcap_license",
26    visibility: [":__subpackages__"],
27    license_kinds: [
28        "SPDX-license-identifier-Apache-2.0",
29        "SPDX-license-identifier-BSD",
30        "SPDX-license-identifier-BSD-3-Clause",
31    ],
32    license_text: [
33        "NOTICE",
34    ],
35}
36
37cc_defaults {
38    name: "libcap_defaults",
39    cflags: [
40        "-Wno-pointer-arith",
41        "-Wno-tautological-compare",
42        "-Wno-unused-parameter",
43        "-Wno-unused-result",
44        "-Wno-unused-variable",
45    ],
46}
47
48cc_library {
49    name: "libcap",
50    host_supported: true,
51    vendor_available: true,
52    product_available: true,
53    ramdisk_available: true,
54    recovery_available: true,
55    defaults: ["libcap_defaults"],
56
57    srcs: [
58        "libcap/cap_alloc.c",
59        "libcap/cap_extint.c",
60        "libcap/cap_file.c",
61        "libcap/cap_flag.c",
62        "libcap/cap_proc.c",
63        "libcap/cap_text.c",
64    ],
65    generated_headers: ["cap_names.h"],
66
67    local_include_dirs: ["libcap/include"],
68    export_include_dirs: ["libcap/include"],
69
70    target: {
71        darwin: {
72            enabled: false,
73        },
74        linux_bionic: {
75            enabled: true,
76        },
77        linux_glibc: {
78            local_include_dirs: ["libcap/include/uapi"],
79        },
80    },
81    apex_available: [
82        "//apex_available:platform",
83        "com.android.adbd",
84        "com.android.art",
85        "com.android.art.debug",
86        "com.android.compos",
87        "com.android.media.swcodec",
88        "com.android.virt",
89    ],
90    min_sdk_version: "29",
91}
92
93cc_binary {
94    name: "getcap",
95    defaults: ["libcap_defaults"],
96    srcs: ["progs/getcap.c"],
97    static_libs: [
98        "libcap",
99    ],
100}
101
102cc_binary {
103    name: "setcap",
104    defaults: ["libcap_defaults"],
105    srcs: ["progs/setcap.c"],
106    static_libs: [
107        "libcap",
108    ],
109}
110
111//
112// Generate cap_names.list.h from the <linux/capability.h> header (using awk).
113//
114
115genrule {
116    name: "cap_names.list.h",
117    srcs: ["libcap/include/uapi/linux/capability.h"],
118    out: ["cap_names.list.h"],
119    tool_files: ["generate_cap_names_list.awk"],
120    cmd: "awk -f $(location generate_cap_names_list.awk) $(in) > $(out)",
121}
122
123//
124// Generate cap_names.h from cap_names.list.h (using _makenames).
125//
126
127genrule {
128    name: "cap_names.h",
129    out: ["cap_names.h"],
130    tools: [":_makenames"],
131    cmd: "$(location :_makenames) > $(out)",
132}
133
134cc_binary {
135    name: "_makenames",
136    defaults: ["libcap_defaults"],
137    srcs: ["libcap/_makenames.c"],
138    generated_headers: ["cap_names.list.h"],
139    host_supported: true,
140}
141