Skip to content

Commit

Permalink
Include pistache recipe in branch stable/v8 (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
szmyd authored Dec 13, 2024
1 parent 1ba0fa7 commit 74308d4
Show file tree
Hide file tree
Showing 14 changed files with 409 additions and 9 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/build_dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ jobs:
runs-on: ${{ inputs.platform }}
steps:
- name: Retrieve Code
uses: actions/checkout@v3
uses: actions/checkout@main
with:
ref: ${{ inputs.branch }}
if: ${{ inputs.testing == 'True' }}

- name: Retrieve Recipe
uses: actions/checkout@v3
uses: actions/checkout@main
with:
repository: eBay/IOManager
ref: ${{ inputs.branch }}
Expand All @@ -92,7 +92,7 @@ jobs:
key_prefix: IOMgrDeps8-${{ inputs.platform }}-${{ inputs.build-type }}-${{ inputs.malloc-impl }}-${{ inputs.prerelease }}

- name: Retrieve Dependencies
uses: actions/checkout@v3
uses: actions/checkout@main
with:
repository: eBay/sisl
path: import/sisl
Expand All @@ -116,13 +116,8 @@ jobs:

- name: Export Recipes
run: |
sudo apt-get install -y python3-pyelftools libaio-dev
python -m pip install pyelftools
./prepare.sh
conan export import/sisl
conan export 3rd_party/dpdk dpdk/nbi.21.05@
conan export 3rd_party/fio fio/nbi.3.28@
conan export 3rd_party/grpc_internal
conan export 3rd_party/spdk spdk/nbi.21.07.y@
cached_pkgs=$(ls -1d ~/.conan/data/*/*/*/*/package | sed 's,.*data/,,' | cut -d'/' -f1,2 | paste -sd',' - -)
echo "::info:: Pre-cached: ${cached_pkgs}"
if: ${{ inputs.testing == 'True' || steps.restore-cache.outputs.cache-hit != 'true' }}
Expand Down
38 changes: 38 additions & 0 deletions 3rd_party/pistache/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
sources:
"nbi.0.0.5.1":
url: "https://github.com/pistacheio/pistache/archive/refs/tags/0.0.5.tar.gz"
sha256: "e2da87ebc01367e33bd8d7800cb2bf5c23e9fb4e6f49dce2cab5f8756df8dca0"
"0.0.5":
url: "https://github.com/pistacheio/pistache/archive/refs/tags/0.0.5.tar.gz"
sha256: "e2da87ebc01367e33bd8d7800cb2bf5c23e9fb4e6f49dce2cab5f8756df8dca0"
"cci.20240107":
url: "https://github.com/pistacheio/pistache/archive/1c733a145b01a4737cf5c7dd3709bd85be404886.tar.gz"
sha256: "156d2a4503be3d6c0726009c83e6d2e6e2e6378e6136436fc2d82d13597b6b0b"
"cci.20201127":
url: "https://github.com/pistacheio/pistache/archive/a3c5c68e0f08e19331d53d12846079ad761fe974.tar.gz"
sha256: "f1abb9e43ff847ebff8edb72623c9942162df134bccfb571af9c7817d3261fae"
patches:
"nbi.0.0.5.1":
- patch_file: "patches/0.0.5-0001-include-cstdint.patch"
patch_description: "include <stddef>"
patch_type: "portability"
patch_source: "https://github.com/pistacheio/pistache/pull/1142"
- patch_file: "patches/0.0.5-0002-disable-older-tls.patch"
patch_description: "disable tls1 and tls1.1"
"0.0.5":
- patch_file: "patches/0.0.5-0001-include-cstdint.patch"
patch_description: "include <stddef>"
patch_type: "portability"
patch_source: "https://github.com/pistacheio/pistache/pull/1142"
"cci.20201127":
- patch_file: "patches/cci.20201127-0001-remove-fpic.patch"
patch_description: "disable fPIC"
patch_type: "conan"
- patch_file: "patches/cci.20201127-0002-include-stddef.patch"
patch_description: "include <stddef>"
patch_type: "portability"
patch_source: "https://github.com/pistacheio/pistache/pull/965"
- patch_file: "patches/cci.20201127-0003-include-cstdint.patch"
patch_description: "include <stddef>"
patch_type: "portability"
patch_source: "https://github.com/pistacheio/pistache/pull/1142"
179 changes: 179 additions & 0 deletions 3rd_party/pistache/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir, replace_in_file, collect_libs
from conan.tools.build import check_min_cppstd
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.scm import Version
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.meson import Meson, MesonToolchain
from conan.tools.layout import basic_layout
from conan.tools.gnu import PkgConfigDeps

import os

required_conan_version = ">=1.53.0"

class PistacheConan(ConanFile):
name = "pistache"
description = "Pistache is a modern and elegant HTTP and REST framework for C++"
license = "Apache-2.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/pistacheio/pistache"
topics = ("http", "rest", "framework", "networking")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_ssl": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_ssl": False,
}

@property
def _min_cppstd(self):
return 17

@property
def _compilers_minimum_version(self):
return {
"gcc": "7",
"clang": "6",
}

def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def layout(self):
if self.version == "cci.20201127":
cmake_layout(self, src_folder="src")
else:
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("rapidjson/cci.20230929")
if self.options.with_ssl:
self.requires("openssl/[>=1.1 <4]")
if self.version != "cci.20201127":
self.requires("date/3.0.1")

def validate(self):
if self.settings.os != "Linux":
raise ConanInvalidConfiguration(f"{self.ref} is only support on Linux.")

if self.settings.compiler == "clang" and self.version in ["cci.20201127", "0.0.5"]:
raise ConanInvalidConfiguration(f"{self.ref}'s clang support is broken. See pistacheio/pistache#835.")

if self.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)

def build_requirements(self):
if self.version != "cci.20201127":
self.tool_requires("meson/1.3.1")
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/2.1.0")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
if self.version == "cci.20201127":
tc = CMakeToolchain(self)
tc.variables["PISTACHE_ENABLE_NETWORK_TESTS"] = False
tc.variables["PISTACHE_USE_SSL"] = self.options.with_ssl
# pistache requires explicit value for fPIC
tc.variables["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True)
tc.generate()

tc = CMakeDeps(self)
tc.generate()
else:
tc = MesonToolchain(self)
tc.project_options["PISTACHE_USE_SSL"] = self.options.with_ssl
tc.project_options["PISTACHE_BUILD_EXAMPLES"] = False
tc.project_options["PISTACHE_BUILD_TESTS"] = False
tc.project_options["PISTACHE_BUILD_DOCS"] = False
tc.generate()

tc = PkgConfigDeps(self)
tc.generate()

env = VirtualBuildEnv(self)
env.generate(scope="build")

def build(self):
apply_conandata_patches(self)
if self.version != "cci.20201127":
replace_in_file(self, os.path.join(self.source_folder, "meson.build"),
"dependency('RapidJSON', fallback: ['rapidjson', 'rapidjson_dep'])",
"dependency('rapidjson', fallback: ['rapidjson', 'rapidjson_dep'])")

if self.version == "cci.20201127":
cmake = CMake(self)
cmake.configure()
cmake.build()
else:
meson = Meson(self)
meson.configure()
meson.build()

def package(self):
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
if self.version == "cci.20201127":
cmake = CMake(self)
cmake.install()
else:
meson = Meson(self)
meson.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
if self.options.shared:
rm(self, "*.a", os.path.join(self.package_folder, "lib"))
fix_apple_shared_install_name(self)

def package_info(self):
# TODO: Pistache does not use namespace
# TODO: Pistache variables are CamelCase e.g Pistache_BUILD_DIRS
self.cpp_info.set_property("cmake_file_name", "Pistache")
self.cpp_info.set_property("cmake_target_name", "Pistache::Pistache")
# if package provides a pkgconfig file (package.pc, usually installed in <prefix>/lib/pkgconfig/)
self.cpp_info.set_property("pkg_config_name", "libpistache")

self.cpp_info.components["libpistache"].libs = collect_libs(self)
self.cpp_info.components["libpistache"].requires = ["rapidjson::rapidjson"]
if self.version != "cci.20201127":
self.cpp_info.components["libpistache"].requires.append("date::date")
if self.options.with_ssl:
self.cpp_info.components["libpistache"].requires.append("openssl::openssl")
self.cpp_info.components["libpistache"].defines = ["PISTACHE_USE_SSL=1"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["libpistache"].system_libs = ["pthread"]
if self.version != "cci.20201127":
self.cpp_info.components["libpistache"].system_libs.append("m")

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.filenames["cmake_find_package"] = "Pistache"
self.cpp_info.filenames["cmake_find_package_multi"] = "Pistache"
self.cpp_info.names["cmake_find_package"] = "Pistache"
self.cpp_info.names["cmake_find_package_multi"] = "Pistache"
self.cpp_info.names["pkg_config"] = "libpistache"
suffix = "_{}".format("shared" if self.options.shared else "static")
self.cpp_info.components["libpistache"].names["cmake_find_package"] = "pistache" + suffix
self.cpp_info.components["libpistache"].names["cmake_find_package_multi"] = "pistache" + suffix
13 changes: 13 additions & 0 deletions 3rd_party/pistache/patches/0.0.5-0001-include-cstdint.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/include/pistache/flags.h b/include/pistache/flags.h
index 9be2b32..ed37150 100644
--- a/include/pistache/flags.h
+++ b/include/pistache/flags.h
@@ -11,7 +11,7 @@
*/

#pragma once
-
+#include <cstdint>
#include <climits>
#include <iostream>
#include <type_traits>
28 changes: 28 additions & 0 deletions 3rd_party/pistache/patches/0.0.5-0002-disable-older-tls.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff -Naur a/src/server/listener.cc b/src/server/listener.cc
--- a/src/server/listener.cc 2022-09-02 13:59:00.000000000 -0700
+++ b/src/server/listener.cc 2024-10-10 11:00:05.512069049 -0700
@@ -105,6 +105,24 @@
throw std::runtime_error(err);
}
}
+ if (!SSL_CTX_set_options(GetSSLContext(ctx), SSL_OP_NO_SSLv3))
+ {
+ std::string err = "SSL error - cannot disable SSLv3: "
+ + ssl_print_errors_to_string();
+ throw std::runtime_error(err);
+ }
+ if (!SSL_CTX_set_options(GetSSLContext(ctx), SSL_OP_NO_TLSv1))
+ {
+ std::string err = "SSL error - cannot disable TLSv1.0: "
+ + ssl_print_errors_to_string();
+ throw std::runtime_error(err);
+ }
+ if (!SSL_CTX_set_options(GetSSLContext(ctx), SSL_OP_NO_TLSv1_1))
+ {
+ std::string err = "SSL error - cannot disable TLSv1.1: "
+ + ssl_print_errors_to_string();
+ throw std::runtime_error(err);
+ }

if (cb != NULL)
{
12 changes: 12 additions & 0 deletions 3rd_party/pistache/patches/cci.20201127-0001-remove-fpic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9cdac6b..b2d13b4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -12,7 +12,6 @@ set(SOURCE_FILES
)

add_library(pistache OBJECT ${SOURCE_FILES})
-set_target_properties(pistache PROPERTIES POSITION_INDEPENDENT_CODE 1)
add_definitions(-DONLY_C_LOCALE=1)

set(PISTACHE_INCLUDE
12 changes: 12 additions & 0 deletions 3rd_party/pistache/patches/cci.20201127-0002-include-stddef.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fixed upstream https://github.com/pistacheio/pistache/pull/965

--- a/include/pistache/typeid.h
+++ b/include/pistache/typeid.h
@@ -11,6 +11,7 @@

#pragma once

+#include <cstddef>
#include <functional>

namespace Pistache {
13 changes: 13 additions & 0 deletions 3rd_party/pistache/patches/cci.20201127-0003-include-cstdint.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/include/pistache/flags.h b/include/pistache/flags.h
index 2538773..fcd0252 100644
--- a/include/pistache/flags.h
+++ b/include/pistache/flags.h
@@ -5,7 +5,7 @@
*/

#pragma once
-
+#include <cstdint>
#include <climits>
#include <iostream>
#include <type_traits>
12 changes: 12 additions & 0 deletions 3rd_party/pistache/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

find_package(Pistache REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE Pistache::Pistache)
if(Pistache_VERSION EQUAL "cci.20201127")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
else()
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
endif()
25 changes: 25 additions & 0 deletions 3rd_party/pistache/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os

class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
Loading

0 comments on commit 74308d4

Please sign in to comment.