Skip to content

Commit

Permalink
#1648 building dependencies with vcpkg (skip ci)
Browse files Browse the repository at this point in the history
  • Loading branch information
CAMOBAP committed Nov 18, 2021
1 parent 5d6b598 commit d5c805d
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 113 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/centos7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ env:
jobs:
tests:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
if: false
container:
image: ${{ matrix.env.IMAGE }}
timeout-minutes: 70
Expand Down Expand Up @@ -127,7 +127,7 @@ jobs:
[ $(grep -c rnp_version_string_full exports) == "1" ]
pkgconfig-cmake-target:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
if: false
container:
image: centos:7
timeout-minutes: 10
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/centos8-ossl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ env:
jobs:
tests:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
if: false
container:
image: ${{ matrix.env.IMAGE }}
timeout-minutes: 70
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/centos8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ env:
jobs:
tests:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
if: false
container:
image: ${{ matrix.env.IMAGE }}
timeout-minutes: 70
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/debian9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
tests:
name: ${{ matrix.env.IMAGE }} [CC ${{ matrix.env.CC }}; GnuPG stable]
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
if: false
container:
image: ${{ matrix.env.IMAGE }}
timeout-minutes: 120
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
CXX: g++
- CC: clang
CXX: clang++
if: "!contains(github.event.head_commit.message, 'skip ci')"
if: false
env: ${{ matrix.env }}
timeout-minutes: 250
steps:
Expand Down
62 changes: 35 additions & 27 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ env:
BUILD_MODE: normal
GPG_VERSION: stable
USE_STATIC_DEPENDENCIES: yes
VCPKG_ROOT: '/usr/local/share/vcpkg'

jobs:
tests:
name: ${{ matrix.os }} [CC ${{ matrix.env.CC }}; GnuPG stable]
name: ${{ matrix.triplet }} ${{ matrix.build_type }} ${{ matrix.env.CC }}; GnuPG stable
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'skip ci')"
timeout-minutes: 50
strategy:
fail-fast: false
matrix:
Expand All @@ -36,43 +39,48 @@ jobs:
CXX: g++
- CC: clang
CXX: clang++
if: "!contains(github.event.head_commit.message, 'skip ci')"
triplet: [x64-linux, x64-linux-dynamic]
build_type: [Release, Debug]
env: ${{ matrix.env }}
timeout-minutes: 50
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup environment
run: |

- run: |
. ci/gha/setup-env.inc.sh
ci/install_noncacheable_dependencies.sh
- name: Cache
id: cache
- if: matrix.triplet == 'x64-linux-dynamic'
run: |
cp ${{ env.VCPKG_ROOT }}/triplets/x64-linux.cmake ${{ env.VCPKG_ROOT }}/triplets/x64-linux-dynamic.cmake
sed -i -- 's/static/dynamic/g' ${{ env.VCPKG_ROOT }}/triplets/x64-linux-dynamic.cmake
- id: vcpkg-cache
uses: actions/cache@v2
with:
path: ${{ env.CACHE_DIR }}
key: ${{ github.workflow }}-${{ runner.os }}-${{ env.BUILD_MODE }}-${{ matrix.env.CC }}-gpg-${{ env.GPG_VERSION }}-${{ hashFiles('ci/**') }}-${{ hashFiles('.github/workflows/**') }}
- name: Build cache
if: steps.cache.outputs.cache-hit != 'true'
run: |
set -x
ci/install_cacheable_dependencies.sh
- name: tests
run: |
set -x
ci/run.sh
- name: Package
run: |
set -x
cd ${LOCAL_BUILDS}/rnp-build
cpack -G DEB -D CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS="${BOTAN_INSTALL}/lib;${JSONC_INSTALL}/lib;${GPG_INSTALL}/lib"
path: ${{ env.VCPKG_ROOT }}/installed
key: vcpkg-${{ matrix.os }}-${{ hashFiles('vcpkg.txt') }}-${{ matrix.triplet }}

- if: steps.vcpkg-cache.outputs.cache-hit != 'true'
run: vcpkg install --triplet ${{ matrix.triplet }} $(cat vcpkg.txt)

- run: ci/run.sh
env:
BUILD_TYPE: ${{ matrix.build_type }}
VCPKG_TRIPLET: ${{ matrix.triplet }}

- run: ci/build_package_deb.sh
env:
BUILD_TYPE: ${{ matrix.build_type }}
VCPKG_TRIPLET: ${{ matrix.triplet }}

cmake-offline-googletest-src:
env:
GTEST_SOURCES: /usr/src/googletest
RNP_TESTS: rnp_tests
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
if: false
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -106,7 +114,7 @@ jobs:
DOWNLOAD_GTEST: Off
RNP_TESTS: rnp_tests
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
if: false
timeout-minutes: 50
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -149,7 +157,7 @@ jobs:
DOWNLOAD_RUBYRNP: Off
RNP_TESTS: rnp_tests.hash_test_success
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
if: false
timeout-minutes: 50
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -179,7 +187,7 @@ jobs:
! ls -la src/tests/ | grep 'ruby' > /dev/null
version-cmake-up-to-date:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
if: false
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
tests:
name: ${{ matrix.os }} msys2 [CC ${{ matrix.env.CC }}; GnuPG stable]
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'skip ci')"
if: false
timeout-minutes: 70
strategy:
fail-fast: false
Expand Down
16 changes: 16 additions & 0 deletions ci/build_package_deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euxo pipefail

main() {
pushd "${LOCAL_BUILDS}/rnp-build"
local build_type_subdir
if [[ "${BUILD_TYPE}" == "Debug" ]]; then
build_type_subdir="/debug"
else
build_type_subdir=""
fi
cpack -G DEB -D CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS="${VCPKG_ROOT}/installed/${VCPKG_TRIPLET}${build_type_subdir}/lib"
popd
}

main "$@"
22 changes: 18 additions & 4 deletions ci/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set -eux
: "${DIST_VERSION:=}"

: "${SKIP_TESTS:=0}"
: "${BUILD_TYPE:=Release}"

