Skip to content

Commit

Permalink
Merge pull request #3 from grisumbras/conan-recipe
Browse files Browse the repository at this point in the history
Added Conan recipe
  • Loading branch information
Lastique authored Nov 5, 2023
2 parents 6c14f5c + 665a6ed commit 9085803
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
103 changes: 103 additions & 0 deletions conan/1.83_compat.patch
Original file line number Diff line number Diff line change
@@ -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 <type_traits>
#include <boost/core/addressof.hpp>
-#include <boost/core/invoke_swap.hpp>
+#include <boost/core/swap.hpp>
#include <boost/scope/unique_resource_fwd.hpp>
#include <boost/scope/detail/config.hpp>
#include <boost/scope/detail/compact_storage.hpp>
@@ -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;
}
}
78 changes: 78 additions & 0 deletions conan/conanfile.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 9085803

Please sign in to comment.