Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongo-cxx-driver: use validate() for checking configuration #4057

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions recipes/mongo-cxx-driver/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ sources:
"3.6.1":
url: https://github.com/mongodb/mongo-cxx-driver/archive/r3.6.1.tar.gz
sha256: c6d1b307f7b074d178c4a815d8739195fb4d7870701064bdad6f1f2360ae0af9
"3.6.2":
url: https://github.com/mongodb/mongo-cxx-driver/archive/r3.6.2.tar.gz
sha256: f50a1acb98a473f0850e2766dc7e84c05415dc63b1a2f851b77b12629ac14d62
patches:
"3.6.1":
- patch_file: "patches/dirs_and_tests.patch"
Expand All @@ -10,3 +13,10 @@ patches:
base_path: "source_subfolder"
- patch_file: "patches/poly_use_std_define.patch"
base_path: "source_subfolder"
"3.6.2":
- patch_file: "patches/dirs_and_tests.patch"
base_path: "source_subfolder"
- patch_file: "patches/link_conan_boost.patch"
base_path: "source_subfolder"
- patch_file: "patches/poly_use_std_define.patch"
base_path: "source_subfolder"
19 changes: 10 additions & 9 deletions recipes/mongo-cxx-driver/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import shutil


required_conan_version = ">=1.28.0"
required_conan_version = ">=1.32.0"


class MongoCxxConan(ConanFile):
Expand Down Expand Up @@ -89,6 +89,15 @@ def configure(self):
if self.options.shared:
del self.options.fPIC

def requirements(self):
self.requires("mongo-c-driver/1.17.2")
if self.options.polyfill == "boost":
self.requires("boost/1.75.0")

def validate(self):
if self.options.with_ssl and not bool(self.options["mongo-c-driver"].with_ssl):
raise ConanInvalidConfiguration("mongo-cxx-driver with_ssl=True requires mongo-c-driver with a ssl implementation")
Comment on lines +98 to +99
Copy link
Contributor Author

@mathbunnyru mathbunnyru Jan 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old code here, everything is from configure() or build() methods.

I followed the recommendation from here:
https://blog.conan.io/2020/12/14/New-conan-release-1-32.html
the validate() method should take over all responsibility for raising ConanInvalidConfiguration errors


if self.options.polyfill == "mnmlstc":
# TODO: add mnmlstc polyfill support
# Cannot model mnmlstc (not packaged, is pulled dynamically) polyfill dependencies
Expand All @@ -114,11 +123,6 @@ def configure(self):
)
)

def requirements(self):
self.requires("mongo-c-driver/1.17.2")
if self.options.polyfill == "boost":
self.requires("boost/1.74.0")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename(self.name + "-r" + self.version, self._source_subfolder)
Expand Down Expand Up @@ -153,10 +157,7 @@ def _patch_sources(self):
tools.patch(**patch)

def build(self):
if self.options.with_ssl and not bool(self.options["mongo-c-driver"].with_ssl):
raise ConanInvalidConfiguration("mongo-cxx-driver with_ssl=True requires mongo-c-driver with a ssl implementation")
self._patch_sources()

cmake = self._configure_cmake()
cmake.build()

Expand Down
2 changes: 2 additions & 0 deletions recipes/mongo-cxx-driver/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"3.6.1":
folder: all
"3.6.2":
folder: all