2020-01-17 21:05:03 +08:00
|
|
|
# Copyright 2019 Google LLC
|
2019-03-19 00:21:48 +08:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
genrule(
|
2019-11-25 20:31:37 +08:00
|
|
|
name = "cap_names_list_h",
|
|
|
|
srcs = ["libcap/include/uapi/linux/capability.h"],
|
|
|
|
outs = ["cap_names.list.h"],
|
2019-03-19 00:21:48 +08:00
|
|
|
# Use the same logic as libcap/Makefile
|
|
|
|
cmd = """
|
|
|
|
sed -ne '/^#define[ \\t]CAP[_A-Z]\+[ \\t]\+[0-9]\+/{s/^#define \([^ \\t]*\)[ \\t]*\([^ \\t]*\)/\{\"\\1\",\\2\},/p;}' $< | \\
|
|
|
|
tr \"[:upper:]\" \"[:lower:]\" > $@
|
|
|
|
""",
|
|
|
|
visibility = ["//visibility:private"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "makenames_textual_hdrs",
|
|
|
|
textual_hdrs = [
|
2019-11-25 20:31:37 +08:00
|
|
|
":cap_names.list.h",
|
|
|
|
"libcap/include/uapi/linux/capability.h",
|
2019-03-19 00:21:48 +08:00
|
|
|
],
|
|
|
|
visibility = ["//visibility:private"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "makenames",
|
|
|
|
srcs = [
|
|
|
|
"libcap/_makenames.c",
|
|
|
|
"libcap/include/sys/capability.h",
|
|
|
|
],
|
|
|
|
includes = [
|
|
|
|
"libcap/..",
|
|
|
|
"libcap/include",
|
|
|
|
"libcap/include/uapi",
|
|
|
|
],
|
|
|
|
visibility = ["//visibility:private"],
|
|
|
|
deps = [":makenames_textual_hdrs"],
|
|
|
|
)
|
|
|
|
|
|
|
|
genrule(
|
|
|
|
name = "cap_names_h",
|
|
|
|
outs = ["libcap/cap_names.h"],
|
|
|
|
cmd = "mkdir -p libcap && $(location makenames) > $@ || { rm -f $@; false; }",
|
|
|
|
tools = [":makenames"],
|
|
|
|
visibility = ["//visibility:private"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "libcap",
|
|
|
|
srcs = [
|
|
|
|
"libcap/cap_alloc.c",
|
|
|
|
"libcap/cap_extint.c",
|
|
|
|
"libcap/cap_file.c",
|
|
|
|
"libcap/cap_flag.c",
|
|
|
|
"libcap/cap_proc.c",
|
|
|
|
"libcap/cap_text.c",
|
|
|
|
],
|
|
|
|
copts = [
|
|
|
|
"-Wno-tautological-compare",
|
|
|
|
"-Wno-unused-result",
|
|
|
|
# Work around sys/xattr.h not declaring this
|
|
|
|
"-DXATTR_NAME_CAPS=\"\\\"security.capability\\\"\"",
|
|
|
|
],
|
|
|
|
includes = [
|
|
|
|
"libcap",
|
|
|
|
"libcap/include",
|
2019-11-25 20:31:37 +08:00
|
|
|
"libcap/include/uapi",
|
2019-03-19 00:21:48 +08:00
|
|
|
],
|
|
|
|
textual_hdrs = [
|
|
|
|
"libcap/include/sys/capability.h",
|
2019-11-25 20:31:37 +08:00
|
|
|
"libcap/include/uapi/linux/capability.h",
|
2019-03-19 00:21:48 +08:00
|
|
|
"libcap/libcap.h",
|
|
|
|
"libcap/cap_names.h",
|
|
|
|
],
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|