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

add co/2.0.2 #7510

Merged
merged 30 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2a8ab79
add package co
idealvin Oct 3, 2021
16583bf
update test package for co
idealvin Oct 3, 2021
be79f6b
fix typo
idealvin Oct 5, 2021
c9d9362
add patch file and fix ci error
idealvin Oct 7, 2021
0fd268b
remove topic conan
idealvin Oct 7, 2021
13f9371
Update recipes/co/all/test_package/conanfile.py
idealvin Oct 7, 2021
cfd6c40
Update recipes/co/all/test_package/test_package.cc
idealvin Oct 7, 2021
ceca037
Update recipes/co/all/test_package/conanfile.py
idealvin Oct 7, 2021
29eb58a
Update recipes/co/all/conanfile.py
idealvin Oct 7, 2021
b71de7c
Update recipes/co/all/conanfile.py
idealvin Oct 7, 2021
ffe8570
Update recipes/co/all/conanfile.py
idealvin Oct 7, 2021
49d4aaa
Update recipes/co/all/test_package/CMakeLists.txt
idealvin Oct 7, 2021
3ad6edb
Update recipes/co/all/test_package/conanfile.py
idealvin Oct 7, 2021
86aa76d
Update recipes/co/all/conanfile.py
idealvin Oct 7, 2021
e28fce9
Update recipes/co/all/conanfile.py
idealvin Oct 7, 2021
2c8ceba
Update recipes/co/all/conanfile.py
SSE4 Oct 8, 2021
4706fb2
Update recipes/co/all/conanfile.py
SSE4 Oct 8, 2021
78edc30
Update recipes/co/all/conanfile.py
idealvin Oct 8, 2021
fcc3fb5
Update recipes/co/all/conanfile.py
idealvin Oct 8, 2021
6324731
Update recipes/co/all/conanfile.py
idealvin Oct 8, 2021
b773395
Update recipes/co/all/conanfile.py
idealvin Oct 9, 2021
1ea10d1
Update recipes/co/all/conanfile.py
idealvin Oct 9, 2021
93cee24
add validate
idealvin Oct 9, 2021
e90259b
add require for libcurl
idealvin Oct 9, 2021
bbf6c85
fix validate
idealvin Oct 9, 2021
8859d8f
Update recipes/co/all/CMakeLists.txt
idealvin Oct 10, 2021
b0b4231
to lowercase
idealvin Oct 10, 2021
b8bf117
to lowercase
idealvin Oct 10, 2021
94d026a
add a patch for co 2.0.2
idealvin Oct 11, 2021
3c4fe47
Update recipes/co/all/conanfile.py
idealvin Oct 12, 2021
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
7 changes: 7 additions & 0 deletions recipes/co/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory("source_subfolder")
8 changes: 8 additions & 0 deletions recipes/co/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sources:
"2.0.2":
url: "https://github.com/idealvin/co/archive/refs/tags/v2.0.2.tar.gz"
sha256: "b5fecc4e0556e33ae11ac2b7c80e37add6cc9d32942e48ce65593f09aa3ef35b"
patches:
"2.0.2":
- patch_file: "patches/001-install-dll.patch"
base_path: "source_subfolder"
102 changes: 102 additions & 0 deletions recipes/co/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
from conans import ConanFile, CMake, tools
idealvin marked this conversation as resolved.
Show resolved Hide resolved
from conans.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.33.0"


class CoConan(ConanFile):
name = "co"
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we fine with co?
Perhaps it 's safer to namespace it? idealvin-co?

Copy link
Contributor

Choose a reason for hiding this comment

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

good catch, CO is very generic abbreviation, it may stand for Cobalt, Carbon Oxide, programming language, etc.

Copy link
Member

@uilianries uilianries Oct 8, 2021

Choose a reason for hiding this comment

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

Mendeleev sent a hi! ⚗️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

About months ago, vcpkg said that the name co is too short, but they accepted it finally.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we fine with co? Perhaps it 's safer to namespace it? idealvin-co?

I think it's a great idea, people who aren't familiar with the project we get confused

Copy link
Member

Choose a reason for hiding this comment

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

co has 2k2 stars and there is no other project using same name in c++ universe. We are fine using co.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, we need to be careful with that.
there are at very least:

not to count numerous generic abbreviation usages like Columbia, Colorado, Corsican, Commercia, etc.
so I agree with @uilianries

