From fe83e5e2ade13612b8188fdd81ed370031873e24 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Tue, 1 Oct 2019 18:56:22 +0200 Subject: [PATCH 1/6] add nghttp2 --- recipes/nghttp2/all/CMakeLists.txt | 7 + recipes/nghttp2/all/conandata.yml | 4 + recipes/nghttp2/all/conanfile.py | 152 ++++++++++++++++++ .../nghttp2/all/test_package/CMakeLists.txt | 11 ++ recipes/nghttp2/all/test_package/conanfile.py | 19 +++ .../nghttp2/all/test_package/test_package.cpp | 21 +++ recipes/nghttp2/config.yml | 3 + 7 files changed, 217 insertions(+) create mode 100644 recipes/nghttp2/all/CMakeLists.txt create mode 100644 recipes/nghttp2/all/conandata.yml create mode 100644 recipes/nghttp2/all/conanfile.py create mode 100644 recipes/nghttp2/all/test_package/CMakeLists.txt create mode 100644 recipes/nghttp2/all/test_package/conanfile.py create mode 100644 recipes/nghttp2/all/test_package/test_package.cpp create mode 100644 recipes/nghttp2/config.yml diff --git a/recipes/nghttp2/all/CMakeLists.txt b/recipes/nghttp2/all/CMakeLists.txt new file mode 100644 index 0000000000000..a96e179310685 --- /dev/null +++ b/recipes/nghttp2/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.12) +project(cmake_wrapper) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/nghttp2/all/conandata.yml b/recipes/nghttp2/all/conandata.yml new file mode 100644 index 0000000000000..4a8e1ee47f8b8 --- /dev/null +++ b/recipes/nghttp2/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.39.2": + sha256: 92a23e4522328c8565028ee0c7270e74add7990614fd1148f2a79d873bc2a1d0 + url: https://github.com/nghttp2/nghttp2/releases/download/v1.39.2/nghttp2-1.39.2.tar.bz2 diff --git a/recipes/nghttp2/all/conanfile.py b/recipes/nghttp2/all/conanfile.py new file mode 100644 index 0000000000000..23a0558fb5624 --- /dev/null +++ b/recipes/nghttp2/all/conanfile.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +from conans import ConanFile, CMake, AutoToolsBuildEnvironment, tools +from conans.errors import ConanInvalidConfiguration + + +class Nghttp2Conan(ConanFile): + name = "nghttp2" + + description = "HTTP/2 C Library and tools" + topics = ("conan", "http") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://nghttp2.org" + license = "MIT" + exports_sources = ["CMakeLists.txt"] + generators = "cmake", "pkg_config" + + settings = "os", "arch", "compiler", "build_type" + options = {"shared": [True, False], + "fPIC": [True, False], + "with_app": [True, False], + "with_hpack": [True, False], + "with_asio": [True, False]} + default_options = {"shared": False, + "fPIC": True, + "with_app": True, + "with_hpack": True, + "with_asio": False} + + _source_subfolder = "source_subfolder" + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + if self.options.with_asio and self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("Build with asio and MSVC is not supported yet, see upstream bug #589") + + def requirements(self): + self.requires.add("zlib/1.2.11") + if self.options.with_app: + self.requires.add("openssl/1.0.2t") + self.requires.add("c-ares/1.15.0") + self.requires.add("libev/4.25") + self.requires.add("libxml2/2.9.9") + if self.options.with_hpack: + self.requires.add("jansson/2.12") + if self.options.with_asio: + self.requires.add("boost/1.70.0") + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_folder = "nghttp2-{0}".format(self.version) + os.rename(extracted_folder, self._source_subfolder) + + def _configure_cmake(self): + cmake = CMake(self) + + cmake.definitions["ENABLE_SHARED_LIB"] = "ON" if self.options.shared else "OFF" + cmake.definitions["ENABLE_STATIC_LIB"] = "OFF" if self.options.shared else "ON" + cmake.definitions["ENABLE_HPACK_TOOLS"] = "ON" if self.options.with_hpack else "OFF" + cmake.definitions["ENABLE_APP"] = "ON" if self.options.with_app else "OFF" + cmake.definitions["ENABLE_EXAMPLES"] = "OFF" + cmake.definitions["ENABLE_PYTHON_BINDINGS"] = "OFF" + cmake.definitions["ENABLE_FAILMALLOC"] = "OFF" + # disable unneeded auto-picked dependencies + cmake.definitions["WITH_LIBXML2"] = "OFF" + cmake.definitions["WITH_JEMALLOC"] = "OFF" + cmake.definitions["WITH_SPDYLAY"] = "OFF" + + cmake.definitions["ENABLE_ASIO_LIB"] = "ON" if self.options.with_asio else "OFF" + + if self.options.with_app: + cmake.definitions['OPENSSL_ROOT_DIR'] = self.deps_cpp_info['openssl'].rootpath + if self.options.with_asio: + cmake.definitions['BOOST_ROOT'] = self.deps_cpp_info['boost'].rootpath + cmake.definitions['ZLIB_ROOT'] = self.deps_cpp_info['zlib'].rootpath + + cmake.configure() + return cmake + + def _build_with_autotools(self): + if self.options.with_app: + os.rename('c-ares.pc', 'libcares.pc') + os.rename('OpenSSL.pc', 'openssl.pc') + + prefix = os.path.abspath(self.package_folder) + with tools.chdir(self._source_subfolder): + env_build = AutoToolsBuildEnvironment(self) + if self.settings.os == 'Windows': + prefix = tools.unix_path(prefix) + args = ['--prefix=%s' % prefix] + if self.options.shared: + args.extend(['--disable-static', '--enable-shared']) + else: + args.extend(['--disable-shared', '--enable-static']) + if self.options.with_hpack: + args.append('--enable-hpack-tools') + else: + args.append('--disable-hpack-tools') + + if self.options.with_app: + args.append('--enable-app') + else: + args.append('--disable-app') + + args.append('--disable-examples') + args.append('--disable-python-bindings') + # disable unneeded auto-picked dependencies + args.append('--without-jemalloc') + args.append('--without-systemd') + args.append('--without-libxml2') + + if self.options.with_asio: + args.append('--enable-asio-lib') + args.append('--with-boost=' + self.deps_cpp_info['boost'].rootpath) + else: + args.append('--without-boost') + + env_build.configure(args=args) + env_build.make() + env_build.make(args=['install']) + + def build(self): + if self.settings.compiler == "Visual Studio": + cmake = self._configure_cmake() + cmake.build() + else: + self._build_with_autotools() + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + if self.settings.compiler == "Visual Studio": + cmake = self._configure_cmake() + cmake.install() + cmake.patch_config_paths() + + # remove unneeded directories + tools.rmdir(os.path.join(self.package_folder, 'share')) + tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig')) + + for la_name in ('libnghttp2.la', 'libnghttp2_asio.la'): + la_file = os.path.join(self.package_folder, "lib", la_name) + if os.path.isfile(la_file): + os.unlink(la_file) + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) + if self.settings.compiler == 'Visual Studio': + if not self.options.shared: + self.cpp_info.defines.append('NGHTTP2_STATICLIB') diff --git a/recipes/nghttp2/all/test_package/CMakeLists.txt b/recipes/nghttp2/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..79e218a67e025 --- /dev/null +++ b/recipes/nghttp2/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 2.8.12) +project(test_package) + +set(CMAKE_VERBOSE_MAKEFILE TRUE) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) diff --git a/recipes/nghttp2/all/test_package/conanfile.py b/recipes/nghttp2/all/test_package/conanfile.py new file mode 100644 index 0000000000000..47369049f8bc8 --- /dev/null +++ b/recipes/nghttp2/all/test_package/conanfile.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/nghttp2/all/test_package/test_package.cpp b/recipes/nghttp2/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..78eefc27ef9d6 --- /dev/null +++ b/recipes/nghttp2/all/test_package/test_package.cpp @@ -0,0 +1,21 @@ +#include + +#if defined(_MSC_VER) +// nghttp2 defaults to int +typedef int ssize_t; +#endif +#include +#include + +int main() +{ + nghttp2_info* info = nghttp2_version(NGHTTP2_VERSION_NUM); + if (info) { + printf("nghttp2 ver=%d version=%s\n", info->version_num, info->version_str); + } else { + printf("nghttp2: cannot get version\n"); + } + return 0; +} + +// vim: et ts=4 sw=4 diff --git a/recipes/nghttp2/config.yml b/recipes/nghttp2/config.yml new file mode 100644 index 0000000000000..9aee41ee3366e --- /dev/null +++ b/recipes/nghttp2/config.yml @@ -0,0 +1,3 @@ +versions: + "1.39.2": + folder: all From 0481727ddc937d991265c44d578cd7eeafdf1179 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Wed, 2 Oct 2019 00:18:46 +0200 Subject: [PATCH 2/6] name needs 'lib' prefix --- recipes/nghttp2/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/nghttp2/all/conanfile.py b/recipes/nghttp2/all/conanfile.py index 23a0558fb5624..808cb661ef427 100644 --- a/recipes/nghttp2/all/conanfile.py +++ b/recipes/nghttp2/all/conanfile.py @@ -7,7 +7,7 @@ class Nghttp2Conan(ConanFile): - name = "nghttp2" + name = "libnghttp2" description = "HTTP/2 C Library and tools" topics = ("conan", "http") From b5e1d1609ebd7cfbc75d243f4077a33aef018f83 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Wed, 2 Oct 2019 00:19:30 +0200 Subject: [PATCH 3/6] use lib prefix --- recipes/{nghttp2 => libnghttp2}/all/CMakeLists.txt | 0 recipes/{nghttp2 => libnghttp2}/all/conandata.yml | 0 recipes/{nghttp2 => libnghttp2}/all/conanfile.py | 0 recipes/{nghttp2 => libnghttp2}/all/test_package/CMakeLists.txt | 0 recipes/{nghttp2 => libnghttp2}/all/test_package/conanfile.py | 0 recipes/{nghttp2 => libnghttp2}/all/test_package/test_package.cpp | 0 recipes/{nghttp2 => libnghttp2}/config.yml | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename recipes/{nghttp2 => libnghttp2}/all/CMakeLists.txt (100%) rename recipes/{nghttp2 => libnghttp2}/all/conandata.yml (100%) rename recipes/{nghttp2 => libnghttp2}/all/conanfile.py (100%) rename recipes/{nghttp2 => libnghttp2}/all/test_package/CMakeLists.txt (100%) rename recipes/{nghttp2 => libnghttp2}/all/test_package/conanfile.py (100%) rename recipes/{nghttp2 => libnghttp2}/all/test_package/test_package.cpp (100%) rename recipes/{nghttp2 => libnghttp2}/config.yml (100%) diff --git a/recipes/nghttp2/all/CMakeLists.txt b/recipes/libnghttp2/all/CMakeLists.txt similarity index 100% rename from recipes/nghttp2/all/CMakeLists.txt rename to recipes/libnghttp2/all/CMakeLists.txt diff --git a/recipes/nghttp2/all/conandata.yml b/recipes/libnghttp2/all/conandata.yml similarity index 100% rename from recipes/nghttp2/all/conandata.yml rename to recipes/libnghttp2/all/conandata.yml diff --git a/recipes/nghttp2/all/conanfile.py b/recipes/libnghttp2/all/conanfile.py similarity index 100% rename from recipes/nghttp2/all/conanfile.py rename to recipes/libnghttp2/all/conanfile.py diff --git a/recipes/nghttp2/all/test_package/CMakeLists.txt b/recipes/libnghttp2/all/test_package/CMakeLists.txt similarity index 100% rename from recipes/nghttp2/all/test_package/CMakeLists.txt rename to recipes/libnghttp2/all/test_package/CMakeLists.txt diff --git a/recipes/nghttp2/all/test_package/conanfile.py b/recipes/libnghttp2/all/test_package/conanfile.py similarity index 100% rename from recipes/nghttp2/all/test_package/conanfile.py rename to recipes/libnghttp2/all/test_package/conanfile.py diff --git a/recipes/nghttp2/all/test_package/test_package.cpp b/recipes/libnghttp2/all/test_package/test_package.cpp similarity index 100% rename from recipes/nghttp2/all/test_package/test_package.cpp rename to recipes/libnghttp2/all/test_package/test_package.cpp diff --git a/recipes/nghttp2/config.yml b/recipes/libnghttp2/config.yml similarity index 100% rename from recipes/nghttp2/config.yml rename to recipes/libnghttp2/config.yml From e6e6d488687fbe5ef6d020817642f3b7da10f07c Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Fri, 4 Oct 2019 10:05:17 +0200 Subject: [PATCH 4/6] review by @danimtb --- recipes/libnghttp2/all/conanfile.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/recipes/libnghttp2/all/conanfile.py b/recipes/libnghttp2/all/conanfile.py index 808cb661ef427..640ac3127883b 100644 --- a/recipes/libnghttp2/all/conanfile.py +++ b/recipes/libnghttp2/all/conanfile.py @@ -8,7 +8,6 @@ class Nghttp2Conan(ConanFile): name = "libnghttp2" - description = "HTTP/2 C Library and tools" topics = ("conan", "http") url = "https://github.com/conan-io/conan-center-index" @@ -16,7 +15,6 @@ class Nghttp2Conan(ConanFile): license = "MIT" exports_sources = ["CMakeLists.txt"] generators = "cmake", "pkg_config" - settings = "os", "arch", "compiler", "build_type" options = {"shared": [True, False], "fPIC": [True, False], @@ -83,14 +81,13 @@ def _configure_cmake(self): def _build_with_autotools(self): if self.options.with_app: os.rename('c-ares.pc', 'libcares.pc') - os.rename('OpenSSL.pc', 'openssl.pc') prefix = os.path.abspath(self.package_folder) with tools.chdir(self._source_subfolder): env_build = AutoToolsBuildEnvironment(self) if self.settings.os == 'Windows': prefix = tools.unix_path(prefix) - args = ['--prefix=%s' % prefix] + args = [] if self.options.shared: args.extend(['--disable-static', '--enable-shared']) else: From 96b87ad49406395f61a14c4b557916dbce009f69 Mon Sep 17 00:00:00 2001 From: javierg Date: Wed, 23 Oct 2019 15:51:12 +0200 Subject: [PATCH 5/6] remove shebang and encoding --- recipes/libnghttp2/all/conanfile.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/recipes/libnghttp2/all/conanfile.py b/recipes/libnghttp2/all/conanfile.py index 640ac3127883b..f1ef9c06529ae 100644 --- a/recipes/libnghttp2/all/conanfile.py +++ b/recipes/libnghttp2/all/conanfile.py @@ -1,6 +1,3 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - import os from conans import ConanFile, CMake, AutoToolsBuildEnvironment, tools from conans.errors import ConanInvalidConfiguration From 2ae8eb3043282889916ff80be20478aad58aa7f0 Mon Sep 17 00:00:00 2001 From: javierg Date: Wed, 23 Oct 2019 16:27:32 +0200 Subject: [PATCH 6/6] restrict to gcc >= 6.0 --- recipes/libnghttp2/all/conanfile.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/recipes/libnghttp2/all/conanfile.py b/recipes/libnghttp2/all/conanfile.py index f1ef9c06529ae..6a06447d162ff 100644 --- a/recipes/libnghttp2/all/conanfile.py +++ b/recipes/libnghttp2/all/conanfile.py @@ -26,6 +26,12 @@ class Nghttp2Conan(ConanFile): _source_subfolder = "source_subfolder" + def configure(self): + if self.settings.compiler == "gcc": + v = tools.Version(str(self.settings.compiler.version)) + if v < "6.0": + raise ConanInvalidConfiguration("gcc >= 6.0 required") + def config_options(self): if self.settings.os == 'Windows': del self.options.fPIC