Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed libsexp to libsexpp; integrated an option to use libsexpp provided by the system #2103

Merged
merged 5 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
with:
fetch-depth: 1
submodules: true
- uses: cachix/install-nix-action@v15
- uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: nix build .?submodules=1
78 changes: 72 additions & 6 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ jobs:
-DCMAKE_BUILD_TYPE=Release .

- name: Build
run: cmake --build build --config "Release" --parallel ${{ env.CORES }}
run: cmake --build build --parallel ${{ env.CORES }}

- name: Test
run: |
mkdir -p "build/Testing/Temporary"
cp "cmake/CTestCostData.txt" "build/Testing/Temporary"
export PATH="$PWD/build/src/lib:$PATH"
ctest --parallel ${{ env.CORES }} --test-dir build -C Debug --output-on-failure
ctest --parallel ${{ env.CORES }} --test-dir build --output-on-failure

cmake-offline-googletest-src:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -145,14 +145,14 @@ jobs:
-DCMAKE_BUILD_TYPE=Release .

- name: Build
run: cmake --build build --config "Release" --parallel ${{ env.CORES }}
run: cmake --build build --parallel ${{ env.CORES }}

- name: Test
run: |
mkdir -p "build/Testing/Temporary"
cp "cmake/CTestCostData.txt" "build/Testing/Temporary"
export PATH="$PWD/build/src/lib:$PATH"
ctest --parallel ${{ env.CORES }} --test-dir build -C Debug --output-on-failure
ctest --parallel ${{ env.CORES }} --test-dir build --output-on-failure

- name: Check googletest
run: |
Expand Down Expand Up @@ -191,21 +191,87 @@ jobs:
-DCMAKE_BUILD_TYPE=Release .

- name: Build
run: cmake --build build --config "Release" --parallel ${{ env.CORES }}
run: cmake --build build --parallel ${{ env.CORES }}

- name: Test
run: |
mkdir -p "build/Testing/Temporary"
cp "cmake/CTestCostData.txt" "build/Testing/Temporary"
export PATH="$PWD/build/src/lib:$PATH"
ctest --parallel ${{ env.CORES }} --test-dir build -C Debug --output-on-failure
ctest --parallel ${{ env.CORES }} --test-dir build --output-on-failure

- name: Check googletest
run: |
[ -d "build/src/tests" ]
[ ! -d "build/src/tests/googletest-build" ]
[ ! -d "build/src/tests/googletest-src" ]

cmake-system-sexpp:
name: system-sexpp, sexpp shared libs ${{ matrix.sexpp_shared_libs }}, rnp shared libs ${{ matrix.rnp_shared_libs }}
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
sexpp_shared_libs: [ 'on', 'off' ]
rnp_shared_libs: ['on', 'off']

steps:
- name: Install dependencies
run: |
sudo apt-get -y update
sudo apt-get -y install cmake libjson-c-dev libbotan-2-dev asciidoctor

- name: Checkout sexpp
uses: actions/checkout@v3
with:
repository: rnpgp/sexpp
path: sexpp

- name: Configure sexpp
run: |
echo CORES="$(nproc --all)" >> $GITHUB_ENV
cmake -S sexpp -B sexpp/build \
-DCMAKE_BUILD_TYPE=Release \
-DDOWNLOAD_GTEST=OFF \
-DWITH_SEXP_TESTS=OFF \
-DBUILD_SHARED_LIBS=${{ matrix.sexpp_shared_libs}}

- name: Build sexpp
run: cmake --build sexpp/build --parallel ${{ env.CORES }}

- name: Install sexpp
run: sudo cmake --install sexpp/build

- name: Clean sexpp
run: rm -rf sexpp

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
submodules: false

- name: Configure
run: |
cmake -B build \
-DBUILD_SHARED_LIBS=${{ matrix.rnp_shared_libs }} \
-DCRYPTO_BACKEND=botan \
-DDOWNLOAD_GTEST=ON \
-DSYSTEM_LIBSEXPP=ON \
-DCMAKE_BUILD_TYPE=Release .

- name: Build
run: cmake --build build --parallel ${{ env.CORES }}

- name: Test
run: |
mkdir -p "build/Testing/Temporary"
cp "cmake/CTestCostData.txt" "build/Testing/Temporary"
export PATH="$PWD/build/src/lib:$PATH"
ctest --parallel ${{ env.CORES }} --test-dir build -R rnp_tests --output-on-failure

package-source:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "src/libsexp"]
path = src/libsexp
url = https://github.com/rnpgp/sexp.git
[submodule "src/libsexpp"]
path = src/libsexpp
url = https://github.com/rnpgp/sexpp.git
36 changes: 32 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ option(ENABLE_COVERAGE "Enable code coverage testing.")
option(ENABLE_SANITIZERS "Enable ASan and other sanitizers.")
option(ENABLE_FUZZERS "Enable fuzz targets.")
option(DOWNLOAD_GTEST "Download Googletest" On)
option(SYSTEM_LIBSEXPP "Use system sexpp library" OFF)

# crypto components
function(tristate_feature_auto NAME DESCRIPTION)
set(${NAME} Auto CACHE STRING ${DESCRIPTION})
Expand Down Expand Up @@ -182,10 +184,36 @@ if (ENABLE_FUZZERS)
endif()
add_subdirectory(src/common)

