2020-01-17 21:05:03 +08:00
|
|
|
# Copyright 2019 Google LLC
|
2019-05-06 20:03:29 +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
|
|
|
|
#
|
2022-01-28 17:38:27 +08:00
|
|
|
# https://www.apache.org/licenses/LICENSE-2.0
|
2019-05-06 20:03:29 +08:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2020-05-29 20:40:31 +08:00
|
|
|
add_subdirectory(tools/filewrapper)
|
2019-05-06 20:03:29 +08:00
|
|
|
add_subdirectory(sandbox2)
|
|
|
|
add_subdirectory(util)
|
2023-05-12 15:29:13 +08:00
|
|
|
if(SAPI_ENABLE_CLANG_TOOL AND NOT SAPI_CLANG_TOOL_EXECUTABLE)
|
2019-06-25 20:48:56 +08:00
|
|
|
add_subdirectory(tools/clang_generator)
|
|
|
|
endif()
|
|
|
|
add_subdirectory(examples)
|
2019-05-06 20:03:29 +08:00
|
|
|
|
2021-01-14 01:25:25 +08:00
|
|
|
# sandboxed_api:config
|
|
|
|
add_library(sapi_config ${SAPI_LIB_TYPE}
|
2023-08-31 15:43:30 +08:00
|
|
|
config.cc
|
2021-01-14 01:25:25 +08:00
|
|
|
config.h
|
|
|
|
)
|
|
|
|
add_library(sapi::config ALIAS sapi_config)
|
2021-02-04 01:00:41 +08:00
|
|
|
target_link_libraries(sapi_config
|
|
|
|
PRIVATE sapi::base
|
2023-08-31 15:43:30 +08:00
|
|
|
PUBLIC absl::config
|
2021-01-14 01:25:25 +08:00
|
|
|
)
|
|
|
|
|
2019-07-09 21:12:49 +08:00
|
|
|
# sandboxed_api:proto_arg
|
2020-03-19 01:47:02 +08:00
|
|
|
sapi_protobuf_generate_cpp(_sapi_proto_arg_pb_cc _sapi_proto_arg_pb_h
|
2019-07-09 21:12:49 +08:00
|
|
|
proto_arg.proto
|
|
|
|
)
|
2020-12-15 01:15:40 +08:00
|
|
|
add_library(sapi_proto_arg_proto ${SAPI_LIB_TYPE}
|
2019-07-09 21:12:49 +08:00
|
|
|
${_sapi_proto_arg_pb_cc}
|
|
|
|
${_sapi_proto_arg_pb_h}
|
|
|
|
)
|
|
|
|
add_library(sapi::proto_arg_proto ALIAS sapi_proto_arg_proto)
|
|
|
|
target_link_libraries(sapi_proto_arg_proto PRIVATE
|
|
|
|
protobuf::libprotobuf
|
|
|
|
sapi::base
|
|
|
|
)
|
|
|
|
|
2019-05-06 20:03:29 +08:00
|
|
|
# sandboxed_api:embed_file
|
2020-12-15 01:15:40 +08:00
|
|
|
add_library(sapi_embed_file ${SAPI_LIB_TYPE}
|
2019-05-06 20:03:29 +08:00
|
|
|
embed_file.cc
|
|
|
|
embed_file.h
|
|
|
|
file_toc.h
|
|
|
|
)
|
|
|
|
add_library(sapi::embed_file ALIAS sapi_embed_file)
|
2020-12-15 01:15:40 +08:00
|
|
|
target_link_libraries(sapi_embed_file
|
2023-08-24 23:57:49 +08:00
|
|
|
PRIVATE absl::strings
|
2020-12-15 01:15:40 +08:00
|
|
|
sandbox2::util
|
|
|
|
sapi::base
|
2023-08-02 20:27:05 +08:00
|
|
|
sapi::fileops
|
2020-12-15 01:15:40 +08:00
|
|
|
sapi::raw_logging
|
2023-08-02 20:27:05 +08:00
|
|
|
PUBLIC absl::flat_hash_map
|
|
|
|
absl::synchronization
|
2019-05-06 20:03:29 +08:00
|
|
|
)
|
2019-07-09 21:12:49 +08:00
|
|
|
|
|
|
|
# sandboxed_api:sapi
|
2020-12-15 01:15:40 +08:00
|
|
|
add_library(sapi_sapi ${SAPI_LIB_TYPE}
|
2019-07-09 21:12:49 +08:00
|
|
|
sandbox.cc
|
|
|
|
sandbox.h
|
|
|
|
transaction.cc
|
|
|
|
transaction.h
|
|
|
|
)
|
|
|
|
add_library(sapi::sapi ALIAS sapi_sapi)
|
2019-07-26 20:50:45 +08:00
|
|
|
target_link_libraries(sapi_sapi
|
2023-08-24 23:57:49 +08:00
|
|
|
PRIVATE absl::base
|
|
|
|
absl::dynamic_annotations
|
2021-04-13 16:43:36 +08:00
|
|
|
absl::flat_hash_map
|
2023-08-24 23:57:49 +08:00
|
|
|
absl::log
|
|
|
|
absl::log_globals
|
2020-09-03 22:40:09 +08:00
|
|
|
absl::status
|
|
|
|
absl::statusor
|
2019-07-26 20:50:45 +08:00
|
|
|
absl::str_format
|
|
|
|
absl::strings
|
|
|
|
absl::synchronization
|
|
|
|
sandbox2::bpf_helper
|
2021-01-14 01:25:25 +08:00
|
|
|
sapi::file_base
|
|
|
|
sapi::fileops
|
|
|
|
sapi::runfiles
|
|
|
|
sapi::strerror
|
2019-07-26 20:50:45 +08:00
|
|
|
sandbox2::util
|
|
|
|
sapi::embed_file
|
|
|
|
sapi::vars
|
2023-08-24 21:23:03 +08:00
|
|
|
PUBLIC absl::check
|
|
|
|
absl::core_headers
|
2019-07-26 20:50:45 +08:00
|
|
|
sandbox2::client
|
2020-12-15 01:15:40 +08:00
|
|
|
sandbox2::sandbox2
|
2019-07-26 20:50:45 +08:00
|
|
|
sapi::base
|
|
|
|
sapi::status
|
2019-07-09 21:12:49 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# sandboxed_api:call
|
2020-12-15 01:15:40 +08:00
|
|
|
add_library(sapi_call ${SAPI_LIB_TYPE}
|
2019-07-09 21:12:49 +08:00
|
|
|
call.h
|
|
|
|
)
|
|
|
|
add_library(sapi::call ALIAS sapi_call)
|
|
|
|
target_link_libraries(sapi_call PRIVATE
|
2023-08-24 23:57:49 +08:00
|
|
|
absl::core_headers
|
2019-07-09 21:12:49 +08:00
|
|
|
sapi::var_type
|
|
|
|
sapi::base
|
|
|
|
)
|
|
|
|
|
|
|
|
# sandboxed_api:lenval_core
|
2020-12-15 01:15:40 +08:00
|
|
|
add_library(sapi_lenval_core ${SAPI_LIB_TYPE}
|
2019-07-09 21:12:49 +08:00
|
|
|
lenval_core.h
|
|
|
|
)
|
|
|
|
add_library(sapi::lenval_core ALIAS sapi_lenval_core)
|
|
|
|
target_link_libraries(sapi_lenval_core PRIVATE
|
|
|
|
sapi::base
|
|
|
|
)
|
|
|
|
|
|
|
|
# sandboxed_api:var_type
|
2020-12-15 01:15:40 +08:00
|
|
|
add_library(sapi_var_type ${SAPI_LIB_TYPE}
|
2019-07-09 21:12:49 +08:00
|
|
|
var_type.h
|
|
|
|
)
|
|
|
|
add_library(sapi::var_type ALIAS sapi_var_type)
|
|
|
|
target_link_libraries(sapi_var_type PRIVATE
|
|
|
|
sapi::base
|
|
|
|
)
|
|
|
|
|
|
|
|
# sandboxed_api:vars
|
2020-12-15 01:15:40 +08:00
|
|
|
add_library(sapi_vars ${SAPI_LIB_TYPE}
|
2022-01-19 18:37:25 +08:00
|
|
|
proto_helper.cc
|
2019-07-09 21:12:49 +08:00
|
|
|
proto_helper.h
|
|
|
|
rpcchannel.cc
|
|
|
|
rpcchannel.h
|
|
|
|
var_abstract.cc
|
|
|
|
var_abstract.h
|
|
|
|
var_array.h
|
|
|
|
var_int.cc
|
|
|
|
var_int.h
|
|
|
|
var_lenval.cc
|
|
|
|
var_lenval.h
|
|
|
|
var_proto.h
|
|
|
|
var_ptr.h
|
|
|
|
var_reg.h
|
|
|
|
var_struct.h
|
|
|
|
var_void.h
|
|
|
|
vars.h
|
|
|
|
)
|
|
|
|
add_library(sapi::vars ALIAS sapi_vars)
|
2020-12-15 01:15:40 +08:00
|
|
|
target_link_libraries(sapi_vars
|
|
|
|
PRIVATE absl::core_headers
|
|
|
|
absl::status
|
|
|
|
absl::statusor
|
|
|
|
absl::str_format
|
|
|
|
absl::strings
|
|
|
|
absl::synchronization
|
2021-07-30 18:54:45 +08:00
|
|
|
absl::utility
|
2020-12-15 01:15:40 +08:00
|
|
|
sandbox2::comms
|
|
|
|
sapi::base
|
|
|
|
sapi::call
|
|
|
|
sapi::lenval_core
|
|
|
|
sapi::proto_arg_proto
|
|
|
|
sapi::status
|
|
|
|
sapi::var_type
|
2022-10-20 21:48:06 +08:00
|
|
|
PUBLIC absl::log
|
2019-07-09 21:12:49 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# sandboxed_api:client
|
2020-12-15 01:15:40 +08:00
|
|
|
add_library(sapi_client ${SAPI_LIB_TYPE}
|
2019-07-09 21:12:49 +08:00
|
|
|
client.cc
|
|
|
|
)
|
|
|
|
add_library(sapi::client ALIAS sapi_client)
|
2020-12-15 01:15:40 +08:00
|
|
|
target_link_libraries(sapi_client
|
2023-08-24 21:23:03 +08:00
|
|
|
PRIVATE absl::check
|
|
|
|
absl::core_headers
|
2021-02-01 23:10:43 +08:00
|
|
|
absl::dynamic_annotations
|
2022-10-20 21:48:06 +08:00
|
|
|
absl::flags_parse
|
2023-08-24 21:23:03 +08:00
|
|
|
absl::log
|
2023-08-24 23:57:49 +08:00
|
|
|
absl::log_flags
|
2022-10-20 21:48:06 +08:00
|
|
|
absl::log_initialize
|
2023-08-25 16:48:53 +08:00
|
|
|
absl::statusor
|
2020-12-15 01:15:40 +08:00
|
|
|
absl::strings
|
|
|
|
libffi::libffi
|
|
|
|
sandbox2::comms
|
|
|
|
sandbox2::forkingclient
|
|
|
|
sandbox2::logsink
|
|
|
|
sapi::base
|
|
|
|
sapi::call
|
|
|
|
sapi::lenval_core
|
|
|
|
sapi::proto_arg_proto
|
|
|
|
sapi::vars
|
|
|
|
${CMAKE_DL_LIBS}
|
2019-07-09 21:12:49 +08:00
|
|
|
)
|
|
|
|
|
2022-04-21 16:17:08 +08:00
|
|
|
if(BUILD_TESTING AND SAPI_BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
|
2021-02-01 23:10:43 +08:00
|
|
|
# sandboxed_api:testing
|
|
|
|
add_library(sapi_testing ${SAPI_LIB_TYPE}
|
|
|
|
testing.cc
|
|
|
|
testing.h
|
|
|
|
)
|
|
|
|
add_library(sapi::testing ALIAS sapi_testing)
|
2023-03-03 00:45:23 +08:00
|
|
|
target_link_libraries(sapi_testing
|
|
|
|
PRIVATE absl::strings
|
|
|
|
sapi::file_base
|
|
|
|
sapi::base
|
|
|
|
PUBLIC sapi::config
|
|
|
|
sandbox2::allow_all_syscalls
|
|
|
|
sandbox2::policybuilder
|
2021-02-01 23:10:43 +08:00
|
|
|
)
|
|
|
|
|
2019-11-21 20:03:47 +08:00
|
|
|
# sandboxed_api:sapi_test
|
|
|
|
add_executable(sapi_test
|
|
|
|
sapi_test.cc
|
|
|
|
)
|
|
|
|
target_link_libraries(sapi_test PRIVATE
|
2020-09-03 22:40:09 +08:00
|
|
|
absl::status
|
2020-12-15 01:15:40 +08:00
|
|
|
absl::statusor
|
2023-08-25 16:48:53 +08:00
|
|
|
absl::time
|
2019-11-21 20:03:47 +08:00
|
|
|
benchmark
|
2020-12-15 01:15:40 +08:00
|
|
|
sandbox2::result
|
|
|
|
sapi::proto_arg_proto
|
2019-11-21 20:03:47 +08:00
|
|
|
sapi::sapi
|
|
|
|
sapi::status
|
|
|
|
sapi::status_matchers
|
|
|
|
sapi::stringop_sapi
|
|
|
|
sapi::sum_sapi
|
|
|
|
sapi::test_main
|
2021-02-01 23:10:43 +08:00
|
|
|
sapi::testing
|
2019-11-21 20:03:47 +08:00
|
|
|
)
|
2020-12-15 01:15:40 +08:00
|
|
|
gtest_discover_tests_xcompile(sapi_test)
|
2019-11-21 20:03:47 +08:00
|
|
|
endif()
|
2020-12-15 01:15:40 +08:00
|
|
|
|
|
|
|
# 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)
|
2021-01-14 01:25:25 +08:00
|
|
|
install(TARGETS ${_sapi_targets}
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
2020-12-15 01:15:40 +08:00
|
|
|
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})
|
2021-01-14 01:25:25 +08:00
|
|
|
install(FILES ${_file}
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sandboxed_api/${_dir})
|
2020-12-15 01:15:40 +08:00
|
|
|
endforeach()
|
2020-12-16 22:45:33 +08:00
|
|
|
|
|
|
|
configure_file(
|
|
|
|
"${PROJECT_SOURCE_DIR}/cmake/sapi.pc.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/sapi.pc"
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
|
2021-01-14 01:25:25 +08:00
|
|
|
install(FILES "${PROJECT_BINARY_DIR}/sapi.pc"
|
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|