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"
|
||||
)
|
||||
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
|
||||
# limitations under the License.
|
||||
|
||||
add_executable(
|
||||
sapi_minibroli
|
||||
|
||||
add_executable(sapi_minibrotli
|
||||
main.cc
|
||||
../utils/utils_brotli.cc
|
||||
../utils/utils_brotli_enc.cc
|
||||
../utils/utils_brotli_dec.cc
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
sapi_minibroli PRIVATE
|
||||
|
||||
sapi_brotli
|
||||
sapi::sapi
|
||||
absl::flags_parse
|
||||
target_link_libraries(sapi_minibrotli
|
||||
PRIVATE absl::flags_parse
|
||||
sapi_contrib::brotli
|
||||
sapi::logging
|
||||
sapi::sapi
|
||||
)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "contrib/brotli/utils/utils_brotli.h"
|
||||
#include "contrib/brotli/utils/utils_brotli_dec.h"
|
||||
#include "contrib/brotli/utils/utils_brotli_enc.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
|
||||
ABSL_FLAG(bool, decompress, false, "decompress");
|
||||
|
||||
|
@ -61,7 +62,7 @@ absl::Status DecompressInMemory(BrotliSandbox &sandbox,
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
std::string prog_name(argv[0]);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
std::vector<char *> args = absl::ParseCommandLine(argc, argv);
|
||||
|
||||
if (args.size() != 3) {
|
||||
|
|
|
@ -30,6 +30,9 @@ if(NOT TARGET sapi::sapi)
|
|||
endif()
|
||||
|
||||
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(
|
||||
libblosc
|
||||
|
||||
|
@ -38,45 +41,37 @@ FetchContent_Declare(
|
|||
)
|
||||
FetchContent_MakeAvailable(libblosc)
|
||||
|
||||
add_sapi_library(
|
||||
sapi_blosc
|
||||
add_sapi_library(sapi_blosc
|
||||
FUNCTIONS blosc_init
|
||||
blosc_destroy
|
||||
|
||||
FUNCTIONS
|
||||
blosc_init
|
||||
blosc_destroy
|
||||
blosc_compress
|
||||
blosc_decompress
|
||||
|
||||
blosc_compress
|
||||
blosc_decompress
|
||||
blosc_get_nthreads
|
||||
blosc_set_nthreads
|
||||
|
||||
blosc_get_nthreads
|
||||
blosc_set_nthreads
|
||||
blosc_get_compressor
|
||||
blosc_set_compressor
|
||||
|
||||
blosc_get_compressor
|
||||
blosc_set_compressor
|
||||
blosc_list_compressors
|
||||
|
||||
blosc_list_compressors
|
||||
blosc_get_version_string
|
||||
|
||||
blosc_get_version_string
|
||||
blosc_get_blocksize
|
||||
blosc_set_blocksize
|
||||
|
||||
blosc_get_blocksize
|
||||
blosc_set_blocksize
|
||||
|
||||
blosc_set_splitmode
|
||||
|
||||
blosc_cbuffer_sizes
|
||||
blosc_cbuffer_validate
|
||||
blosc_cbuffer_versions
|
||||
|
||||
INPUTS
|
||||
"${libblosc_SOURCE_DIR}/blosc/blosc.h"
|
||||
blosc_set_splitmode
|
||||
|
||||
blosc_cbuffer_sizes
|
||||
blosc_cbuffer_validate
|
||||
blosc_cbuffer_versions
|
||||
INPUTS "${libblosc_SOURCE_DIR}/blosc/blosc.h"
|
||||
LIBRARY blosc_static
|
||||
LIBRARY_NAME Cblosc
|
||||
NAMESPACE ""
|
||||
)
|
||||
|
||||
add_library(sapi_contrib::blosc ALIAS sapi_blosc)
|
||||
|
||||
target_include_directories(sapi_blosc INTERFACE
|
||||
"${PROJECT_BINARY_DIR}"
|
||||
)
|
||||
|
|
|
@ -12,9 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
add_executable(
|
||||
sapi_miniblosc
|
||||
|
||||
add_executable(sapi_miniblosc
|
||||
main.cc
|
||||
../utils/utils_blosc.cc
|
||||
)
|
||||
|
@ -23,10 +21,9 @@ target_include_directories(sapi_miniblosc INTERFACE
|
|||
"${SAPI_SOURCE_DIR}"
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
sapi_miniblosc PRIVATE
|
||||
|
||||
sapi_blosc
|
||||
sapi::sapi
|
||||
absl::flags_parse
|
||||
target_link_libraries(sapi_miniblosc
|
||||
PRIVATE sapi_contrib::blosc
|
||||
absl::flags_parse
|
||||
sapi::logging
|
||||
sapi::sapi
|
||||
)
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "contrib/c-blosc/sandboxed.h"
|
||||
#include "contrib/c-blosc/utils/utils_blosc.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
|
||||
ABSL_FLAG(bool, decompress, false, "decompress");
|
||||
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[]) {
|
||||
std::string prog_name(argv[0]);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (args.size() != 3) {
|
||||
std::cerr << "Usage:\n " << prog_name << " INPUT OUTPUT\n";
|
||||
|
|
|
@ -128,7 +128,7 @@ add_sapi_library(
|
|||
LIBRARY_NAME Hunspell
|
||||
NAMESPACE ""
|
||||
)
|
||||
|
||||
add_library(sapi_contrib::hunspell ALIAS sapi_hunspell)
|
||||
target_include_directories(sapi_hunspell INTERFACE
|
||||
"${PROJECT_BINARY_DIR}"
|
||||
)
|
||||
|
|
|
@ -12,15 +12,12 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
add_executable(
|
||||
sapi_minihunspell
|
||||
|
||||
add_executable(sapi_minihunspell
|
||||
main.cc
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
sapi_minihunspell PRIVATE
|
||||
|
||||
sapi_hunspell
|
||||
sapi::sapi
|
||||
target_link_libraries(sapi_minihunspell
|
||||
PRIVATE sapi_contrib::hunspell
|
||||
sapi::logging
|
||||
sapi::sapi
|
||||
)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "contrib/hunspell/sandboxed.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
|
||||
absl::Status PrintSuggest(HunspellApi& api, sapi::v::RemotePtr& hunspellrp,
|
||||
sapi::v::ConstCStr& word) {
|
||||
|
@ -52,7 +53,7 @@ absl::Status PrintSuggest(HunspellApi& api, sapi::v::RemotePtr& hunspellrp,
|
|||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (argc != 4) {
|
||||
std::cerr << "Usage:\n " << argv[0];
|
||||
|
|
|
@ -31,7 +31,7 @@ FetchContent_Declare(jsonnet
|
|||
GIT_REPOSITORY https://github.com/google/jsonnet.git
|
||||
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)
|
||||
create_directory_symlink("${jsonnet_SOURCE_DIR}"
|
||||
"${PROJECT_BINARY_DIR}/jsonnet")
|
||||
|
|
|
@ -22,6 +22,7 @@ foreach(target IN ITEMS base multiple_files yaml_stream formatter)
|
|||
sapi_contrib::jsonnet
|
||||
sapi::file_base
|
||||
sapi::fileops
|
||||
sapi::logging
|
||||
sapi::sapi
|
||||
)
|
||||
endforeach()
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "contrib/jsonnet/jsonnet_base_sandbox.h"
|
||||
#include "sandboxed_api/util/fileops.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/util/path.h"
|
||||
|
||||
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[]) {
|
||||
using sapi::file_util::fileops::Basename;
|
||||
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
if (!(argc == 3)) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "contrib/jsonnet/jsonnet_base_transaction.h"
|
||||
|
||||
#include "sandboxed_api/util/fileops.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/util/path.h"
|
||||
|
||||
absl::Status JsonnetTransaction::Main() {
|
||||
|
@ -64,7 +65,7 @@ absl::Status JsonnetTransaction::Main() {
|
|||
int main(int argc, char* argv[]) {
|
||||
using sapi::file_util::fileops::Basename;
|
||||
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
if (!(argc == 3)) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "jsonnet_sapi.sapi.h" // NOLINT(build/include)
|
||||
#include "sandboxed_api/util/fileops.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/util/path.h"
|
||||
|
||||
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[]) {
|
||||
using sapi::file_util::fileops::Basename;
|
||||
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
if (!(argc == 3)) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "jsonnet_sapi.sapi.h" // NOLINT(build/include)
|
||||
#include "sandboxed_api/util/fileops.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/util/path.h"
|
||||
|
||||
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[]) {
|
||||
using sapi::file_util::fileops::Basename;
|
||||
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
if (!(argc == 3)) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "contrib/jsonnet/jsonnet_base_sandbox.h"
|
||||
#include "sandboxed_api/util/fileops.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/util/path.h"
|
||||
|
||||
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[]) {
|
||||
using sapi::file_util::fileops::Basename;
|
||||
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
if (!(argc == 3)) {
|
||||
|
|
|
@ -80,25 +80,19 @@ target_include_directories(libxls PUBLIC
|
|||
|
||||
configure_file(xls.gen.h.in xls.gen.h)
|
||||
|
||||
add_sapi_library(
|
||||
sapi_libxls
|
||||
add_sapi_library(sapi_libxls
|
||||
FUNCTIONS xls_open_file
|
||||
|
||||
FUNCTIONS
|
||||
xls_open_file
|
||||
xls_getWorkSheet
|
||||
xls_parseWorkSheet
|
||||
|
||||
xls_getWorkSheet
|
||||
xls_parseWorkSheet
|
||||
xls_cell
|
||||
|
||||
xls_cell
|
||||
|
||||
xls_close_WS
|
||||
xls_close_WB
|
||||
|
||||
xls_getError
|
||||
|
||||
INPUTS
|
||||
"${CMAKE_BINARY_DIR}/xls.gen.h"
|
||||
xls_close_WS
|
||||
xls_close_WB
|
||||
|
||||
xls_getError
|
||||
INPUTS "${PROJECT_BINARY_DIR}/xls.gen.h"
|
||||
LIBRARY libxls
|
||||
LIBRARY_NAME Libxls
|
||||
NAMESPACE ""
|
||||
|
|
|
@ -20,5 +20,6 @@ add_executable(sapi_minixls
|
|||
target_link_libraries(sapi_minixls
|
||||
PRIVATE sapi_libxls
|
||||
absl::flags_parse
|
||||
sapi::logging
|
||||
sapi::sapi
|
||||
)
|
||||
|
|
|
@ -25,13 +25,14 @@
|
|||
#include "absl/flags/parse.h"
|
||||
#include "contrib/libxls/sandboxed.h"
|
||||
#include "contrib/libxls/utils/utils_libxls.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
|
||||
ABSL_FLAG(uint32_t, sheet, 0, "sheet number");
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
std::string prog_name(argv[0]);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (args.size() != 2) {
|
||||
std::cerr << "Usage:\n " << prog_name << " INPUT\n";
|
||||
|
|
|
@ -27,7 +27,12 @@ if(NOT TARGET sapi::sapi)
|
|||
EXCLUDE_FROM_ALL)
|
||||
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
|
||||
GIT_REPOSITORY https://github.com/nih-at/libzip/
|
||||
GIT_TAG 34b13ca4e887a5aba050015e3a179069643f4e76
|
||||
|
|
|
@ -12,17 +12,14 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
add_executable(
|
||||
sapi_minizip
|
||||
|
||||
add_executable(sapi_minizip
|
||||
main.cc
|
||||
../utils/utils_zip.cc
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
sapi_minizip PRIVATE
|
||||
|
||||
sapi_zip
|
||||
sapi::sapi
|
||||
absl::flags_parse
|
||||
target_link_libraries(sapi_minizip
|
||||
PRIVATE sapi_contrib::libzip
|
||||
sapi::logging
|
||||
sapi::sapi
|
||||
absl::flags_parse
|
||||
)
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "absl/flags/parse.h"
|
||||
#include "contrib/libzip/sandboxed.h"
|
||||
#include "contrib/libzip/utils/utils_zip.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
|
||||
ABSL_FLAG(bool, list, false, "list files");
|
||||
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[]) {
|
||||
std::string prog_name(argv[0]);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (args.size() < 2 || args.size() > 3) {
|
||||
std::cerr << "Usage:\n " << prog_name << " ZIPFILE [OUTFILE]\n";
|
||||
|
|
|
@ -99,9 +99,10 @@ target_include_directories(pffft_sapi INTERFACE
|
|||
add_executable(pffft_sandboxed
|
||||
main_pffft_sandboxed.cc
|
||||
)
|
||||
target_link_libraries(pffft_sandboxed PRIVATE
|
||||
absl::flags
|
||||
absl::flags_parse
|
||||
sapi_contrib::pffft
|
||||
sapi::sapi
|
||||
target_link_libraries(pffft_sandboxed
|
||||
PRIVATE sapi_contrib::pffft
|
||||
absl::flags
|
||||
absl::flags_parse
|
||||
sapi::logging
|
||||
sapi::sapi
|
||||
)
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
#include <cstring>
|
||||
#include <ctime>
|
||||
|
||||
#include <glog/logging.h>
|
||||
#include "pffft_sapi.sapi.h" // NOLINT(build/include)
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/flags/parse.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/vars.h"
|
||||
|
||||
class PffftSapiSandbox : public PffftSandbox {
|
||||
|
@ -179,7 +179,7 @@ absl::Status PffftMain() {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
absl::ParseCommandLine(argc, argv);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (absl::Status status = PffftMain(); !status.ok()) {
|
||||
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
|
||||
turbojpeg_sapi
|
||||
sapi::logging
|
||||
sapi::base
|
||||
gtest
|
||||
gmock
|
||||
|
|
|
@ -23,11 +23,11 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
#include "glog/logging.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "sandboxed_api/testing.h"
|
||||
#include "sandboxed_api/util/fileops.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/util/path.h"
|
||||
#include "sandboxed_api/util/status_matchers.h"
|
||||
#include "turbojpeg_sapi.sapi.h" // NOLINT(build/include)
|
||||
|
@ -175,7 +175,7 @@ TEST_F(TurboJpegSapiSandboxTest, Decompressor) {
|
|||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
::google::InitGoogleLogging(program_invocation_short_name);
|
||||
::sapi::InitLogging(program_invocation_short_name);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
@ -12,17 +12,14 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
add_executable(
|
||||
sapi_miniuriparser
|
||||
|
||||
add_executable(sapi_miniuriparser
|
||||
main.cc
|
||||
../utils/utils_uriparser.cc
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
sapi_miniuriparser PRIVATE
|
||||
|
||||
sapi_uriparser
|
||||
sapi::sapi
|
||||
absl::flags_parse
|
||||
target_link_libraries(sapi_miniuriparser
|
||||
PRIVATE sapi_contrib::uriparser
|
||||
sapi::logging
|
||||
sapi::sapi
|
||||
absl::flags_parse
|
||||
)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "absl/flags/parse.h"
|
||||
#include "contrib/uriparser/sandboxed.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) {
|
||||
if (!r.ok()) {
|
||||
|
@ -37,8 +38,8 @@ void Print(const char* name, const absl::StatusOr<std::string>& r) {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
std::string prog_name(argv[0]);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (args.size() < 2) {
|
||||
std::cerr << "Usage:\n " << prog_name << " URI ...\n";
|
||||
|
|
|
@ -67,7 +67,8 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
|
|||
woff2_sapi_test.cc
|
||||
)
|
||||
target_link_libraries(woff2_sapi_test PRIVATE
|
||||
woff2_sapi
|
||||
sapi_contrib::woff2
|
||||
sapi::logging
|
||||
sapi::base
|
||||
gtest
|
||||
gmock
|
||||
|
|
|
@ -23,12 +23,12 @@
|
|||
#include <optional>
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
#include "glog/logging.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "contrib/woff2/woff2_wrapper.h"
|
||||
#include "sandboxed_api/testing.h"
|
||||
#include "sandboxed_api/util/fileops.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/util/path.h"
|
||||
#include "sandboxed_api/util/status_matchers.h"
|
||||
#include "woff2_sapi.sapi.h" // NOLINT(build/include)
|
||||
|
@ -131,7 +131,7 @@ TEST_F(Woff2SapiSandboxTest, Decompress) {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc < 1) return 255;
|
||||
::google::InitGoogleLogging(argv[0]);
|
||||
::sapi::InitLogging(argv[0]);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
@ -16,8 +16,9 @@ add_executable(sapi_minizopfli
|
|||
main.cc
|
||||
../utils/utils_zopfli.cc
|
||||
)
|
||||
target_link_libraries(sapi_minizopfli PRIVATE
|
||||
sapi_contrib::zopfli
|
||||
sapi::sapi
|
||||
absl::flags_parse
|
||||
target_link_libraries(sapi_minizopfli
|
||||
PRIVATE sapi_contrib::zopfli
|
||||
sapi::logging
|
||||
sapi::sapi
|
||||
absl::flags_parse
|
||||
)
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "absl/flags/parse.h"
|
||||
#include "contrib/zopfli/sandboxed.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, zlib, false, "zlib compression");
|
||||
|
@ -59,8 +60,8 @@ absl::Status CompressMainFD(ZopfliApi& api, std::string& infile_s,
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
std::string prog_name(argv[0]);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (args.size() != 3) {
|
||||
std::cerr << "Usage:\n " << prog_name << " INPUT OUTPUT\n";
|
||||
|
|
|
@ -12,17 +12,14 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
add_executable(
|
||||
sapi_minizstd
|
||||
|
||||
add_executable(sapi_minizstd
|
||||
main.cc
|
||||
../utils/utils_zstd.cc
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
sapi_minizstd PRIVATE
|
||||
|
||||
sapi_zstd
|
||||
sapi::sapi
|
||||
absl::flags_parse
|
||||
target_link_libraries(sapi_minizstd
|
||||
PRIVATE sapi_contrib::zstd
|
||||
sapi::logging
|
||||
sapi::sapi
|
||||
absl::flags_parse
|
||||
)
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "absl/flags/parse.h"
|
||||
#include "contrib/zstd/sandboxed.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, decompress, false, "decompress");
|
||||
|
@ -78,8 +79,8 @@ absl::Status FileDescriptor(ZstdApi& api, std::string infile_s,
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
std::string prog_name(argv[0]);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (args.size() != 3) {
|
||||
std::cerr << "Usage:\n " << prog_name << " INPUT OUTPUT\n";
|
||||
|
|
|
@ -86,7 +86,7 @@ absl::Status Example1() {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (absl::Status status = Example1(); !status.ok()) {
|
||||
LOG(ERROR) << "Example1 failed: " << status.ToString();
|
||||
|
|
|
@ -106,7 +106,7 @@ absl::Status Example2() {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (absl::Status status = Example2(); !status.ok()) {
|
||||
LOG(ERROR) << "Example2 failed: " << status.ToString();
|
||||
|
|
|
@ -169,7 +169,7 @@ absl::Status Example3(const std::string& ssl_certificate,
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
// Get input parameters (should be absolute paths)
|
||||
if (argc != 5) {
|
||||
|
|
|
@ -131,7 +131,7 @@ absl::Status Example4() {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (absl::Status status = Example4(); !status.ok()) {
|
||||
LOG(ERROR) << "Example4 failed: " << status.ToString();
|
||||
|
|
|
@ -101,7 +101,7 @@ absl::Status Example5() {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (absl::Status status = Example5(); !status.ok()) {
|
||||
LOG(ERROR) << "Example5 failed: " << status.ToString();
|
||||
|
|
|
@ -39,7 +39,7 @@ static void PrintUsage() {
|
|||
}
|
||||
|
||||
int main(int unused_argc, char* argv[]) {
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
const char* filename = nullptr;
|
||||
int compress;
|
||||
int flags;
|
||||
|
|
|
@ -79,7 +79,7 @@ absl::Status HelloWorld() {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (absl::Status status = HelloWorld(); !status.ok()) {
|
||||
LOG(ERROR) << "HelloWorld failed: " << status.ToString();
|
||||
|
|
|
@ -103,7 +103,7 @@ absl::Status IdleBasic() {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (absl::Status status = IdleBasic(); !status.ok()) {
|
||||
LOG(ERROR) << "IdleBasic failed: " << status.ToString();
|
||||
|
|
|
@ -96,7 +96,7 @@ absl::Status UVCat(std::string filearg) {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (argc != 2) {
|
||||
LOG(ERROR) << "wrong number of arguments (1 expected)";
|
||||
|
|
|
@ -172,7 +172,7 @@ void EncodeDecodeTwoSteps(SapiLodepngSandbox& sandbox, LodepngApi& api) {
|
|||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
const std::string images_path = CreateTempDirAtCWD();
|
||||
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[]) {
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
const std::string images_path = CreateTempDirAtCWD();
|
||||
CHECK(sandbox2::file_util::fileops::Exists(images_path, false))
|
||||
|
|
|
@ -55,7 +55,7 @@ class Openjp2SapiSandbox : public Openjp2Sandbox {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (argc != 3) {
|
||||
std::cerr << "Usage: " << basename(argv[0]) << " absolute/path/to/INPUT.jp2"
|
||||
|
|
|
@ -185,6 +185,7 @@ cc_library(
|
|||
"//sandboxed_api/sandbox2:forkingclient",
|
||||
"//sandboxed_api/sandbox2:logsink",
|
||||
"//sandboxed_api/util:flags",
|
||||
"//sandboxed_api/util:logging",
|
||||
"@com_google_absl//absl/base:dynamic_annotations",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_glog//:glog",
|
||||
|
|
|
@ -184,6 +184,7 @@ target_link_libraries(sapi_client
|
|||
sapi::call
|
||||
sapi::flags
|
||||
sapi::lenval_core
|
||||
sapi::logging
|
||||
sapi::proto_arg_proto
|
||||
sapi::vars
|
||||
${CMAKE_DL_LIBS}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "sandboxed_api/sandbox2/comms.h"
|
||||
#include "sandboxed_api/sandbox2/forkingclient.h"
|
||||
#include "sandboxed_api/sandbox2/logsink.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/vars.h"
|
||||
|
||||
#include <ffi.h>
|
||||
|
@ -415,10 +416,8 @@ void ServeRequest(sandbox2::Comms* comms) {
|
|||
} // namespace sapi
|
||||
|
||||
ABSL_ATTRIBUTE_WEAK int main(int argc, char* argv[]) {
|
||||
gflags::SetCommandLineOptionWithMode("userspace_coredumper", "false",
|
||||
gflags::SET_FLAG_IF_DEFAULT);
|
||||
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
|
||||
// same FD, although this is not true. During process setup `dup2()` will be
|
||||
|
|
|
@ -83,6 +83,7 @@ cc_binary(
|
|||
"//sandboxed_api:sapi",
|
||||
"//sandboxed_api:vars",
|
||||
"//sandboxed_api/util:flags",
|
||||
"//sandboxed_api/util:logging",
|
||||
"@com_google_absl//absl/memory",
|
||||
"@com_google_absl//absl/status",
|
||||
"@com_google_absl//absl/strings",
|
||||
|
|
|
@ -84,6 +84,7 @@ target_link_libraries(sapi_main_sum PRIVATE
|
|||
glog::glog
|
||||
sapi::base
|
||||
sapi::flags
|
||||
sapi::logging
|
||||
sapi::sapi
|
||||
sapi::status
|
||||
sapi::sum_sapi
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "sandboxed_api/examples/sum/sum-sapi.sapi.h"
|
||||
#include "sandboxed_api/examples/sum/sum_params.pb.h"
|
||||
#include "sandboxed_api/transaction.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/vars.h"
|
||||
|
||||
namespace {
|
||||
|
@ -207,7 +208,7 @@ absl::Status test_addition(sapi::Sandbox* sandbox, int a, int b, int c) {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
absl::Status status;
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ cc_binary(
|
|||
":zlib-sapi_embed",
|
||||
"//sandboxed_api:vars",
|
||||
"//sandboxed_api/util:flags",
|
||||
"//sandboxed_api/util:logging",
|
||||
"@com_google_absl//absl/base:core_headers",
|
||||
"@com_google_absl//absl/status:statusor",
|
||||
],
|
||||
|
|
|
@ -37,6 +37,7 @@ target_link_libraries(sapi_main_zlib PRIVATE
|
|||
sapi::base
|
||||
glog::glog
|
||||
sapi::flags
|
||||
sapi::logging
|
||||
sapi::sapi
|
||||
sapi::status
|
||||
sapi::zlib_sapi
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "sandboxed_api/util/flag.h"
|
||||
#include "absl/status/statusor.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"
|
||||
|
||||
// Need to define these manually, as zlib.h cannot be directly included. The
|
||||
|
@ -39,7 +39,7 @@
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
sapi::Sandbox sandbox(sapi::zlib::zlib_sapi_embed_create());
|
||||
sapi::zlib::ZlibApi api(&sandbox);
|
||||
|
|
|
@ -35,6 +35,7 @@ cc_binary(
|
|||
"//sandboxed_api/sandbox2:comms",
|
||||
"//sandboxed_api/sandbox2/util:bpf_helper",
|
||||
"//sandboxed_api/util:flags",
|
||||
"//sandboxed_api/util:logging",
|
||||
"//sandboxed_api/util:runfiles",
|
||||
"@com_google_absl//absl/memory",
|
||||
"@com_google_glog//:glog",
|
||||
|
|
|
@ -28,6 +28,7 @@ target_link_libraries(sandbox2_crc4sandbox PRIVATE
|
|||
sandbox2::sandbox2
|
||||
sapi::base
|
||||
sapi::flags
|
||||
sapi::logging
|
||||
)
|
||||
|
||||
# sandboxed_api/sandbox2/examples/crc4:crc4bin
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "sandboxed_api/sandbox2/result.h"
|
||||
#include "sandboxed_api/sandbox2/sandbox2.h"
|
||||
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/util/runfiles.h"
|
||||
|
||||
using std::string; // gflags <-> Abseil Flags
|
||||
|
@ -89,7 +90,7 @@ bool SandboxedCRC4(sandbox2::Comms* comms, uint32_t* crc4) {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (absl::GetFlag(FLAGS_input).empty()) {
|
||||
LOG(ERROR) << "Parameter --input required.";
|
||||
|
|
|
@ -32,6 +32,7 @@ cc_binary(
|
|||
"//sandboxed_api/sandbox2:comms",
|
||||
"//sandboxed_api/sandbox2:forkserver",
|
||||
"//sandboxed_api/util:flags",
|
||||
"//sandboxed_api/util:logging",
|
||||
"//sandboxed_api/util:runfiles",
|
||||
"@com_google_absl//absl/memory",
|
||||
],
|
||||
|
|
|
@ -29,6 +29,7 @@ target_link_libraries(sandbox2_custom_fork_sandbox PRIVATE
|
|||
sandbox2::sandbox2
|
||||
sapi::base
|
||||
sapi::flags
|
||||
sapi::logging
|
||||
sapi::raw_logging
|
||||
)
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "sandboxed_api/sandbox2/policybuilder.h"
|
||||
#include "sandboxed_api/sandbox2/result.h"
|
||||
#include "sandboxed_api/sandbox2/sandbox2.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/util/runfiles.h"
|
||||
|
||||
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[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
// This test is incompatible with sanitizers.
|
||||
// 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/util:fileops",
|
||||
"//sandboxed_api/util:flags",
|
||||
"//sandboxed_api/util:logging",
|
||||
"//sandboxed_api/util:runfiles",
|
||||
"@com_google_absl//absl/base:core_headers",
|
||||
],
|
||||
|
|
|
@ -28,6 +28,7 @@ target_link_libraries(sandbox2_network_sandbox PRIVATE
|
|||
sandbox2::sandbox2
|
||||
sapi::base
|
||||
sapi::flags
|
||||
sapi::logging
|
||||
)
|
||||
|
||||
# sandboxed_api/sandbox2/examples/network_bin:network_bin
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "sandboxed_api/sandbox2/sandbox2.h"
|
||||
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
||||
#include "sandboxed_api/util/fileops.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/util/runfiles.h"
|
||||
|
||||
namespace {
|
||||
|
@ -174,7 +175,7 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
int port = 8085;
|
||||
std::thread server_thread{Server,port};
|
||||
server_thread.detach();
|
||||
|
|
|
@ -31,6 +31,7 @@ cc_binary(
|
|||
"//sandboxed_api/sandbox2/util:bpf_helper",
|
||||
"//sandboxed_api/util:fileops",
|
||||
"//sandboxed_api/util:flags",
|
||||
"//sandboxed_api/util:logging",
|
||||
"//sandboxed_api/util:runfiles",
|
||||
"@com_google_absl//absl/base:core_headers",
|
||||
],
|
||||
|
|
|
@ -28,6 +28,7 @@ target_link_libraries(sandbox2_networkproxy_sandbox PRIVATE
|
|||
sandbox2::sandbox2
|
||||
sapi::base
|
||||
sapi::flags
|
||||
sapi::logging
|
||||
)
|
||||
|
||||
# sandboxed_api/sandbox2/examples/networkproxy:networkproxy_bin
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "sandboxed_api/sandbox2/sandbox2.h"
|
||||
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
||||
#include "sandboxed_api/util/fileops.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/util/runfiles.h"
|
||||
|
||||
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);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
int port = 8085;
|
||||
std::thread server_thread{Server,port};
|
||||
server_thread.detach();
|
||||
|
|
|
@ -35,6 +35,7 @@ cc_binary(
|
|||
"//sandboxed_api/sandbox2",
|
||||
"//sandboxed_api/sandbox2/util:bpf_helper",
|
||||
"//sandboxed_api/util:flags",
|
||||
"//sandboxed_api/util:logging",
|
||||
"//sandboxed_api/util:runfiles",
|
||||
"@com_google_absl//absl/memory",
|
||||
],
|
||||
|
|
|
@ -27,6 +27,7 @@ target_link_libraries(sandbox2_static_sandbox PRIVATE
|
|||
sandbox2::sandbox2
|
||||
sapi::base
|
||||
sapi::flags
|
||||
sapi::logging
|
||||
)
|
||||
|
||||
# sandboxed_api/sandbox2/examples/static:static_bin
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "sandboxed_api/sandbox2/result.h"
|
||||
#include "sandboxed_api/sandbox2/sandbox2.h"
|
||||
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/util/runfiles.h"
|
||||
|
||||
std::unique_ptr<sandbox2::Policy> GetPolicy() {
|
||||
|
@ -127,7 +128,7 @@ int main(int argc, char* argv[]) {
|
|||
return EXIT_SUCCESS;
|
||||
}
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
// Note: In your own code, use sapi::GetDataDependencyFilePath() instead.
|
||||
const std::string path = sapi::internal::GetSapiDataDependencyFilePath(
|
||||
|
|
|
@ -35,6 +35,7 @@ cc_binary(
|
|||
"//sandboxed_api/sandbox2/util:bpf_helper",
|
||||
"//sandboxed_api/util:fileops",
|
||||
"//sandboxed_api/util:flags",
|
||||
"//sandboxed_api/util:logging",
|
||||
"@com_google_absl//absl/memory",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/strings:str_format",
|
||||
|
|
|
@ -23,9 +23,9 @@ target_link_libraries(sandbox2_sandbox2tool PRIVATE
|
|||
absl::strings
|
||||
absl::time
|
||||
sandbox2::bpf_helper
|
||||
# sandbox2::ipc
|
||||
sandbox2::sandbox2
|
||||
sandbox2::util
|
||||
sapi::base
|
||||
sapi::flags
|
||||
sapi::logging
|
||||
)
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "sandboxed_api/sandbox2/util.h"
|
||||
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
||||
#include "sandboxed_api/util/fileops.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
|
@ -106,7 +107,7 @@ void OutputFD(int fd) {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (argc < 2) {
|
||||
absl::FPrintF(stderr, "Usage: %s [flags] -- cmd args...", argv[0]);
|
||||
|
|
|
@ -27,6 +27,7 @@ cc_binary(
|
|||
"//sandboxed_api/sandbox2:comms",
|
||||
"//sandboxed_api/sandbox2/util:bpf_helper",
|
||||
"//sandboxed_api/util:flags",
|
||||
"//sandboxed_api/util:logging",
|
||||
"//sandboxed_api/util:runfiles",
|
||||
"@com_google_absl//absl/memory",
|
||||
],
|
||||
|
|
|
@ -24,6 +24,7 @@ target_link_libraries(sandbox2_zpipe_sandbox PRIVATE
|
|||
absl::memory
|
||||
sandbox2::bpf_helper
|
||||
sandbox2::comms
|
||||
sapi::logging
|
||||
sapi::runfiles
|
||||
sandbox2::sandbox2
|
||||
sapi::base
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "sandboxed_api/sandbox2/result.h"
|
||||
#include "sandboxed_api/sandbox2/sandbox2.h"
|
||||
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
|
||||
#include "sandboxed_api/util/logging.h"
|
||||
#include "sandboxed_api/util/runfiles.h"
|
||||
|
||||
using std::string;
|
||||
|
@ -73,7 +74,7 @@ std::unique_ptr<sandbox2::Policy> GetPolicy() {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
sapi::InitLogging(argv[0]);
|
||||
|
||||
if (absl::GetFlag(FLAGS_input).empty()) {
|
||||
LOG(ERROR) << "Parameter --input required.";
|
||||
|
|
|
@ -73,9 +73,7 @@ cc_library(
|
|||
name = "fileops",
|
||||
srcs = ["fileops.cc"],
|
||||
hdrs = ["fileops.h"],
|
||||
copts = sapi_platform_copts([
|
||||
"-Wno-deprecated-declarations", # readdir64_r
|
||||
]),
|
||||
copts = sapi_platform_copts(),
|
||||
deps = [
|
||||
":strerror",
|
||||
"@com_google_absl//absl/strings",
|
||||
|
@ -105,6 +103,18 @@ cc_library(
|
|||
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
|
||||
# facility.
|
||||
cc_library(
|
||||
|
|
|
@ -48,7 +48,7 @@ target_link_libraries(sapi_util_fileops PRIVATE
|
|||
)
|
||||
|
||||
# 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}
|
||||
flag.h
|
||||
"${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)
|
||||
target_link_libraries(sapi_util_flags PUBLIC
|
||||
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
|
||||
|
|
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