prepare_build_prerequisites() {
CMAKE=cmake
Expand All @@ -32,11 +33,19 @@ prepare_build_prerequisites() {
prepare_test_env() {
prepare_build_tool_env

export LD_LIBRARY_PATH="${GPG_INSTALL}/lib:${BOTAN_INSTALL}/lib:${JSONC_INSTALL}/lib:${RNP_INSTALL}/lib:$LD_LIBRARY_PATH"
if [[ "${BUILD_TYPE}" == "Debug" ]]; then
build_type_subdir="/debug"
else
build_type_subdir=""
fi

lib_path="${VCPKG_ROOT}/installed/${VCPKG_TRIPLET}${build_type_subdir}/lib"

export LD_LIBRARY_PATH="${lib_path}"

# update dll search path for windows
if [[ "${OS}" = "msys" ]]; then
export PATH="${LOCAL_BUILDS}/rnp-build/lib:${LOCAL_BUILDS}/rnp-build/bin:${LOCAL_BUILDS}/rnp-build/src/lib:${BOTAN_INSTALL}/bin:$PATH"
export PATH="${lib_path}:$PATH"
fi
}

Expand Down Expand Up @@ -81,11 +90,16 @@ main() {
pushd "${LOCAL_BUILDS}/rnp-build"

cmakeopts=(
-DCMAKE_BUILD_TYPE=Release # RelWithDebInfo -- DebInfo commented out to speed up recurring CI runs.
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" # RelWithDebInfo -- DebInfo commented out to speed up recurring CI runs.
-DBUILD_SHARED_LIBS=yes
-DCMAKE_INSTALL_PREFIX="${RNP_INSTALL}"
-DCMAKE_PREFIX_PATH="${BOTAN_INSTALL};${JSONC_INSTALL};${GPG_INSTALL}"
)

[ -n "${VCPKG_TRIPLET:-}" ] && [ -n "${VCPKG_ROOT:-}" ] && {
cmakeopts+=(-DVCPKG_TARGET_TRIPLET="${VCPKG_TRIPLET}")
cmakeopts+=(-DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
}

[[ ${SKIP_TESTS} = 1 ]] && cmakeopts+=(-DBUILD_TESTING=OFF)
[[ "${BUILD_MODE}" = "coverage" ]] && cmakeopts+=(-DENABLE_COVERAGE=yes)
[[ "${BUILD_MODE}" = "sanitize" ]] && cmakeopts+=(-DENABLE_SANITIZERS=yes)
Expand Down
2 changes: 2 additions & 0 deletions cmake/Modules/FindBotan2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ if (BOTAN2_FOUND AND NOT TARGET Botan2::Botan2)
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${BOTAN2_INCLUDE_DIRS}"
)
# https://gitlab.kitware.com/cmake/cmake/-/issues/15052
file(MAKE_DIRECTORY ${BOTAN2_INCLUDE_DIRS})
endif()
# set the required libraries for the target
if (EXISTS "${BOTAN2_LIBRARY}")
Expand Down
87 changes: 12 additions & 75 deletions src/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,83 +44,20 @@ if(MSVC)
)
endif()

add_executable(generate generate.c)
foreach(exe_name generate encrypt decrypt sign verify dump)
add_executable(${exe_name} ${exe_name}.c)

target_include_directories(generate
PRIVATE
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/src/lib"
)

target_link_libraries(generate
PRIVATE
librnp
)

add_executable(encrypt encrypt.c)

target_include_directories(encrypt
PRIVATE
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/src/lib"
)

target_link_libraries(encrypt
PRIVATE
librnp
)

add_executable(decrypt decrypt.c)

target_include_directories(decrypt
PRIVATE
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/src/lib"
)

target_link_libraries(decrypt
PRIVATE
librnp
)

add_executable(sign sign.c)

target_include_directories(sign
PRIVATE
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/src/lib"
)

target_link_libraries(sign
PRIVATE
librnp
)

add_executable(verify verify.c)

target_include_directories(verify
PRIVATE
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/src/lib"
)

target_link_libraries(verify
PRIVATE
librnp
)

add_executable(dump dump.c)

target_include_directories(dump
PRIVATE
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/src/lib"
)
target_include_directories(${exe_name}
PRIVATE
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/src/lib"
)

target_link_libraries(dump
PRIVATE
librnp
)
target_link_libraries(${exe_name}
PRIVATE
librnp
)
endforeach()

if(MSVC)
target_include_directories(dump
Expand Down
16 changes: 16 additions & 0 deletions src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,22 @@ else()
add_library(librnp-static ALIAS librnp)
endif()

if (BOTAN2_LIBRARY MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
# /usr/bin/ld: libbotan-2.a(src_lib_utils_thread_utils_thread_pool.o):
# in function `std::thread::thread<void (Botan::Thread_Pool::*)(), Botan::Thread_Pool*, void>(
# void (Botan::Thread_Pool::*&&)(), Botan::Thread_Pool*&&)':
# /usr/include/c++/9/thread:126: undefined reference to `pthread_create'
# target_link_options(librnp-obj INTERFACE -pthread)
if (BUILD_SHARED_LIBS)
target_link_options(librnp-static INTERFACE -pthread)
target_link_options(librnp PRIVATE -pthread)
else()
target_link_options(librnp INTERFACE -pthread)
endif()
endif()
endif()

foreach (prop LINK_LIBRARIES INTERFACE_LINK_LIBRARIES INCLUDE_DIRECTORIES INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(val librnp-obj ${prop})
set_property(TARGET librnp PROPERTY ${prop} ${val})
Expand Down

0 comments on commit d5c805d

Please sign in to comment.