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

tl-expected: modernize #9159

Merged
merged 3 commits into from
Feb 7, 2022
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: 5 additions & 5 deletions recipes/tl-expected/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sources:
"1.0.0":
url: https://github.com/TartanLlama/expected/archive/v1.0.0.zip
sha256: c1733556cbd3b532a02b68e2fbc2091b5bc2cccc279e4f6c6bd83877aabd4b02
"20190710":
url: https://github.com/TartanLlama/expected/archive/6fe2af5191214cce620899f7f06585c047b9f1fc.zip
sha256: 25b009593fcb27aafd3e836e0e726da351b4be7a20703b9bb709a5efd61c26d0
url: "https://github.com/TartanLlama/expected/archive/6fe2af5191214cce620899f7f06585c047b9f1fc.zip"
sha256: "25b009593fcb27aafd3e836e0e726da351b4be7a20703b9bb709a5efd61c26d0"
"1.0.0":
url: "https://github.com/TartanLlama/expected/archive/refs/tags/v1.0.0.tar.gz"
sha256: "8f5124085a124113e75e3890b4e923e3a4de5b26a973b891b3deb40e19c03cee"
36 changes: 18 additions & 18 deletions recipes/tl-expected/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from conans import ConanFile, CMake, tools
from fnmatch import fnmatch
from conans import ConanFile, tools
import os

required_conan_version = ">=1.28.0"
required_conan_version = ">=1.43.0"


class TlExpectedConan(ConanFile):
Expand All @@ -12,38 +11,39 @@ class TlExpectedConan(ConanFile):
description = "C++11/14/17 std::expected with functional-style extensions"
topics = ("cpp11", "cpp14", "cpp17", "expected")
license = "CC0-1.0"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _archive_dir(self):
# the archive expands to a directory named expected-[COMMIT SHA1];
# we'd like to put this under a stable name
expected_dirs = [
de for de in os.scandir(self.source_folder)
if de.is_dir() and fnmatch(de.name, "expected-*")
]
return expected_dirs[0].name
def validate(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 11)

def package_id(self):
self.info.header_only()

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename(self._archive_dir, self._source_subfolder)
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def package(self):
self.copy("*",
src=os.path.join(self._source_subfolder, "include"),
dst="include")
self.copy("COPYING", src=self._source_subfolder, dst="licenses")

def package_id(self):
self.info.header_only()

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "tl-expected")
self.cpp_info.set_property("cmake_target_name", "tl::expected")

# TODO: to remove in conan v2 once cmake_find_package* generators removed
self.cpp_info.filenames["cmake_find_package"] = "tl-expected"
self.cpp_info.filenames["cmake_find_package_multi"] = "tl-expected"
self.cpp_info.names["cmake_find_package"] = "tl"
self.cpp_info.names["cmake_find_package_multi"] = "tl"
self.cpp_info.components["expected"].name = "expected"
self.cpp_info.components["expected"].names["cmake_find_package"] = "expected"
self.cpp_info.components["expected"].names["cmake_find_package_multi"] = "expected"
self.cpp_info.components["expected"].set_property("cmake_target_name", "tl::expected")
8 changes: 4 additions & 4 deletions recipes/tl-expected/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)
set(CMAKE_CXX_STANDARD 11)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
conan_basic_setup(TARGETS)

find_package(tl-expected REQUIRED)
find_package(tl-expected REQUIRED CONFIG)

add_executable(${PROJECT_NAME} example.cpp)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} tl::expected)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11)
6 changes: 3 additions & 3 deletions recipes/tl-expected/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@


class ExpectedTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package"
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

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

def test(self):
if not tools.cross_building(self.settings):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
5 changes: 2 additions & 3 deletions recipes/tl-expected/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
versions:
"1.0.0":
folder: all
"20190710":
folder: all
"1.0.0":
folder: all