aboutsummaryrefslogtreecommitdiff
path: root/Android.bp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-06-04 14:38:03 -0700
committerElliott Hughes <enh@google.com>2020-06-04 14:38:03 -0700
commita8b83dfc8446798384bea2a0c2a6a49812761117 (patch)
treebe1a3aa7ef32be001f2ff37e581f1fd8271f48c7 /Android.bp
parent028186e8f275de18b7107bf246339415f81c7007 (diff)
downloadlibcap-a8b83dfc8446798384bea2a0c2a6a49812761117.tar.gz
libcap: generate cap_names.h at build time.
Test: treehugger Change-Id: I4a9d1b878f1d1074ef28587a76adb54646b0bfc4
Diffstat (limited to 'Android.bp')
-rw-r--r--Android.bp63
1 files changed, 39 insertions, 24 deletions
diff --git a/Android.bp b/Android.bp
index eb03cd8..3fb5c4e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,22 +1,6 @@
-// Copyright (C) 2015 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
cc_defaults {
name: "libcap_defaults",
cflags: [
- "-Wall",
- "-Werror",
"-Wno-unused-parameter",
"-Wno-unused-result",
"-Wno-tautological-compare",
@@ -41,6 +25,7 @@ cc_library {
"libcap/cap_proc.c",
"libcap/cap_text.c",
],
+ generated_headers: ["cap_names.h"],
local_include_dirs: ["libcap/include"],
export_include_dirs: ["libcap/include"],
@@ -66,11 +51,8 @@ cc_library {
cc_binary {
name: "getcap",
-
- srcs: ["progs/getcap.c"],
-
defaults: ["libcap_defaults"],
-
+ srcs: ["progs/getcap.c"],
static_libs: [
"libcap",
],
@@ -78,12 +60,45 @@ cc_binary {
cc_binary {
name: "setcap",
-
- srcs: ["progs/setcap.c"],
-
defaults: ["libcap_defaults"],
-
+ srcs: ["progs/setcap.c"],
static_libs: [
"libcap",
],
}
+
+//
+// Generate cap_names.list.h from the <linux/capability.h> header (using awk).
+//
+
+genrule {
+ name: "cap_names.list.h",
+ srcs: ["libcap/include/uapi/linux/capability.h"],
+ out: ["cap_names.list.h"],
+ tool_files: [":generate_cap_names_list.awk"],
+ cmd: "awk -f $(location :generate_cap_names_list.awk) $(in) > $(out)",
+}
+
+filegroup {
+ name: "generate_cap_names_list.awk",
+ srcs: ["generate_cap_names_list.awk"],
+}
+
+//
+// Generate cap_names.h from cap_names.list.h (using _makenames).
+//
+
+genrule {
+ name: "cap_names.h",
+ out: ["cap_names.h"],
+ tools: [":_makenames"],
+ cmd: "$(location :_makenames) > $(out)",
+}
+
+cc_binary {
+ name: "_makenames",
+ defaults: ["libcap_defaults"],
+ srcs: ["libcap/_makenames.c"],
+ generated_headers: ["cap_names.list.h"],
+ host_supported: true,
+}