Enable shared libraries build and cross-compilation

This allows resource-constrained environments to benefit from the
space savings of dynamic linking. This is not meant to be used in
the general case.

PiperOrigin-RevId: 347398828
Change-Id: Ia634959148a31159878f48c44255dd733424a2b8
This commit is contained in:
Anton D. Kachalov 2020-12-14 09:15:40 -08:00 committed by Copybara-Service
parent 218435d88e
commit 0e8d16e011
32 changed files with 359 additions and 285 deletions

View File

@ -32,6 +32,8 @@ set(SAPI_CXX_STANDARD 17)
set(SAPI_BINARY_DIR "${PROJECT_BINARY_DIR}" CACHE INTERNAL "" FORCE)
set(SAPI_SOURCE_DIR "${PROJECT_SOURCE_DIR}" CACHE INTERNAL "" FORCE)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE CACHE BOOL "" FORCE)
include(CheckCXXCompilerFlag)
# TODO(cblichmann): Only apply this to SAPI and its dependencies

View File

@ -16,7 +16,7 @@
find_path(libcap_INCLUDE_DIR sys/capability.h)
# Look for static library only.
find_library(libcap_LIBRARY libcap.a)
find_library(libcap_LIBRARY cap)
mark_as_advanced(libcap_INCLUDE_DIR libcap_LIBRARY)
include(FindPackageHandleStandardArgs)

View File

@ -16,7 +16,7 @@
find_path(libffi_INCLUDE_DIR ffitarget.h)
# Look for static library only.
find_library(libffi_LIBRARY libffi.a)
find_library(libffi_LIBRARY ffi)
mark_as_advanced(libffi_INCLUDE_DIR libffi_LIBRARY)
include(FindPackageHandleStandardArgs)

View File

@ -200,3 +200,10 @@ function(add_sapi_library)
)
endif()
endfunction()
# Wrapper for gtest_discover_tests to exclude tests discover when cross compiling.
macro(gtest_discover_tests_xcompile)
if (NOT CMAKE_CROSSCOMPILING)
gtest_discover_tests(${ARGV})
endif()
endmacro()

View File

@ -21,7 +21,20 @@ endfunction()
# Use static libraries
set(_sapi_saved_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
if (SAPI_ENABLE_SHARED_LIBS)
set(SAPI_LIB_TYPE SHARED)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX})
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
# Imply linking with system-wide libs
set(SAPI_DOWNLOAD_LIBCAP OFF CACHE BOOL "" FORCE)
set(SAPI_DOWNLOAD_LIBFFI OFF CACHE BOOL "" FORCE)
set(SAPI_DOWNLOAD_PROTOBUF OFF CACHE BOOL "" FORCE)
set(SAPI_DOWNLOAD_ZLIB OFF CACHE BOOL "" FORCE)
add_compile_definitions(SAPI_LIB_IS_SHARED=1)
else()
set(SAPI_LIB_TYPE STATIC)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()
if(SAPI_ENABLE_TESTS)
if(SAPI_DOWNLOAD_GOOGLETEST)
@ -71,6 +84,8 @@ if(SAPI_DOWNLOAD_GLOG)
endif()
check_target(glog::glog)
add_dependencies(glog gflags::gflags)
if(SAPI_DOWNLOAD_PROTOBUF)
include(cmake/protobuf/Download.cmake)
check_target(protobuf::libprotobuf)
@ -88,6 +103,8 @@ if(SAPI_ENABLE_EXAMPLES)
endif()
endif()
find_package(Threads REQUIRED)
if(NOT SAPI_ENABLE_GENERATOR)
# Find Python 3 and add its location to the cache so that its available in
# the add_sapi_library() macro in embedding projects.

View File

@ -36,6 +36,10 @@ option(SAPI_DOWNLOAD_ZLIB "Download zlib at config time (only if SAPI_ENABLE_EXA
option(SAPI_ENABLE_TESTS "Build unit tests" ON)
option(SAPI_ENABLE_GENERATOR "Build Clang based code generator from source" OFF)
# This flag should be only enabled for embedded and resource-constrained
# environments
option(SAPI_ENABLE_SHARED_LIBS "Build SAPI shared libs" OFF)
option(SAPI_HARDENED_SOURCE "Build with hardening compiler options" OFF)
option(SAPI_FORCE_COLOR_OUTPUT "Force colored compiler diagnostics when using Ninja" ON)

View File

@ -40,6 +40,7 @@ set(ABSL_USE_GOOGLETEST_HEAD OFF CACHE BOOL "" FORCE)
set(ABSL_RUN_TESTS OFF CACHE BOOL "" FORCE)
set(BUILD_TESTING OFF) # Avoid errors when re-configuring SAPI
set(ABSL_CXX_STANDARD ${SAPI_CXX_STANDARD} CACHE STRING "" FORCE)
set(ABSL_ENABLE_INSTALL ON CACHE BOOL "" FORCE)
add_subdirectory("${CMAKE_BINARY_DIR}/absl-src"
"${CMAKE_BINARY_DIR}/absl-build" EXCLUDE_FROM_ALL)

View File

@ -33,7 +33,9 @@ if(error)
endif()
set(GFLAGS_IS_SUBPROJECT TRUE)
set(GFLAGS_INSTALL_SHARED_LIBS FALSE)
set(GFLAGS_BUILD_SHARED_LIBS ${SAPI_ENABLE_SHARED_LIBS})
set(GFLAGS_INSTALL_SHARED_LIBS ${SAPI_ENABLE_SHARED_LIBS})
set(GFLAGS_INSTALL_HEADERS OFF) # TODO: Temporary off
set(GFLAGS_BUILD_TESTING FALSE)
add_subdirectory("${CMAKE_BINARY_DIR}/gflags-src"

View File

@ -14,6 +14,11 @@
# Downloads and unpacks glog at configure time
# Allows use target_link_libraries() with targets in other directories.
if(POLICY CMP0079)
cmake_policy(SET CMP0079 NEW)
endif()
set(workdir "${CMAKE_BINARY_DIR}/glog-download")
configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in"
@ -34,18 +39,30 @@ endif()
# Force gflags from subdirectory
set(WITH_GFLAGS OFF CACHE BOOL "" FORCE)
set(HAVE_LIB_GFLAGS 1)
set(HAVE_LIB_GFLAGS 1 CACHE STRING "" FORCE)
set(WITH_UNWIND OFF CACHE BOOL "" FORCE)
set(UNWIND_LIBRARY FALSE)
set(HAVE_PWD_H FALSE)
set(WITH_PKGCONFIG ON CACHE BOOL "" FORCE)
set(_glog_BUILD_TESTING ${BUILD_TESTING})
set(BUILD_TESTING FALSE)
set(BUILD_SHARED_LIBS ${SAPI_ENABLE_SHARED_LIBS})
add_subdirectory("${CMAKE_BINARY_DIR}/glog-src"
"${CMAKE_BINARY_DIR}/glog-build" EXCLUDE_FROM_ALL)
set(BUILD_TESTING ${_glog_BUILD_TESTING})
set(_glog_BUILD_TESTING)
target_include_directories(glog PUBLIC
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/gflags-build/include>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/glog-build>
)
add_library(gflags_nothreads STATIC IMPORTED)
set_target_properties(gflags_nothreads PROPERTIES
IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/gflags-build/libgflags_nothreads.a")
target_link_libraries(glog PRIVATE
-Wl,--whole-archive
gflags_nothreads
-Wl,--no-whole-archive
)

View File

@ -44,19 +44,34 @@ add_custom_command(OUTPUT ${_cap_src}/libcap/cap_names.list.h
tr [:upper:] [:lower:] > ${_cap_src}/libcap/cap_names.list.h
)
add_executable(libcap_makenames
${_cap_src}/libcap/cap_names.list.h
${_cap_src}/libcap/_makenames.c
)
target_include_directories(libcap_makenames PUBLIC
${_cap_src}/libcap
${_cap_src}/libcap/include
${_cap_src}/libcap/include/uapi
)
if (CMAKE_CROSSCOMPILING AND BUILD_C_COMPILER)
add_custom_command(OUTPUT ${_cap_src}/libcap/libcap_makenames
VERBATIM
# Use the same logic as libcap/Makefile
COMMAND ${BUILD_C_COMPILER} ${BUILD_C_FLAGS} ${_cap_src}/libcap/_makenames.c -o ${_cap_src}/libcap/libcap_makenames
DEPENDS ${_cap_src}/libcap/cap_names.list.h ${_cap_src}/libcap/_makenames.c
)
add_custom_command(OUTPUT ${_cap_src}/libcap/cap_names.h
COMMAND libcap_makenames > ${_cap_src}/libcap/cap_names.h
)
add_custom_command(OUTPUT ${_cap_src}/libcap/cap_names.h
COMMAND ${_cap_src}/libcap/libcap_makenames > ${_cap_src}/libcap/cap_names.h
DEPENDS ${_cap_src}/libcap/libcap_makenames
)
else()
add_executable(libcap_makenames
${_cap_src}/libcap/cap_names.list.h
${_cap_src}/libcap/_makenames.c
)
target_include_directories(libcap_makenames PUBLIC
${_cap_src}/libcap
${_cap_src}/libcap/include
${_cap_src}/libcap/include/uapi
)
add_custom_command(OUTPUT ${_cap_src}/libcap/cap_names.h
COMMAND libcap_makenames > ${_cap_src}/libcap/cap_names.h
)
endif()
add_library(cap STATIC
${_cap_src}/libcap/cap_alloc.c

View File

@ -23,6 +23,7 @@ ExternalProject_Add(libffi
CONFIGURE_COMMAND ./configure
--disable-dependency-tracking
--disable-builddir
${SAPI_THIRD_PARTY_CONFIGUREOPTS}
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""

View File

@ -26,6 +26,7 @@ ExternalProject_Add(libunwind
--disable-minidebuginfo
--disable-shared
--enable-ptrace
${SAPI_THIRD_PARTY_CONFIGUREOPTS}
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""

View File

@ -24,7 +24,7 @@ add_subdirectory(examples)
sapi_protobuf_generate_cpp(_sapi_proto_arg_pb_cc _sapi_proto_arg_pb_h
proto_arg.proto
)
add_library(sapi_proto_arg_proto STATIC
add_library(sapi_proto_arg_proto ${SAPI_LIB_TYPE}
${_sapi_proto_arg_pb_cc}
${_sapi_proto_arg_pb_h}
)
@ -35,29 +35,29 @@ target_link_libraries(sapi_proto_arg_proto PRIVATE
)
# sandboxed_api:embed_file
add_library(sapi_embed_file STATIC
add_library(sapi_embed_file ${SAPI_LIB_TYPE}
embed_file.cc
embed_file.h
file_toc.h
)
add_library(sapi::embed_file ALIAS sapi_embed_file)
target_link_libraries(sapi_embed_file PRIVATE
absl::flat_hash_map
absl::status
absl::statusor
absl::strings
absl::synchronization
glog::glog
sandbox2::fileops
sandbox2::strerror
sandbox2::util
sapi::base
sapi::raw_logging
sapi::status
target_link_libraries(sapi_embed_file
PRIVATE absl::flat_hash_map
absl::status
absl::statusor
absl::strings
absl::synchronization
sandbox2::fileops
sandbox2::strerror
sandbox2::util
sapi::base
sapi::raw_logging
sapi::status
PUBLIC glog::glog
)
# sandboxed_api:sapi
add_library(sapi_sapi STATIC
add_library(sapi_sapi ${SAPI_LIB_TYPE}
sandbox.cc
sandbox.h
transaction.cc
@ -76,19 +76,19 @@ target_link_libraries(sapi_sapi
sandbox2::file_base
sandbox2::fileops
sandbox2::runfiles
sandbox2::sandbox2
sandbox2::strerror
sandbox2::util
sapi::embed_file
sapi::vars
PUBLIC absl::core_headers
sandbox2::client
sandbox2::sandbox2
sapi::base
sapi::status
)
# sandboxed_api:call
add_library(sapi_call STATIC
add_library(sapi_call ${SAPI_LIB_TYPE}
call.h
)
add_library(sapi::call ALIAS sapi_call)
@ -99,7 +99,7 @@ target_link_libraries(sapi_call PRIVATE
)
# sandboxed_api:lenval_core
add_library(sapi_lenval_core STATIC
add_library(sapi_lenval_core ${SAPI_LIB_TYPE}
lenval_core.h
)
add_library(sapi::lenval_core ALIAS sapi_lenval_core)
@ -108,7 +108,7 @@ target_link_libraries(sapi_lenval_core PRIVATE
)
# sandboxed_api:var_type
add_library(sapi_var_type STATIC
add_library(sapi_var_type ${SAPI_LIB_TYPE}
var_type.h
)
add_library(sapi::var_type ALIAS sapi_var_type)
@ -117,7 +117,7 @@ target_link_libraries(sapi_var_type PRIVATE
)
# sandboxed_api:vars
add_library(sapi_vars STATIC
add_library(sapi_vars ${SAPI_LIB_TYPE}
proto_helper.h
rpcchannel.cc
rpcchannel.h
@ -138,45 +138,47 @@ add_library(sapi_vars STATIC
vars.h
)
add_library(sapi::vars ALIAS sapi_vars)
target_link_libraries(sapi_vars PRIVATE
absl::core_headers
absl::status
absl::statusor
absl::str_format
absl::strings
absl::synchronization
glog::glog
sandbox2::comms
sapi::base
sapi::call
sapi::lenval_core
sapi::proto_arg_proto
sapi::status
sapi::var_type
target_link_libraries(sapi_vars
PRIVATE absl::core_headers
absl::status
absl::statusor
absl::str_format
absl::strings
absl::synchronization
sandbox2::comms
sapi::base
sapi::call
sapi::lenval_core
sapi::proto_arg_proto
sapi::status
sapi::var_type
PUBLIC glog::glog
)
# sandboxed_api:client
add_library(sapi_client STATIC
add_library(sapi_client ${SAPI_LIB_TYPE}
client.cc
)
add_library(sapi::client ALIAS sapi_client)
target_link_libraries(sapi_client PRIVATE
absl::core_headers
absl::strings
glog::glog
libffi::libffi
sandbox2::client
sandbox2::comms
sandbox2::forkingclient
sandbox2::logsink
sapi::base
sapi::call
sapi::flags
sapi::lenval_core
sapi::vars
target_link_libraries(sapi_client
PRIVATE absl::core_headers
absl::strings
libffi::libffi
sandbox2::client
sandbox2::comms
sandbox2::forkingclient
sandbox2::logsink
sapi::base
sapi::call
sapi::flags
sapi::lenval_core
sapi::proto_arg_proto
sapi::vars
${CMAKE_DL_LIBS}
PUBLIC glog::glog
)
if(SAPI_ENABLE_TESTS)
if(SAPI_ENABLE_TESTS AND NOT CMAKE_CROSSCOMPILING)
# sandboxed_api:sapi_test
add_executable(sapi_test
sapi_test.cc
@ -184,7 +186,10 @@ if(SAPI_ENABLE_TESTS)
target_link_libraries(sapi_test PRIVATE
absl::memory
absl::status
absl::statusor
benchmark
sandbox2::result
sapi::proto_arg_proto
sapi::sapi
sapi::status
sapi::status_matchers
@ -192,5 +197,22 @@ if(SAPI_ENABLE_TESTS)
sapi::sum_sapi
sapi::test_main
)
gtest_discover_tests(sapi_test)
gtest_discover_tests_xcompile(sapi_test)
endif()
# Install headers and libraries, excluding tools, tests and examples
foreach(_dir IN ITEMS . sandbox2 sandbox2/network_proxy sandbox2/util util)
get_property(_sapi_targets DIRECTORY ${_dir} PROPERTY BUILDSYSTEM_TARGETS)
list(FILTER _sapi_targets INCLUDE REGEX ^\(sapi|sandbox2\).*)
list(FILTER _sapi_targets EXCLUDE REGEX _test)
install(TARGETS ${_sapi_targets} DESTINATION ${CMAKE_INSTALL_LIBDIR})
set_property(TARGET ${_sapi_targets} PROPERTY SOVERSION 1)
endforeach()
file(GLOB_RECURSE _sapi_headers true ${CMAKE_CURRENT_LIST_DIR}/*.h)
list(FILTER _sapi_headers EXCLUDE REGEX /\(tools|examples\)/)
foreach(_file ${_sapi_headers})
get_filename_component(_dir ${_file} DIRECTORY)
string(REPLACE ${CMAKE_CURRENT_LIST_DIR} "" _dir ${_dir})
install(FILES ${_file} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sandboxed_api/${_dir})
endforeach()

View File

@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if(SAPI_ENABLE_EXAMPLES OR SAPI_ENABLE_TESTS)
if((SAPI_ENABLE_EXAMPLES OR SAPI_ENABLE_TESTS) AND NOT CMAKE_CROSSCOMPILING)
# TODO(cblichmann): These are depended on by sapi::sapi_test
add_subdirectory(stringop)
add_subdirectory(sum)
endif()
if(SAPI_ENABLE_EXAMPLES)
if(SAPI_ENABLE_EXAMPLES AND SAPI_DOWNLOAD_ZLIB)
add_subdirectory(zlib)
endif()

View File

@ -32,5 +32,5 @@ if(SAPI_ENABLE_TESTS)
sapi::test_main
sapi::vars
)
gtest_discover_tests(sapi_main_stringop)
gtest_discover_tests_xcompile(sapi_main_stringop)
endif()

View File

@ -18,7 +18,7 @@ add_subdirectory(util)
add_subdirectory(network_proxy)
# sandboxed_api/sandbox2:config
add_library(sandbox2_config STATIC
add_library(sandbox2_config ${SAPI_LIB_TYPE}
config.h
)
add_library(sandbox2::config ALIAS sandbox2_config)
@ -28,7 +28,7 @@ target_link_libraries(sandbox2_config PRIVATE
)
# sandboxed_api/sandbox2:bpfdisassembler
add_library(sandbox2_bpfdisassembler STATIC
add_library(sandbox2_bpfdisassembler ${SAPI_LIB_TYPE}
bpfdisassembler.cc
bpfdisassembler.h
)
@ -39,7 +39,7 @@ target_link_libraries(sandbox2_bpfdisassembler PRIVATE
)
# sandboxed_api/sandbox2:regs
add_library(sandbox2_regs STATIC
add_library(sandbox2_regs ${SAPI_LIB_TYPE}
regs.cc
regs.h
)
@ -56,7 +56,7 @@ target_link_libraries(sandbox2_regs PRIVATE
)
# sandboxed_api/sandbox2:syscall
add_library(sandbox2_syscall STATIC
add_library(sandbox2_syscall ${SAPI_LIB_TYPE}
syscall.cc
syscall.h
syscall_defs.cc
@ -71,11 +71,10 @@ target_link_libraries(sandbox2_syscall
sandbox2::util
sapi::base
PUBLIC glog::glog
gflags::gflags
)
# sandboxed_api/sandbox2:result
add_library(sandbox2_result STATIC
add_library(sandbox2_result ${SAPI_LIB_TYPE}
result.cc
result.h
)
@ -96,7 +95,7 @@ target_link_libraries(sandbox2_result PRIVATE
sapi_protobuf_generate_cpp(_sandbox2_logserver_pb_h _sandbox2_logserver_pb_cc
logserver.proto
)
add_library(sandbox2_logserver_proto STATIC
add_library(sandbox2_logserver_proto ${SAPI_LIB_TYPE}
${_sandbox2_logserver_pb_cc}
${_sandbox2_logserver_pb_h}
)
@ -107,7 +106,7 @@ target_link_libraries(sandbox2_logserver_proto
)
# sandboxed_api/sandbox2:logserver
add_library(sandbox2_logserver STATIC
add_library(sandbox2_logserver ${SAPI_LIB_TYPE}
logserver.cc
logserver.h
)
@ -121,7 +120,7 @@ target_link_libraries(sandbox2_logserver
)
# sandboxed_api/sandbox2:logsink
add_library(sandbox2_logsink STATIC
add_library(sandbox2_logsink ${SAPI_LIB_TYPE}
logsink.cc
logsink.h
)
@ -136,7 +135,7 @@ target_link_libraries(sandbox2_logsink
)
# sandboxed_api/sandbox2:ipc
add_library(sandbox2_ipc STATIC
add_library(sandbox2_ipc ${SAPI_LIB_TYPE}
ipc.cc
ipc.h
)
@ -154,7 +153,7 @@ target_link_libraries(sandbox2_ipc PRIVATE
)
# sandboxed_api/sandbox2:policy
add_library(sandbox2_policy STATIC
add_library(sandbox2_policy ${SAPI_LIB_TYPE}
policy.cc
policy.h
)
@ -174,7 +173,7 @@ target_link_libraries(sandbox2_policy PRIVATE
)
# sandboxed_api/sandbox2:notify
add_library(sandbox2_notify STATIC
add_library(sandbox2_notify ${SAPI_LIB_TYPE}
notify.h
)
add_library(sandbox2::notify ALIAS sandbox2_notify)
@ -186,7 +185,7 @@ target_link_libraries(sandbox2_notify PRIVATE
)
# sandboxed_api/sandbox2:limits
add_library(sandbox2_limits STATIC
add_library(sandbox2_limits ${SAPI_LIB_TYPE}
limits.h
)
add_library(sandbox2::limits ALIAS sandbox2_limits)
@ -206,7 +205,6 @@ add_executable(sandbox2::forkserver_bin ALIAS sandbox2_forkserver_bin)
target_link_libraries(sandbox2_forkserver_bin PRIVATE
absl::core_headers
absl::strings
glog::glog
sandbox2::client
sandbox2::comms
sandbox2::forkserver
@ -214,6 +212,7 @@ target_link_libraries(sandbox2_forkserver_bin PRIVATE
sandbox2::strerror
sapi::base
sapi::raw_logging
PUBLIC glog::glog
)
# sandboxed_api/sandbox2:forkserver_bin_embed
@ -225,7 +224,7 @@ sapi_cc_embed_data(NAME sandbox2_forkserver_bin_embed
add_library(sandbox2::forkserver_bin_embed ALIAS sandbox2_forkserver_bin_embed)
# sandboxed_api/sandbox2:global_forkserver
add_library(sandbox2_global_forkserver STATIC
add_library(sandbox2_global_forkserver ${SAPI_LIB_TYPE}
global_forkclient.cc
global_forkclient.h
)
@ -266,30 +265,30 @@ target_link_libraries(sandbox2_start_global_forkserver_lib_constructor PRIVATE
)
# sandboxed_api/sandbox2:executor
add_library(sandbox2_executor STATIC
add_library(sandbox2_executor ${SAPI_LIB_TYPE}
executor.cc
executor.h
)
add_library(sandbox2::executor ALIAS sandbox2_executor)
target_link_libraries(sandbox2_executor PRIVATE
absl::core_headers
absl::memory
absl::strings
glog::glog
sandbox2::fileops
sandbox2::fork_client
sandbox2::forkserver_proto
sandbox2::global_forkserver
sandbox2::ipc
sandbox2::limits
sandbox2::namespace
sandbox2::util
sapi::base
sapi::status_proto
target_link_libraries(sandbox2_executor
PRIVATE absl::core_headers
absl::memory
absl::strings
sandbox2::fileops
sandbox2::forkserver_proto
sandbox2::ipc
sandbox2::limits
sandbox2::namespace
sandbox2::util
sapi::base
sapi::status_proto
PUBLIC glog::glog
sandbox2::fork_client
sandbox2::global_forkserver
)
# sandboxed_api/sandbox2:sandbox2
add_library(sandbox2_sandbox2 STATIC
add_library(sandbox2_sandbox2 ${SAPI_LIB_TYPE}
monitor.cc
monitor.h
policybuilder.cc
@ -306,16 +305,19 @@ target_link_libraries(sandbox2_sandbox2
absl::flat_hash_set
absl::memory
absl::optional
absl::status
absl::statusor
absl::str_format
absl::strings
absl::synchronization
sapi::base
PUBLIC absl::status
absl::statusor
absl::time
sapi::flags
sapi::status
sandbox2::bpf_helper
sandbox2::client
sandbox2::comms
sandbox2::config
sandbox2::comms
sandbox2::executor
sandbox2::file_base
sandbox2::fileops
@ -324,9 +326,12 @@ target_link_libraries(sandbox2_sandbox2
sandbox2::global_forkserver
sandbox2::ipc
sandbox2::limits
sandbox2::logsink
sandbox2::mounts
sandbox2::mounttree_proto
sandbox2::namespace
sandbox2::network_proxy_client
sandbox2::network_proxy_server
sandbox2::notify
sandbox2::policy
sandbox2::regs
@ -337,14 +342,10 @@ target_link_libraries(sandbox2_sandbox2
sandbox2::unwind_proto
sandbox2::util
sandbox2::violation_proto
sapi::base
PUBLIC sapi::flags
sapi::status
sandbox2::logsink
)
# sandboxed_api/sandbox2:client
add_library(sandbox2_client STATIC
add_library(sandbox2_client ${SAPI_LIB_TYPE}
client.cc
client.h
)
@ -365,7 +366,7 @@ target_link_libraries(sandbox2_client
)
# sandboxed_api/sandbox2:sanitizer
add_library(sandbox2_sanitizer STATIC
add_library(sandbox2_sanitizer ${SAPI_LIB_TYPE}
sanitizer.cc
sanitizer.h
)
@ -382,7 +383,7 @@ target_link_libraries(sandbox2_sanitizer
)
# sandboxed_api/sandbox2:forkserver
add_library(sandbox2_forkserver STATIC
add_library(sandbox2_forkserver ${SAPI_LIB_TYPE}
forkserver.cc
forkserver.h
)
@ -412,7 +413,7 @@ target_link_libraries(sandbox2_forkserver PRIVATE
)
# sandboxed_api/sandbox2:fork_client
add_library(sandbox2_fork_client STATIC
add_library(sandbox2_fork_client ${SAPI_LIB_TYPE}
fork_client.cc
fork_client.h
)
@ -427,32 +428,32 @@ target_link_libraries(sandbox2_fork_client PRIVATE
)
# sandboxed_api/sandbox2:mounts
add_library(sandbox2_mounts STATIC
add_library(sandbox2_mounts ${SAPI_LIB_TYPE}
mounts.cc
mounts.h
)
add_library(sandbox2::mounts ALIAS sandbox2_mounts)
target_link_libraries(sandbox2_mounts PRIVATE
absl::core_headers
absl::flat_hash_set
absl::status
absl::statusor
absl::str_format
absl::strings
protobuf::libprotobuf
sandbox2::config
sandbox2::file_base
sandbox2::fileops
sandbox2::minielf
sandbox2::mounttree_proto
sandbox2::strerror
sapi::base
sapi::raw_logging
sapi::status
target_link_libraries(sandbox2_mounts
PRIVATE absl::core_headers
absl::flat_hash_set
absl::status
absl::statusor
absl::str_format
absl::strings
protobuf::libprotobuf
sandbox2::config
sandbox2::file_base
sandbox2::fileops
sandbox2::minielf
sandbox2::strerror
sapi::base
sapi::raw_logging
sapi::status
PUBLIC sandbox2::mounttree_proto
)
# sandboxed_api/sandbox2:namespace
add_library(sandbox2_namespace STATIC
add_library(sandbox2_namespace ${SAPI_LIB_TYPE}
namespace.cc
namespace.h
)
@ -475,7 +476,7 @@ target_link_libraries(sandbox2_namespace PRIVATE
)
# sandboxed_api/sandbox2:forkingclient
add_library(sandbox2_forkingclient STATIC
add_library(sandbox2_forkingclient ${SAPI_LIB_TYPE}
forkingclient.cc
forkingclient.h
)
@ -489,7 +490,7 @@ target_link_libraries(sandbox2_forkingclient
)
# sandboxed_api/sandbox2:util
add_library(sandbox2_util STATIC
add_library(sandbox2_util ${SAPI_LIB_TYPE}
util.cc
util.h
)
@ -515,28 +516,28 @@ target_compile_options(sandbox2_util PRIVATE
)
# sandboxed_api/sandbox2:buffer
add_library(sandbox2_buffer STATIC
add_library(sandbox2_buffer ${SAPI_LIB_TYPE}
buffer.cc
buffer.h
)
add_library(sandbox2::buffer ALIAS sandbox2_buffer)
target_link_libraries(sandbox2_buffer PRIVATE
absl::core_headers
absl::memory
absl::status
absl::statusor
absl::strings
sandbox2::strerror
sandbox2::util
sapi::base
sapi::status
target_link_libraries(sandbox2_buffer
PRIVATE absl::core_headers
absl::memory
absl::status
absl::strings
sandbox2::strerror
sandbox2::util
sapi::base
sapi::status
PUBLIC absl::statusor
)
# sandboxed_api/sandbox2:forkserver_proto
sapi_protobuf_generate_cpp(_sandbox2_forkserver_pb_h _sandbox2_forkserver_pb_cc
forkserver.proto
)
add_library(sandbox2_forkserver_proto STATIC
add_library(sandbox2_forkserver_proto ${SAPI_LIB_TYPE}
${_sandbox2_forkserver_pb_cc}
${_sandbox2_forkserver_pb_h}
)
@ -551,7 +552,7 @@ target_link_libraries(sandbox2_forkserver_proto PRIVATE
sapi_protobuf_generate_cpp(_sandbox2_mounttree_pb_h _sandbox2_mounttree_pb_cc
mounttree.proto
)
add_library(sandbox2_mounttree_proto STATIC
add_library(sandbox2_mounttree_proto ${SAPI_LIB_TYPE}
${_sandbox2_mounttree_pb_cc}
${_sandbox2_mounttree_pb_h}
)
@ -562,7 +563,7 @@ target_link_libraries(sandbox2_mounttree_proto PRIVATE
)
# sandboxed_api/sandbox2:comms
add_library(sandbox2_comms STATIC
add_library(sandbox2_comms ${SAPI_LIB_TYPE}
comms.cc
comms.h
)
@ -589,7 +590,7 @@ target_link_libraries(sandbox2_comms
sapi_protobuf_generate_cpp(_sandbox2_violation_pb_cc _sandbox2_violation_pb_h
violation.proto
)
add_library(sandbox2_violation_proto STATIC
add_library(sandbox2_violation_proto ${SAPI_LIB_TYPE}
${_sandbox2_violation_pb_cc}
${_sandbox2_violation_pb_h}
)
@ -616,7 +617,7 @@ if(SAPI_ENABLE_TESTS)
sandbox2::syscall
sapi::test_main
)
gtest_discover_tests(sandbox2_syscall_test)
gtest_discover_tests_xcompile(sandbox2_syscall_test)
# sandboxed_api/sandbox2:mounts_test
add_executable(sandbox2_mounts_test
@ -637,7 +638,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_mounts_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_mounts_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -666,7 +667,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_namespace_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_namespace_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -686,12 +687,13 @@ if(SAPI_ENABLE_TESTS)
sandbox2::buffer
sandbox2::comms
sandbox2::config
sandbox2::ipc
sandbox2::sandbox2
sandbox2::testing
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_buffer_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_buffer_test PROPERTIES
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -700,7 +702,7 @@ if(SAPI_ENABLE_TESTS)
_sandbox2_comms_test_pb_h _sandbox2_comms_test_pb_cc
comms_test.proto
)
add_library(sandbox2_comms_test_proto STATIC
add_library(sandbox2_comms_test_proto ${SAPI_LIB_TYPE}
${_sandbox2_comms_test_pb_cc}
${_sandbox2_comms_test_pb_h}
)
@ -714,20 +716,16 @@ if(SAPI_ENABLE_TESTS)
add_executable(sandbox2_comms_test
comms_test.cc
)
set_target_properties(sandbox2_comms_test PROPERTIES
OUTPUT_NAME comms_test
target_link_libraries(sandbox2_comms_test
PRIVATE absl::fixed_array
absl::strings
sandbox2::comms
sandbox2::comms_test_proto
sapi::status_matchers
sapi::test_main
PUBLIC glog::glog
)
target_link_libraries(sandbox2_comms_test PRIVATE
absl::fixed_array
absl::strings
glog::glog
gflags::gflags
sandbox2::comms
sandbox2::comms_test_proto
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_comms_test)
gtest_discover_tests_xcompile(sandbox2_comms_test)
# sandboxed_api/sandbox2:forkserver_test
add_executable(sandbox2_forkserver_test
@ -742,7 +740,6 @@ if(SAPI_ENABLE_TESTS)
)
target_link_libraries(sandbox2_forkserver_test PRIVATE
absl::strings
glog::glog
sandbox2::comms
sandbox2::forkserver
sandbox2::forkserver_proto
@ -750,7 +747,7 @@ if(SAPI_ENABLE_TESTS)
sandbox2::testing
sapi::test_main
)
gtest_discover_tests(sandbox2_forkserver_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_forkserver_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -776,7 +773,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_limits_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_limits_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -802,7 +799,7 @@ if(SAPI_ENABLE_TESTS)
sandbox2::testing
sapi::test_main
)
gtest_discover_tests(sandbox2_notify_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_notify_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -832,7 +829,7 @@ if(SAPI_ENABLE_TESTS)
sandbox2::testing
sapi::test_main
)
gtest_discover_tests(sandbox2_policy_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_policy_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -860,7 +857,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_sandbox2_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_sandbox2_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -888,7 +885,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_sanitizer_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_sanitizer_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -906,7 +903,7 @@ if(SAPI_ENABLE_TESTS)
sandbox2::util
sapi::test_main
)
gtest_discover_tests(sandbox2_util_test)
gtest_discover_tests_xcompile(sandbox2_util_test)
# sandboxed_api/sandbox2:stack_trace_test
add_executable(sandbox2_stack_trace_test
@ -933,7 +930,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_stack_trace_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_stack_trace_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -952,19 +949,20 @@ if(SAPI_ENABLE_TESTS)
absl::memory
sandbox2::bpf_helper
sandbox2::comms
sandbox2::ipc
sandbox2::sandbox2
sandbox2::testing
sapi::flags
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_ipc_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_ipc_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
# sandboxed_api/sandbox2:testing
add_library(sandbox2_testing STATIC
add_library(sandbox2_testing ${SAPI_LIB_TYPE}
testing.cc
testing.h
)
@ -985,19 +983,18 @@ if(SAPI_ENABLE_TESTS)
add_dependencies(sandbox2_policybuilder_test
sandbox2::testcase_print_fds
)
target_link_libraries(sandbox2_policybuilder_test PRIVATE
absl::memory
absl::strings
glog::glog
sandbox2::bpf_helper
sandbox2::comms
sandbox2::sandbox2
sandbox2::testing
sapi::flags
sapi::status_matchers
sapi::test_main
target_link_libraries(sandbox2_policybuilder_test
PRIVATE absl::memory
absl::strings
sandbox2::bpf_helper
sandbox2::comms
sandbox2::testing
sapi::flags
sapi::status_matchers
sapi::test_main
PUBLIC sandbox2::sandbox2
)
gtest_discover_tests(sandbox2_policybuilder_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_policybuilder_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)

View File

@ -32,7 +32,6 @@
#include "absl/memory/memory.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/executor.h"
#include "sandboxed_api/sandbox2/ipc.h"
#include "sandboxed_api/sandbox2/limits.h"
#include "sandboxed_api/sandbox2/policy.h"
#include "sandboxed_api/sandbox2/policybuilder.h"

View File

@ -29,7 +29,6 @@
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/executor.h"
#include "sandboxed_api/sandbox2/forkserver.h"
#include "sandboxed_api/sandbox2/ipc.h"
#include "sandboxed_api/sandbox2/limits.h"
#include "sandboxed_api/sandbox2/policy.h"
#include "sandboxed_api/sandbox2/policybuilder.h"

View File

@ -21,7 +21,6 @@ add_dependencies(sandbox2_network_sandbox
sandbox2::network_bin
)
target_link_libraries(sandbox2_network_sandbox PRIVATE
glog::glog
sandbox2::bpf_helper
sandbox2::comms
sandbox2::fileops
@ -39,8 +38,6 @@ set_target_properties(sandbox2_network_bin PROPERTIES OUTPUT_NAME network_bin)
add_executable(sandbox2::network_bin ALIAS sandbox2_network_bin)
target_link_libraries(sandbox2_network_bin PRIVATE
absl::str_format
glog::glog
gflags::gflags
sandbox2::client
sandbox2::comms
sandbox2::fileops

View File

@ -31,7 +31,6 @@
#include "sandboxed_api/util/flag.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/executor.h"
#include "sandboxed_api/sandbox2/ipc.h"
#include "sandboxed_api/sandbox2/policy.h"
#include "sandboxed_api/sandbox2/policybuilder.h"
#include "sandboxed_api/sandbox2/sandbox2.h"

View File

@ -21,7 +21,6 @@ add_dependencies(sandbox2_networkproxy_sandbox
sandbox2::networkproxy_bin
)
target_link_libraries(sandbox2_networkproxy_sandbox PRIVATE
glog::glog
sandbox2::bpf_helper
sandbox2::comms
sandbox2::fileops
@ -39,12 +38,9 @@ set_target_properties(sandbox2_networkproxy_bin PROPERTIES
OUTPUT_NAME networkproxy_bin
)
add_executable(sandbox2::networkproxy_bin ALIAS sandbox2_networkproxy_bin)
target_link_libraries(sandbox2_networkproxy_bin PRIVATE
absl::status
target_link_libraries(sandbox2_networkproxy_bin PRIVATE absl::status
absl::statusor
absl::str_format
glog::glog
gflags::gflags
sandbox2::client
sandbox2::comms
sandbox2::fileops
@ -52,4 +48,5 @@ target_link_libraries(sandbox2_networkproxy_bin PRIVATE
sapi::base
sapi::flags
sapi::status
sandbox2::strerror
)

View File

@ -19,7 +19,6 @@
#include "sandboxed_api/util/flag.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/executor.h"
#include "sandboxed_api/sandbox2/ipc.h"
#include "sandboxed_api/sandbox2/policy.h"
#include "sandboxed_api/sandbox2/policybuilder.h"
#include "sandboxed_api/sandbox2/sandbox2.h"

View File

@ -31,7 +31,6 @@
#include "sandboxed_api/util/flag.h"
#include "absl/memory/memory.h"
#include "sandboxed_api/sandbox2/executor.h"
#include "sandboxed_api/sandbox2/ipc.h"
#include "sandboxed_api/sandbox2/limits.h"
#include "sandboxed_api/sandbox2/policy.h"
#include "sandboxed_api/sandbox2/policybuilder.h"

View File

@ -22,6 +22,7 @@ target_link_libraries(sandbox2_sandbox2tool PRIVATE
absl::memory
absl::strings
sandbox2::bpf_helper
# sandbox2::ipc
sandbox2::sandbox2
sandbox2::util
sapi::base

View File

@ -24,6 +24,7 @@ target_link_libraries(sandbox2_zpipe_sandbox PRIVATE
absl::memory
sandbox2::bpf_helper
sandbox2::comms
# sandbox2::ipc
sandbox2::runfiles
sandbox2::sandbox2
sapi::base

View File

@ -31,7 +31,6 @@
#include "absl/memory/memory.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/executor.h"
#include "sandboxed_api/sandbox2/ipc.h"
#include "sandboxed_api/sandbox2/limits.h"
#include "sandboxed_api/sandbox2/policy.h"
#include "sandboxed_api/sandbox2/policybuilder.h"

View File

@ -13,14 +13,13 @@
# limitations under the License.
# sandboxed_api/sandbox2/network_proxy:server
add_library(sandbox2_network_proxy_server STATIC
add_library(sandbox2_network_proxy_server ${SAPI_LIB_TYPE}
server.cc
server.h
)
add_library(sandbox2::network_proxy_server ALIAS sandbox2_network_proxy_server)
target_link_libraries(sandbox2_network_proxy_server PRIVATE
absl::memory
glog::glog
sandbox2::comms
sandbox2::fileops
sandbox2::network_proxy_filtering
@ -28,7 +27,7 @@ target_link_libraries(sandbox2_network_proxy_server PRIVATE
)
# sandboxed_api/sandbox2/network_proxy:filtering
add_library(sandbox2_network_proxy_filtering STATIC
add_library(sandbox2_network_proxy_filtering ${SAPI_LIB_TYPE}
filtering.cc
filtering.h
)
@ -36,15 +35,17 @@ add_library(sandbox2::network_proxy_filtering ALIAS sandbox2_network_proxy_filte
target_link_libraries(sandbox2_network_proxy_filtering
PRIVATE absl::memory
absl::status
glog::glog
sandbox2::comms
sandbox2::fileops
sapi::base
PUBLIC sapi::status
PUBLIC absl::statusor
glog::glog
sandbox2::strerror
sapi::status
)
# sandboxed_api/sandbox2/network_proxy:client
add_library(sandbox2_network_proxy_client STATIC
add_library(sandbox2_network_proxy_client ${SAPI_LIB_TYPE}
client.cc
client.h
)
@ -70,13 +71,11 @@ if(SAPI_ENABLE_TESTS)
)
target_link_libraries(sandbox2_filtering_test PRIVATE
absl::strings
glog::glog
gflags::gflags
sandbox2::network_proxy_filtering
sandbox2::testing
sapi::base
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_filtering_test)
gtest_discover_tests_xcompile(sandbox2_filtering_test)
endif()

View File

@ -12,7 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(_sandbox2_fully_static_linkopts -static)
if(SAPI_LIB_TYPE STREQUAL "STATIC")
set(_sandbox2_linkopts -static)
else()
set(_sandbox2_linkopts ${CMAKE_THREAD_LIBS_INIT})
endif()
# sandboxed_api/sandbox2/testcases:abort
add_executable(sandbox2_testcase_abort
@ -36,7 +40,7 @@ set_target_properties(sandbox2_testcase_add_policy_on_syscalls PROPERTIES
OUTPUT_NAME add_policy_on_syscalls
)
target_link_libraries(sandbox2_testcase_add_policy_on_syscalls PRIVATE
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:buffer
@ -52,7 +56,7 @@ target_link_libraries(sandbox2_testcase_buffer PRIVATE
sandbox2::buffer
sandbox2::comms
sapi::base
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:ipc
@ -65,10 +69,6 @@ set_target_properties(sandbox2_testcase_ipc PROPERTIES
add_executable(sandbox2::testcase_ipc ALIAS sandbox2_testcase_ipc)
target_link_libraries(sandbox2_testcase_ipc PRIVATE
absl::strings
-Wl,--whole-archive
gflags::gflags
-Wl,--no-whole-archive
glog::glog
sandbox2::client
sandbox2::comms
sapi::base
@ -86,7 +86,7 @@ set_target_properties(sandbox2_testcase_malloc_system PROPERTIES
)
target_link_libraries(sandbox2_testcase_malloc_system PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:minimal_dynamic
@ -112,7 +112,7 @@ set_target_properties(sandbox2_testcase_minimal PROPERTIES
)
target_link_libraries(sandbox2_testcase_minimal PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:personality
@ -126,7 +126,7 @@ set_target_properties(sandbox2_testcase_personality PROPERTIES
)
target_link_libraries(sandbox2_testcase_personality PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:pidcomms
@ -138,15 +138,11 @@ set_target_properties(sandbox2_testcase_pidcomms PROPERTIES
OUTPUT_NAME pidcomms
)
target_link_libraries(sandbox2_testcase_pidcomms PRIVATE
-Wl,--whole-archive
gflags::gflags
-Wl,--no-whole-archive
glog::glog
sandbox2::client
sandbox2::comms
sapi::base
sapi::raw_logging
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:policy
@ -160,7 +156,7 @@ set_target_properties(sandbox2_testcase_policy PROPERTIES
target_link_libraries(sandbox2_testcase_policy PRIVATE
sapi::base
sandbox2::config
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:print_fds
@ -173,7 +169,7 @@ set_target_properties(sandbox2_testcase_print_fds PROPERTIES
)
target_link_libraries(sandbox2_testcase_print_fds PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:sanitizer
@ -186,7 +182,7 @@ set_target_properties(sandbox2_testcase_sanitizer PROPERTIES
)
target_link_libraries(sandbox2_testcase_sanitizer PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:sleep
@ -199,7 +195,7 @@ set_target_properties(sandbox2_testcase_sleep PROPERTIES
)
target_link_libraries(sandbox2_testcase_sleep PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:symbolize
@ -214,9 +210,10 @@ target_link_libraries(sandbox2_testcase_symbolize PRIVATE
absl::core_headers
absl::strings
sandbox2::temp_file
sandbox2::strerror
sapi::base
sapi::raw_logging
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:starve
@ -241,14 +238,10 @@ set_target_properties(sandbox2_testcase_tsync PROPERTIES
OUTPUT_NAME tsync
)
target_link_libraries(sandbox2_testcase_tsync PRIVATE
-Wl,--whole-archive
gflags::gflags
-Wl,--no-whole-archive
glog::glog
sandbox2::client
sandbox2::comms
sapi::base
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:hostname
@ -261,7 +254,7 @@ set_target_properties(sandbox2_testcase_hostname PROPERTIES
)
target_link_libraries(sandbox2_testcase_hostname PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:limits
@ -274,7 +267,7 @@ set_target_properties(sandbox2_testcase_limits PROPERTIES
)
target_link_libraries(sandbox2_testcase_limits PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)
# sandboxed_api/sandbox2/testcases:namespace
@ -287,5 +280,5 @@ set_target_properties(sandbox2_testcase_namespace PROPERTIES
)
target_link_libraries(sandbox2_testcase_namespace PRIVATE
sapi::base
${_sandbox2_fully_static_linkopts}
${_sandbox2_linkopts}
)

View File

@ -13,7 +13,7 @@
# limitations under the License.
# sandboxed_api/sandbox2/util:bpf_helper
add_library(sandbox2_util_bpf_helper STATIC
add_library(sandbox2_util_bpf_helper ${SAPI_LIB_TYPE}
bpf_helper.c
bpf_helper.h
)
@ -23,7 +23,7 @@ target_link_libraries(sandbox2_util_bpf_helper PRIVATE
)
# sandboxed_api/sandbox2/util:file_helpers
add_library(sandbox2_util_file_helpers STATIC
add_library(sandbox2_util_file_helpers ${SAPI_LIB_TYPE}
file_helpers.cc
file_helpers.h
)
@ -35,7 +35,7 @@ target_link_libraries(sandbox2_util_file_helpers PRIVATE
)
# sandboxed_api/sandbox2/util:fileops
add_library(sandbox2_util_fileops STATIC
add_library(sandbox2_util_fileops ${SAPI_LIB_TYPE}
fileops.cc
fileops.h
)
@ -47,7 +47,7 @@ target_link_libraries(sandbox2_util_fileops PRIVATE
)
# sandboxed_api/sandbox2/util:file_base
add_library(sandbox2_util_file_base STATIC
add_library(sandbox2_util_file_base ${SAPI_LIB_TYPE}
path.cc
path.h
)
@ -58,7 +58,7 @@ target_link_libraries(sandbox2_util_file_base PRIVATE
)
# sandboxed_api/sandbox2/util:strerror
add_library(sandbox2_util_strerror STATIC
add_library(sandbox2_util_strerror ${SAPI_LIB_TYPE}
strerror.cc
strerror.h
)
@ -69,7 +69,7 @@ target_link_libraries(sandbox2_util_strerror PRIVATE
)
# sandboxed_api/sandbox2/util:minielf
add_library(sandbox2_util_minielf STATIC
add_library(sandbox2_util_minielf ${SAPI_LIB_TYPE}
minielf.cc
minielf.h
)
@ -77,13 +77,14 @@ add_library(sandbox2::minielf ALIAS sandbox2_util_minielf)
target_link_libraries(sandbox2_util_minielf PRIVATE
absl::status
absl::strings
sandbox2::strerror
sandbox2::util
sapi::base
sapi::raw_logging
)
# sandboxed_api/sandbox2/util:temp_file
add_library(sandbox2_util_temp_file STATIC
add_library(sandbox2_util_temp_file ${SAPI_LIB_TYPE}
temp_file.cc
temp_file.h
)
@ -98,20 +99,20 @@ target_link_libraries(sandbox2_util_temp_file
)
# sandboxed_api/sandbox2/util:maps_parser
add_library(sandbox2_util_maps_parser STATIC
add_library(sandbox2_util_maps_parser ${SAPI_LIB_TYPE}
maps_parser.cc
maps_parser.h
)
add_library(sandbox2::maps_parser ALIAS sandbox2_util_maps_parser)
target_link_libraries(sandbox2_util_maps_parser PRIVATE
absl::status
absl::statusor
absl::strings
sapi::base
target_link_libraries(sandbox2_util_maps_parser
PRIVATE absl::status
absl::strings
sapi::base
PUBLIC absl::statusor
)
# sandboxed_api/sandbox2/util:runfiles
add_library(sandbox2_util_runfiles STATIC
add_library(sandbox2_util_runfiles ${SAPI_LIB_TYPE}
runfiles.h
runfiles_nobazel.cc
)
@ -139,7 +140,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_file_helpers_test)
gtest_discover_tests_xcompile(sandbox2_file_helpers_test)
# sandboxed_api/sandbox2/util:fileops_test
add_executable(sandbox2_fileops_test
@ -156,7 +157,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_fileops_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_fileops_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -173,7 +174,7 @@ if(SAPI_ENABLE_TESTS)
sandbox2::file_base
sapi::test_main
)
gtest_discover_tests(sandbox2_file_base_test)
gtest_discover_tests_xcompile(sandbox2_file_base_test)
# sandboxed_api/sandbox2/util:strerror
add_executable(sandbox2_strerror_test
@ -187,7 +188,7 @@ if(SAPI_ENABLE_TESTS)
sandbox2::strerror
sapi::test_main
)
gtest_discover_tests(sandbox2_strerror_test)
gtest_discover_tests_xcompile(sandbox2_strerror_test)
# sandboxed_api/sandbox2/util:minielf_test
add_executable(sandbox2_minielf_test
@ -200,17 +201,18 @@ if(SAPI_ENABLE_TESTS)
testdata/hello_world COPYONLY)
configure_file(testdata/chrome_grte_header
testdata/chrome_grte_header COPYONLY)
target_link_libraries(sandbox2_minielf_test PRIVATE
absl::algorithm_container
absl::strings
sandbox2::file_helpers
sandbox2::maps_parser
sandbox2::minielf
sandbox2::testing
sapi::status_matchers
sapi::test_main
target_link_libraries(sandbox2_minielf_test
PRIVATE absl::algorithm_container
absl::strings
sandbox2::file_helpers
sandbox2::maps_parser
sandbox2::minielf
sandbox2::testing
sapi::status_matchers
sapi::test_main
PUBLIC absl::statusor
)
gtest_discover_tests(sandbox2_minielf_test PROPERTIES
gtest_discover_tests_xcompile(sandbox2_minielf_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)
@ -230,7 +232,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_temp_file_test)
gtest_discover_tests_xcompile(sandbox2_temp_file_test)
# sandboxed_api/sandbox2/util:maps_parser_test
add_executable(sandbox2_maps_parser_test
@ -244,5 +246,5 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sandbox2_maps_parser_test)
gtest_discover_tests_xcompile(sandbox2_maps_parser_test)
endif()

View File

@ -81,5 +81,5 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sapi_generator_test)
gtest_discover_tests_xcompile(sapi_generator_test)
endif()

View File

@ -18,6 +18,7 @@ add_executable(filewrapper
)
target_link_libraries(filewrapper PRIVATE
absl::strings
absl::str_format
sandbox2::fileops
sandbox2::strerror
sapi::base
@ -48,7 +49,7 @@ if(SAPI_ENABLE_TESTS)
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests(sapi_filewrapper_test PROPERTIES
gtest_discover_tests_xcompile(sapi_filewrapper_test PROPERTIES
ENVIRONMENT "TEST_TMPDIR=/tmp"
ENVIRONMENT "TEST_SRCDIR=${PROJECT_BINARY_DIR}"
)

View File

@ -16,7 +16,7 @@
sapi_protobuf_generate_cpp(_sapi_util_status_pb_cc _sapi_util_status_pb_h
status.proto
)
add_library(sapi_util_status_proto STATIC
add_library(sapi_util_status_proto ${SAPI_LIB_TYPE}
${_sapi_util_status_pb_cc}
${_sapi_util_status_pb_h}
)
@ -27,7 +27,7 @@ target_link_libraries(sapi_util_status_proto
)
# sandboxed_api/util:status
add_library(sapi_util_status STATIC
add_library(sapi_util_status ${SAPI_LIB_TYPE}
status.cc
status.h
status_macros.h
@ -43,7 +43,7 @@ target_link_libraries(sapi_util_status
)
# sandboxed_api/util:statusor
add_library(sapi_util_statusor STATIC
add_library(sapi_util_statusor ${SAPI_LIB_TYPE}
statusor.h
)
add_library(sapi::statusor ALIAS sapi_util_statusor)
@ -55,16 +55,19 @@ target_link_libraries(sapi_util_statusor PRIVATE
)
# sandboxed_api/util:flag
add_library(sapi_util_flags STATIC
file(WRITE ${SAPI_BINARY_DIR}/sapi_util_flags_force_cxx_linkage.cc "")
add_library(sapi_util_flags ${SAPI_LIB_TYPE}
flag.h
"${SAPI_BINARY_DIR}/sapi_util_flags_force_cxx_linkage.cc"
)
add_library(sapi::flags ALIAS sapi_util_flags)
target_link_libraries(sapi_util_flags PUBLIC
gflags::gflags
glog::glog
# gflags::gflags
)
# sandboxed_api/util:raw_logging
add_library(sapi_util_raw_logging STATIC
add_library(sapi_util_raw_logging ${SAPI_LIB_TYPE}
raw_logging.cc
raw_logging.h
)
@ -78,7 +81,7 @@ target_link_libraries(sapi_util_raw_logging PRIVATE
if(SAPI_ENABLE_TESTS)
# sandboxed_api/util:status_matchers
add_library(sapi_util_status_matchers STATIC
add_library(sapi_util_status_matchers ${SAPI_LIB_TYPE}
status_matchers.h
)
add_library(sapi::status_matchers ALIAS sapi_util_status_matchers)
@ -103,7 +106,7 @@ if(SAPI_ENABLE_TESTS)
absl::status
absl::type_traits
)
gtest_discover_tests(sapi_status_test)
gtest_discover_tests_xcompile(sapi_status_test)
# sandboxed_api/util:status_macros_test
add_executable(sapi_status_macros_test
@ -119,5 +122,5 @@ if(SAPI_ENABLE_TESTS)
absl::statusor
absl::type_traits
)
gtest_discover_tests(sapi_status_macros_test)
gtest_discover_tests_xcompile(sapi_status_macros_test)
endif()