diff --git a/README.md b/README.md index d411960..51326e5 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,30 @@ This library is currently proposed for review and potential inclusion into [Boos * **include** - Interface headers of Boost.Scope * **test** - Boost.Scope unit tests +### Installation + +#### Using Conan + +```` +git clone https://github.com/Lastique/scope +conan create scope/conan --build missing +```` + +This will build a boost_scope package using your default profile and put it +in the local Conan cache along with all direct and transitive dependencies. +Since Scope only depends on a few header-only Boost libraries, you can +save some time by requesting header-only Boost: + +``` +conan create scope/conan -o 'boost*:header_only=True' --build missing +```` +Following one of those approaches you can use the package as usual. For +example, using a `conanfile.txt`: +``` +[requires] +boost_scope/1.0.0 +```` + ### More information * Read the [documentation](https://lastique.github.io/scope/libs/scope/doc/html/index.html). diff --git a/conan/1.83_compat.patch b/conan/1.83_compat.patch new file mode 100644 index 0000000..b08b4e8 --- /dev/null +++ b/conan/1.83_compat.patch @@ -0,0 +1,103 @@ +diff --git a/include/boost/scope/unique_resource.hpp b/include/boost/scope/unique_resource.hpp +index 08f4fc6..c97e3b1 100644 +--- a/include/boost/scope/unique_resource.hpp ++++ b/include/boost/scope/unique_resource.hpp +@@ -16,7 +16,7 @@ + + #include + #include +-#include ++#include + #include + #include + #include +@@ -615,8 +615,8 @@ private: + + void swap_impl(unique_resource_data& that, std::true_type, std::true_type) noexcept + { +- boost::core::invoke_swap(get_internal_resource(), that.get_internal_resource()); +- boost::core::invoke_swap(get_internal_deleter(), that.get_internal_deleter()); ++ boost::swap(get_internal_resource(), that.get_internal_resource()); ++ boost::swap(get_internal_deleter(), that.get_internal_deleter()); + + const bool allocated = m_allocated; + m_allocated = that.m_allocated; +@@ -625,14 +625,14 @@ private: + + void swap_impl(unique_resource_data& that, std::true_type, std::false_type) + { +- boost::core::invoke_swap(get_internal_resource(), that.get_internal_resource()); ++ boost::swap(get_internal_resource(), that.get_internal_resource()); + try + { +- boost::core::invoke_swap(get_internal_deleter(), that.get_internal_deleter()); ++ boost::swap(get_internal_deleter(), that.get_internal_deleter()); + } + catch (...) + { +- boost::core::invoke_swap(get_internal_resource(), that.get_internal_resource()); ++ boost::swap(get_internal_resource(), that.get_internal_resource()); + throw; + } + +@@ -643,14 +643,14 @@ private: + + void swap_impl(unique_resource_data& that, std::false_type, std::false_type) + { +- boost::core::invoke_swap(get_internal_deleter(), that.get_internal_deleter()); ++ boost::swap(get_internal_deleter(), that.get_internal_deleter()); + try + { +- boost::core::invoke_swap(get_internal_resource(), that.get_internal_resource()); ++ boost::swap(get_internal_resource(), that.get_internal_resource()); + } + catch (...) + { +- boost::core::invoke_swap(get_internal_deleter(), that.get_internal_deleter()); ++ boost::swap(get_internal_deleter(), that.get_internal_deleter()); + throw; + } + +@@ -896,34 +896,34 @@ private: + + void swap_impl(unique_resource_data& that, std::true_type, std::true_type) noexcept + { +- boost::core::invoke_swap(get_internal_resource(), that.get_internal_resource()); +- boost::core::invoke_swap(get_internal_deleter(), that.get_internal_deleter()); ++ boost::swap(get_internal_resource(), that.get_internal_resource()); ++ boost::swap(get_internal_deleter(), that.get_internal_deleter()); + } + + void swap_impl(unique_resource_data& that, std::true_type, std::false_type) + { +- boost::core::invoke_swap(get_internal_resource(), that.get_internal_resource()); ++ boost::swap(get_internal_resource(), that.get_internal_resource()); + try + { +- boost::core::invoke_swap(get_internal_deleter(), that.get_internal_deleter()); ++ boost::swap(get_internal_deleter(), that.get_internal_deleter()); + } + catch (...) + { +- boost::core::invoke_swap(get_internal_resource(), that.get_internal_resource()); ++ boost::swap(get_internal_resource(), that.get_internal_resource()); + throw; + } + } + + void swap_impl(unique_resource_data& that, std::false_type, std::false_type) + { +- boost::core::invoke_swap(get_internal_deleter(), that.get_internal_deleter()); ++ boost::swap(get_internal_deleter(), that.get_internal_deleter()); + try + { +- boost::core::invoke_swap(get_internal_resource(), that.get_internal_resource()); ++ boost::swap(get_internal_resource(), that.get_internal_resource()); + } + catch (...) + { +- boost::core::invoke_swap(get_internal_deleter(), that.get_internal_deleter()); ++ boost::swap(get_internal_deleter(), that.get_internal_deleter()); + throw; + } + } diff --git a/conan/conanfile.py b/conan/conanfile.py new file mode 100644 index 0000000..3ddd832 --- /dev/null +++ b/conan/conanfile.py @@ -0,0 +1,78 @@ +# Copyright 2023 Dmitry Arkhipov (grisumbras@yandex.ru) +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +from conan import ConanFile +from conan.errors import ( + ConanException, + ConanInvalidConfiguration, +) +from conan.tools.files import ( + copy, + patch, +) +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import ( + cmake_layout, +) +from conan.tools.scm import Version + +import os + +required_conan_version = ">=1.53.0" + +class ScopeConan(ConanFile): + name = "boost_scope" + version = "1.0.0" + description = ( + "Boost.Scope provides a number of scope guard utilities described " + + "in C++ Extensions for Library Fundamentals, Version 3") + + url = "https://github.com/Lastique/scope" + homepage = "https://github.com/Lastique/scope" + license = "BSL-1.0" + topics = "cpp" + + settings = "compiler", "build_type" + + requires = "boost/[>=1.83.0]" + + @property + def _min_compiler_version_default_cxx11(self): + # Minimum compiler version having c++ standard >= 11 by default + return { + "apple-clang": 99, # assume apple-clang will default to c++11 in the distant future + "gcc": 6, + "clang": 6, + "Visual Studio": 14, # guess + "msvc": 190, # guess + }.get(str(self.settings.compiler)) + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + else: + version_cxx11_standard_json = self._min_compiler_version_default_cxx11 + if not version_cxx11_standard_json: + self.output.warning("Assuming the compiler supports c++11 by default") + elif Version(self.settings.compiler.version) < version_cxx11_standard_json: + raise ConanInvalidConfiguration("Boost.Scope requires C++11") + + def export_sources(self): + src = os.path.join(self.recipe_folder, "..") + copy(self, "LICENSE", src, self.export_sources_folder) + copy(self, "include*", src, self.export_sources_folder) + copy(self, "conan/1.83_compat.patch", src, self.export_sources_folder) + + def build(self): + patch_file = os.path.join(self.source_folder, "conan/1.83_compat.patch") + patch(self, patch_file=patch_file) + + def package(self): + copy(self, "include/*", self.source_folder, self.package_folder) + copy(self, "LICENSE", self.source_folder, self.package_folder) + + def package_id(self): + self.info.clear()