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

New package: libq #22828

Merged
merged 29 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2d364fa
Add libq package
metalMajor Feb 9, 2024
c0ff54b
check minimum cppstd
metalMajor Feb 20, 2024
466d2b3
remove unused import
metalMajor Feb 20, 2024
1ab71a5
Merge branch 'master' into package/libq
metalMajor Feb 20, 2024
3399439
Bases the package file on cmake_package template.
metalMajor Feb 26, 2024
bbafb8c
Merge branch 'package/libq' of git@github.com:metalMajor/conan-center…
metalMajor Feb 26, 2024
13acf9a
add test package from template
metalMajor Feb 27, 2024
0d06baf
Fixes to the recipe
AbrilRBS May 4, 2024
991b70e
Unvendor libq - Still does not work
AbrilRBS May 4, 2024
aba7aa7
Fix static lib package_info
AbrilRBS May 4, 2024
4d58026
Merge branch 'package/libq' of git@github.com:metalMajor/conan-center…
metalMajor Oct 24, 2024
ca3f32f
Fix to package_info libs
metalMajor Oct 24, 2024
4dae208
fix package_info libs names
metalMajor Oct 24, 2024
4948151
fails on gcc 7.5 it seems
metalMajor Oct 25, 2024
b9dcf64
make exception for static
metalMajor Oct 25, 2024
4a9cb42
use system_libs as suggested by the compile output on windows
metalMajor Nov 14, 2024
b452880
add both libs and system_libs
metalMajor Nov 14, 2024
70d3fbd
another try for windows
metalMajor Nov 14, 2024
c12c9a4
only allow shared on msvc as test
metalMajor Nov 14, 2024
dccd428
skip windows as test
metalMajor Nov 14, 2024
78c8f41
implement suggested code review changes
metalMajor Nov 14, 2024
0545f74
fix linter warnings
metalMajor Nov 14, 2024
2a23fcd
fix apple install name
metalMajor Nov 14, 2024
8f42030
Update recipes/libq/all/conandata.yml
metalMajor Nov 14, 2024
634a938
update to conan2 version style
metalMajor Nov 14, 2024
c226148
Fix compilation in Windows and Macos
AbrilRBS Nov 14, 2024
b08331a
Add missing patch file
AbrilRBS Nov 14, 2024
71394e9
Use static-library for Windows.
uilianries Nov 15, 2024
471c8e9
Remove unused imports
uilianries Nov 15, 2024
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
4 changes: 4 additions & 0 deletions recipes/libq/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"cci.20180504":
metalMajor marked this conversation as resolved.
Show resolved Hide resolved
url: "https://github.com/grantila/q/archive/0117848bb3e6f0b130b546bc5851caf5f95f8b7e.zip"
sha256: "f5e51c1abbbec8e6da2155740917d7f1f60628745363ebd4e2aadfd7ef2ff682"
98 changes: 98 additions & 0 deletions recipes/libq/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rm, rmdir
from conan.tools.scm import Version
from conan.tools.apple import fix_apple_shared_install_name

required_conan_version = ">=1.53.0"

class libqConan(ConanFile):
name = "libq"
description = "A platform-independent promise library for C++, implementing asynchronous continuations."
license = "Apache-2.0"
topics = ("async", "promises")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/grantila/q"
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
settings = "os", "compiler", "build_type", "arch"
package_type = "library"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}

@property
def _min_cppstd(self):
return 17

@property
def _compilers_minimum_version(self):
return {
"apple-clang": "10",
"clang": "7",
"gcc": "7"
}

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def layout(self):
cmake_layout(self, src_folder="src")

def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)
if self.settings.os in ["Windows"]:
# FIXME: Test package is not capable to find q.lib
raise ConanInvalidConfiguration(f"{self.ref} Conan recipe is not supported in Windows. Contributions are welcome.")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["q_BUILD_TESTS"] = False
tc.variables["q_BUILD_APPS"] = False

tc.generate()

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

def package(self):
copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
fix_apple_shared_install_name(self)

rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))

def package_info(self):
self.cpp_info.libs = ["q"]
self.cpp_info.set_property("cmake_file_name", "libq")
self.cpp_info.set_property("cmake_target_name", "libq::libq")

if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")
self.cpp_info.system_libs.append("pthread")
self.cpp_info.system_libs.append("dl")
9 changes: 9 additions & 0 deletions recipes/libq/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.15)

project(test_package LANGUAGES CXX) # if the project uses c++

find_package(libq REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE libq::libq)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
27 changes: 27 additions & 0 deletions recipes/libq/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


# It will become the standard on Conan 2.x
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

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

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
24 changes: 24 additions & 0 deletions recipes/libq/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <cstdlib>
#include <q/lib.hpp>
#include <q/blocking_dispatcher.hpp>
#include <q/execution_context.hpp>
#include <q/promise.hpp>
#include <iostream>
#include <thread>

int main(void) {
q::initialize();

auto ctx = q::make_execution_context<q::blocking_dispatcher>("test");

std::thread t([&ctx](){
ctx->dispatcher()->start();
});
std::this_thread::yield();
ctx->dispatcher()->terminate(q::termination::annihilate);
ctx->dispatcher()->await_termination();
t.join();

q::uninitialize();
return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/libq/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"cci.20180504":
metalMajor marked this conversation as resolved.
Show resolved Hide resolved
folder: all