From ae97d28a7f30643fac8b50948b7234115aaf128a Mon Sep 17 00:00:00 2001 From: Maxim Samsonov Date: Sat, 9 Mar 2024 19:59:08 +0300 Subject: [PATCH] CI optimization and fixes --- .github/workflows/macos.yml | 2 +- .github/workflows/ubuntu.yml | 4 ++-- .github/workflows/windows-msys.yml | 4 ++-- CMakeLists.txt | 28 +++++++++++++++++----------- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 7ca974a1d..eb16a377f 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -90,7 +90,7 @@ jobs: - name: Install packages run: | brew install \ - bison flex gnu-sed bash boost double-conversion jemalloc fmt glog pkg-config ccache + bison flex gnu-sed bash boost double-conversion jemalloc glog pkg-config ccache fmt - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 325469108..7901f7c16 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -79,7 +79,7 @@ jobs: - { scope: 'MKD', tests: 'OFF' } include: - - config: { os: ubuntu-20.04, env: { CC: clang-12, CXX: clang++-12 }, build_type: Debug, extra_opts: '-DENABLE_ASAN=1' } + - config: { os: ubuntu-20.04, env: { CC: clang-12, CXX: clang++-12 }, build_type: RelWithDebInfo, extra_opts: '-DENABLE_ASAN=1' } setup: { scope: 'ALL', tests: 'ON' } - config: { os: ubuntu-20.04, env: { CC: clang-12, CXX: clang++-12 }, build_type: RelWithDebInfo, extra_opts: '-DENABLE_TSAN=1' } setup: { scope: 'ALL', tests: 'ON' } @@ -97,7 +97,7 @@ jobs: run: | sudo apt-get -y update sudo apt-get -y install \ - binutils-dev libevent-dev acl-dev libfmt-dev libjemalloc-dev ccache \ + binutils-dev libevent-dev acl-dev libjemalloc-dev libfmt-dev ccache \ libdouble-conversion-dev libiberty-dev liblz4-dev libssl-dev liblzma-dev \ libunwind-dev libdwarf-dev libelf-dev libgoogle-glog-dev libutfcpp-dev \ libboost-filesystem-dev libboost-program-options-dev libboost-system-dev \ diff --git a/.github/workflows/windows-msys.yml b/.github/workflows/windows-msys.yml index f25f2b062..3a141a70c 100644 --- a/.github/workflows/windows-msys.yml +++ b/.github/workflows/windows-msys.yml @@ -63,7 +63,7 @@ env: jobs: build: - name: windows-msys [${{ matrix.env.CC }}, ${{ matrix.setup.scope }}] + name: windows-msys [${{ matrix.env.CC }}, scope ${{ matrix.setup.scope }}, Release] runs-on: windows-latest strategy: fail-fast: false @@ -107,8 +107,8 @@ jobs: diffutils:p libevent:p double-conversion:p - glog:p fmt:p + glog:p dlfcn:p ninja:p ccache:p diff --git a/CMakeLists.txt b/CMakeLists.txt index 07a7c9e70..a1d34412f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,6 +162,7 @@ set(IS_MSYS OFF) if(MSVC) set(OSTYPE_TXT "Windows") message(STATUS "OSTYPE (forced by MSVC): '${OSTYPE_TXT}'") + set(PREFER_SYSTEM_LIBFMT ON) elseif(MINGW) set(OSTYPE_TXT "msys") message(STATUS "OSTYPE (forced by MINGW): '${OSTYPE_TXT}'") @@ -351,6 +352,7 @@ else() GIT_TAG 10.1.0 ) FetchContent_MakeAvailable(fmt) + include_directories(${fmt_SOURCE_DIR}/include) endif() find_package(Boost 1.67 REQUIRED COMPONENTS chrono iostreams program_options) @@ -380,6 +382,9 @@ if(PKG_CONFIG_FOUND) endif(MSVC) pkg_check_modules(ZSTD IMPORTED_TARGET libzstd>=1.5.2) pkg_check_modules(XXHASH IMPORTED_TARGET libxxhash>=0.8.1) + if(PREFER_SYSTEM_LIBFMT) + pkg_check_modules(FMT IMPORTED_TARGET libfmt>=10.1.0) + endif() endif() if(XXHASH_FOUND) @@ -565,6 +570,7 @@ list( if(DWARFS_GIT_BUILD) list(APPEND LIBDWARFS_SRC ${CMAKE_CURRENT_BINARY_DIR}/src/dwarfs/version.cpp) + include_directories(dwarfs PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include) else() list(APPEND LIBDWARFS_SRC src/dwarfs/version.cpp) endif() @@ -588,17 +594,13 @@ add_library(dwarfs ${LIBDWARFS_SRC}) add_library(dwarfs_compression ${LIBDWARFS_COMPRESSION_SRC}) add_library(dwarfs_tool src/dwarfs/tool.cpp) -if(DWARFS_GIT_BUILD) - target_include_directories(dwarfs PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include) -endif() +# [maxirmx] For me it does not make sense but is required on Ubuntu 20.04 (gcc 10.5) +target_link_libraries(dwarfs_tool dwarfs) target_compile_definitions( dwarfs_tool PRIVATE PRJ_BUILD_ID="${CMAKE_SYSTEM_PROCESSOR}, ${CMAKE_SYSTEM}, ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" ) -target_link_libraries(dwarfs_compression folly) -target_link_libraries(dwarfs_tool dwarfs) - if(STATIC_BUILD_DO_NOT_USE) add_link_options(-static -static-libgcc) endif(STATIC_BUILD_DO_NOT_USE) @@ -606,7 +608,6 @@ endif(STATIC_BUILD_DO_NOT_USE) if("${TEBAKO_BUILD_SCOPE}" STREQUAL "ALL" OR "${TEBAKO_BUILD_SCOPE}" STREQUAL "MKD") add_library(mkdwarfs_main src/mkdwarfs_main.cpp) - target_link_libraries(mkdwarfs_main folly) add_executable(mkdwarfs src/mkdwarfs.cpp) target_link_libraries(mkdwarfs mkdwarfs_main) @@ -622,10 +623,6 @@ if("${TEBAKO_BUILD_SCOPE}" STREQUAL "ALL") add_library(dwarfsbench_main src/dwarfsbench_main.cpp) add_library(dwarfsextract_main src/dwarfsextract_main.cpp) - target_link_libraries(dwarfsck_main folly) - target_link_libraries(dwarfsbench_main folly) - target_link_libraries(dwarfsextract_main folly) - add_executable(dwarfsck src/dwarfsck.cpp) add_executable(dwarfsbench src/dwarfsbench.cpp) add_executable(dwarfsextract src/dwarfsextract.cpp) @@ -950,6 +947,9 @@ foreach(tgt dwarfs dwarfs_compression dwarfs_tool ${BINARY_TARGETS} ${MAIN_TARGE set_property(TARGET ${tgt} PROPERTY CXX_EXTENSIONS OFF) add_dependencies(${tgt} metadata_thrift) + if (NOT ("${OSTYPE_TXT}" MATCHES "Windows")) + add_dependencies(${tgt} ${LIBARCHIVE_PRJ}) + endif() if(ENABLE_ASAN) target_compile_options(${tgt} PRIVATE -fsanitize=address @@ -1007,6 +1007,12 @@ list(APPEND LIBRARIES ${Boost_LIBRARIES} ) +if(PREFER_SYSTEM_LIBFMT) + list(APPEND LIBRARIES PkgConfig::FMT) +else() + list(APPEND LIBRARIES fmt) +endif() + if(LIBLZ4_FOUND) list(APPEND LIBRARIES PkgConfig::LIBLZ4) endif()