mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Introduce a transitional logging utility library
Instead of calling `google::InitGoogleLogging()` directly, introduce an indirection via a new utility library. After this change, Sandboxed API should consistently use `sapi::InitLogging()` everywhere. For now, `sapi::InitLogging()` simply calls its glog equivalent. However, this enables us to migrate away from the gflags dependency and use Abseil flags. Once a follow-up change lands, `sapi::InitLogging()` will instead initialize the google logging library with flags defined from Aseil. Later still, once Abseil releases logging, we can then drop the glog dependency entirely. PiperOrigin-RevId: 445363592 Change-Id: Ia23a7dc88b8ffe65a422ea4d5233bba7bdd1303a
This commit is contained in:
parent
905c252e71
commit
51799f99ae
|
@ -38,5 +38,6 @@ set_target_properties(gflags_nothreads PROPERTIES
|
||||||
IMPORTED_LOCATION "${gflags_BINARY_DIR}/libgflags_nothreads.a"
|
IMPORTED_LOCATION "${gflags_BINARY_DIR}/libgflags_nothreads.a"
|
||||||
)
|
)
|
||||||
target_link_libraries(glog PRIVATE
|
target_link_libraries(glog PRIVATE
|
||||||
-Wl,--whole-archive gflags_nothreads -Wl,--no-whole-archive
|
#-Wl,--whole-archive gflags_nothreads -Wl,--no-whole-archive
|
||||||
|
gflags_nothreads
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,19 +12,15 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
add_executable(
|
add_executable(sapi_minibrotli
|
||||||
sapi_minibroli
|
|
||||||
|
|
||||||
main.cc
|
main.cc
|
||||||
../utils/utils_brotli.cc
|
../utils/utils_brotli.cc
|
||||||
../utils/utils_brotli_enc.cc
|
../utils/utils_brotli_enc.cc
|
||||||
../utils/utils_brotli_dec.cc
|
../utils/utils_brotli_dec.cc
|
||||||
)
|
)
|
||||||
|
target_link_libraries(sapi_minibrotli
|
||||||
target_link_libraries(
|
PRIVATE absl::flags_parse
|
||||||
sapi_minibroli PRIVATE
|
sapi_contrib::brotli
|
||||||
|
sapi::logging
|
||||||
sapi_brotli
|
sapi::sapi
|
||||||
sapi::sapi
|
|
||||||
absl::flags_parse
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "contrib/brotli/utils/utils_brotli.h"
|
#include "contrib/brotli/utils/utils_brotli.h"
|
||||||
#include "contrib/brotli/utils/utils_brotli_dec.h"
|
#include "contrib/brotli/utils/utils_brotli_dec.h"
|
||||||
#include "contrib/brotli/utils/utils_brotli_enc.h"
|
#include "contrib/brotli/utils/utils_brotli_enc.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
|
|
||||||
ABSL_FLAG(bool, decompress, false, "decompress");
|
ABSL_FLAG(bool, decompress, false, "decompress");
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ absl::Status DecompressInMemory(BrotliSandbox &sandbox,
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
std::string prog_name(argv[0]);
|
std::string prog_name(argv[0]);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
std::vector<char *> args = absl::ParseCommandLine(argc, argv);
|
std::vector<char *> args = absl::ParseCommandLine(argc, argv);
|
||||||
|
|
||||||
if (args.size() != 3) {
|
if (args.size() != 3) {
|
||||||
|
|
|
@ -30,6 +30,9 @@ if(NOT TARGET sapi::sapi)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(HIDE_SYMBOLS OFF CACHE BOOL "" FORCE)
|
set(HIDE_SYMBOLS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(BUILD_FUZZERS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
libblosc
|
libblosc
|
||||||
|
|
||||||
|
@ -38,45 +41,37 @@ FetchContent_Declare(
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(libblosc)
|
FetchContent_MakeAvailable(libblosc)
|
||||||
|
|
||||||
add_sapi_library(
|
add_sapi_library(sapi_blosc
|
||||||
sapi_blosc
|
FUNCTIONS blosc_init
|
||||||
|
blosc_destroy
|
||||||
|
|
||||||
FUNCTIONS
|
blosc_compress
|
||||||
blosc_init
|
blosc_decompress
|
||||||
blosc_destroy
|
|
||||||
|
|
||||||
blosc_compress
|
blosc_get_nthreads
|
||||||
blosc_decompress
|
blosc_set_nthreads
|
||||||
|
|
||||||
blosc_get_nthreads
|
blosc_get_compressor
|
||||||
blosc_set_nthreads
|
blosc_set_compressor
|
||||||
|
|
||||||
blosc_get_compressor
|
blosc_list_compressors
|
||||||
blosc_set_compressor
|
|
||||||
|
|
||||||
blosc_list_compressors
|
blosc_get_version_string
|
||||||
|
|
||||||
blosc_get_version_string
|
blosc_get_blocksize
|
||||||
|
blosc_set_blocksize
|
||||||
|
|
||||||
blosc_get_blocksize
|
blosc_set_splitmode
|
||||||
blosc_set_blocksize
|
|
||||||
|
|
||||||
blosc_set_splitmode
|
|
||||||
|
|
||||||
blosc_cbuffer_sizes
|
|
||||||
blosc_cbuffer_validate
|
|
||||||
blosc_cbuffer_versions
|
|
||||||
|
|
||||||
INPUTS
|
|
||||||
"${libblosc_SOURCE_DIR}/blosc/blosc.h"
|
|
||||||
|
|
||||||
|
blosc_cbuffer_sizes
|
||||||
|
blosc_cbuffer_validate
|
||||||
|
blosc_cbuffer_versions
|
||||||
|
INPUTS "${libblosc_SOURCE_DIR}/blosc/blosc.h"
|
||||||
LIBRARY blosc_static
|
LIBRARY blosc_static
|
||||||
LIBRARY_NAME Cblosc
|
LIBRARY_NAME Cblosc
|
||||||
NAMESPACE ""
|
NAMESPACE ""
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(sapi_contrib::blosc ALIAS sapi_blosc)
|
add_library(sapi_contrib::blosc ALIAS sapi_blosc)
|
||||||
|
|
||||||
target_include_directories(sapi_blosc INTERFACE
|
target_include_directories(sapi_blosc INTERFACE
|
||||||
"${PROJECT_BINARY_DIR}"
|
"${PROJECT_BINARY_DIR}"
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,9 +12,7 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
add_executable(
|
add_executable(sapi_miniblosc
|
||||||
sapi_miniblosc
|
|
||||||
|
|
||||||
main.cc
|
main.cc
|
||||||
../utils/utils_blosc.cc
|
../utils/utils_blosc.cc
|
||||||
)
|
)
|
||||||
|
@ -23,10 +21,9 @@ target_include_directories(sapi_miniblosc INTERFACE
|
||||||
"${SAPI_SOURCE_DIR}"
|
"${SAPI_SOURCE_DIR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(sapi_miniblosc
|
||||||
sapi_miniblosc PRIVATE
|
PRIVATE sapi_contrib::blosc
|
||||||
|
absl::flags_parse
|
||||||
sapi_blosc
|
sapi::logging
|
||||||
sapi::sapi
|
sapi::sapi
|
||||||
absl::flags_parse
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include "contrib/c-blosc/sandboxed.h"
|
#include "contrib/c-blosc/sandboxed.h"
|
||||||
#include "contrib/c-blosc/utils/utils_blosc.h"
|
#include "contrib/c-blosc/utils/utils_blosc.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
|
|
||||||
ABSL_FLAG(bool, decompress, false, "decompress");
|
ABSL_FLAG(bool, decompress, false, "decompress");
|
||||||
ABSL_FLAG(int, clevel, 5, "compression level");
|
ABSL_FLAG(int, clevel, 5, "compression level");
|
||||||
|
@ -52,8 +53,8 @@ absl::Status Stream(CbloscApi& api, std::string& infile_s,
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
std::string prog_name(argv[0]);
|
std::string prog_name(argv[0]);
|
||||||
google::InitGoogleLogging(argv[0]);
|
|
||||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||||
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (args.size() != 3) {
|
if (args.size() != 3) {
|
||||||
std::cerr << "Usage:\n " << prog_name << " INPUT OUTPUT\n";
|
std::cerr << "Usage:\n " << prog_name << " INPUT OUTPUT\n";
|
||||||
|
|
|
@ -128,7 +128,7 @@ add_sapi_library(
|
||||||
LIBRARY_NAME Hunspell
|
LIBRARY_NAME Hunspell
|
||||||
NAMESPACE ""
|
NAMESPACE ""
|
||||||
)
|
)
|
||||||
|
add_library(sapi_contrib::hunspell ALIAS sapi_hunspell)
|
||||||
target_include_directories(sapi_hunspell INTERFACE
|
target_include_directories(sapi_hunspell INTERFACE
|
||||||
"${PROJECT_BINARY_DIR}"
|
"${PROJECT_BINARY_DIR}"
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,15 +12,12 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
add_executable(
|
add_executable(sapi_minihunspell
|
||||||
sapi_minihunspell
|
|
||||||
|
|
||||||
main.cc
|
main.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(sapi_minihunspell
|
||||||
sapi_minihunspell PRIVATE
|
PRIVATE sapi_contrib::hunspell
|
||||||
|
sapi::logging
|
||||||
sapi_hunspell
|
sapi::sapi
|
||||||
sapi::sapi
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "contrib/hunspell/sandboxed.h"
|
#include "contrib/hunspell/sandboxed.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
|
|
||||||
absl::Status PrintSuggest(HunspellApi& api, sapi::v::RemotePtr& hunspellrp,
|
absl::Status PrintSuggest(HunspellApi& api, sapi::v::RemotePtr& hunspellrp,
|
||||||
sapi::v::ConstCStr& word) {
|
sapi::v::ConstCStr& word) {
|
||||||
|
@ -52,7 +53,7 @@ absl::Status PrintSuggest(HunspellApi& api, sapi::v::RemotePtr& hunspellrp,
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (argc != 4) {
|
if (argc != 4) {
|
||||||
std::cerr << "Usage:\n " << argv[0];
|
std::cerr << "Usage:\n " << argv[0];
|
||||||
|
|
|
@ -31,7 +31,7 @@ FetchContent_Declare(jsonnet
|
||||||
GIT_REPOSITORY https://github.com/google/jsonnet.git
|
GIT_REPOSITORY https://github.com/google/jsonnet.git
|
||||||
GIT_TAG v0.18.0 # 2021-12-21
|
GIT_TAG v0.18.0 # 2021-12-21
|
||||||
)
|
)
|
||||||
option(BUILD_TESTS "" OFF) # Do not build jsonnet tests
|
set(BUILD_TESTS OFF CACHE BOOL "" FORCE) # Do not build jsonnet tests
|
||||||
FetchContent_MakeAvailable(jsonnet)
|
FetchContent_MakeAvailable(jsonnet)
|
||||||
create_directory_symlink("${jsonnet_SOURCE_DIR}"
|
create_directory_symlink("${jsonnet_SOURCE_DIR}"
|
||||||
"${PROJECT_BINARY_DIR}/jsonnet")
|
"${PROJECT_BINARY_DIR}/jsonnet")
|
||||||
|
|
|
@ -22,6 +22,7 @@ foreach(target IN ITEMS base multiple_files yaml_stream formatter)
|
||||||
sapi_contrib::jsonnet
|
sapi_contrib::jsonnet
|
||||||
sapi::file_base
|
sapi::file_base
|
||||||
sapi::fileops
|
sapi::fileops
|
||||||
|
sapi::logging
|
||||||
sapi::sapi
|
sapi::sapi
|
||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "contrib/jsonnet/jsonnet_base_sandbox.h"
|
#include "contrib/jsonnet/jsonnet_base_sandbox.h"
|
||||||
#include "sandboxed_api/util/fileops.h"
|
#include "sandboxed_api/util/fileops.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/util/path.h"
|
#include "sandboxed_api/util/path.h"
|
||||||
|
|
||||||
absl::Status JsonnetMain(std::string in_file, std::string out_file) {
|
absl::Status JsonnetMain(std::string in_file, std::string out_file) {
|
||||||
|
@ -72,7 +73,7 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) {
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
using sapi::file_util::fileops::Basename;
|
using sapi::file_util::fileops::Basename;
|
||||||
|
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
|
|
||||||
if (!(argc == 3)) {
|
if (!(argc == 3)) {
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "contrib/jsonnet/jsonnet_base_transaction.h"
|
#include "contrib/jsonnet/jsonnet_base_transaction.h"
|
||||||
|
|
||||||
#include "sandboxed_api/util/fileops.h"
|
#include "sandboxed_api/util/fileops.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/util/path.h"
|
#include "sandboxed_api/util/path.h"
|
||||||
|
|
||||||
absl::Status JsonnetTransaction::Main() {
|
absl::Status JsonnetTransaction::Main() {
|
||||||
|
@ -64,7 +65,7 @@ absl::Status JsonnetTransaction::Main() {
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
using sapi::file_util::fileops::Basename;
|
using sapi::file_util::fileops::Basename;
|
||||||
|
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
|
|
||||||
if (!(argc == 3)) {
|
if (!(argc == 3)) {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "jsonnet_sapi.sapi.h" // NOLINT(build/include)
|
#include "jsonnet_sapi.sapi.h" // NOLINT(build/include)
|
||||||
#include "sandboxed_api/util/fileops.h"
|
#include "sandboxed_api/util/fileops.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/util/path.h"
|
#include "sandboxed_api/util/path.h"
|
||||||
|
|
||||||
class JsonnetSapiSandbox : public JsonnetSandbox {
|
class JsonnetSapiSandbox : public JsonnetSandbox {
|
||||||
|
@ -104,7 +105,7 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) {
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
using sapi::file_util::fileops::Basename;
|
using sapi::file_util::fileops::Basename;
|
||||||
|
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
|
|
||||||
if (!(argc == 3)) {
|
if (!(argc == 3)) {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "jsonnet_sapi.sapi.h" // NOLINT(build/include)
|
#include "jsonnet_sapi.sapi.h" // NOLINT(build/include)
|
||||||
#include "sandboxed_api/util/fileops.h"
|
#include "sandboxed_api/util/fileops.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/util/path.h"
|
#include "sandboxed_api/util/path.h"
|
||||||
|
|
||||||
class JsonnetSapiSandbox : public JsonnetSandbox {
|
class JsonnetSapiSandbox : public JsonnetSandbox {
|
||||||
|
@ -107,7 +108,7 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) {
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
using sapi::file_util::fileops::Basename;
|
using sapi::file_util::fileops::Basename;
|
||||||
|
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
|
|
||||||
if (!(argc == 3)) {
|
if (!(argc == 3)) {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "contrib/jsonnet/jsonnet_base_sandbox.h"
|
#include "contrib/jsonnet/jsonnet_base_sandbox.h"
|
||||||
#include "sandboxed_api/util/fileops.h"
|
#include "sandboxed_api/util/fileops.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/util/path.h"
|
#include "sandboxed_api/util/path.h"
|
||||||
|
|
||||||
absl::Status JsonnetMain(std::string in_file, std::string out_file) {
|
absl::Status JsonnetMain(std::string in_file, std::string out_file) {
|
||||||
|
@ -72,7 +73,7 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) {
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
using sapi::file_util::fileops::Basename;
|
using sapi::file_util::fileops::Basename;
|
||||||
|
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
|
|
||||||
if (!(argc == 3)) {
|
if (!(argc == 3)) {
|
||||||
|
|
|
@ -80,25 +80,19 @@ target_include_directories(libxls PUBLIC
|
||||||
|
|
||||||
configure_file(xls.gen.h.in xls.gen.h)
|
configure_file(xls.gen.h.in xls.gen.h)
|
||||||
|
|
||||||
add_sapi_library(
|
add_sapi_library(sapi_libxls
|
||||||
sapi_libxls
|
FUNCTIONS xls_open_file
|
||||||
|
|
||||||
FUNCTIONS
|
xls_getWorkSheet
|
||||||
xls_open_file
|
xls_parseWorkSheet
|
||||||
|
|
||||||
xls_getWorkSheet
|
xls_cell
|
||||||
xls_parseWorkSheet
|
|
||||||
|
|
||||||
xls_cell
|
xls_close_WS
|
||||||
|
xls_close_WB
|
||||||
xls_close_WS
|
|
||||||
xls_close_WB
|
|
||||||
|
|
||||||
xls_getError
|
|
||||||
|
|
||||||
INPUTS
|
|
||||||
"${CMAKE_BINARY_DIR}/xls.gen.h"
|
|
||||||
|
|
||||||
|
xls_getError
|
||||||
|
INPUTS "${PROJECT_BINARY_DIR}/xls.gen.h"
|
||||||
LIBRARY libxls
|
LIBRARY libxls
|
||||||
LIBRARY_NAME Libxls
|
LIBRARY_NAME Libxls
|
||||||
NAMESPACE ""
|
NAMESPACE ""
|
||||||
|
|
|
@ -20,5 +20,6 @@ add_executable(sapi_minixls
|
||||||
target_link_libraries(sapi_minixls
|
target_link_libraries(sapi_minixls
|
||||||
PRIVATE sapi_libxls
|
PRIVATE sapi_libxls
|
||||||
absl::flags_parse
|
absl::flags_parse
|
||||||
|
sapi::logging
|
||||||
sapi::sapi
|
sapi::sapi
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,13 +25,14 @@
|
||||||
#include "absl/flags/parse.h"
|
#include "absl/flags/parse.h"
|
||||||
#include "contrib/libxls/sandboxed.h"
|
#include "contrib/libxls/sandboxed.h"
|
||||||
#include "contrib/libxls/utils/utils_libxls.h"
|
#include "contrib/libxls/utils/utils_libxls.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
|
|
||||||
ABSL_FLAG(uint32_t, sheet, 0, "sheet number");
|
ABSL_FLAG(uint32_t, sheet, 0, "sheet number");
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
std::string prog_name(argv[0]);
|
std::string prog_name(argv[0]);
|
||||||
google::InitGoogleLogging(argv[0]);
|
|
||||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||||
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
std::cerr << "Usage:\n " << prog_name << " INPUT\n";
|
std::cerr << "Usage:\n " << prog_name << " INPUT\n";
|
||||||
|
|
|
@ -27,7 +27,12 @@ if(NOT TARGET sapi::sapi)
|
||||||
EXCLUDE_FROM_ALL)
|
EXCLUDE_FROM_ALL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(BUILD_SHARED_LIBS off)
|
set(BUILD_SHARED_LIBS OFF)
|
||||||
|
set(BUILD_TOOLS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(BUILD_REGRESS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||||
|
set(BUILD_DOC OFF CACHE BOOL "" FORCE)
|
||||||
|
set(LIBZIP_DO_INSTALL OFF CACHE BOOL "" FORCE)
|
||||||
FetchContent_Declare(libzip
|
FetchContent_Declare(libzip
|
||||||
GIT_REPOSITORY https://github.com/nih-at/libzip/
|
GIT_REPOSITORY https://github.com/nih-at/libzip/
|
||||||
GIT_TAG 34b13ca4e887a5aba050015e3a179069643f4e76
|
GIT_TAG 34b13ca4e887a5aba050015e3a179069643f4e76
|
||||||
|
|
|
@ -12,17 +12,14 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
add_executable(
|
add_executable(sapi_minizip
|
||||||
sapi_minizip
|
|
||||||
|
|
||||||
main.cc
|
main.cc
|
||||||
../utils/utils_zip.cc
|
../utils/utils_zip.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(sapi_minizip
|
||||||
sapi_minizip PRIVATE
|
PRIVATE sapi_contrib::libzip
|
||||||
|
sapi::logging
|
||||||
sapi_zip
|
sapi::sapi
|
||||||
sapi::sapi
|
absl::flags_parse
|
||||||
absl::flags_parse
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "absl/flags/parse.h"
|
#include "absl/flags/parse.h"
|
||||||
#include "contrib/libzip/sandboxed.h"
|
#include "contrib/libzip/sandboxed.h"
|
||||||
#include "contrib/libzip/utils/utils_zip.h"
|
#include "contrib/libzip/utils/utils_zip.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
|
|
||||||
ABSL_FLAG(bool, list, false, "list files");
|
ABSL_FLAG(bool, list, false, "list files");
|
||||||
ABSL_FLAG(std::string, unzip, "", "unzip");
|
ABSL_FLAG(std::string, unzip, "", "unzip");
|
||||||
|
@ -83,8 +84,8 @@ absl::Status DeleteFile(LibZip& zip, const std::string& filename) {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
std::string prog_name(argv[0]);
|
std::string prog_name(argv[0]);
|
||||||
google::InitGoogleLogging(argv[0]);
|
|
||||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||||
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (args.size() < 2 || args.size() > 3) {
|
if (args.size() < 2 || args.size() > 3) {
|
||||||
std::cerr << "Usage:\n " << prog_name << " ZIPFILE [OUTFILE]\n";
|
std::cerr << "Usage:\n " << prog_name << " ZIPFILE [OUTFILE]\n";
|
||||||
|
|
|
@ -99,9 +99,10 @@ target_include_directories(pffft_sapi INTERFACE
|
||||||
add_executable(pffft_sandboxed
|
add_executable(pffft_sandboxed
|
||||||
main_pffft_sandboxed.cc
|
main_pffft_sandboxed.cc
|
||||||
)
|
)
|
||||||
target_link_libraries(pffft_sandboxed PRIVATE
|
target_link_libraries(pffft_sandboxed
|
||||||
absl::flags
|
PRIVATE sapi_contrib::pffft
|
||||||
absl::flags_parse
|
absl::flags
|
||||||
sapi_contrib::pffft
|
absl::flags_parse
|
||||||
sapi::sapi
|
sapi::logging
|
||||||
|
sapi::sapi
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#include <glog/logging.h>
|
|
||||||
#include "pffft_sapi.sapi.h" // NOLINT(build/include)
|
#include "pffft_sapi.sapi.h" // NOLINT(build/include)
|
||||||
#include "absl/flags/flag.h"
|
#include "absl/flags/flag.h"
|
||||||
#include "absl/flags/parse.h"
|
#include "absl/flags/parse.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/vars.h"
|
#include "sandboxed_api/vars.h"
|
||||||
|
|
||||||
class PffftSapiSandbox : public PffftSandbox {
|
class PffftSapiSandbox : public PffftSandbox {
|
||||||
|
@ -179,7 +179,7 @@ absl::Status PffftMain() {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
absl::ParseCommandLine(argc, argv);
|
absl::ParseCommandLine(argc, argv);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (absl::Status status = PffftMain(); !status.ok()) {
|
if (absl::Status status = PffftMain(); !status.ok()) {
|
||||||
LOG(ERROR) << "Initialization failed: " << status.ToString();
|
LOG(ERROR) << "Initialization failed: " << status.ToString();
|
||||||
|
|
|
@ -18,6 +18,7 @@ add_executable(turbojpeg_sapi_test turbojpeg_sapi_test.cc)
|
||||||
|
|
||||||
target_link_libraries(turbojpeg_sapi_test PRIVATE
|
target_link_libraries(turbojpeg_sapi_test PRIVATE
|
||||||
turbojpeg_sapi
|
turbojpeg_sapi
|
||||||
|
sapi::logging
|
||||||
sapi::base
|
sapi::base
|
||||||
gtest
|
gtest
|
||||||
gmock
|
gmock
|
||||||
|
|
|
@ -23,11 +23,11 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "gflags/gflags.h"
|
#include "gflags/gflags.h"
|
||||||
#include "glog/logging.h"
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "sandboxed_api/testing.h"
|
#include "sandboxed_api/testing.h"
|
||||||
#include "sandboxed_api/util/fileops.h"
|
#include "sandboxed_api/util/fileops.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/util/path.h"
|
#include "sandboxed_api/util/path.h"
|
||||||
#include "sandboxed_api/util/status_matchers.h"
|
#include "sandboxed_api/util/status_matchers.h"
|
||||||
#include "turbojpeg_sapi.sapi.h" // NOLINT(build/include)
|
#include "turbojpeg_sapi.sapi.h" // NOLINT(build/include)
|
||||||
|
@ -175,7 +175,7 @@ TEST_F(TurboJpegSapiSandboxTest, Decompressor) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
::google::InitGoogleLogging(program_invocation_short_name);
|
::sapi::InitLogging(program_invocation_short_name);
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,17 +12,14 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
add_executable(
|
add_executable(sapi_miniuriparser
|
||||||
sapi_miniuriparser
|
|
||||||
|
|
||||||
main.cc
|
main.cc
|
||||||
../utils/utils_uriparser.cc
|
../utils/utils_uriparser.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(sapi_miniuriparser
|
||||||
sapi_miniuriparser PRIVATE
|
PRIVATE sapi_contrib::uriparser
|
||||||
|
sapi::logging
|
||||||
sapi_uriparser
|
sapi::sapi
|
||||||
sapi::sapi
|
absl::flags_parse
|
||||||
absl::flags_parse
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "absl/flags/parse.h"
|
#include "absl/flags/parse.h"
|
||||||
#include "contrib/uriparser/sandboxed.h"
|
#include "contrib/uriparser/sandboxed.h"
|
||||||
#include "contrib/uriparser/utils/utils_uriparser.h"
|
#include "contrib/uriparser/utils/utils_uriparser.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
|
|
||||||
void Print(const char* name, const absl::StatusOr<std::string>& r) {
|
void Print(const char* name, const absl::StatusOr<std::string>& r) {
|
||||||
if (!r.ok()) {
|
if (!r.ok()) {
|
||||||
|
@ -37,8 +38,8 @@ void Print(const char* name, const absl::StatusOr<std::string>& r) {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
std::string prog_name(argv[0]);
|
std::string prog_name(argv[0]);
|
||||||
google::InitGoogleLogging(argv[0]);
|
|
||||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||||
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
std::cerr << "Usage:\n " << prog_name << " URI ...\n";
|
std::cerr << "Usage:\n " << prog_name << " URI ...\n";
|
||||||
|
|
|
@ -67,7 +67,8 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
|
||||||
woff2_sapi_test.cc
|
woff2_sapi_test.cc
|
||||||
)
|
)
|
||||||
target_link_libraries(woff2_sapi_test PRIVATE
|
target_link_libraries(woff2_sapi_test PRIVATE
|
||||||
woff2_sapi
|
sapi_contrib::woff2
|
||||||
|
sapi::logging
|
||||||
sapi::base
|
sapi::base
|
||||||
gtest
|
gtest
|
||||||
gmock
|
gmock
|
||||||
|
|
|
@ -23,12 +23,12 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include "gflags/gflags.h"
|
#include "gflags/gflags.h"
|
||||||
#include "glog/logging.h"
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "contrib/woff2/woff2_wrapper.h"
|
#include "contrib/woff2/woff2_wrapper.h"
|
||||||
#include "sandboxed_api/testing.h"
|
#include "sandboxed_api/testing.h"
|
||||||
#include "sandboxed_api/util/fileops.h"
|
#include "sandboxed_api/util/fileops.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/util/path.h"
|
#include "sandboxed_api/util/path.h"
|
||||||
#include "sandboxed_api/util/status_matchers.h"
|
#include "sandboxed_api/util/status_matchers.h"
|
||||||
#include "woff2_sapi.sapi.h" // NOLINT(build/include)
|
#include "woff2_sapi.sapi.h" // NOLINT(build/include)
|
||||||
|
@ -131,7 +131,7 @@ TEST_F(Woff2SapiSandboxTest, Decompress) {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
if (argc < 1) return 255;
|
if (argc < 1) return 255;
|
||||||
::google::InitGoogleLogging(argv[0]);
|
::sapi::InitLogging(argv[0]);
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,9 @@ add_executable(sapi_minizopfli
|
||||||
main.cc
|
main.cc
|
||||||
../utils/utils_zopfli.cc
|
../utils/utils_zopfli.cc
|
||||||
)
|
)
|
||||||
target_link_libraries(sapi_minizopfli PRIVATE
|
target_link_libraries(sapi_minizopfli
|
||||||
sapi_contrib::zopfli
|
PRIVATE sapi_contrib::zopfli
|
||||||
sapi::sapi
|
sapi::logging
|
||||||
absl::flags_parse
|
sapi::sapi
|
||||||
|
absl::flags_parse
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "absl/flags/parse.h"
|
#include "absl/flags/parse.h"
|
||||||
#include "contrib/zopfli/sandboxed.h"
|
#include "contrib/zopfli/sandboxed.h"
|
||||||
#include "contrib/zopfli/utils/utils_zopfli.h"
|
#include "contrib/zopfli/utils/utils_zopfli.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
|
|
||||||
ABSL_FLAG(bool, stream, false, "stream memory to sandbox");
|
ABSL_FLAG(bool, stream, false, "stream memory to sandbox");
|
||||||
ABSL_FLAG(bool, zlib, false, "zlib compression");
|
ABSL_FLAG(bool, zlib, false, "zlib compression");
|
||||||
|
@ -59,8 +60,8 @@ absl::Status CompressMainFD(ZopfliApi& api, std::string& infile_s,
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
std::string prog_name(argv[0]);
|
std::string prog_name(argv[0]);
|
||||||
google::InitGoogleLogging(argv[0]);
|
|
||||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||||
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (args.size() != 3) {
|
if (args.size() != 3) {
|
||||||
std::cerr << "Usage:\n " << prog_name << " INPUT OUTPUT\n";
|
std::cerr << "Usage:\n " << prog_name << " INPUT OUTPUT\n";
|
||||||
|
|
|
@ -12,17 +12,14 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
add_executable(
|
add_executable(sapi_minizstd
|
||||||
sapi_minizstd
|
|
||||||
|
|
||||||
main.cc
|
main.cc
|
||||||
../utils/utils_zstd.cc
|
../utils/utils_zstd.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(sapi_minizstd
|
||||||
sapi_minizstd PRIVATE
|
PRIVATE sapi_contrib::zstd
|
||||||
|
sapi::logging
|
||||||
sapi_zstd
|
sapi::sapi
|
||||||
sapi::sapi
|
absl::flags_parse
|
||||||
absl::flags_parse
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "absl/flags/parse.h"
|
#include "absl/flags/parse.h"
|
||||||
#include "contrib/zstd/sandboxed.h"
|
#include "contrib/zstd/sandboxed.h"
|
||||||
#include "contrib/zstd/utils/utils_zstd.h"
|
#include "contrib/zstd/utils/utils_zstd.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
|
|
||||||
ABSL_FLAG(bool, stream, false, "stream data to sandbox");
|
ABSL_FLAG(bool, stream, false, "stream data to sandbox");
|
||||||
ABSL_FLAG(bool, decompress, false, "decompress");
|
ABSL_FLAG(bool, decompress, false, "decompress");
|
||||||
|
@ -78,8 +79,8 @@ absl::Status FileDescriptor(ZstdApi& api, std::string infile_s,
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
std::string prog_name(argv[0]);
|
std::string prog_name(argv[0]);
|
||||||
google::InitGoogleLogging(argv[0]);
|
|
||||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||||
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (args.size() != 3) {
|
if (args.size() != 3) {
|
||||||
std::cerr << "Usage:\n " << prog_name << " INPUT OUTPUT\n";
|
std::cerr << "Usage:\n " << prog_name << " INPUT OUTPUT\n";
|
||||||
|
|
|
@ -86,7 +86,7 @@ absl::Status Example1() {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (absl::Status status = Example1(); !status.ok()) {
|
if (absl::Status status = Example1(); !status.ok()) {
|
||||||
LOG(ERROR) << "Example1 failed: " << status.ToString();
|
LOG(ERROR) << "Example1 failed: " << status.ToString();
|
||||||
|
|
|
@ -106,7 +106,7 @@ absl::Status Example2() {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (absl::Status status = Example2(); !status.ok()) {
|
if (absl::Status status = Example2(); !status.ok()) {
|
||||||
LOG(ERROR) << "Example2 failed: " << status.ToString();
|
LOG(ERROR) << "Example2 failed: " << status.ToString();
|
||||||
|
|
|
@ -169,7 +169,7 @@ absl::Status Example3(const std::string& ssl_certificate,
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
// Get input parameters (should be absolute paths)
|
// Get input parameters (should be absolute paths)
|
||||||
if (argc != 5) {
|
if (argc != 5) {
|
||||||
|
|
|
@ -131,7 +131,7 @@ absl::Status Example4() {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (absl::Status status = Example4(); !status.ok()) {
|
if (absl::Status status = Example4(); !status.ok()) {
|
||||||
LOG(ERROR) << "Example4 failed: " << status.ToString();
|
LOG(ERROR) << "Example4 failed: " << status.ToString();
|
||||||
|
|
|
@ -101,7 +101,7 @@ absl::Status Example5() {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (absl::Status status = Example5(); !status.ok()) {
|
if (absl::Status status = Example5(); !status.ok()) {
|
||||||
LOG(ERROR) << "Example5 failed: " << status.ToString();
|
LOG(ERROR) << "Example5 failed: " << status.ToString();
|
||||||
|
|
|
@ -39,7 +39,7 @@ static void PrintUsage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int unused_argc, char* argv[]) {
|
int main(int unused_argc, char* argv[]) {
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
const char* filename = nullptr;
|
const char* filename = nullptr;
|
||||||
int compress;
|
int compress;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
|
@ -79,7 +79,7 @@ absl::Status HelloWorld() {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (absl::Status status = HelloWorld(); !status.ok()) {
|
if (absl::Status status = HelloWorld(); !status.ok()) {
|
||||||
LOG(ERROR) << "HelloWorld failed: " << status.ToString();
|
LOG(ERROR) << "HelloWorld failed: " << status.ToString();
|
||||||
|
|
|
@ -103,7 +103,7 @@ absl::Status IdleBasic() {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (absl::Status status = IdleBasic(); !status.ok()) {
|
if (absl::Status status = IdleBasic(); !status.ok()) {
|
||||||
LOG(ERROR) << "IdleBasic failed: " << status.ToString();
|
LOG(ERROR) << "IdleBasic failed: " << status.ToString();
|
||||||
|
|
|
@ -96,7 +96,7 @@ absl::Status UVCat(std::string filearg) {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
LOG(ERROR) << "wrong number of arguments (1 expected)";
|
LOG(ERROR) << "wrong number of arguments (1 expected)";
|
||||||
|
|
|
@ -172,7 +172,7 @@ void EncodeDecodeTwoSteps(SapiLodepngSandbox& sandbox, LodepngApi& api) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
const std::string images_path = CreateTempDirAtCWD();
|
const std::string images_path = CreateTempDirAtCWD();
|
||||||
CHECK(sandbox2::file_util::fileops::Exists(images_path, false))
|
CHECK(sandbox2::file_util::fileops::Exists(images_path, false))
|
||||||
|
|
|
@ -99,7 +99,7 @@ void EncodeDecodeTwoSteps(const std::string& images_path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
const std::string images_path = CreateTempDirAtCWD();
|
const std::string images_path = CreateTempDirAtCWD();
|
||||||
CHECK(sandbox2::file_util::fileops::Exists(images_path, false))
|
CHECK(sandbox2::file_util::fileops::Exists(images_path, false))
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Openjp2SapiSandbox : public Openjp2Sandbox {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
std::cerr << "Usage: " << basename(argv[0]) << " absolute/path/to/INPUT.jp2"
|
std::cerr << "Usage: " << basename(argv[0]) << " absolute/path/to/INPUT.jp2"
|
||||||
|
|
|
@ -185,6 +185,7 @@ cc_library(
|
||||||
"//sandboxed_api/sandbox2:forkingclient",
|
"//sandboxed_api/sandbox2:forkingclient",
|
||||||
"//sandboxed_api/sandbox2:logsink",
|
"//sandboxed_api/sandbox2:logsink",
|
||||||
"//sandboxed_api/util:flags",
|
"//sandboxed_api/util:flags",
|
||||||
|
"//sandboxed_api/util:logging",
|
||||||
"@com_google_absl//absl/base:dynamic_annotations",
|
"@com_google_absl//absl/base:dynamic_annotations",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_glog//:glog",
|
"@com_google_glog//:glog",
|
||||||
|
|
|
@ -184,6 +184,7 @@ target_link_libraries(sapi_client
|
||||||
sapi::call
|
sapi::call
|
||||||
sapi::flags
|
sapi::flags
|
||||||
sapi::lenval_core
|
sapi::lenval_core
|
||||||
|
sapi::logging
|
||||||
sapi::proto_arg_proto
|
sapi::proto_arg_proto
|
||||||
sapi::vars
|
sapi::vars
|
||||||
${CMAKE_DL_LIBS}
|
${CMAKE_DL_LIBS}
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "sandboxed_api/sandbox2/comms.h"
|
#include "sandboxed_api/sandbox2/comms.h"
|
||||||
#include "sandboxed_api/sandbox2/forkingclient.h"
|
#include "sandboxed_api/sandbox2/forkingclient.h"
|
||||||
#include "sandboxed_api/sandbox2/logsink.h"
|
#include "sandboxed_api/sandbox2/logsink.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/vars.h"
|
#include "sandboxed_api/vars.h"
|
||||||
|
|
||||||
#include <ffi.h>
|
#include <ffi.h>
|
||||||
|
@ -415,10 +416,8 @@ void ServeRequest(sandbox2::Comms* comms) {
|
||||||
} // namespace sapi
|
} // namespace sapi
|
||||||
|
|
||||||
ABSL_ATTRIBUTE_WEAK int main(int argc, char* argv[]) {
|
ABSL_ATTRIBUTE_WEAK int main(int argc, char* argv[]) {
|
||||||
gflags::SetCommandLineOptionWithMode("userspace_coredumper", "false",
|
|
||||||
gflags::SET_FLAG_IF_DEFAULT);
|
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
// Note regarding the FD usage here: Parent and child seem to make use of the
|
// Note regarding the FD usage here: Parent and child seem to make use of the
|
||||||
// same FD, although this is not true. During process setup `dup2()` will be
|
// same FD, although this is not true. During process setup `dup2()` will be
|
||||||
|
|
|
@ -83,6 +83,7 @@ cc_binary(
|
||||||
"//sandboxed_api:sapi",
|
"//sandboxed_api:sapi",
|
||||||
"//sandboxed_api:vars",
|
"//sandboxed_api:vars",
|
||||||
"//sandboxed_api/util:flags",
|
"//sandboxed_api/util:flags",
|
||||||
|
"//sandboxed_api/util:logging",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/status",
|
"@com_google_absl//absl/status",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
|
|
|
@ -84,6 +84,7 @@ target_link_libraries(sapi_main_sum PRIVATE
|
||||||
glog::glog
|
glog::glog
|
||||||
sapi::base
|
sapi::base
|
||||||
sapi::flags
|
sapi::flags
|
||||||
|
sapi::logging
|
||||||
sapi::sapi
|
sapi::sapi
|
||||||
sapi::status
|
sapi::status
|
||||||
sapi::sum_sapi
|
sapi::sum_sapi
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "sandboxed_api/examples/sum/sum-sapi.sapi.h"
|
#include "sandboxed_api/examples/sum/sum-sapi.sapi.h"
|
||||||
#include "sandboxed_api/examples/sum/sum_params.pb.h"
|
#include "sandboxed_api/examples/sum/sum_params.pb.h"
|
||||||
#include "sandboxed_api/transaction.h"
|
#include "sandboxed_api/transaction.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/vars.h"
|
#include "sandboxed_api/vars.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -207,7 +208,7 @@ absl::Status test_addition(sapi::Sandbox* sandbox, int a, int b, int c) {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
absl::Status status;
|
absl::Status status;
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ cc_binary(
|
||||||
":zlib-sapi_embed",
|
":zlib-sapi_embed",
|
||||||
"//sandboxed_api:vars",
|
"//sandboxed_api:vars",
|
||||||
"//sandboxed_api/util:flags",
|
"//sandboxed_api/util:flags",
|
||||||
|
"//sandboxed_api/util:logging",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
"@com_google_absl//absl/status:statusor",
|
"@com_google_absl//absl/status:statusor",
|
||||||
],
|
],
|
||||||
|
|
|
@ -37,6 +37,7 @@ target_link_libraries(sapi_main_zlib PRIVATE
|
||||||
sapi::base
|
sapi::base
|
||||||
glog::glog
|
glog::glog
|
||||||
sapi::flags
|
sapi::flags
|
||||||
|
sapi::logging
|
||||||
sapi::sapi
|
sapi::sapi
|
||||||
sapi::status
|
sapi::status
|
||||||
sapi::zlib_sapi
|
sapi::zlib_sapi
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "sandboxed_api/util/flag.h"
|
#include "sandboxed_api/util/flag.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "sandboxed_api/examples/zlib/zlib-sapi.sapi.h"
|
#include "sandboxed_api/examples/zlib/zlib-sapi.sapi.h"
|
||||||
#include "sandboxed_api/examples/zlib/zlib-sapi_embed.h"
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/vars.h"
|
#include "sandboxed_api/vars.h"
|
||||||
|
|
||||||
// Need to define these manually, as zlib.h cannot be directly included. The
|
// Need to define these manually, as zlib.h cannot be directly included. The
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
sapi::Sandbox sandbox(sapi::zlib::zlib_sapi_embed_create());
|
sapi::Sandbox sandbox(sapi::zlib::zlib_sapi_embed_create());
|
||||||
sapi::zlib::ZlibApi api(&sandbox);
|
sapi::zlib::ZlibApi api(&sandbox);
|
||||||
|
|
|
@ -35,6 +35,7 @@ cc_binary(
|
||||||
"//sandboxed_api/sandbox2:comms",
|
"//sandboxed_api/sandbox2:comms",
|
||||||
"//sandboxed_api/sandbox2/util:bpf_helper",
|
"//sandboxed_api/sandbox2/util:bpf_helper",
|
||||||
"//sandboxed_api/util:flags",
|
"//sandboxed_api/util:flags",
|
||||||
|
"//sandboxed_api/util:logging",
|
||||||
"//sandboxed_api/util:runfiles",
|
"//sandboxed_api/util:runfiles",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_glog//:glog",
|
"@com_google_glog//:glog",
|
||||||
|
|
|
@ -28,6 +28,7 @@ target_link_libraries(sandbox2_crc4sandbox PRIVATE
|
||||||
sandbox2::sandbox2
|
sandbox2::sandbox2
|
||||||
sapi::base
|
sapi::base
|
||||||
sapi::flags
|
sapi::flags
|
||||||
|
sapi::logging
|
||||||
)
|
)
|
||||||
|
|
||||||
# sandboxed_api/sandbox2/examples/crc4:crc4bin
|
# sandboxed_api/sandbox2/examples/crc4:crc4bin
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "sandboxed_api/sandbox2/result.h"
|
#include "sandboxed_api/sandbox2/result.h"
|
||||||
#include "sandboxed_api/sandbox2/sandbox2.h"
|
#include "sandboxed_api/sandbox2/sandbox2.h"
|
||||||
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/util/runfiles.h"
|
#include "sandboxed_api/util/runfiles.h"
|
||||||
|
|
||||||
using std::string; // gflags <-> Abseil Flags
|
using std::string; // gflags <-> Abseil Flags
|
||||||
|
@ -89,7 +90,7 @@ bool SandboxedCRC4(sandbox2::Comms* comms, uint32_t* crc4) {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (absl::GetFlag(FLAGS_input).empty()) {
|
if (absl::GetFlag(FLAGS_input).empty()) {
|
||||||
LOG(ERROR) << "Parameter --input required.";
|
LOG(ERROR) << "Parameter --input required.";
|
||||||
|
|
|
@ -32,6 +32,7 @@ cc_binary(
|
||||||
"//sandboxed_api/sandbox2:comms",
|
"//sandboxed_api/sandbox2:comms",
|
||||||
"//sandboxed_api/sandbox2:forkserver",
|
"//sandboxed_api/sandbox2:forkserver",
|
||||||
"//sandboxed_api/util:flags",
|
"//sandboxed_api/util:flags",
|
||||||
|
"//sandboxed_api/util:logging",
|
||||||
"//sandboxed_api/util:runfiles",
|
"//sandboxed_api/util:runfiles",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
],
|
],
|
||||||
|
|
|
@ -29,6 +29,7 @@ target_link_libraries(sandbox2_custom_fork_sandbox PRIVATE
|
||||||
sandbox2::sandbox2
|
sandbox2::sandbox2
|
||||||
sapi::base
|
sapi::base
|
||||||
sapi::flags
|
sapi::flags
|
||||||
|
sapi::logging
|
||||||
sapi::raw_logging
|
sapi::raw_logging
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "sandboxed_api/sandbox2/policybuilder.h"
|
#include "sandboxed_api/sandbox2/policybuilder.h"
|
||||||
#include "sandboxed_api/sandbox2/result.h"
|
#include "sandboxed_api/sandbox2/result.h"
|
||||||
#include "sandboxed_api/sandbox2/sandbox2.h"
|
#include "sandboxed_api/sandbox2/sandbox2.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/util/runfiles.h"
|
#include "sandboxed_api/util/runfiles.h"
|
||||||
|
|
||||||
std::unique_ptr<sandbox2::Policy> GetPolicy() {
|
std::unique_ptr<sandbox2::Policy> GetPolicy() {
|
||||||
|
@ -94,7 +95,7 @@ static int SandboxIteration(sandbox2::ForkClient* fork_client, int32_t i) {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
// This test is incompatible with sanitizers.
|
// This test is incompatible with sanitizers.
|
||||||
// The `SKIP_SANITIZERS_AND_COVERAGE` macro won't work for us here since we
|
// The `SKIP_SANITIZERS_AND_COVERAGE` macro won't work for us here since we
|
||||||
|
|
|
@ -35,6 +35,7 @@ cc_binary(
|
||||||
"//sandboxed_api/sandbox2/util:bpf_helper",
|
"//sandboxed_api/sandbox2/util:bpf_helper",
|
||||||
"//sandboxed_api/util:fileops",
|
"//sandboxed_api/util:fileops",
|
||||||
"//sandboxed_api/util:flags",
|
"//sandboxed_api/util:flags",
|
||||||
|
"//sandboxed_api/util:logging",
|
||||||
"//sandboxed_api/util:runfiles",
|
"//sandboxed_api/util:runfiles",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
],
|
],
|
||||||
|
|
|
@ -28,6 +28,7 @@ target_link_libraries(sandbox2_network_sandbox PRIVATE
|
||||||
sandbox2::sandbox2
|
sandbox2::sandbox2
|
||||||
sapi::base
|
sapi::base
|
||||||
sapi::flags
|
sapi::flags
|
||||||
|
sapi::logging
|
||||||
)
|
)
|
||||||
|
|
||||||
# sandboxed_api/sandbox2/examples/network_bin:network_bin
|
# sandboxed_api/sandbox2/examples/network_bin:network_bin
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "sandboxed_api/sandbox2/sandbox2.h"
|
#include "sandboxed_api/sandbox2/sandbox2.h"
|
||||||
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
||||||
#include "sandboxed_api/util/fileops.h"
|
#include "sandboxed_api/util/fileops.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/util/runfiles.h"
|
#include "sandboxed_api/util/runfiles.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -174,7 +175,7 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
int port = 8085;
|
int port = 8085;
|
||||||
std::thread server_thread{Server,port};
|
std::thread server_thread{Server,port};
|
||||||
server_thread.detach();
|
server_thread.detach();
|
||||||
|
|
|
@ -31,6 +31,7 @@ cc_binary(
|
||||||
"//sandboxed_api/sandbox2/util:bpf_helper",
|
"//sandboxed_api/sandbox2/util:bpf_helper",
|
||||||
"//sandboxed_api/util:fileops",
|
"//sandboxed_api/util:fileops",
|
||||||
"//sandboxed_api/util:flags",
|
"//sandboxed_api/util:flags",
|
||||||
|
"//sandboxed_api/util:logging",
|
||||||
"//sandboxed_api/util:runfiles",
|
"//sandboxed_api/util:runfiles",
|
||||||
"@com_google_absl//absl/base:core_headers",
|
"@com_google_absl//absl/base:core_headers",
|
||||||
],
|
],
|
||||||
|
|
|
@ -28,6 +28,7 @@ target_link_libraries(sandbox2_networkproxy_sandbox PRIVATE
|
||||||
sandbox2::sandbox2
|
sandbox2::sandbox2
|
||||||
sapi::base
|
sapi::base
|
||||||
sapi::flags
|
sapi::flags
|
||||||
|
sapi::logging
|
||||||
)
|
)
|
||||||
|
|
||||||
# sandboxed_api/sandbox2/examples/networkproxy:networkproxy_bin
|
# sandboxed_api/sandbox2/examples/networkproxy:networkproxy_bin
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "sandboxed_api/sandbox2/sandbox2.h"
|
#include "sandboxed_api/sandbox2/sandbox2.h"
|
||||||
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
||||||
#include "sandboxed_api/util/fileops.h"
|
#include "sandboxed_api/util/fileops.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/util/runfiles.h"
|
#include "sandboxed_api/util/runfiles.h"
|
||||||
|
|
||||||
ABSL_FLAG(bool, connect_with_handler, true, "Connect using automatic mode.");
|
ABSL_FLAG(bool, connect_with_handler, true, "Connect using automatic mode.");
|
||||||
|
@ -124,7 +125,7 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
int port = 8085;
|
int port = 8085;
|
||||||
std::thread server_thread{Server,port};
|
std::thread server_thread{Server,port};
|
||||||
server_thread.detach();
|
server_thread.detach();
|
||||||
|
|
|
@ -35,6 +35,7 @@ cc_binary(
|
||||||
"//sandboxed_api/sandbox2",
|
"//sandboxed_api/sandbox2",
|
||||||
"//sandboxed_api/sandbox2/util:bpf_helper",
|
"//sandboxed_api/sandbox2/util:bpf_helper",
|
||||||
"//sandboxed_api/util:flags",
|
"//sandboxed_api/util:flags",
|
||||||
|
"//sandboxed_api/util:logging",
|
||||||
"//sandboxed_api/util:runfiles",
|
"//sandboxed_api/util:runfiles",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
],
|
],
|
||||||
|
|
|
@ -27,6 +27,7 @@ target_link_libraries(sandbox2_static_sandbox PRIVATE
|
||||||
sandbox2::sandbox2
|
sandbox2::sandbox2
|
||||||
sapi::base
|
sapi::base
|
||||||
sapi::flags
|
sapi::flags
|
||||||
|
sapi::logging
|
||||||
)
|
)
|
||||||
|
|
||||||
# sandboxed_api/sandbox2/examples/static:static_bin
|
# sandboxed_api/sandbox2/examples/static:static_bin
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "sandboxed_api/sandbox2/result.h"
|
#include "sandboxed_api/sandbox2/result.h"
|
||||||
#include "sandboxed_api/sandbox2/sandbox2.h"
|
#include "sandboxed_api/sandbox2/sandbox2.h"
|
||||||
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/util/runfiles.h"
|
#include "sandboxed_api/util/runfiles.h"
|
||||||
|
|
||||||
std::unique_ptr<sandbox2::Policy> GetPolicy() {
|
std::unique_ptr<sandbox2::Policy> GetPolicy() {
|
||||||
|
@ -127,7 +128,7 @@ int main(int argc, char* argv[]) {
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
// Note: In your own code, use sapi::GetDataDependencyFilePath() instead.
|
// Note: In your own code, use sapi::GetDataDependencyFilePath() instead.
|
||||||
const std::string path = sapi::internal::GetSapiDataDependencyFilePath(
|
const std::string path = sapi::internal::GetSapiDataDependencyFilePath(
|
||||||
|
|
|
@ -35,6 +35,7 @@ cc_binary(
|
||||||
"//sandboxed_api/sandbox2/util:bpf_helper",
|
"//sandboxed_api/sandbox2/util:bpf_helper",
|
||||||
"//sandboxed_api/util:fileops",
|
"//sandboxed_api/util:fileops",
|
||||||
"//sandboxed_api/util:flags",
|
"//sandboxed_api/util:flags",
|
||||||
|
"//sandboxed_api/util:logging",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_absl//absl/strings:str_format",
|
"@com_google_absl//absl/strings:str_format",
|
||||||
|
|
|
@ -23,9 +23,9 @@ target_link_libraries(sandbox2_sandbox2tool PRIVATE
|
||||||
absl::strings
|
absl::strings
|
||||||
absl::time
|
absl::time
|
||||||
sandbox2::bpf_helper
|
sandbox2::bpf_helper
|
||||||
# sandbox2::ipc
|
|
||||||
sandbox2::sandbox2
|
sandbox2::sandbox2
|
||||||
sandbox2::util
|
sandbox2::util
|
||||||
sapi::base
|
sapi::base
|
||||||
sapi::flags
|
sapi::flags
|
||||||
|
sapi::logging
|
||||||
)
|
)
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include "sandboxed_api/sandbox2/util.h"
|
#include "sandboxed_api/sandbox2/util.h"
|
||||||
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
||||||
#include "sandboxed_api/util/fileops.h"
|
#include "sandboxed_api/util/fileops.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ void OutputFD(int fd) {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
absl::FPrintF(stderr, "Usage: %s [flags] -- cmd args...", argv[0]);
|
absl::FPrintF(stderr, "Usage: %s [flags] -- cmd args...", argv[0]);
|
||||||
|
|
|
@ -27,6 +27,7 @@ cc_binary(
|
||||||
"//sandboxed_api/sandbox2:comms",
|
"//sandboxed_api/sandbox2:comms",
|
||||||
"//sandboxed_api/sandbox2/util:bpf_helper",
|
"//sandboxed_api/sandbox2/util:bpf_helper",
|
||||||
"//sandboxed_api/util:flags",
|
"//sandboxed_api/util:flags",
|
||||||
|
"//sandboxed_api/util:logging",
|
||||||
"//sandboxed_api/util:runfiles",
|
"//sandboxed_api/util:runfiles",
|
||||||
"@com_google_absl//absl/memory",
|
"@com_google_absl//absl/memory",
|
||||||
],
|
],
|
||||||
|
|
|
@ -24,6 +24,7 @@ target_link_libraries(sandbox2_zpipe_sandbox PRIVATE
|
||||||
absl::memory
|
absl::memory
|
||||||
sandbox2::bpf_helper
|
sandbox2::bpf_helper
|
||||||
sandbox2::comms
|
sandbox2::comms
|
||||||
|
sapi::logging
|
||||||
sapi::runfiles
|
sapi::runfiles
|
||||||
sandbox2::sandbox2
|
sandbox2::sandbox2
|
||||||
sapi::base
|
sapi::base
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "sandboxed_api/sandbox2/result.h"
|
#include "sandboxed_api/sandbox2/result.h"
|
||||||
#include "sandboxed_api/sandbox2/sandbox2.h"
|
#include "sandboxed_api/sandbox2/sandbox2.h"
|
||||||
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
#include "sandboxed_api/util/runfiles.h"
|
#include "sandboxed_api/util/runfiles.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
@ -73,7 +74,7 @@ std::unique_ptr<sandbox2::Policy> GetPolicy() {
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
sapi::InitLogging(argv[0]);
|
||||||
|
|
||||||
if (absl::GetFlag(FLAGS_input).empty()) {
|
if (absl::GetFlag(FLAGS_input).empty()) {
|
||||||
LOG(ERROR) << "Parameter --input required.";
|
LOG(ERROR) << "Parameter --input required.";
|
||||||
|
|
|
@ -73,9 +73,7 @@ cc_library(
|
||||||
name = "fileops",
|
name = "fileops",
|
||||||
srcs = ["fileops.cc"],
|
srcs = ["fileops.cc"],
|
||||||
hdrs = ["fileops.h"],
|
hdrs = ["fileops.h"],
|
||||||
copts = sapi_platform_copts([
|
copts = sapi_platform_copts(),
|
||||||
"-Wno-deprecated-declarations", # readdir64_r
|
|
||||||
]),
|
|
||||||
deps = [
|
deps = [
|
||||||
":strerror",
|
":strerror",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
|
@ -105,6 +103,18 @@ cc_library(
|
||||||
deps = ["@com_github_gflags_gflags//:gflags"],
|
deps = ["@com_github_gflags_gflags//:gflags"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Transitional library that helps configure glog with Abseil flags to
|
||||||
|
# avoid a dependency on gflags.
|
||||||
|
cc_library(
|
||||||
|
name = "logging",
|
||||||
|
srcs = ["logging.cc"],
|
||||||
|
hdrs = ["logging.h"],
|
||||||
|
copts = sapi_platform_copts(),
|
||||||
|
deps = [
|
||||||
|
"@com_google_glog//:glog",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
# Small support library emulating verbose logging using Abseil's raw logging
|
# Small support library emulating verbose logging using Abseil's raw logging
|
||||||
# facility.
|
# facility.
|
||||||
cc_library(
|
cc_library(
|
||||||
|
|
|
@ -48,7 +48,7 @@ target_link_libraries(sapi_util_fileops PRIVATE
|
||||||
)
|
)
|
||||||
|
|
||||||
# sandboxed_api/util:flag
|
# sandboxed_api/util:flag
|
||||||
file(WRITE ${SAPI_BINARY_DIR}/sapi_util_flags_force_cxx_linkage.cc "")
|
file(WRITE "${SAPI_BINARY_DIR}/sapi_util_flags_force_cxx_linkage.cc" "")
|
||||||
add_library(sapi_util_flags ${SAPI_LIB_TYPE}
|
add_library(sapi_util_flags ${SAPI_LIB_TYPE}
|
||||||
flag.h
|
flag.h
|
||||||
"${SAPI_BINARY_DIR}/sapi_util_flags_force_cxx_linkage.cc"
|
"${SAPI_BINARY_DIR}/sapi_util_flags_force_cxx_linkage.cc"
|
||||||
|
@ -56,7 +56,19 @@ add_library(sapi_util_flags ${SAPI_LIB_TYPE}
|
||||||
add_library(sapi::flags ALIAS sapi_util_flags)
|
add_library(sapi::flags ALIAS sapi_util_flags)
|
||||||
target_link_libraries(sapi_util_flags PUBLIC
|
target_link_libraries(sapi_util_flags PUBLIC
|
||||||
glog::glog
|
glog::glog
|
||||||
# gflags::gflags
|
gflags::gflags
|
||||||
|
)
|
||||||
|
|
||||||
|
# sandboxed_api/util:logging
|
||||||
|
add_library(sapi_util_logging ${SAPI_LIB_TYPE}
|
||||||
|
logging.cc
|
||||||
|
logging.h
|
||||||
|
)
|
||||||
|
add_library(sapi::logging ALIAS sapi_util_logging)
|
||||||
|
target_link_libraries(sapi_util_logging
|
||||||
|
PUBLIC glog::glog
|
||||||
|
PRIVATE sapi::base
|
||||||
|
INTERFACE absl::core_headers
|
||||||
)
|
)
|
||||||
|
|
||||||
# sandboxed_api/util:raw_logging
|
# sandboxed_api/util:raw_logging
|
||||||
|
|
25
sandboxed_api/util/logging.cc
Normal file
25
sandboxed_api/util/logging.cc
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright 2022 Google LLC
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
// https://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.
|
||||||
|
|
||||||
|
#include "sandboxed_api/util/logging.h"
|
||||||
|
|
||||||
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
namespace sapi {
|
||||||
|
|
||||||
|
void InitLogging(const char* argv0) {
|
||||||
|
google::InitGoogleLogging(argv0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace sapi
|
26
sandboxed_api/util/logging.h
Normal file
26
sandboxed_api/util/logging.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright 2022 Google LLC
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
// https://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.
|
||||||
|
|
||||||
|
#ifndef SANDBOXED_API_UTIL_LOGGING_H_
|
||||||
|
#define SANDBOXED_API_UTIL_LOGGING_H_
|
||||||
|
|
||||||
|
namespace sapi {
|
||||||
|
|
||||||
|
// Initialize the logging library. The program name specified by argv0 will be
|
||||||
|
// visible in log outputs.
|
||||||
|
void InitLogging(const char* argv0);
|
||||||
|
|
||||||
|
} // namespace sapi
|
||||||
|
|
||||||
|
#endif // SANDBOXED_API_UTIL_LOGGING_H_
|
Loading…
Reference in New Issue
Block a user