url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/idealvin/co"
license = "MIT"
description = "A go-style coroutine library in C++11 and more."
topics = ("co", "coroutine", "c++11")
exports_sources = "CMakeLists.txt", "patches/*"
generators = "cmake", "cmake_find_package"

settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_libcurl": [True, False],
"with_openssl": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_libcurl": False,
"with_openssl": False,
}

_cmake = None

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

@property
def _build_subfolder(self):
return "build_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC

def requirements(self):
if self.options.with_libcurl:
self.requires("libcurl/7.79.1")
if self.options.with_openssl:
self.requires("openssl/1.1.1l")

def build_requirements(self):
if self.settings.os == "Macos" and self.settings.arch == "armv8":
# The OSX_ARCHITECTURES target property is now respected for the ASM language
self.build_requires("cmake/3.20.1")
Comment on lines +57 to +59
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 This is ok as long as we don't need to add this to many recipes in order to build M1 binaries.

Anyway, we should think about a solution from the CI side, because upgrading CMake system-wide is not a solution (we will use minimum version required here https://github.com/conan-io/tribe/blob/main/design/004-tools-cmake.md)


SSE4 marked this conversation as resolved.
Show resolved Hide resolved
def source(self):
tools.get(**self.conan_data["sources"][self.version],
strip_root=True, destination=self._source_subfolder)

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
cmake = self._configure_cmake()
cmake.build()

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
if not self.options.shared:
self._cmake.definitions["FPIC"] = self.options.get_safe("fPIC", False)
runtime = self.settings.get_safe("compiler.runtime")
if runtime:
self._cmake.definitions["STATIC_VS_CRT"] = "MT" in runtime
self._cmake.definitions["WITH_LIBCURL"] = self.options.with_libcurl
self._cmake.definitions["WITH_OPENSSL"] = self.options.with_openssl
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

def package(self):
self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
self.cpp_info.libs = ["co"]
self.cpp_info.names["cmake_find_package"] = "co"
self.cpp_info.names["cmake_find_package_multi"] = "co"

def validate(self):
if self.options.with_libcurl:
if not self.options.with_openssl:
raise ConanInvalidConfiguration(f"{self.name} requires with_openssl=True when using with_libcurl=True")
if self.options["libcurl"].with_ssl != "openssl":
raise ConanInvalidConfiguration(f"{self.name} requires libcurl:with_ssl='openssl' to be enabled")
if not self.options["libcurl"].with_zlib:
raise ConanInvalidConfiguration(f"{self.name} requires libcurl:with_zlib=True to be enabled")
uilianries marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 10 additions & 0 deletions recipes/co/all/patches/001-install-dll.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9e03c9a..499b550 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -112,4 +112,5 @@ install(
TARGETS co
SSE4 marked this conversation as resolved.
Show resolved Hide resolved
LIBRARY DESTINATION lib # shared lib installed to ${CMAKE_INSTALL_PREFIX}/lib
ARCHIVE DESTINATION lib # static lib installed to ${CMAKE_INSTALL_PREFIX}/lib
+ RUNTIME DESTINATION bin
)
13 changes: 13 additions & 0 deletions recipes/co/all/patches/002-fix-event-destruct.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/co/co.cc b/src/co/co.cc
index 8921296..838ac16 100644
--- a/src/co/co.cc
+++ b/src/co/co.cc
@@ -8,7 +8,7 @@ namespace co {
class EventImpl {
public:
EventImpl() : _counter(0), _signaled(false), _has_cond(false) {}
- ~EventImpl() { co::xx::cond_destroy(&_cond); }
+ ~EventImpl() { if (_has_cond) co::xx::cond_destroy(&_cond); }

bool wait(uint32 ms);

11 changes: 11 additions & 0 deletions recipes/co/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +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(TARGETS)

find_package(co REQUIRED)

add_executable(${PROJECT_NAME} test_package.cc)
target_link_libraries(${PROJECT_NAME} co::co)
16 changes: 16 additions & 0 deletions recipes/co/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from conans import ConanFile, CMake, tools
import os

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

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

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
7 changes: 7 additions & 0 deletions recipes/co/all/test_package/test_package.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "co/str.h"
#include <iostream>

int main() {
std::cout << str::from(123) << std::endl;
return 0;
}
3 changes: 3 additions & 0 deletions recipes/co/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.0.2":
folder: all