mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-08 11:59:48 -04:00
chore: allow builing static binaries on alpine
This commit is contained in:
parent
0cdd2706d2
commit
8c3f30e91d
@ -41,6 +41,25 @@ set(DWARFS_VERSION
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES
|
||||
".a"
|
||||
CACHE STRING "please look for static libs")
|
||||
set(Boost_USE_STATIC_LIBS
|
||||
ON
|
||||
CACHE BOOL "only static boost libs")
|
||||
set(BOOST_LINK_STATIC
|
||||
"ON"
|
||||
CACHE STRING "yes, really")
|
||||
set(USE_STATIC_DEPS_ON_UNIX
|
||||
ON
|
||||
CACHE BOOL "yes")
|
||||
set(GFLAGS_SHARED
|
||||
OFF
|
||||
CACHE BOOL "static")
|
||||
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
|
||||
list(APPEND PKG_CONFIG_EXECUTABLE "--static")
|
||||
|
||||
find_package(Boost 1.67 REQUIRED COMPONENTS date_time filesystem
|
||||
program_options system)
|
||||
|
||||
@ -56,37 +75,39 @@ set(compiler_only
|
||||
ON
|
||||
CACHE BOOL "only build thrift compiler")
|
||||
|
||||
set(FOLLY_HAVE_ELF OFF CACHE BOOL "" FORCE)
|
||||
|
||||
add_subdirectory(folly EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(fbthrift EXCLUDE_FROM_ALL)
|
||||
|
||||
if(WITH_TESTS)
|
||||
# Download and unpack googletest at configure time
|
||||
configure_file(CMakeLists.txt.gtest googletest-download/CMakeLists.txt)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download)
|
||||
if(result)
|
||||
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} --build .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download)
|
||||
if(result)
|
||||
message(FATAL_ERROR "Build step for googletest failed: ${result}")
|
||||
endif()
|
||||
# # Download and unpack googletest at configure time
|
||||
# configure_file(CMakeLists.txt.gtest googletest-download/CMakeLists.txt)
|
||||
# execute_process(
|
||||
# COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||
# RESULT_VARIABLE result
|
||||
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download)
|
||||
# if(result)
|
||||
# message(FATAL_ERROR "CMake step for googletest failed: ${result}")
|
||||
# endif()
|
||||
# execute_process(
|
||||
# COMMAND ${CMAKE_COMMAND} --build .
|
||||
# RESULT_VARIABLE result
|
||||
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download)
|
||||
# if(result)
|
||||
# message(FATAL_ERROR "Build step for googletest failed: ${result}")
|
||||
# endif()
|
||||
|
||||
# Prevent overriding the parent project's compiler/linker settings on Windows
|
||||
set(gtest_force_shared_crt
|
||||
ON
|
||||
CACHE BOOL "" FORCE)
|
||||
# # Prevent overriding the parent project's compiler/linker settings on Windows
|
||||
# set(gtest_force_shared_crt
|
||||
# ON
|
||||
# CACHE BOOL "" FORCE)
|
||||
|
||||
# Add googletest directly to our build. This defines the gtest and gtest_main
|
||||
# targets.
|
||||
add_subdirectory(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
||||
${CMAKE_CURRENT_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL)
|
||||
# # Add googletest directly to our build. This defines the gtest and gtest_main
|
||||
# # targets.
|
||||
# add_subdirectory(
|
||||
# ${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
||||
# ${CMAKE_CURRENT_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL)
|
||||
|
||||
enable_testing()
|
||||
include(GoogleTest)
|
||||
@ -129,6 +150,10 @@ add_executable(dwarfs-bin src/dwarfs.cpp)
|
||||
add_executable(dwarfsck src/dwarfsck.cpp)
|
||||
add_executable(dwarfsbench src/dwarfsbench.cpp)
|
||||
|
||||
foreach(tgt mkdwarfs dwarfs-bin dwarfsck dwarfsbench)
|
||||
target_link_options(${tgt} PRIVATE -static -static-libgcc)
|
||||
endforeach()
|
||||
|
||||
list(APPEND BINARY_TARGETS mkdwarfs dwarfs-bin dwarfsck dwarfsbench)
|
||||
|
||||
if(WITH_TESTS)
|
||||
@ -309,6 +334,7 @@ install(FILES ${MAN_PAGES} DESTINATION share/man/man1)
|
||||
install(DIRECTORY include/dwarfs DESTINATION include)
|
||||
|
||||
set(CPACK_SOURCE_GENERATOR "TBZ2")
|
||||
set(CPACK_GENERATOR "TXZ")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <bits/types/struct_iovec.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <folly/small_vector.h>
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <stdexcept>
|
||||
|
||||
#include <cxxabi.h>
|
||||
#include <execinfo.h>
|
||||
// #include <execinfo.h>
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
@ -37,6 +37,7 @@ namespace dwarfs {
|
||||
|
||||
namespace {
|
||||
|
||||
#if 0
|
||||
void backtrace(std::ostream& os) {
|
||||
const int stack_size = 5;
|
||||
const int stack_offset = 2;
|
||||
@ -69,6 +70,8 @@ void backtrace(std::ostream& os) {
|
||||
|
||||
::free(strings);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
logger::level_type logger::parse_level(std::string_view level) {
|
||||
@ -104,9 +107,9 @@ void stream_logger::write(level_type level, const std::string& output) {
|
||||
std::lock_guard<std::mutex> lock(mx_);
|
||||
os_ << t << " " << output << "\n";
|
||||
|
||||
if (threshold_ == TRACE) {
|
||||
backtrace(os_);
|
||||
}
|
||||
// if (threshold_ == TRACE) {
|
||||
// backtrace(os_);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user