Unverified Commit 9dc080b9 authored by Kip's avatar Kip Committed by GitHub

Merge pull request #870 from Tachi107/meson

Add Meson support
parents e655d4a0 f8a7e38b
...@@ -34,3 +34,10 @@ ...@@ -34,3 +34,10 @@
.vscode .vscode
.idea .idea
# Clangd cache
.cache
# Meson Wrap DB cache
/subprojects/*
!/subprojects/*.wrap
[submodule "third-party/rapidjson"]
path = third-party/rapidjson
url = https://github.com/Tencent/rapidjson
branch = v1.1.0
[submodule "third-party/googletest"]
path = third-party/googletest
url = https://github.com/google/googletest.git
branch = release-1.7.0
language: cpp language: cpp
os: linux os: linux
dist: bionic dist: focal
branches: branches:
only: only:
...@@ -32,70 +32,126 @@ _apt_pkgs: &_apt_pkgs ...@@ -32,70 +32,126 @@ _apt_pkgs: &_apt_pkgs
- 'lcov' - 'lcov'
- 'cppcheck' - 'cppcheck'
- 'clang-format-9' - 'clang-format-9'
- 'python3-pip'
- 'python3-setuptools'
- 'ninja-build'
- 'libblocksruntime-dev'
- 'rapidjson-dev'
_apt_srcs: &_apt_srcs _apt_srcs: &_apt_srcs
- 'ubuntu-toolchain-r-test' - 'ubuntu-toolchain-r-test'
_env_clang_4: &_env_clang_4 _env_clang_6: &_env_clang_6
- COMPILER=clang++-4.0 - CC=clang-6.0
- COV_TOOL=llvm-cov-4.0 - CXX=clang++-6.0
- COV_TOOL=llvm-cov-6.0
- COV_TOOL_ARGS=gcov - COV_TOOL_ARGS=gcov
_env_clang_5: &_env_clang_5 _env_clang_7: &_env_clang_7
- COMPILER=clang++-5.0 - CC=clang-7
- COV_TOOL=llvm-cov-5.0 - CXX=clang++-7
- COV_TOOL=llvm-cov-7
- COV_TOOL_ARGS=gcov - COV_TOOL_ARGS=gcov
_env_clang_6: &_env_clang_6 _env_clang_8: &_env_clang_8
- COMPILER=clang++-6.0 - CC=clang-8
- COV_TOOL=llvm-cov-6.0 - CXX=clang++-8
- COV_TOOL=llvm-cov-8
- COV_TOOL_ARGS=gcov
_env_clang_9: &_env_clang_9
- CC=clang-9
- CXX=clang++-9
- COV_TOOL=llvm-cov-9
- COV_TOOL_ARGS=gcov
_env_clang_10: &_env_clang_10
- CC=clang-10
- CXX=clang++-10
- COV_TOOL=llvm-cov-10
- COV_TOOL_ARGS=gcov - COV_TOOL_ARGS=gcov
_env_gcc_7: &_env_gcc_7 _env_gcc_7: &_env_gcc_7
- COMPILER=g++-7 - CC=gcc-7
- CXX=g++-7
- COV_TOOL=gcov-7 - COV_TOOL=gcov-7
- COV_TOOL_ARGS= - COV_TOOL_ARGS=
_env_gcc_8: &_env_gcc_8 _env_gcc_8: &_env_gcc_8
- COMPILER=g++-8 - CC=gcc-8
- CXX=g++-8
- COV_TOOL=gcov-8 - COV_TOOL=gcov-8
- COV_TOOL_ARGS= - COV_TOOL_ARGS=
_env_gcc_9: &_env_gcc_9
- CC=gcc-9
- CXX=g++-9
- COV_TOOL=gcov-9
- COV_TOOL_ARGS=
_env_gcc_10: &_env_gcc_10
- CC=gcc-10
- CXX=g++-10
- COV_TOOL=gcov-10
- COV_TOOL_ARGS=
jobs: jobs:
include: include:
# Linux clang builds # Linux clang builds
- arch: amd64 - arch: amd64
env: *_env_clang_4 env: *_env_clang_6
addons: addons:
apt: apt:
sources: sources:
- *_apt_srcs - *_apt_srcs
- ['llvm-toolchain-bionic-4.0'] - ['llvm-toolchain-6.0']
packages: packages:
- *_apt_pkgs - *_apt_pkgs
- ['clang-4.0', 'llvm-4.0-tools', 'libstdc++-6-dev'] - ['clang-6.0', 'llvm-6.0-tools', 'libstdc++-7-dev']
- arch: amd64 - arch: amd64
env: *_env_clang_5 env: *_env_clang_7
addons: addons:
apt: apt:
sources: sources:
- *_apt_srcs - *_apt_srcs
- ['llvm-toolchain-bionic-5.0', 'fish'] - ['llvm-toolchain-7']
packages: packages:
- *_apt_pkgs - *_apt_pkgs
- ['clang-5.0', 'llvm-5.0-tools', 'libstdc++-6-dev'] - ['clang-7', 'llvm-7-tools', 'libstdc++-7-dev']
- arch: amd64 - arch: amd64
env: *_env_clang_6 env: *_env_clang_8
addons: addons:
apt: apt:
sources: sources:
- *_apt_srcs - *_apt_srcs
- ['llvm-toolchain-bionic-6.0'] - ['llvm-toolchain-8']
packages: packages:
- *_apt_pkgs - *_apt_pkgs
- ['clang-6.0', 'llvm-6.0-tools', 'libstdc++-6-dev'] - ['clang-8', 'llvm-8-tools', 'libstdc++-8-dev']
- arch: amd64
env: *_env_clang_9
addons:
apt:
sources:
- *_apt_srcs
- ['llvm-toolchain-9']
packages:
- *_apt_pkgs
- ['clang-9', 'llvm-9-tools', 'libstdc++-9-dev']
- arch: amd64
env: *_env_clang_10
addons:
apt:
sources:
- *_apt_srcs
- ['llvm-toolchain-10']
packages:
- *_apt_pkgs
- ['clang-10', 'llvm-10-tools', 'libstdc++-10-dev']
# Linux GCC builds # Linux GCC builds
- arch: amd64 - arch: amd64
...@@ -104,7 +160,7 @@ jobs: ...@@ -104,7 +160,7 @@ jobs:
apt: apt:
sources: sources:
- *_apt_srcs - *_apt_srcs
packages: packages:
- *_apt_pkgs - *_apt_pkgs
- ['g++-7'] - ['g++-7']
...@@ -114,17 +170,37 @@ jobs: ...@@ -114,17 +170,37 @@ jobs:
apt: apt:
sources: sources:
- *_apt_srcs - *_apt_srcs
packages: packages:
- *_apt_pkgs - *_apt_pkgs
- ['g++-8'] - ['g++-8']
- arch: amd64
env: *_env_gcc_9
addons:
apt:
sources:
- *_apt_srcs
packages:
- *_apt_pkgs
- ['g++-9']
- arch: amd64
env: *_env_gcc_10
addons:
apt:
sources:
- *_apt_srcs
packages:
- *_apt_pkgs
- ['g++-10']
- arch: ppc64le - arch: ppc64le
env: *_env_gcc_8 env: *_env_gcc_8
addons: addons:
apt: apt:
sources: sources:
- *_apt_srcs - *_apt_srcs
packages: packages:
- *_apt_pkgs - *_apt_pkgs
- ['g++-8'] - ['g++-8']
...@@ -134,7 +210,7 @@ jobs: ...@@ -134,7 +210,7 @@ jobs:
apt: apt:
sources: sources:
- *_apt_srcs - *_apt_srcs
packages: packages:
- *_apt_pkgs - *_apt_pkgs
- ['g++-8'] - ['g++-8']
...@@ -144,7 +220,7 @@ jobs: ...@@ -144,7 +220,7 @@ jobs:
apt: apt:
sources: sources:
- *_apt_srcs - *_apt_srcs
packages: packages:
- *_apt_pkgs - *_apt_pkgs
- ['g++-8'] - ['g++-8']
...@@ -157,9 +233,10 @@ before_install: ...@@ -157,9 +233,10 @@ before_install:
install: install:
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR} - mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
# Install Meson >=0.57.0
- sudo pip3 install -qqq --ignore-installed meson
before_script: before_script:
- export CXX=${COMPILER}
- cd ${TRAVIS_BUILD_DIR} - cd ${TRAVIS_BUILD_DIR}
# Enable core dumps # Enable core dumps
...@@ -176,25 +253,44 @@ before_script: ...@@ -176,25 +253,44 @@ before_script:
- service --status-all || true - service --status-all || true
- initctl list || true - initctl list || true
# Debug build # Meson debug build
- cmake -H. - meson setup meson_build_debug
-BBuild-Debug --buildtype=debug
-DCMAKE_BUILD_TYPE=Debug -Db_coverage=true
-DPISTACHE_BUILD_TESTS=true
-DPISTACHE_BUILD_EXAMPLES=true -DPISTACHE_BUILD_EXAMPLES=true
-DPISTACHE_USE_SSL=true
# Meson debug build, no SSL
- meson setup meson_build_debug_nossl
--buildtype=debug
-Db_coverage=true
-DPISTACHE_BUILD_TESTS=true -DPISTACHE_BUILD_TESTS=true
-DPISTACHE_BUILD_EXAMPLES=true
-DPISTACHE_USE_SSL=false
# Meson release build
- meson setup meson_build_release
--buildtype=release
-DPISTACHE_USE_SSL=true -DPISTACHE_USE_SSL=true
# Debug build, no SSL # CMake debug build
- cmake -H. - cmake -S .
-BBuild-Debug-nossl -B cmake_build_debug
-DCMAKE_BUILD_TYPE=Debug
-DPISTACHE_BUILD_TESTS=true
-DPISTACHE_USE_SSL=true
# CMake debug build, no SSL
- cmake -S .
-B cmake_build_debug-nossl
-DCMAKE_BUILD_TYPE=Debug -DCMAKE_BUILD_TYPE=Debug
-DPISTACHE_BUILD_EXAMPLES=true
-DPISTACHE_BUILD_TESTS=true -DPISTACHE_BUILD_TESTS=true
-DPISTACHE_USE_SSL=false -DPISTACHE_USE_SSL=false
# Release build # CMake release build
- cmake -H. - cmake -S .
-BBuild-Release -B cmake_build_release
-DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE=Release
-DPISTACHE_USE_SSL=true -DPISTACHE_USE_SSL=true
...@@ -202,17 +298,23 @@ script: ...@@ -202,17 +298,23 @@ script:
# Set the ulimit # Set the ulimit
- ulimit -c unlimited -S - ulimit -c unlimited -S
# Debug build # CMake debug build
- cd Build-Debug - cmake --build cmake_build_debug --parallel 2 --target all test -- ARGS='-V'
- make -j 2 all test ARGS="-V"
# CMake debug build, no SSL
- cmake --build cmake_build_debug-nossl --parallel 2 --target all test -- ARGS='-V'
# Debug build, no SSL # CMake release build
- cd ../Build-Debug-nossl - cmake --build cmake_build_release --parallel 2 -- ARGS='-V'
- make -j 2 all test ARGS="-V"
# Release build # Meson debug build
- cd ../Build-Release - meson compile -C meson_build_debug --jobs 2 && meson test -C meson_build_debug || (cat meson_build_debug/meson-logs/testlog.txt && false)
- make -j 2
# Meson debug build, no SSL
- meson compile -C meson_build_debug_nossl --jobs 2 && meson test -C meson_build_debug_nossl || (cat meson_build_debug/meson-logs/testlog.txt && false)
# Meson release build
- meson compile -C meson_build_release --jobs 2
after_failure: after_failure:
- CRASHFILES=$(find /var/crash/ -mindepth 1 -maxdepth 1 -print) - CRASHFILES=$(find /var/crash/ -mindepth 1 -maxdepth 1 -print)
...@@ -224,10 +326,8 @@ after_failure: ...@@ -224,10 +326,8 @@ after_failure:
if [ -n "$CRASHFILES" ]; then echo "$CRASHFILES" | while IFS= read -r CRASH; do echo "Crash report: $CRASH"; DIR="/tmp/$(basename $CRASH).d"; apport-unpack "$CRASH" "$DIR"; EXE=$(cat $DIR/ExecutablePath); CORE="$DIR/CoreDump"; echo "Coredump $CORE for $EXE"; /usr/bin/gdb $EXE $CORE -ex "thread apply all bt" -ex "set pagination 0" -batch; done; fi if [ -n "$CRASHFILES" ]; then echo "$CRASHFILES" | while IFS= read -r CRASH; do echo "Crash report: $CRASH"; DIR="/tmp/$(basename $CRASH).d"; apport-unpack "$CRASH" "$DIR"; EXE=$(cat $DIR/ExecutablePath); CORE="$DIR/CoreDump"; echo "Coredump $CORE for $EXE"; /usr/bin/gdb $EXE $CORE -ex "thread apply all bt" -ex "set pagination 0" -batch; done; fi
after_success: after_success:
- cd ../Build-Debug
- sudo su -c "echo 'if [ \"\$1\" = \"-v\" ] ; then $COV_TOOL --version ; else $COV_TOOL $COV_TOOL_ARGS \$@ ; fi' > /usr/local/bin/cov-tool" && sudo chmod +x /usr/local/bin/cov-tool - sudo su -c "echo 'if [ \"\$1\" = \"-v\" ] ; then $COV_TOOL --version ; else $COV_TOOL $COV_TOOL_ARGS \$@ ; fi' > /usr/local/bin/cov-tool" && sudo chmod +x /usr/local/bin/cov-tool
- lcov --capture --gcov-tool cov-tool --directory . --output-file coverage.info - lcov --capture --gcov-tool cov-tool --directory . --output-file coverage.info
- lcov --remove coverage.info '/usr/*' '*tests/*' '*third-party/*' --output-file coverage.info - lcov --remove coverage.info '/usr/*' '*tests/*' '*examples/*' '*subprojects/*' --output-file coverage.info
- lcov --list coverage.info - lcov --list coverage.info
- bash <(curl -s https://codecov.io/bash) -f coverage.info || echo "Codecov did not collect coverage reports" - bash <(curl -s https://codecov.io/bash) -f coverage.info || echo "Codecov did not collect coverage reports"
cmake_minimum_required (VERSION 3.9) cmake_minimum_required (VERSION 3.11)
set(CMAKE_BUILD_TYPE_INIT Release) set(CMAKE_BUILD_TYPE_INIT Release)
...@@ -18,16 +18,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) ...@@ -18,16 +18,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
include(CheckAtomic) include(CheckAtomic)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
add_compile_options(-g -Og -ftest-coverage -fstack-protector-all --param=ssp-buffer-size=4)
endif()
option(BUILD_SHARED_LIBS "build shared library" ON) option(BUILD_SHARED_LIBS "build shared library" ON)
option(PISTACHE_BUILD_TESTS "build tests alongside the project" OFF) option(PISTACHE_BUILD_TESTS "build tests alongside the project" OFF)
option(PISTACHE_ENABLE_NETWORK_TESTS "if tests are built, run ones needing network access" ON) option(PISTACHE_ENABLE_NETWORK_TESTS "if tests are built, run ones needing network access" ON)
option(PISTACHE_BUILD_EXAMPLES "build examples alongside the project" OFF)
option(PISTACHE_BUILD_DOCS "build docs alongside the project" OFF)
option(PISTACHE_INSTALL "add pistache as install target (recommended)" ON)
option(PISTACHE_USE_SSL "add support for SSL server" OFF) option(PISTACHE_USE_SSL "add support for SSL server" OFF)
option(PISTACHE_PIC "Enable pistache PIC" ON) option(PISTACHE_PIC "Enable pistache PIC" ON)
...@@ -40,32 +33,6 @@ if(CMAKE_INTERPROCEDURAL_OPTIMIZATION OR CMAKE_CXX_FLAGS MATCHES "-flto" OR CMAK ...@@ -40,32 +33,6 @@ if(CMAKE_INTERPROCEDURAL_OPTIMIZATION OR CMAKE_CXX_FLAGS MATCHES "-flto" OR CMAK
endif() endif()
endif() endif()
if (PISTACHE_BUILD_TESTS)
find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind)
find_program(CTEST_COVERAGE_COMMAND NAMES gcov)
find_program(CMAKE_CXX_CPPCHECK NAMES cppcheck)
if (CMAKE_CXX_CPPCHECK)
message("-- Cppcheck found " ${CMAKE_CXX_CPPCHECK})
list(
APPEND CMAKE_CXX_CPPCHECK
"--enable=all"
"-DCPPCHECK"
"--suppress=*:${PROJECT_SOURCE_DIR}/third-party*"
"--suppress=*:${PROJECT_SOURCE_DIR}/tests*"
"--suppress=noExplicitConstructor:include/pistache/optional.h"
)
else()
message("-- Cppcheck not found")
set(CMAKE_CXX_CPPCHECK "")
endif()
INCLUDE(Dart)
add_custom_target(test_memcheck COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --test-action memcheck)
add_custom_target(coverage COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --test-action coverage)
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
...@@ -96,6 +63,9 @@ endif () ...@@ -96,6 +63,9 @@ endif ()
string(REGEX MATCH "VERSION_GIT_DATE *([0-9]+)" _ ${VERSION_FILE}) string(REGEX MATCH "VERSION_GIT_DATE *([0-9]+)" _ ${VERSION_FILE})
set(VERSION_GIT_DATE ${CMAKE_MATCH_1}) set(VERSION_GIT_DATE ${CMAKE_MATCH_1})
# Full version
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-git${VERSION_GIT_DATE})
# Make available in a header file... # Make available in a header file...
configure_file ( configure_file (
"include/pistache/version.h.in" "include/pistache/version.h.in"
...@@ -103,16 +73,6 @@ endif () ...@@ -103,16 +73,6 @@ endif ()
@ONLY @ONLY
) )
# Install version header...
if(PISTACHE_INSTALL)
install (
FILES
${CMAKE_CURRENT_BINARY_DIR}/include/pistache/version.h
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/pistache/
)
endif()
# Set public interface version... # Set public interface version...
# Major should be incremented every time a non-backward compatible change # Major should be incremented every time a non-backward compatible change
...@@ -125,109 +85,27 @@ endif () ...@@ -125,109 +85,27 @@ endif ()
string(REGEX MATCH "SONAME_VERSION_MINOR *([0-9]+)" _ ${VERSION_FILE}) string(REGEX MATCH "SONAME_VERSION_MINOR *([0-9]+)" _ ${VERSION_FILE})
set(SONAME_VERSION_MINOR ${CMAKE_MATCH_1}) set(SONAME_VERSION_MINOR ${CMAKE_MATCH_1})
# Set libraries that we need to link against...
# Minimum...
set(LIBS "-lpistache -lpthread")
if (NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
set(LIBS "-latomic")
endif ()
# If building with OpenSSL support...
if(PISTACHE_USE_SSL)
set(LIBS "${LIBS} -lssl -lcrypto")
endif(PISTACHE_USE_SSL)
# Configure the pkg-config metadata...
# Initialize the metadata variables and to support remote builds...
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}/)
set(libs ${LIBS})
set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}/)
set(version ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-git${VERSION_GIT_DATE})
# Perform substitutions...
configure_file (
"libpistache.pc.in"
"libpistache.pc"
@ONLY
)
# Install pkg-config metadata into standard location within the prefix...
if(PISTACHE_INSTALL)
install (
FILES
${CMAKE_CURRENT_BINARY_DIR}/libpistache.pc
DESTINATION
${CMAKE_INSTALL_LIBDIR}/pkgconfig/
)
endif()
add_subdirectory (src) add_subdirectory (src)
if (PISTACHE_BUILD_EXAMPLES)
add_subdirectory (examples)
endif()
if (PISTACHE_BUILD_TESTS) if (PISTACHE_BUILD_TESTS)
find_package(GTest) include(CTest)
find_package(GTest QUIET)
if (NOT GTEST_FOUND) if (NOT GTEST_FOUND)
ADD_SUBDIRECTORY (third-party/googletest) message("GoogleTest not found. Consider installing it on your system. Downloading it from source...")
set(GTEST_INCLUDE_DIRS ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_SHALLOW true
)
set(BUILD_GMOCK OFF CACHE BOOL "")
FetchContent_GetProperties(googletest)
if(NOT googletest_POPULATED)
FetchContent_Populate(googletest)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
endif()
endif() endif()
enable_testing() enable_testing()
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
if (PISTACHE_BUILD_DOCS)
find_package(Doxygen
REQUIRED dot
OPTIONAL_COMPONENTS mscgen dia)
if (DOXYGEN_FOUND)
set(DOXYGEN_IN ${CMAKE_SOURCE_DIR}/docs/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile)
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
add_custom_target(docs
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs
COMMENT "Generating doxygen documentation"
VERBATIM)
message("-- Adding doxygen documentation done")
else(DOXYGEN_FOUND)
message(FATAL_ERROR "Doxygen need to be installed to generate the doxygen documentation")
endif(DOXYGEN_FOUND)
endif()
# Generate source tarball...
# Define version of source archive...
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
# Generate a .tar.bz2
set(CPACK_SOURCE_GENERATOR "TBZ2")
# Set filename...
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
# Don't include these files in the archive...
set(CPACK_SOURCE_IGNORE_FILES
"/build/;/debian/;/prefix/;/.git*/;~$;${CPACK_SOURCE_IGNORE_FILES}")
# Include the CPack module for generating the archive and add the standard
# dist target to the generated makefile...
include(CPack)
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
#-------------------------------------------------------------------------------
# Copyright (c) 2013-2013, Lars Baehren <lbaehren@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#-------------------------------------------------------------------------------
# - Check for the presence of RAPIDJSON
#
# The following variables are set when RAPIDJSON is found:
# RAPIDJSON_FOUND = Set to true, if all components of RapidJSON have been
# found.
# RAPIDJSON_INCLUDES = Include path for the header files of RAPIDJSON
# RAPIDJSON_LIBRARIES = Link these to use RAPIDJSON
# RAPIDJSON_LFLAGS = Linker flags (optional)
if (NOT RAPIDJSON_FOUND)
if (NOT RAPIDJSON_ROOT_DIR)
set (RAPIDJSON_ROOT_DIR ${CMAKE_INSTALL_PREFIX})
endif (NOT RAPIDJSON_ROOT_DIR)
##____________________________________________________________________________
## Check for the header files
find_path (RAPIDJSON_INCLUDES
NAMES rapidjson/rapidjson.h rapidjson/reader.h rapidjson/writer.h
HINTS ${RAPIDJSON_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
PATH_SUFFIXES include
)
##____________________________________________________________________________
## Actions taken when all components have been found
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (RAPIDJSON DEFAULT_MSG RAPIDJSON_INCLUDES)
if (RAPIDJSON_FOUND)
## Update
get_filename_component (RAPIDJSON_ROOT_DIR ${RAPIDJSON_INCLUDES} PATH)
## Feedback
if (NOT RAPIDJSON_FIND_QUIETLY)
message (STATUS "Found components for RapidJSON")
message (STATUS "RAPIDJSON_ROOT_DIR = ${RAPIDJSON_ROOT_DIR}")
message (STATUS "RAPIDJSON_INCLUDES = ${RAPIDJSON_INCLUDES}")
endif (NOT RAPIDJSON_FIND_QUIETLY)
else (RAPIDJSON_FOUND)
if (RAPIDJSON_FIND_REQUIRED)
message (FATAL_ERROR "Could not find RapidJSON!")
endif (RAPIDJSON_FIND_REQUIRED)
endif (RAPIDJSON_FOUND)
##____________________________________________________________________________
## Mark advanced variables
mark_as_advanced (
RAPIDJSON_ROOT_DIR
RAPIDJSON_INCLUDES
)
endif (NOT RAPIDJSON_FOUND)
\ No newline at end of file
# Pistache # Pistache
[![N|Solid](pistache.io/static/img/logo.png)](https://www.github.com/pistacheio/pistache) [![N|Solid](pistache.io/static/img/logo.png)](https://www.github.com/pistacheio/pistache)
[![Build Status](https://travis-ci.org/pistacheio/pistache.svg?branch=master)](https://travis-ci.org/pistacheio/pistache) [![Build Status](https://travis-ci.org/pistacheio/pistache.svg?branch=master)](https://travis-ci.org/pistacheio/pistache)
Pistache is a modern and elegant HTTP and REST framework for C++. It is entirely written in pure-C++14 and provides a clear and pleasant API. Pistache is a modern and elegant HTTP and REST framework for C++. It is entirely written in pure-C++14 and provides a clear and pleasant API.
# Documentation ## Documentation
We are still looking for a volunteer to document fully the API. In the mean time, partial documentation is available at [http://pistache.io](http://pistache.io). If you are interested in helping with this, please open an issue ticket. We are still looking for a volunteer to document fully the API. In the mean time, partial documentation is available at [pistache.io](http://pistache.io). If you are interested in helping with this, please open an issue ticket.
A comparison of Pistache to other C++ RESTful APIs was created by guteksan and is available [here](https://github.com/guteksan/REST-CPP-benchmark). A comparison of Pistache to other C++ RESTful APIs was created by guteksan and is available [here](https://github.com/guteksan/REST-CPP-benchmark).
# Dependencies ## Dependencies
Pistache has the following third party dependencies Pistache has the following third party dependencies
- [CMake](https://cmake.org) - [Meson](https://mesonbuild.com)
- [Doxygen](https://www.doxygen.nl/) - [Doxygen](https://www.doxygen.nl/)
- [Googletest](https://github.com/google/googletest) - [Googletest](https://github.com/google/googletest)
- [OpenSSL](https://www.openssl.org/) - [OpenSSL](https://www.openssl.org/)
- [RapidJSON](https://rapidjson.org/) - [RapidJSON](https://rapidjson.org/)
# Contributing ## Contributing
Pistache is released under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). Contributors are welcome! Pistache is released under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). Contributors are welcome!
...@@ -31,17 +32,18 @@ For those that prefer IRC over Slack, the rag-tag crew of maintainers idle in `# ...@@ -31,17 +32,18 @@ For those that prefer IRC over Slack, the rag-tag crew of maintainers idle in `#
The [Launchpad Team](https://launchpad.net/~pistache+team) administers the daily and stable Ubuntu pre-compiled packages. The [Launchpad Team](https://launchpad.net/~pistache+team) administers the daily and stable Ubuntu pre-compiled packages.
## Release Versioning ### Release Versioning
Please update `version.txt` accordingly with each unstable or stable release. Please update `version.txt` accordingly with each unstable or stable release.
## Interface Versioning ### Interface Versioning
The version of the library's public interface (ABI) is not the same as the release version. The interface version is primarily associated with the _external_ interface of the library. Different platforms handle this differently, such as AIX, GNU/Linux, and Solaris. The version of the library's public interface (ABI) is not the same as the release version. The interface version is primarily associated with the _external_ interface of the library. Different platforms handle this differently, such as AIX, GNU/Linux, and Solaris.
GNU Libtool abstracts each platform's idiosyncrasies away because it is more portable than using `ar(1)` or `ranlib(1)` directly. However, it is a pain to integrate with CMake so we made do without it by setting the SONAME directly. GNU Libtool abstracts each platform's idiosyncrasies away because it is more portable than using `ar(1)` or `ranlib(1)` directly. However, it is a pain to integrate with CMake so we made do without it by setting the SONAME directly.
When Pistache is installed it will normally ship: When Pistache is installed it will normally ship:
- `libpistache-<release>.so.X.Y`: This is the actual shared-library binary file. The _X_ and _Y_ values are the major and minor interface versions respectively. - `libpistache-<release>.so.X.Y`: This is the actual shared-library binary file. The _X_ and _Y_ values are the major and minor interface versions respectively.
- `libpistache-<release>.so.X`: This is the _soname_ soft link that points to the binary file. It is what other programs and other libraries reference internally. You should never need to directly reference this file in your build environment. - `libpistache-<release>.so.X`: This is the _soname_ soft link that points to the binary file. It is what other programs and other libraries reference internally. You should never need to directly reference this file in your build environment.
...@@ -54,15 +56,18 @@ If your contribution has modified the interface, you may need to update the majo ...@@ -54,15 +56,18 @@ If your contribution has modified the interface, you may need to update the majo
The major version should be incremented every time a non-backward compatible change occured in the ABI. The minor version should be incremented every time a backward compatible change occurs. This can be done by modifying `version.txt` accordingly. The major version should be incremented every time a non-backward compatible change occured in the ABI. The minor version should be incremented every time a backward compatible change occurs. This can be done by modifying `version.txt` accordingly.
# Precompiled Packages ## Precompiled Packages
If you have no need to modify the Pistache source, you are strongly recommended to use precompiled packages for your distribution. This will save you time. If you have no need to modify the Pistache source, you are strongly recommended to use precompiled packages for your distribution. This will save you time.
## Debian and Ubuntu ### Debian and Ubuntu
We have submitted a [Request for Packaging](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=929593) downstream to Debian. Once we have an official Debian package maintainer intimately familiar with the [Debian Policy Manual](https://www.debian.org/doc/debian-policy/), we can expect to eventually see it become available in Debian and all derivatives (e.g. Ubuntu and many others). We have submitted a [Request for Packaging](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=929593) downstream to Debian. Once we have an official Debian package maintainer intimately familiar with the [Debian Policy Manual](https://www.debian.org/doc/debian-policy/), we can expect to eventually see it become available in Debian and all derivatives (e.g. Ubuntu and many others).
But until then currently Pistache has partially compliant upstream Debianization. Our long term goal is to have our source package properly Debianized downstream by a Debian Policy Manual SME. In the mean time consider using our PPAs to avoid having to build from source. But until then currently Pistache has partially compliant upstream Debianization. Our long term goal is to have our source package properly Debianized downstream by a Debian Policy Manual SME. In the mean time consider using our PPAs to avoid having to build from source.
### Supported Architectures #### Supported Architectures
Currently Pistache is built and tested on a number of [architectures](https://wiki.debian.org/SupportedArchitectures). Some of these are suitable for desktop or server use and others for embedded environments. As of this writing we do not currently have any MIPS related packages that have been either built or tested. The `ppc64el` builds are occasionally tested on POWER9 hardware, courtesy of IBM. Currently Pistache is built and tested on a number of [architectures](https://wiki.debian.org/SupportedArchitectures). Some of these are suitable for desktop or server use and others for embedded environments. As of this writing we do not currently have any MIPS related packages that have been either built or tested. The `ppc64el` builds are occasionally tested on POWER9 hardware, courtesy of IBM.
- amd64 - amd64
...@@ -72,7 +77,8 @@ Currently Pistache is built and tested on a number of [architectures](https://wi ...@@ -72,7 +77,8 @@ Currently Pistache is built and tested on a number of [architectures](https://wi
- ppc64el - ppc64el
- s390x - s390x
### Ubuntu PPA (Unstable) #### Ubuntu PPA (Unstable)
The project builds [daily unstable snapshots](https://launchpad.net/~pistache+team/+archive/ubuntu/unstable) in a separate unstable PPA. To use it, run the following: The project builds [daily unstable snapshots](https://launchpad.net/~pistache+team/+archive/ubuntu/unstable) in a separate unstable PPA. To use it, run the following:
```console ```console
...@@ -81,7 +87,8 @@ $ sudo apt update ...@@ -81,7 +87,8 @@ $ sudo apt update
$ sudo apt install libpistache-dev $ sudo apt install libpistache-dev
``` ```
### Ubuntu PPA (Stable) #### Ubuntu PPA (Stable)
Currently there are no stable release of Pistache published into the [stable](https://launchpad.net/~pistache+team/+archive/ubuntu/stable) PPA. However, when that time comes, run the following to install a stable package: Currently there are no stable release of Pistache published into the [stable](https://launchpad.net/~pistache+team/+archive/ubuntu/stable) PPA. However, when that time comes, run the following to install a stable package:
```console ```console
...@@ -90,111 +97,122 @@ $ sudo apt update ...@@ -90,111 +97,122 @@ $ sudo apt update
$ sudo apt install libpistache-dev $ sudo apt install libpistache-dev
``` ```
## Other Distributions ### Other Distributions
Package maintainers, please insert instructions for users to install pre-compiled packages from your respective repositories here. Package maintainers, please insert instructions for users to install pre-compiled packages from your respective repositories here.
# Use via pkg-config ## Use via pkg-config
If you would like to automatically have your project's build environment use the appropriate compiler and linker build flags, [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) can greatly simplify things. It is the portable international _de facto_ standard for determining build flags. The development packages include a pkg-config manifest. If you would like to automatically have your project's build environment use the appropriate compiler and linker build flags, [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) can greatly simplify things. It is the portable international _de facto_ standard for determining build flags. The development packages include a pkg-config manifest.
## GNU Autotools ### GNU Autotools
To [use](https://autotools.io/pkgconfig/pkg_check_modules.html) with the GNU Autotools, as an example, include the following snippet in your project's `configure.ac`: To [use](https://autotools.io/pkgconfig/pkg_check_modules.html) with the GNU Autotools, as an example, include the following snippet in your project's `configure.ac`:
```makefile
# Pistache...
PKG_CHECK_MODULES(
[libpistache], [libpistache >= 0.0.2], [],
[AC_MSG_ERROR([libpistache >= 0.0.2 missing...])])
YOURPROJECT_CXXFLAGS="$YOURPROJECT_CXXFLAGS $libpistache_CFLAGS"
YOURPROJECT_LIBS="$YOURPROJECT_LIBS $libpistache_LIBS"
``` ```
# Pistache... ### Meson
PKG_CHECK_MODULES(
[libpistache], [libpistache >= 0.0.2], [], To use with Meson, you just need to add `dependency('pistache')` as a dependency for your executable. If you have this repository as a submodule in the `subprojects` directory of your project, Meson will automatically build the library from source if it is not installed on the system.
[AC_MSG_ERROR([libpistache >= 0.0.2 missing...])])
YOURPROJECT_CXXFLAGS="$YOURPROJECT_CXXFLAGS $libpistache_CFLAGS" ```meson
YOURPROJECT_LIBS="$YOURPROJECT_LIBS $libpistache_LIBS" project(
'MyPistacheProject',
'cpp',
meson_version: '>=0.55.0'
)
executable(
'MyPistacheExecutable',
sources: 'main.cpp',
dependencies: dependency('pistache')
)
``` ```
## CMake If you're using a Meson version older than 0.55.0 you'll have to use the "older" syntax for `depependecy()`:
```meson
dependencies: dependency('pistache', fallback ['pistache', 'pistache_static_dep'])
```
### CMake
To use with a CMake build environment, use the [FindPkgConfig](https://cmake.org/cmake/help/latest/module/FindPkgConfig.html) module. Here is an example: To use with a CMake build environment, use the [FindPkgConfig](https://cmake.org/cmake/help/latest/module/FindPkgConfig.html) module. Here is an example:
```cmake ```cmake
cmake_minimum_required(3.4 FATAL_ERROR) cmake_minimum_required(3.4 FATAL_ERROR)
project("MyPistacheProject") project("MyPistacheProject")
# Find the library. # Find the library.
find_package(Pistache 0.0.2 REQUIRED) find_package(Pistache 0.0.2 REQUIRED)
add_executable(${PROJECT_NAME} main.cpp) add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} pistache_shared) target_link_libraries(${PROJECT_NAME} pistache_shared)
``` ```
## Makefile ### Makefile
To use within a vanilla makefile, you can call `pkg-config` directly to supply compiler and linker flags using shell substitution. To use within a vanilla makefile, you can call `pkg-config` directly to supply compiler and linker flags using shell substitution.
``` ```makefile
CFLAGS=-g3 -Wall -Wextra -Werror ... CFLAGS=-g3 -Wall -Wextra -Werror ...
LDFLAGS=-lfoo ... LDFLAGS=-lfoo ...
... ...
CFLAGS+= $(pkg-config --cflags libpistache) CFLAGS+= $(pkg-config --cflags libpistache)
LDFLAGS+= $(pkg-config --libs libpistache) LDFLAGS+= $(pkg-config --libs libpistache)
``` ```
# Building from source ## Building from source
To download the latest available release, clone the repository over github. To download the latest available release, clone the repository over GitHub.
```console ```sh
$ git clone https://github.com/oktal/pistache.git $ git clone https://github.com/pistacheio/pistache.git
```
Then, init the submodules:
```console
$ git submodule update --init
``` ```
Now, compile the sources: Now, compile the sources:
```console ```sh
$ cd pistache $ cd pistache
$ mkdir -p {build,prefix} $ meson setup build \
$ cd build --buildtype=release \
$ cmake -G "Unix Makefiles" \ -DPISTACHE_USE_SSL=true \
-DCMAKE_BUILD_TYPE=Release \ -DPISTACHE_BUILD_EXAMPLES=true \
-DPISTACHE_BUILD_EXAMPLES=true \ -DPISTACHE_BUILD_TESTS=true \
-DPISTACHE_BUILD_TESTS=true \ -DPISTACHE_BUILD_DOCS=false \
-DPISTACHE_BUILD_DOCS=false \ --prefix=$PWD/prefix
-DPISTACHE_USE_SSL=true \ $ meson compile -C build
-DCMAKE_INSTALL_PREFIX=$PWD/../prefix \ $ meson install -C build
../
$ make -j
$ make install
```
If you chose to build the examples, then perform the following to build the examples.
```console
$ cd examples
$ make -j
``` ```
Optionally, you can also build and run the tests (tests require the examples): Optionally, you can also run the tests:
```console ```sh
$ cmake -G "Unix Makefiles" -DPISTACHE_BUILD_EXAMPLES=true -DPISTACHE_BUILD_TESTS=true .. $ meson test -C build
$ make test test_memcheck
``` ```
Be patient, async_test can take some time before completing. And that's it, now you can start playing with your newly installed Pistache framework. Be patient, async_test can take some time before completing. And that's it, now you can start playing with your newly installed Pistache framework.
Some other CMAKE defines: Some other Meson options:
| Option | Default | Description | | Option | Default | Description |
|-------------------------------|-------------|------------------------------------------------| |-------------------------------|-------------|------------------------------------------------|
| PISTACHE_BUILD_EXAMPLES | False | Build all of the example apps | | PISTACHE_USE_SSL | False | Build server with SSL support |
| PISTACHE_BUILD_TESTS | False | Build all of the unit tests | | PISTACHE_BUILD_TESTS | False | Build all of the unit tests |
| PISTACHE_ENABLE_NETWORK_TESTS | True | Run unit tests requiring remote network access | | PISTACHE_ENABLE_NETWORK_TESTS | True | Run unit tests requiring remote network access |
| PISTACHE_USE_SSL | False | Build server with SSL support | | PISTACHE_BUILD_EXAMPLES | False | Build all of the example apps |
| PISTACHE_BUILD_DOCS | False | Build Doxygen docs |
# Continuous Integration Testing ## Continuous Integration Testing
It is important that all patches pass unit testing. Unfortunately developers make all kinds of changes to their local development environment that can have unintended consequences. This can means sometimes tests on the developer's computer pass when they should not, and other times failing when they should not have. It is important that all patches pass unit testing. Unfortunately developers make all kinds of changes to their local development environment that can have unintended consequences. This can means sometimes tests on the developer's computer pass when they should not, and other times failing when they should not have.
To properly validate that things are working, continuous integration (CI) is required. This means compiling, performing local in-tree unit tests, installing through the system package manager, and finally testing the actually installed build artifacts to ensure they do what the user expects them to do. To properly validate that things are working, continuous integration (CI) is required. This means compiling, performing local in-tree unit tests, installing through the system package manager, and finally testing the actually installed build artifacts to ensure they do what the user expects them to do.
...@@ -202,35 +220,40 @@ The key thing to remember is that in order to do this properly, this all needs t ...@@ -202,35 +220,40 @@ The key thing to remember is that in order to do this properly, this all needs t
There are [different ways](https://wiki.debian.org/qa.debian.org#Other_distributions) of performing CI on different distros. The most common one is via the international [DEP-8](https://dep-team.pages.debian.net/deps/dep8/) standard as used by hundreds of different operating systems. There are [different ways](https://wiki.debian.org/qa.debian.org#Other_distributions) of performing CI on different distros. The most common one is via the international [DEP-8](https://dep-team.pages.debian.net/deps/dep8/) standard as used by hundreds of different operating systems.
## Autopkgtest ### Autopkgtest
On Debian based distributions, `autopkgtest` implements the DEP-8 standard. To create and use a build image environment for Ubuntu, follow these steps. First install the autopkgtest(1) tools: On Debian based distributions, `autopkgtest` implements the DEP-8 standard. To create and use a build image environment for Ubuntu, follow these steps. First install the autopkgtest(1) tools:
```
```sh
$ sudo apt install autopkgtest $ sudo apt install autopkgtest
``` ```
Next create the test image, substituting `groovy` or `amd64` for other releases or architectures: Next create the test image, substituting `groovy` or `amd64` for other releases or architectures:
```
```sh
$ autopkgtest-buildvm-ubuntu-cloud -r groovy -a amd64 $ autopkgtest-buildvm-ubuntu-cloud -r groovy -a amd64
``` ```
Generate a Pistache source package in the parent directory of `pistache_source`: Generate a Pistache source package in the parent directory of `pistache_source`:
```
```sh
$ cd pistache_source $ cd pistache_source
$ sudo apt build-dep pistache $ sudo apt build-dep pistache
$ ./debian/rules get-orig-source $ ./debian/rules get-orig-source
$ debuild -S -sa -uc $ debuild -S -sa -uc -us
``` ```
Test the source package on the host architecture in QEMU with KVM support and 8GB of RAM and four CPUs: Test the source package on the host architecture in QEMU with KVM support and 8GB of RAM and four CPUs:
```
```sh
$ autopkgtest --shell-fail --apt-upgrade ../pistache_(...).dsc -- \ $ autopkgtest --shell-fail --apt-upgrade ../pistache_(...).dsc -- \
qemu --ram-size=8192 --cpus=4 --show-boot path_to_build_image.img \ qemu --ram-size=8192 --cpus=4 --show-boot path_to_build_image.img \
--qemu-options='-enable-kvm' --qemu-options='-enable-kvm'
``` ```
# Example ## Example
## Hello World (server) ### Hello World (server)
```cpp ```cpp
#include <pistache/endpoint.h> #include <pistache/endpoint.h>
......
...@@ -4,9 +4,9 @@ Priority: optional ...@@ -4,9 +4,9 @@ Priority: optional
Maintainer: Kip Warner <kip@thevertigo.com> Maintainer: Kip Warner <kip@thevertigo.com>
Standards-Version: 4.2.1 Standards-Version: 4.2.1
Build-Depends: Build-Depends:
cmake (>= 3.8.0), meson (>= 0.50.0),
cppcheck, cppcheck,
debhelper-compat (= 11), debhelper-compat (= 12),
dh-exec, dh-exec,
libc6-dev (>= 2.26), libc6-dev (>= 2.26),
libcurl4-openssl-dev, libcurl4-openssl-dev,
...@@ -19,7 +19,7 @@ Build-Depends: ...@@ -19,7 +19,7 @@ Build-Depends:
valgrind valgrind
Vcs-Git: https://github.com/pistacheio/pistache.git Vcs-Git: https://github.com/pistacheio/pistache.git
Vcs-browser: https://github.com/pistacheio/pistache Vcs-browser: https://github.com/pistacheio/pistache
Homepage: https://github.com/pistacheio/pistache Homepage: http://pistache.io
Package: libpistache-dev Package: libpistache-dev
Architecture: any Architecture: any
...@@ -59,4 +59,3 @@ Description: elegant C++ REST framework ...@@ -59,4 +59,3 @@ Description: elegant C++ REST framework
Pistache is released under the Apache License 2.0 license. Pistache is released under the Apache License 2.0 license.
. .
This package contains the shared library built with SSL support. This package contains the shared library built with SSL support.
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: pistache Upstream-Name: pistache
Upstream-Contact: Dennis Jenkins <dennis.jenkins.75@gmail.com> Upstream-Contact: Dennis Jenkins <dennis.jenkins.75@gmail.com>
Source: https://github.com/oktal/pistache.git Source: https://github.com/pistacheio/pistache.git
Comment: Upstream's Debianization. Comment: Upstream's Debianization.
Files: * Files: *
......
usr/include
usr/lib/*/pkgconfig usr/lib/*/pkgconfig
usr/lib/*/cmake
usr/include usr
usr/lib/*/libpistache*.a usr/lib/*/libpistache*.a
usr/lib/*/libpistache*.so usr/lib/*/libpistache*.so
usr/lib/*/libpistache*.so.* usr/lib/*/libpistache*.so.*
...@@ -12,20 +12,21 @@ export DH_OPTIONS=-v ...@@ -12,20 +12,21 @@ export DH_OPTIONS=-v
# Set flags for how the package will be compiled and built. Note separated with # Set flags for how the package will be compiled and built. Note separated with
# white space and not comma, as per DPM § 4.9.1... # white space and not comma, as per DPM § 4.9.1...
# Set various group related security hardening build flags for format, # Set various group related security hardening build flags for format,
# fortify, stackprotector, relro, bindnow, and pie... # fortify, stackprotector, relro, bindnow, and pie...
DH_BUILD_MAINT_OPTIONS = hardening=+all DH_BUILD_MAINT_OPTIONS = hardening=+all
# Skip unit testing... # Skip unit testing...
#DH_BUILD_MAINT_OPTIONS += nocheck #DH_BUILD_MAINT_OPTIONS += nocheck
# The above should be reflected when dpkg-buildflags is called and merged # The above should be reflected when dpkg-buildflags is called and merged
# with the defaults... # with the defaults...
export DH_BUILD_MAINT_OPTIONS export DH_BUILD_MAINT_OPTIONS
export DPKG_EXPORT_BUILDFLAGS = 1
# Standard rules and preset shell variables... # Should be avoided since debhelper 9
include /usr/share/dpkg/default.mk # https://www.debian.org/doc/manuals/debmake-doc/ch05.en.html#variablesrules
# Including only the necessary variables
include /usr/share/dpkg/pkg-info.mk
# Directory containing package since may not be called from current working # Directory containing package since may not be called from current working
# directory. MAKEFILE_LIST pre-defined by Make and appended each time another # directory. MAKEFILE_LIST pre-defined by Make and appended each time another
...@@ -38,63 +39,61 @@ SOURCE_DIR = $(abspath $(PACKAGE_DIR)/../) ...@@ -38,63 +39,61 @@ SOURCE_DIR = $(abspath $(PACKAGE_DIR)/../)
# Main packaging script based on debhelper 7 syntax. The % is an implicit # Main packaging script based on debhelper 7 syntax. The % is an implicit
# pattern rule that acts as a universal target... # pattern rule that acts as a universal target...
%: %:
dh $@ dh $@ --buildsystem=meson
# Configure source... # Configure source...
override_dh_auto_configure: override_dh_auto_configure:
dh_auto_configure -- \ dh_auto_configure -- \
-G "Unix Makefiles" \ -DPISTACHE_BUILD_EXAMPLES=true \
-DCMAKE_BUILD_TYPE=Release \ -DPISTACHE_BUILD_TESTS=true \
-DPISTACHE_BUILD_EXAMPLES=true \ -DPISTACHE_ENABLE_NETWORK_TESTS=false \
-DPISTACHE_BUILD_TESTS=true \ -DPISTACHE_BUILD_DOCS=false \
-DPISTACHE_ENABLE_NETWORK_TESTS=false \ -DPISTACHE_USE_SSL=true \
-DPISTACHE_BUILD_DOCS=false \
-DPISTACHE_USE_SSL=true \
-DCMAKE_INSTALL_PREFIX=/usr \
$(SOURCE_DIR)
# Perform unit testing, but only if not disabled... # It is pointless to customize the tests until we upgrade to debhelper-compat 13,
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) # because debhelper 12 runs ninja test instead of meson test, and --wrap=valgrind
override_dh_auto_test: # is only supported by the latter.
ifeq "$(DEB_BUILD_ARCH)" "armhf" #override_dh_auto_test:
@echo "# Performing unit tests, but skipping memcheck because valgrind broken on this platform..." #ifeq "$(DEB_BUILD_ARCH)" "armhf"
dh_auto_test -- test || { find . -iname "LastTest.log" -exec cat {} \; ; exit 99; } # @echo "# Performing unit tests, but skipping valgrind because it is broken on this platform..."
else # dh_auto_test
@echo "# Performing all unit tests..." #else
dh_auto_test -- test test_memcheck || { find . -iname "LastTest.log" -exec cat {} \; ; exit 99; } # @echo "# Performing all unit tests..."
endif # dh_auto_test -- --wrap=valgrind
endif #endif
# get-orig-source is deprecated since version 4.1.4 of the Debian Policy
# Prepare an upstream vanilla distribution tarball as per DPM § 4.9... # Prepare an upstream vanilla distribution tarball as per DPM § 4.9...
# http://wiki.debian.org/onlyjob/get-orig-source # http://wiki.debian.org/onlyjob/get-orig-source
get-orig-source: $(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM).orig.tar.bz2 $(info I: $(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM)) get-orig-source: $(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM).orig.tar.gz $(info I: $(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM))
@ @
# Prepare an upstream vanilla distribution tarball... # Prepare an upstream vanilla distribution tarball...
$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM).orig.tar.bz2: # meson dist does not include .github in the source tarball (mesonbuild/meson#8541)
# so it is necessary to manually add the folder to the archive
$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM).orig.tar.gz:
@echo "# Preparing source for $(DEB_SOURCE) v$(DEB_VERSION_UPSTREAM)..." @echo "# Preparing source for $(DEB_SOURCE) v$(DEB_VERSION_UPSTREAM)..."
cd $(SOURCE_DIR) \ cd $(SOURCE_DIR) \
&& cd $(PACKAGE_DIR) \ && cd $(PACKAGE_DIR) \
&& mkdir -p $(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM) \ && meson setup $(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM) .. \
&& cd $(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM) \ --buildtype=plain \
&& cmake \ -DPISTACHE_BUILD_EXAMPLES=true \
-G "Unix Makefiles" \ -DPISTACHE_BUILD_TESTS=true \
-DCMAKE_BUILD_TYPE=Release \ -DPISTACHE_ENABLE_NETWORK_TESTS=false \
-DPISTACHE_BUILD_EXAMPLES=true \ -DPISTACHE_BUILD_DOCS=false \
-DPISTACHE_BUILD_TESTS=true \ -DPISTACHE_USE_SSL=true \
-DPISTACHE_ENABLE_NETWORK_TESTS=false \ --prefix=/usr \
-DPISTACHE_BUILD_DOCS=false \ --wrap-mode=nodownload \
-DPISTACHE_USE_SSL=true \ && meson dist -C $(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM) --no-tests --formats=gztar \
-DCMAKE_INSTALL_PREFIX=/usr \ && cd $(PACKAGE_DIR)/$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM) \
$(SOURCE_DIR) \ && mkdir $(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM) \
&& make dist \ && cp -r $(SOURCE_DIR)/.github $(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM) \
&& mv -v $(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM).tar.bz2 $(SOURCE_DIR)/../$@ && gunzip $(PACKAGE_DIR)/$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM)/meson-dist/$(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM).tar.gz \
&& tar --append --file=$(PACKAGE_DIR)/$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM)/meson-dist/$(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM).tar $(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM)/.github \
&& gzip $(PACKAGE_DIR)/$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM)/meson-dist/$(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM).tar \
&& mv $(PACKAGE_DIR)/$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM)/meson-dist/$(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM).tar.gz $(SOURCE_DIR)/../$@
@echo "# Cleaning up..." @echo "# Cleaning up..."
cd $(PACKAGE_DIR)/$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM) \ $(RM) -r $(PACKAGE_DIR)/$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM)
&& make clean
cd $(PACKAGE_DIR) \
&& $(RM) -r $(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM)
# Targets which aren't actual products... # Targets which aren't actual products...
.PHONY: get-orig-source override_dh_auto_configure override_dh_auto_test .PHONY: get-orig-source override_dh_auto_configure# override_dh_auto_test
pistache source: source-is-missing assets/js/jquery.min.js
pistache source: source-is-missing assets/js/modernizr.js line length is 8708 characters (>512)
version=4 version=4
opts=filenamemangle=s/.+\/v?(\d\S+)\.tar\.bz2/pistache-$1\.tar\.bz2/ \ opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/pistache-$1\.tar\.gz/ \
https://github.com/oktal/pistache/tags .*/?(\d+\.\d+.\d+)\.tar\.bz2 https://github.com/pistacheio/pistache/tags .*/v?(\d\S*)\.tar\.gz
OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@/docs/ OUTPUT_DIRECTORY = @CURRENT_BUILD_DIR@/docs/
INPUT = @CMAKE_SOURCE_DIR@/README.md @CMAKE_SOURCE_DIR@/src/ @CMAKE_SOURCE_DIR@/include/ @CMAKE_SOURCE_DIR@/examples/ @CMAKE_SOURCE_DIR@/docs/ INPUT = @SOURCE_DIR@/README.md @SOURCE_DIR@/src/ @SOURCE_DIR@/include/ @SOURCE_DIR@/examples/ @SOURCE_DIR@/docs/
USE_MDFILE_AS_MAINPAGE = @CMAKE_SOURCE_DIR@/README.md USE_MDFILE_AS_MAINPAGE = @SOURCE_DIR@/README.md
EXCLUDE_PATTERNS = */.git/* EXCLUDE_PATTERNS = */.git/*
EXCLUDE_PATTERNS += */subprojects/*
EXCLUDE_PATTERNS += */tests/* EXCLUDE_PATTERNS += */tests/*
EXCLUDE_PATTERNS += */third-party/*
DOXYFILE_ENCODING = UTF-8 DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = @PROJECT_NAME@ PROJECT_NAME = @PROJECT_NAME@
......
doxygen = find_program('doxygen')
dot = find_program('dot')
mscgen = find_program('mscgen', required: false)
configure_file(input: 'Doxyfile.in', output: 'Doxyfile', configuration: {
'CURRENT_BUILD_DIR': meson.current_build_dir(),
'SOURCE_DIR': meson.source_root(),
'PROJECT_NAME': meson.project_name()
})
run_target('docs', command: [doxygen, meson.current_build_dir()/'Doxyfile'])
function(pistache_example example_name)
set(EXAMPLE_EXECUTABLE run_${example_name})
set(EXAMPLE_SOURCE ${example_name}.cc)
add_executable(${EXAMPLE_EXECUTABLE} ${EXAMPLE_SOURCE})
target_link_libraries(${EXAMPLE_EXECUTABLE} pistache_static)
endfunction()
pistache_example(hello_server)
pistache_example(http_server)
pistache_example(http_client)
pistache_example(rest_server)
pistache_example(custom_header)
pistache_example(http_server_shutdown)
set(RAPIDJSON_ROOT_DIR PATH "${PROJECT_SOURCE_DIR}/third-party/rapidjson")
find_package(RapidJSON)
if (RAPIDJSON_FOUND)
include_directories(${RAPIDJSON_INCLUDES})
pistache_example(rest_description)
else()
message(FATAL_ERROR "RapidJSON not found. Could not build rest_description example.")
endif()
pistache_example_files = [
'custom_header',
'hello_server',
'http_client',
'http_server_shutdown',
'http_server',
'rest_server',
'rest_description'
]
foreach example_name : pistache_example_files
executable('run'+example_name, example_name+'.cc', dependencies: pistache_static_dep)
endforeach
subdir('pistache')
configure_file(input: 'version.h.in', output: 'version.h', configuration: version_data_conf, install: get_option('PISTACHE_INSTALL'), install_dir: prefix/get_option('includedir')/'pistache')
install_headers([
'async.h',
'base64.h',
'client.h',
'common.h',
'config.h',
'cookie.h',
'description.h',
'endpoint.h',
'errors.h',
'flags.h',
'http_defs.h',
'http.h',
'http_header.h',
'http_headers.h',
'iterator_adapter.h',
'listener.h',
'log.h',
'mailbox.h',
'mime.h',
'net.h',
'optional.h',
'os.h',
'peer.h',
'prototype.h',
'reactor.h',
'route_bind.h',
'router.h',
'ssl_wrappers.h',
'stream.h',
'string_logger.h',
'string_view.h',
'tcp.h',
'timer_pool.h',
'transport.h',
'type_checkers.h',
'typeid.h',
'utils.h',
'view.h'
], subdir: 'pistache')
install_subdir('thirdparty', install_dir: prefix/get_option('includedir')/'pistache')
...@@ -11,4 +11,3 @@ Requires: ...@@ -11,4 +11,3 @@ Requires:
Libs: -L'${libdir}/' @libs@ Libs: -L'${libdir}/' @libs@
Libs.private: Libs.private:
Cflags: -I'${includedir}/' Cflags: -I'${includedir}/'
project(
'pistache',
'cpp',
version: '0.0.002',
license: 'Apache-2.0',
default_options: [
'cpp_std=c++17',
'buildtype=release',
'b_ndebug=if-release',
'b_lto=false',
'warning_level=3'
],
meson_version: '>=0.50.0'
)
compiler = meson.get_compiler('cpp')
compiler_id = compiler.get_id()
prefix = get_option('prefix')
pc_libs = ['-lpistache', '-pthread']
# Wrapping arguments inside a call to get_supported_arguments so that only supported arguments get applied
# No need for -Wall -Wextra -Wpedantic, since warning_level is 3
add_project_arguments(compiler.get_supported_arguments(['-Wconversion', '-Wno-missing-field-initializers']), language: 'cpp')
# No need for --coverage, since b_coverage is set
if get_option('b_coverage')
add_project_arguments(compiler.get_supported_arguments(['-fstack-protector-all', '--param=ssp-buffer-size=4']), language: 'cpp')
endif
##### BEGIN CheckAtomic.cmake
is_libatomic_needed = false
cxx_atomics_check_code = '''
#include <atomic>
std::atomic<int> x;
int main(){return x;}
'''
has_working_cxx_atomics = compiler.compiles(cxx_atomics_check_code, name: 'std::atomic')
if (compiler_id.contains('clang') or compiler_id.contains('gcc')) and not has_working_cxx_atomics
assert(compiler.has_function('__atomic_fetch_add_4', args: '-latomic'), 'Host compiler appears to require libatomic, but cannot find it.')
has_working_cxx_atomics = compiler.compiles(cxx_atomics_check_code, args: '-latomic', name: 'std::atomic with libatomic')
assert(has_working_cxx_atomics, 'Host compiler must support std::atomic!')
is_libatomic_needed = true
endif
cxx_atomics64_check_code = '''
#include <atomic>
#include <cstdint>
std::atomic<uint64_t> x(0);
int main() {
uint64_t i = x.load(std::memory_order_relaxed);
return 0;
}
'''
has_working_cxx_atomics64 = compiler.compiles(cxx_atomics64_check_code, name: 'std::atomic<uint64_t>')
if not has_working_cxx_atomics64
assert(compiler.has_function('__atomic_load_8', args: '-latomic'), 'Host compiler appears to require libatomic for 64-bit operations, but cannot find it.')
has_working_cxx_atomics = compiler.compiles(cxx_atomics_check_code, args: '-latomic', name: 'std::atomic<uint64_t> with libatomic')
assert(has_working_cxx_atomics, 'Host compiler must support 64-bit std::atomic')
is_libatomic_needed = true
endif
##### END CheckAtomic.cmake
if is_libatomic_needed
pc_libs += '-latomic'
endif
deps_libpistache = [dependency('threads'), dependency('RapidJSON', fallback: ['rapidjson', 'rapidjson_dep'])]
if get_option('PISTACHE_USE_SSL')
deps_libpistache += dependency('openssl')
pc_libs += ['-lssl', '-lcrypto']
endif
version_data_raw = ''
if meson.version().version_compare('>=0.57.0')
fs = import('fs')
version_data_raw = fs.read('version.txt').split('\n')
else
# Ugly workaround for reading a file
version_data_raw = run_command(
find_program('python3'), '-c', 'print(open("version.txt").read())'
).stdout().strip().split('\n')
endif
version_data_conf = configuration_data()
foreach _ : version_data_raw
if _ != ''
__ = _.split(' ')
version_data_conf.set(__[0], __[-1])
endif
endforeach
pistache_version_str = '.'.join([version_data_conf.get_unquoted('VERSION_MAJOR'), version_data_conf.get_unquoted('VERSION_MINOR'), version_data_conf.get_unquoted('VERSION_PATCH')])
pistache_soversion_str = '.'.join([version_data_conf.get_unquoted('SONAME_VERSION_MAJOR'), version_data_conf.get_unquoted('SONAME_VERSION_MINOR')])
configure_file(input: 'libpistache.pc.in', output: 'libpistache.pc', install: get_option('PISTACHE_INSTALL'), install_dir: get_option('libdir')/'pkgconfig', configuration: {
'prefix': prefix,
'exec_prefix': prefix/get_option('bindir'),
'libdir': prefix/get_option('libdir'),
'libs': ' '.join(pc_libs),
'includedir': prefix/get_option('includedir'),
'version': pistache_version_str+'-git'+version_data_conf.get_unquoted('VERSION_GIT_DATE')
})
incl_pistache = include_directories('include')
subdir('include')
subdir('src')
if get_option('PISTACHE_BUILD_TESTS')
subdir('tests')
endif
if get_option('PISTACHE_BUILD_EXAMPLES')
subdir('examples')
endif
if get_option('PISTACHE_BUILD_DOCS')
subdir('docs')
endif
option('PISTACHE_BUILD_TESTS', type: 'boolean', value: false, description: 'build tests alongside the project')
option('PISTACHE_ENABLE_NETWORK_TESTS', type: 'boolean', value: true, description: 'if tests are built, run ones needing network access')
option('PISTACHE_BUILD_EXAMPLES', type: 'boolean', value: false, description: 'build examples alongside the project')
option('PISTACHE_BUILD_DOCS', type: 'boolean', value: false, description: 'build docs alongside the project')
option('PISTACHE_INSTALL', type: 'boolean', value: true, description: 'add pistache as install target (recommended)')
option('PISTACHE_USE_SSL', type: 'boolean', value: false, description: 'add support for SSL server')
...@@ -24,12 +24,10 @@ sudo apt install libpistache-dev ...@@ -24,12 +24,10 @@ sudo apt install libpistache-dev
Otherwise, here's how to build and install the latest release: Otherwise, here's how to build and install the latest release:
```shell ```shell
git clone --recurse-submodules https://github.com/pistacheio/pistache.git git clone https://github.com/pistacheio/pistache.git
cd pistache cd pistache
mkdir build && cd build meson setup build
cmake -DCMAKE_BUILD_TYPE=Release .. meson install -C build
make
sudo make install
``` ```
Also, Pistache does not support Windows yet, but should work fine under [WSL](https://docs.microsoft.com/windows/wsl/about). Also, Pistache does not support Windows yet, but should work fine under [WSL](https://docs.microsoft.com/windows/wsl/about).
......
...@@ -18,14 +18,32 @@ add_definitions(-DONLY_C_LOCALE=1) ...@@ -18,14 +18,32 @@ add_definitions(-DONLY_C_LOCALE=1)
set(PISTACHE_INCLUDE set(PISTACHE_INCLUDE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
find_package(RapidJSON QUIET)
if (NOT RapidJSON_FOUND)
message("RapidJSON not found. Consider installing it on your system. Downloading it from source...")
include(FetchContent)
FetchContent_Declare(
RapidJSON
GIT_REPOSITORY https://github.com/Tencent/rapidjson.git
GIT_TAG v1.1.0
GIT_SHALLOW true
) )
set(RAPIDJSON_BUILD_DOC OFF CACHE BOOL "")
set(RAPIDJSON_BUILD_EXAMPLES OFF CACHE BOOL "")
set(RAPIDJSON_BUILD_TESTS OFF CACHE BOOL "")
if(NOT RapidJSON_POPULATED)
FetchContent_Populate(RapidJSON)
add_subdirectory(${rapidjson_SOURCE_DIR} ${rapidjson_BINARY_DIR})
endif()
target_include_directories(pistache PRIVATE ${rapidjson_SOURCE_DIR}/include)
else()
target_include_directories(pistache PRIVATE ${RAPIDJSON_INCLUDE_DIRS})
endif()
target_include_directories(pistache PUBLIC ${PISTACHE_INCLUDE}) target_include_directories(pistache PUBLIC ${PISTACHE_INCLUDE})
set(include_install_dir ${CMAKE_INSTALL_INCLUDEDIR})
set(lib_install_dir ${CMAKE_INSTALL_LIBDIR})
set(bin_install_dir ${CMAKE_INSTALL_BINDIR})
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
add_library(pistache_shared SHARED $<TARGET_OBJECTS:pistache>) add_library(pistache_shared SHARED $<TARGET_OBJECTS:pistache>)
target_link_libraries(pistache_shared PRIVATE Threads::Threads ${CMAKE_REQUIRED_LIBRARIES}) target_link_libraries(pistache_shared PRIVATE Threads::Threads ${CMAKE_REQUIRED_LIBRARIES})
...@@ -51,7 +69,7 @@ endif () ...@@ -51,7 +69,7 @@ endif ()
set(Pistache_OUTPUT_NAME "pistache") set(Pistache_OUTPUT_NAME "pistache")
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
set_target_properties(pistache_shared PROPERTIES set_target_properties(pistache_shared PROPERTIES
OUTPUT_NAME ${Pistache_OUTPUT_NAME}-${version} OUTPUT_NAME ${Pistache_OUTPUT_NAME}-${VERSION}
SOVERSION ${SONAME_VERSION_MAJOR}.${SONAME_VERSION_MINOR} SOVERSION ${SONAME_VERSION_MAJOR}.${SONAME_VERSION_MINOR}
) )
endif () endif ()
...@@ -59,50 +77,3 @@ endif () ...@@ -59,50 +77,3 @@ endif ()
set_target_properties(pistache_static PROPERTIES set_target_properties(pistache_static PROPERTIES
OUTPUT_NAME ${Pistache_OUTPUT_NAME} OUTPUT_NAME ${Pistache_OUTPUT_NAME}
) )
if (PISTACHE_INSTALL)
set(Pistache_CMAKE_INSTALL_PATH "${CMAKE_INSTALL_LIBDIR}/cmake/pistache")
set(Pistache_CONFIG_FILE "PistacheConfig.cmake")
set(Pistache_CONFIG_VERSION_FILE "PistacheConfigVersion.cmake")
if (BUILD_SHARED_LIBS)
install(
TARGETS pistache_shared
EXPORT PistacheTargets
ARCHIVE DESTINATION ${lib_install_dir}
LIBRARY DESTINATION ${lib_install_dir}
RUNTIME DESTINATION ${bin_install_dir}
INCLUDES DESTINATION ${include_install_dir})
endif ()
install(
DIRECTORY "${PROJECT_SOURCE_DIR}/include/pistache"
DESTINATION ${include_install_dir}
FILES_MATCHING PATTERN "*.*h")
install(TARGETS pistache_static
EXPORT PistacheTargets
DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(EXPORT PistacheTargets
DESTINATION ${Pistache_CMAKE_INSTALL_PATH}
EXPORT_LINK_INTERFACE_LIBRARIES
COMPONENT cmake-config
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${Pistache_CONFIG_FILE}.in"
"${CMAKE_CURRENT_BINARY_DIR}/${Pistache_CONFIG_FILE}"
INSTALL_DESTINATION ${Pistache_CMAKE_INSTALL_PATH}
PATH_VARS include_install_dir lib_install_dir
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${Pistache_CONFIG_VERSION_FILE}"
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
COMPATIBILITY AnyNewerVersion)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/${Pistache_CONFIG_FILE}"
"${CMAKE_CURRENT_BINARY_DIR}/${Pistache_CONFIG_VERSION_FILE}"
DESTINATION ${Pistache_CMAKE_INSTALL_PATH}
COMPONENT cmake-config
)
endif()
@PACKAGE_INIT@
set_and_check ( Pistache_INCLUDE_DIRS "@PACKAGE_include_install_dir@")
set_and_check ( Pistache_LIBRARIES "@PACKAGE_lib_install_dir@")
#Required for the static library
find_package(Threads REQUIRED)
if (@PISTACHE_USE_SSL@)
find_package(OpenSSL REQUIRED COMPONENTS SSL Crypto)
endif ()
include("${CMAKE_CURRENT_LIST_DIR}/PistacheTargets.cmake")
...@@ -32,7 +32,7 @@ bool parse_RFC_1123(const std::string &s, time_point &tp) { ...@@ -32,7 +32,7 @@ bool parse_RFC_1123(const std::string &s, time_point &tp) {
bool parse_RFC_850(const std::string &s, time_point &tp) { bool parse_RFC_850(const std::string &s, time_point &tp) {
std::istringstream in{s}; std::istringstream in{s};
in >> date::parse("%a, %d-%b-%y %T %Z", tp); in >> date::parse("%A, %d-%b-%y %T %Z", tp);
return !in.fail(); return !in.fail();
} }
......
...@@ -246,7 +246,7 @@ void Transport::asyncWriteImpl(Fd fd) { ...@@ -246,7 +246,7 @@ void Transport::asyncWriteImpl(Fd fd) {
} }
// EBADF can happen when the HTTP parser, in the case of // EBADF can happen when the HTTP parser, in the case of
// an error, closes fd before the entire request is processed. // an error, closes fd before the entire request is processed.
// https://github.com/oktal/pistache/issues/501 // https://github.com/pistacheio/pistache/issues/501
else if (errno == EBADF || errno == EPIPE || errno == ECONNRESET) { else if (errno == EBADF || errno == EPIPE || errno == ECONNRESET) {
wq.pop_front(); wq.pop_front();
toWrite.erase(fd); toWrite.erase(fd);
......
pistache_common_src = [
'common'/'base64.cc',
'common'/'cookie.cc',
'common'/'description.cc',
'common'/'http.cc',
'common'/'http_defs.cc',
'common'/'http_header.cc',
'common'/'http_headers.cc',
'common'/'mime.cc',
'common'/'net.cc',
'common'/'os.cc',
'common'/'peer.cc',
'common'/'reactor.cc',
'common'/'stream.cc',
'common'/'string_logger.cc',
'common'/'tcp.cc',
'common'/'timer_pool.cc',
'common'/'transport.cc',
'common'/'utils.cc'
]
pistache_server_src = [
'server'/'endpoint.cc',
'server'/'listener.cc',
'server'/'router.cc'
]
pistache_client_src = [
'client'/'client.cc'
]
if get_option('PISTACHE_USE_SSL')
add_project_arguments('-DPISTACHE_USE_SSL', language: 'cpp')
endif
libpistache_static = static_library(
'pistache', pistache_common_src+pistache_server_src+pistache_client_src,
include_directories: incl_pistache,
dependencies: deps_libpistache,
install: get_option('PISTACHE_INSTALL'),
pic: get_option('b_staticpic')
)
libpistache_shared = shared_library(
'pistache', pistache_common_src+pistache_server_src+pistache_client_src,
version: pistache_version_str,
soversion: pistache_soversion_str,
include_directories: incl_pistache,
dependencies: deps_libpistache,
install: get_option('PISTACHE_INSTALL')
)
pistache_static_dep = declare_dependency(link_with: libpistache_static, include_directories: incl_pistache)
pistache_shared_dep = declare_dependency(link_with: libpistache_shared, include_directories: incl_pistache)
if meson.version().version_compare('>=0.54.0')
if get_option('default_library') == 'static'
meson.override_dependency('pistache', pistache_static_dep)
else
meson.override_dependency('pistache', pistache_shared_dep)
endif
endif
[wrap-file]
directory = googletest-release-1.10.0
source_url = https://github.com/google/googletest/archive/release-1.10.0.zip
source_filename = gtest-1.10.0.zip
source_hash = 94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91
patch_url = https://wrapdb.mesonbuild.com/v1/projects/gtest/1.10.0/1/get_zip
patch_filename = gtest-1.10.0-1-wrap.zip
patch_hash = 04ff14e8880e4e465f6260221e9dfd56fea6bc7cce4c4aff0dc528e4a2c8f514
[wrap-file]
directory = rapidjson-1.1.0
source_url = https://github.com/Tencent/rapidjson/archive/v1.1.0.zip
source_filename = rapidjson-1.1.0.zip
source_hash = 8e00c38829d6785a2dfb951bb87c6974fa07dfe488aa5b25deec4b8bc0f6a3ab
patch_url = https://wrapdb.mesonbuild.com/v1/projects/rapidjson/1.1.0/1/get_zip
patch_filename = rapidjson-1.1.0-1-wrap.zip
patch_hash = 7e651680dc74da51b4d0ca4bd3de5d1cf2143dd6d81421b97a43d67536a84486
...@@ -54,4 +54,3 @@ if (PISTACHE_USE_SSL) ...@@ -54,4 +54,3 @@ if (PISTACHE_USE_SSL)
pistache_test(https_server_test) pistache_test(https_server_test)
endif (PISTACHE_USE_SSL) endif (PISTACHE_USE_SSL)
configure_file(input: 'server.crt', output: 'server.crt', copy: true)
configure_file(input: 'server.key', output: 'server.key', copy: true)
configure_file(input: 'client.key', output: 'client.key', copy: true)
configure_file(input: 'client.crt', output: 'client.crt', copy: true)
configure_file(input: 'rootCA.crt', output: 'rootCA.crt', copy: true)
configure_file(input: 'server_from_intermediate_with_chain.crt', output: 'server_from_intermediate_with_chain.crt', copy: true)
configure_file(input: 'server_from_intermediate.crt', output: 'server_from_intermediate.crt', copy: true)
configure_file(input: 'server_from_intermediate.key', output: 'server_from_intermediate.key', copy: true)
configure_file(input: 'intermediateCA.crt', output: 'intermediateCA.crt', copy: true)
curl_dep = dependency('libcurl')
gtest_main_dep = dependency('gtest', main: true, fallback: ['gtest', 'gtest_main_dep'])
pistache_test_files = [
'mime_test',
'headers_test',
'async_test',
'typeid_test',
'router_test',
'cookie_test',
'cookie_test_2',
'cookie_test_3',
'view_test',
'http_parsing_test',
'http_uri_test',
'http_server_test',
'http_client_test',
'listener_test',
'request_size_test',
'streaming_test',
'rest_server_test',
'string_view_test',
'mailbox_test',
'stream_test',
'reactor_test',
'threadname_test',
'optional_test',
'log_api_test',
'string_logger_test'
]
if get_option('PISTACHE_ENABLE_NETWORK_TESTS')
pistache_test_files += 'net_test'
endif
if get_option('PISTACHE_USE_SSL')
pistache_test_files += 'https_server_test'
subdir('certs')
endif
foreach test_name : pistache_test_files
test(
test_name,
executable(
'run_'+test_name,
test_name+'.cc',
dependencies: [
pistache_shared_dep,
gtest_main_dep,
curl_dep
]
),
timeout: 60,
workdir: meson.current_build_dir(),
is_parallel: false
)
endforeach
cppcheck = find_program('cppcheck', required: false)
if cppcheck.found()
cppcheck_args = [
'--project=' + (meson.build_root()/'compile_commands.json'),
'--enable=all',
'-DCPPCHECK',
'--suppress=*:*tests/*',
'--suppress=*:*subprojects/*',
'--suppress=noExplicitConstructor:include/pistache/optional.h',
'--std=' + get_option('cpp_std')
]
run_target(
'cppcheck',
command: [
cppcheck,
cppcheck_args
]
)
else
warning('Can\'t find Cppcheck')
endif
Subproject commit c99458533a9b4c743ed51537e25989ea55944908
Subproject commit f54b0e47a08782a6131cc3d60f94d038fa6e0a51
...@@ -5,4 +5,3 @@ VERSION_GIT_DATE 20210107 ...@@ -5,4 +5,3 @@ VERSION_GIT_DATE 20210107
SONAME_VERSION_MAJOR 0 SONAME_VERSION_MAJOR 0
SONAME_VERSION_MINOR 0 SONAME_VERSION_MINOR 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment