Use full workspace name to access Bazel packages in generator

Since the interface generator is invoked via a Bazel macro, it will be
expanded in the embedding context of the project using SAPI, so package access
needs to go through the full workspace root @com_google_sandboxed_api.

This change also modifies the CMakeLists.txt accordingly, as the "external"
subdirectory is no longer needed/wanted.

PiperOrigin-RevId: 255918784
Change-Id: I052c687509f65fef7f011a9d1a074a171595330f
This commit is contained in:
Christian Blichmann 2019-07-01 02:53:20 -07:00 committed by Copybara-Service
parent 0d16c136ae
commit 4e20e0702a
9 changed files with 17 additions and 50 deletions

View File

@ -69,12 +69,12 @@ find_package(ZLIB REQUIRED)
# Make Bazel-like includes work
configure_file(cmake/libcap_capability.h.in
external/org_kernel_libcap/libcap/include/sys/capability.h
libcap/include/sys/capability.h
@ONLY)
set(libunwind_INCLUDE_DIR
${PROJECT_BINARY_DIR}/Dependencies/Source/libunwind/include)
configure_file(cmake/libunwind_ptrace.h.in
external/org_gnu_libunwind/include/libunwind-ptrace.h
libunwind-ptrace.h
@ONLY)
# Library with basic project settings. The empty file is there to be able to

View File

@ -1,34 +0,0 @@
# Copyright 2019 Google LLC. All Rights Reserved.
#
# 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.
# On Debian, install libunwind-dev to use this module.
find_path(libunwind_INCLUDE_DIR sys/capability.h)
# Look for static library only.
find_library(libunwind_LIBRARY libcap.a)
mark_as_advanced(libunwind_INCLUDE_DIR libcap_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(libunwind
REQUIRED_VARS libunwind_LIBRARY libcap_INCLUDE_DIR
)
if(libunwind_FOUND AND NOT TARGET libcap::libcap)
add_library(libunwind::libcap UNKNOWN IMPORTED)
set_target_properties(libunwind::libcap PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${libunwind_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${libunwind_INCLUDE_DIR}"
)
endif()

View File

@ -131,6 +131,7 @@ filegroup(
hdrs = [
"include/config.h",
"include/libunwind.h",
"include/libunwind-ptrace.h",
],
copts = LIBUNWIND_COPTS + [
# Assume our inferior doesn't have frame pointers, regardless of

View File

@ -72,7 +72,7 @@ def sapi_interface_impl(ctx):
# Append system headers as dependencies
input_files += cc_ctx.headers.to_list()
append_all(extra_flags, "-D", cc_ctx.defines)
append_all(extra_flags, "-D", cc_ctx.defines.to_list())
append_all(extra_flags, "-isystem", cc_ctx.system_includes.to_list())
append_all(extra_flags, "-iquote", cc_ctx.quote_includes.to_list())
@ -133,7 +133,7 @@ sapi_interface = rule(
executable = True,
cfg = "host",
allow_files = True,
default = Label("//sandboxed_api/" +
default = Label("@com_google_sandboxed_api//sandboxed_api/" +
"tools/generator2:sapi_generator"),
),
},
@ -180,7 +180,7 @@ def sapi_library(
else:
lib_hdrs += [generated_header]
default_deps = ["//sandboxed_api/sandbox2"]
default_deps = ["@com_google_sandboxed_api//sandboxed_api/sandbox2"]
# Library that contains generated interface and sandboxed binary as a data
# dependency. Add this as a dependency instead of original library.
@ -191,8 +191,8 @@ def sapi_library(
data = [":" + name + ".bin"],
deps = sort_deps(
[
"//sandboxed_api:sapi",
"//sandboxed_api:vars",
"@com_google_sandboxed_api//sandboxed_api:sapi",
"@com_google_sandboxed_api//sandboxed_api:vars",
] + deps +
([":" + name + "_embed"] if embed else []) +
(default_deps if add_default_deps else []),
@ -208,7 +208,7 @@ def sapi_library(
] + exported_funcs, # must be both referenced, and exported
deps = [
":" + name + ".lib",
"//sandboxed_api:client",
"@com_google_sandboxed_api//sandboxed_api:client",
],
**common
)

View File

@ -49,7 +49,7 @@ def sapi_deps():
if "six_archive" not in native.existing_rules():
http_archive(
name = "six_archive",
build_file = "//sandboxed_api:bazel/external/six.BUILD",
build_file = "@com_google_sandboxed_api//sandboxed_api:bazel/external/six.BUILD",
sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
strip_prefix = "six-1.10.0",
urls = [
@ -88,7 +88,7 @@ def sapi_deps():
# libcap
http_archive(
name = "org_kernel_libcap",
build_file = "//sandboxed_api:bazel/external/libcap.BUILD",
build_file = "@com_google_sandboxed_api//sandboxed_api:bazel/external/libcap.BUILD",
sha256 = "ef83108f77314e50bae926ae473f9b130b15240d17cbae05089e19c36a8676d6",
strip_prefix = "libcap-2.13",
urls = ["https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.13.tar.gz"],
@ -97,7 +97,7 @@ def sapi_deps():
# libffi
autotools_repository(
name = "org_sourceware_libffi",
build_file = "//sandboxed_api:bazel/external/libffi.BUILD",
build_file = "@com_google_sandboxed_api//sandboxed_api:bazel/external/libffi.BUILD",
sha256 = "403d67aabf1c05157855ea2b1d9950263fb6316536c8c333f5b9ab1eb2f20ecf",
strip_prefix = "libffi-3.3-rc0",
urls = ["https://github.com/libffi/libffi/releases/download/v3.3-rc0/libffi-3.3-rc0.tar.gz"],
@ -106,7 +106,7 @@ def sapi_deps():
# libunwind
autotools_repository(
name = "org_gnu_libunwind",
build_file = "//sandboxed_api:bazel/external/libunwind.BUILD",
build_file = "@com_google_sandboxed_api//sandboxed_api:bazel/external/libunwind.BUILD",
configure_args = [
"--disable-documentation",
"--disable-minidebuginfo",

View File

@ -26,7 +26,7 @@
#include "absl/memory/memory.h"
#include "absl/strings/str_cat.h"
#include "external/org_kernel_libcap/libcap/include/sys/capability.h"
#include "libcap/include/sys/capability.h"
#include "sandboxed_api/sandbox2/forkserver.h"
#include "sandboxed_api/sandbox2/forkserver.pb.h"
#include "sandboxed_api/sandbox2/global_forkclient.h"

View File

@ -28,7 +28,7 @@
#include <glog/logging.h>
#include "sandboxed_api/util/flag.h"
#include "external/org_kernel_libcap/libcap/include/sys/capability.h"
#include "libcap/include/sys/capability.h"
#include "sandboxed_api/sandbox2/bpfdisassembler.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/regs.h"

View File

@ -29,7 +29,7 @@
#include "absl/strings/numbers.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/strip.h"
#include "external/org_kernel_libcap/libcap/include/sys/capability.h"
#include "libcap/include/sys/capability.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/executor.h"
#include "sandboxed_api/sandbox2/ipc.h"

View File

@ -25,7 +25,7 @@
#include <vector>
#include "absl/strings/str_cat.h"
#include "external/org_gnu_libunwind/include/libunwind-ptrace.h"
#include "libunwind-ptrace.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/unwind/unwind.pb.h"
#include "sandboxed_api/sandbox2/util/maps_parser.h"