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 the project and project artifacts to sexpp; added a filter for symbol visibility #48

Merged
merged 4 commits into from
Jun 26, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 7 additions & 28 deletions .github/workflows/coverity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ jobs:
env:
CC: gcc
CXX: g++
COVERITY_TOKEN: AK2euT-neBcvZB1g_m3pbg
MAKEFLAGS: j4
COVERITY_TOKEN: qjcM1CWLcq9PJB3yL0ZXIw
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -55,30 +55,9 @@ jobs:
- name: Configure
run: cmake -Bbuild -DDOWNLOAD_GTEST=OFF

- name: Download Coverity
env:
TOKEN: AK2euT-neBcvZB1g_m3pbg
run: |
wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=$TOKEN&project=$GITHUB_REPOSITORY" -O cov-analysis-linux64.tar.gz
mkdir cov-analysis-linux64
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64

- name: Build
run: |
set -x
export PATH="$PWD/cov-analysis-linux64/bin:$PATH"
cov-build --dir cov-int cmake --build build

- name: Submit
env:
TOKEN: AK2euT-neBcvZB1g_m3pbg
run: |
tar czvf results.tgz cov-int
curl \
--form project=$GITHUB_REPOSITORY \
--form token=$TOKEN \
--form email=m.samsonov@computer.org \
--form file=@results.tgz \
--form version=$GITHUB_REF \
--form description=$GITHUB_SHA \
https://scan.coverity.com/builds?project=$GITHUB_REPOSITORY
- name: Coverity Scan
uses: vapier/coverity-scan-action@v1
with:
email: maxirmx@sw.consulting
token: ${{ env.COVERITY_TOKEN }}
command: cmake --build build
16 changes: 8 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ jobs:
source: '.'
extensions: 'h,cpp,c'
clangFormatVersion: 11
inplace: True
- uses: EndBug/add-and-commit@v9
with:
author_name: A robot on behalf of Maxim Samsonov
author_email: m.samsonov@computer.org
message: 'Committing clang-format changes'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# inplace: True
# - uses: EndBug/add-and-commit@v9
# with:
# author_name: A robot on behalf of Maxim Samsonov
# author_email: m.samsonov@computer.org
# message: 'Committing clang-format changes'
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shellcheck:
runs-on: ubuntu-latest
steps:
Expand Down
88 changes: 44 additions & 44 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
cmake_minimum_required(VERSION 3.14)

include(cmake/version.cmake)
determine_version("${CMAKE_CURRENT_SOURCE_DIR}" SEXP)