set(WITH_SEXP_CLI OFF)
set(WITH_SEXP_TESTS OFF)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME development)
add_subdirectory(src/libsexp EXCLUDE_FROM_ALL)
if (SYSTEM_LIBSEXPP)
find_package(PkgConfig QUIET)
pkg_check_modules(SEXPP sexpp>=0.8.7 REQUIRED)
find_library(SEXPP_LIBRARY
NAMES
"libsexpp"
"sexpp"
HINTS
"${SEXPP_LIBRARY_DIRS}"
)
add_library(sexpp UNKNOWN IMPORTED)
set_target_properties(sexpp
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SEXPP_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${SEXPP_LIBRARY}"
)
else (SYSTEM_LIBSEXPP)
# If we use system libsexpp is not used we build sexpp static library
# If librnp is shared, libsexpp.a is a transient artifact which is hidden from
# the end user.
# If librnp is static we install libsexpp.a aside
set(SAVED_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
set(WITH_SEXP_CLI OFF)
set(WITH_SEXP_TESTS OFF)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME development)
add_subdirectory(src/libsexpp EXCLUDE_FROM_ALL)
set(BUILD_SHARED_LIBS ${SAVED_BUILD_SHARED_LIBS})
endif (SYSTEM_LIBSEXPP)

add_subdirectory(src/lib)
add_subdirectory(src/rnp)
Expand Down
28 changes: 19 additions & 9 deletions src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ target_include_directories(librnp-obj
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/src"
"${SEXPP_INCLUDE_DIRS}"
)
target_link_libraries(librnp-obj PRIVATE JSON-C::JSON-C)
if (CRYPTO_BACKEND_BOTAN)
Expand All @@ -342,7 +343,7 @@ elseif (CRYPTO_BACKEND_OPENSSL)
target_link_libraries(librnp-obj PRIVATE OpenSSL::Crypto)
endif()

target_link_libraries(librnp-obj PRIVATE sexp)
target_link_libraries(librnp-obj PRIVATE sexpp)

set_target_properties(librnp-obj PROPERTIES CXX_VISIBILITY_PRESET hidden)
if (TARGET BZip2::BZip2)
Expand Down Expand Up @@ -398,7 +399,7 @@ foreach (prop LINK_LIBRARIES INTERFACE_LINK_LIBRARIES INCLUDE_DIRECTORIES INTERF
get_target_property(val librnp-obj ${prop})
if (BUILD_SHARED_LIBS)
set_property(TARGET librnp-static PROPERTY ${prop} ${val})
list(REMOVE_ITEM val "$<LINK_ONLY:sexp>")
list(REMOVE_ITEM val "$<LINK_ONLY:sexpp>")
set_property(TARGET librnp PROPERTY ${prop} ${val})
else()
set_property(TARGET librnp PROPERTY ${prop} ${val})
Expand Down Expand Up @@ -431,12 +432,11 @@ endif()
# On Unix like systems we will build/install/pack either shared library librnp.so or static librnp.a
# On Windows we will build/install/pack either dynamic and import libraries rnp.dll, rnp.lib or static library rnp-static.lib

# If a client application uses shared rnp library, sexp is statically linked to librnp.so and libsexp.a is not installed
# If a client application uses static rnp library, it still needs libsexp.a and it is installed
# If a client application uses shared rnp library, sexpp is statically linked to librnp.so and libsexpp.a is not installed
# If a client application uses static rnp library, it still needs libsexpp.a and it is installed

if (BUILD_SHARED_LIBS)
# both static and shared libraries
install(TARGETS librnp
install(TARGETS librnp
EXPORT rnp-targets
LIBRARY
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand All @@ -456,13 +456,23 @@ install(TARGETS librnp
)
endif(WIN32)
else(BUILD_SHARED_LIBS)
# static libraries only
install(TARGETS librnp sexp
# static libraries
# install libsexpp unless system-installed libsexpp is used
if (SYSTEM_LIBSEXPP)
install(TARGETS librnp
EXPORT rnp-targets
ARCHIVE
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT development
)
else (SYSTEM_LIBSEXPP)
install(TARGETS librnp sexpp
EXPORT rnp-targets
ARCHIVE
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT development
)
)
endif (SYSTEM_LIBSEXPP)
endif(BUILD_SHARED_LIBS)

# install headers
Expand Down
4 changes: 2 additions & 2 deletions src/librekey/g23_sexp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#ifndef RNP_G23_SEXP_HPP
#define RNP_G23_SEXP_HPP

#include "sexp/sexp.h"
#include "sexp/ext-key-format.h"
#include "sexpp/sexp.h"
#include "sexpp/ext-key-format.h"

#define SXP_MAX_DEPTH 30

Expand Down
1 change: 0 additions & 1 deletion src/libsexp
Submodule libsexp deleted from b6bf03
1 change: 1 addition & 0 deletions src/libsexpp
Submodule libsexpp added at e265f6
3 changes: 2 additions & 1 deletion src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,13 @@ target_include_directories(rnp_tests
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/src/lib"
"${BOTAN_INCLUDE_DIRS}"
"${SEXPP_INCLUDE_DIRS}"
)
target_link_libraries(rnp_tests
PRIVATE
librnp-static
JSON-C::JSON-C
sexp
sexpp
${GTestMain}
)
if (CRYPTO_BACKEND_LOWERCASE STREQUAL "openssl")
Expand Down