determine_version("${CMAKE_CURRENT_SOURCE_DIR}" SEXPP)
# project name, etc
project(sexp
VERSION "${SEXP_VERSION}"
project(sexpp
VERSION "${SEXPP_VERSION}"
LANGUAGES C CXX
DESCRIPTION "S-expressions parser and generator C++ library, fully compliant to [https://people.csail.mit.edu/rivest/Sexp.txt]"
)
Expand Down Expand Up @@ -111,7 +110,7 @@ if(NOT MSVC)

endif(NOT MSVC)

add_library(sexp ${TYPE}
add_library(sexpp ${TYPE}
"src/sexp-input.cpp"
"src/sexp-output.cpp"
"src/sexp-object.cpp"
Expand All @@ -120,43 +119,44 @@ add_library(sexp ${TYPE}
"src/sexp-error.cpp"
"src/sexp-depth-manager.cpp"
"src/ext-key-format.cpp"
"include/sexp/sexp.h"
"include/sexp/sexp-error.h"
"include/sexp/ext-key-format.h"
"include/sexpp/sexp.h"
"include/sexpp/sexp-error.h"
"include/sexpp/ext-key-format.h"
)

target_compile_features(sexp PUBLIC cxx_std_11)
target_include_directories(sexp PUBLIC
target_compile_features(sexpp PUBLIC cxx_std_11)
target_include_directories(sexpp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

string(REGEX MATCH "^([0-9]+)\\.[0-9]+\\.[0-9]+$" vmatches "${SEXP_VERSION}")
if (NOT vmatches)
message(FATAL_ERROR "Failed to extract major version from SEXP_VERSION (${SEXP_VERSION}).")
endif()
set(SEXP_MAJOR_VERSION "${CMAKE_MATCH_1}")
if (BUILD_SHARED_LIBS)
target_compile_definitions(sexpp PUBLIC BUILD_SHARED_LIBS)
set_target_properties(sexpp PROPERTIES CXX_VISIBILITY_PRESET "hidden")
endif (BUILD_SHARED_LIBS)

set_target_properties(sexp PROPERTIES
set_target_properties(sexpp PROPERTIES
POSITION_INDEPENDENT_CODE ON
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
VERSION "${SEXP_VERSION}"
SOVERSION "${SEXP_MAJOR_VERSION}"
OUTPUT_NAME "sexp"
VERSION "${SEXPP_VERSION}"
SOVERSION "${SEXPP_MAJOR_VERSION}"
OUTPUT_NAME "sexpp"
)

if(WITH_SEXP_CLI)
add_executable (sexp-cli
if (WITH_SEXP_CLI)
add_executable (sexpp-cli
src/sexp-main.cpp
include/sexp/sexp.h
include/sexp/sexp-error.h
include/sexpp/sexp.h
include/sexpp/sexp-error.h
)
target_include_directories (sexp-cli PUBLIC include)
target_link_libraries(sexp-cli PRIVATE sexp)
target_compile_features(sexp-cli PUBLIC cxx_std_11)
set_target_properties(sexp-cli PROPERTIES RUNTIME_OUTPUT_NAME sexp)
set_target_properties(sexp-cli PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif(WITH_SEXP_CLI)
target_include_directories (sexpp-cli PUBLIC include)
target_link_libraries(sexpp-cli PRIVATE sexpp)
target_compile_features(sexpp-cli PUBLIC cxx_std_11)
set_target_properties(sexpp-cli PROPERTIES
RUNTIME_OUTPUT_NAME sexpp
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endif (WITH_SEXP_CLI)


if(WITH_SEXP_TESTS)
Expand Down Expand Up @@ -194,7 +194,7 @@ if(WITH_SEXP_TESTS)
@ONLY
)

add_executable(sexp-tests
add_executable(sexpp-tests
"tests/src/baseline-tests.cpp"
"tests/src/exception-tests.cpp"
"tests/src/primitives-tests.cpp"
Expand Down Expand Up @@ -229,45 +229,45 @@ if(WITH_SEXP_TESTS)
set(GTest GTest::GTest)

if(NOT MSVC)
target_link_libraries(sexp-tests PRIVATE pthread)
target_link_libraries(sexpp-tests PRIVATE pthread)
endif(NOT MSVC)
endif(DOWNLOAD_GTEST)

target_link_libraries(sexp-tests PRIVATE
sexp
target_link_libraries(sexpp-tests PRIVATE
sexpp
${GTestMain}
${GTest}
)

target_include_directories(sexp-tests PRIVATE
target_include_directories(sexpp-tests PRIVATE
tests/include
include
"${GTEST_INCLUDE_DIRS}"
)

target_compile_features(sexp-tests PUBLIC cxx_std_11)
set_target_properties(sexp-tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
target_compile_features(sexpp-tests PUBLIC cxx_std_11)
set_target_properties(sexpp-tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

gtest_discover_tests(sexp-tests)
gtest_discover_tests(sexpp-tests)
endif(WITH_SEXP_TESTS)

set(CONFIGURED_PC "${CMAKE_CURRENT_BINARY_DIR}/sexp.pc")
set(CONFIGURED_PC "${CMAKE_CURRENT_BINARY_DIR}/sexpp.pc")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/sexp.pc.in"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/sexpp.pc.in"
"${CONFIGURED_PC}"
@ONLY
)

if (WIN32 AND BUILD_SHARED_LIBS)
install(TARGETS sexp RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(TARGETS sexp ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(TARGETS sexpp RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(TARGETS sexpp ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
else(WIN32 AND BUILD_SHARED_LIBS)
install(TARGETS sexp DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(TARGETS sexpp DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif(WIN32 AND BUILD_SHARED_LIBS)

install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(FILES "${CONFIGURED_PC}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
if(WITH_SEXP_CLI)
install(TARGETS sexp-cli DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES man/sexp.1 DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
install(TARGETS sexpp-cli DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES man/sexpp.1 DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
endif(WITH_SEXP_CLI)
22 changes: 11 additions & 11 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ image:https://github.com/rnpgp/sexp/workflows/build-and-test-deb/badge.svg["Buil
image:https://github.com/rnpgp/sexp/workflows/build-and-test-msys/badge.svg["Build status MSys", link="https://github.com/rnpgp/sexp/actions?workflow=build-and-test-msys"]


image:https://codecov.io/gh/rnpgp/sexp/branch/feat/g23/graph/badge.svg["Code coverage", link="https://codecov.io/gh/rnpgp/sexp"]
image:https://github.com/rnpgp/sexp/workflows/CodeQL/badge.svg["CodeQL analysis", link="https://github.com/rnpgp/sexp/actions?workflow=CodeQL"]
image:https://scan.coverity.com/projects/27150/badge.svg["Coverity Scan Build Status", link="https://scan.coverity.com/projects/rnpgp-sexp"]
image:https://codecov.io/gh/rnpgp/sexpp/branch/main/graph/badge.svg["Code coverage", link="https://codecov.io/gh/rnpgp/sexpp"]
image:https://github.com/rnpgp/sexpp/workflows/CodeQL/badge.svg["CodeQL analysis", link="https://github.com/rnpgp/sexpp/actions?workflow=CodeQL"]
image:https://scan.coverity.com/projects/28717/badge.svg["Coverity Scan Build Status", link="https://scan.coverity.com/projects/rnpgp-sexpp"]


== Purpose
Expand Down Expand Up @@ -120,14 +120,14 @@ build with address and other sanitizers (requires clang compiler)



== SEXP command-line utility
== SEXPP command-line utility

The `sexp` command-line utility is reference parser and generator of
The `sexpp` command-line utility is reference parser and generator of
S-Expressions. It can read, parse and print out SEXP in all defined formats.

=== Switches

.`sexp` switches
.`sexpp` switches
[options="header"]
|===
| Switch | Description | Default
Expand Down Expand Up @@ -160,7 +160,7 @@ Prompt for S-Expressions input from console, parse and output it to

[source]
----
$ sexp -o certificate.dat -p -b
$ sexpp -o certificate.dat -p -b

> Input:
> (aa bb (cc dd))
Expand All @@ -173,7 +173,7 @@ advanced transport format with no prompts:

[source,sh]
----
$ sexp -i certificate.dat -x
$ sexpp -i certificate.dat -x

> (2:aa2:bb(2:cc2:dd))
----
Expand All @@ -183,7 +183,7 @@ base64 and advanced format with prompts and no width limitation:

[source,sh]
----
$ sexp -i certificate.dat -a -b -c -p -w 0
$ sexpp -i certificate.dat -a -b -c -p -w 0

> Reading input from certificate.dat
>
Expand All @@ -200,14 +200,14 @@ console in advanced, base64 and canonical formats:

[source,sh]
----
$ sexp -p -a -b -c -x
$ sexpp -p -a -b -c -x
----

or just

[source,sh]
----
$ sexp
$ sexpp

> Input:
> (abc def (ghi jkl))
Expand Down
4 changes: 2 additions & 2 deletions cmake/sexp.pc.in → cmake/sexpp.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@

Name: sexp
Description: S-expressions library
Description: C++ library for working with S-Expressions
Version: @PROJECT_VERSION@
URL: https://github.com/rnpgp/sexp
Libs: -L${libdir} -lsexp
Libs: -L${libdir} -lsexpp
Cflags: -I${includedir}
23 changes: 13 additions & 10 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,30 @@ function(extract_version_info version var_prefix)
# extract the main components
# v1.9.0-3-g5b92266+1546836556
# v1.9.0-3-g5b92266-dirty+1546836556
string(REGEX MATCH "^v?([0-9]+\\.[0-9]+\\.[0-9]+)(-([0-9]+)-g([0-9a-f]+)(-dirty)?)?(\\+([0-9]+))?$" matches "${version}")
string(REGEX MATCH "^v?(([0-9]+)\\.[0-9]+\\.[0-9]+)(-([0-9]+)-g([0-9a-f]+)(-dirty)?)?(\\+([0-9]+))?$" matches "${version}")
if (NOT matches)
message(FATAL_ERROR "Failed to extract version components from ${version}.")
endif()
set(${var_prefix}_VERSION "${CMAKE_MATCH_1}" PARENT_SCOPE) # 1.9.0
if (NOT CMAKE_MATCH_3)
set(CMAKE_MATCH_3 "0")
endif()
set(${var_prefix}_VERSION_NCOMMITS "${CMAKE_MATCH_3}" PARENT_SCOPE) # 3
set(${var_prefix}_MAJOR_VERSION "${CMAKE_MATCH_2}" PARENT_SCOPE) # 1
if (NOT CMAKE_MATCH_4)
set(CMAKE_MATCH_4 "0")
endif()
set(${var_prefix}_VERSION_GIT_REV "${CMAKE_MATCH_4}" PARENT_SCOPE) # 5b92266
if (CMAKE_MATCH_5 STREQUAL "-dirty")
set(${var_prefix}_VERSION_NCOMMITS "${CMAKE_MATCH_4}" PARENT_SCOPE) # 3
if (NOT CMAKE_MATCH_5)
set(CMAKE_MATCH_5 "0")
endif()
set(${var_prefix}_VERSION_GIT_REV "${CMAKE_MATCH_5}" PARENT_SCOPE) # 5b92266
if (CMAKE_MATCH_6 STREQUAL "-dirty")
set(${var_prefix}_VERSION_IS_DIRTY TRUE PARENT_SCOPE)
else()
set(${var_prefix}_VERSION_IS_DIRTY FALSE PARENT_SCOPE)
endif()
# timestamp is optional, default to 0
if (NOT CMAKE_MATCH_7)
set(CMAKE_MATCH_7 "0")
if (NOT CMAKE_MATCH_8)
set(CMAKE_MATCH_8 "0")
endif()
set(${var_prefix}_VERSION_COMMIT_TIMESTAMP "${CMAKE_MATCH_7}" PARENT_SCOPE) # 1546836556
set(${var_prefix}_VERSION_COMMIT_TIMESTAMP "${CMAKE_MATCH_8}" PARENT_SCOPE) # 1546836556
endfunction()

function(determine_version source_dir var_prefix)
Expand Down Expand Up @@ -153,7 +154,9 @@ function(determine_version source_dir var_prefix)
# set the results
set(${var_prefix}_VERSION_SUFFIX "${version_suffix}" PARENT_SCOPE)
set(${var_prefix}_VERSION_FULL "${version_full}" PARENT_SCOPE)
set(${var_prefix}_MAJOR_VERSION "${${local_prefix}_MAJOR_VERSION}" PARENT_SCOPE) # 1
# for informational purposes
message(STATUS "${var_prefix}_MAJOR_VERSION: ${${local_prefix}_MAJOR_VERSION}")
message(STATUS "${var_prefix}_VERSION_SUFFIX: ${version_suffix}")
message(STATUS "${var_prefix}_VERSION_FULL: ${version_full}")
endfunction()
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@
#pragma once

#include <map>

#include "sexp-public.h"
#include "sexp.h"

namespace ext_key_format {

void ext_key_error(
void SEXP_PUBLIC_SYMBOL ext_key_error(
sexp::sexp_exception_t::severity level, const char *msg, size_t c1, size_t c2, int pos);

class ext_key_input_stream_t;

class extended_private_key_t {
class SEXP_PUBLIC_SYMBOL extended_private_key_t {
public:
// Comparison of names is done case insensitively !!!
struct ci_less {
Expand Down Expand Up @@ -67,7 +69,7 @@ class extended_private_key_t {
void parse(ext_key_input_stream_t &is);
};

class ext_key_input_stream_t : public sexp::sexp_input_stream_t {
class SEXP_PUBLIC_SYMBOL ext_key_input_stream_t : public sexp::sexp_input_stream_t {
private:
static const bool namechar[256]; /* true if allowed in the name field */

Expand Down