conan package support
This commit is contained in:
parent
f42d15005b
commit
a17ec9037a
52
.conan/build.py
Normal file
52
.conan/build.py
Normal file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import re
|
||||
import platform
|
||||
from cpt.packager import ConanMultiPackager
|
||||
|
||||
|
||||
def get_version():
|
||||
with open("CMakeLists.txt") as cmake:
|
||||
content = cmake.read()
|
||||
match = re.search(r'project\(uvw VERSION (.*)\)', content)
|
||||
if match:
|
||||
return match.group(1)
|
||||
return os.getenv("TRAVIS_BRANCH", "master")
|
||||
|
||||
def get_username():
|
||||
return os.getenv("CONAN_USERNAME", "skypjack")
|
||||
|
||||
|
||||
def get_reference():
|
||||
version = get_version()
|
||||
username = get_username()
|
||||
return "uvw/{}@{}/stable".format(version, username)
|
||||
|
||||
|
||||
def get_upload():
|
||||
username = get_username()
|
||||
url = "https://api.bintray.com/conan/{}/conan".format(username)
|
||||
default_upload = url if os.getenv("TRAVIS_TAG") else False
|
||||
return os.getenv("CONAN_UPLOAD", default_upload)
|
||||
|
||||
|
||||
def upload_when_stable():
|
||||
return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", "1").lower() not in ["0", "false", "no"]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_folder = os.path.join(".conan", "test_package")
|
||||
builder = ConanMultiPackager(reference=get_reference(),
|
||||
username=get_username(),
|
||||
upload=get_upload(),
|
||||
remotes="https://api.bintray.com/conan/bincrafters/public-conan",
|
||||
test_folder=test_folder,
|
||||
stable_branch_pattern=r'v?\d+\.\d+\.\d+.*',
|
||||
upload_only_when_stable=upload_when_stable())
|
||||
if platform.system() == "Linux":
|
||||
builder.add(settings={"compiler": "gcc", "compiler.version": "8",
|
||||
"arch": "x86_64", "build_type": "Release"},
|
||||
options={}, env_vars={}, build_requires={})
|
||||
builder.run()
|
||||
10
.conan/test_package/CMakeLists.txt
Normal file
10
.conan/test_package/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
project(test_package)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE TRUE)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.cpp)
|
||||
target_link_libraries(${PROJECT_NAME} CONAN_PKG::uvw)
|
||||
20
.conan/test_package/conanfile.py
Normal file
20
.conan/test_package/conanfile.py
Normal file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from conans import ConanFile, CMake
|
||||
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
generators = "cmake"
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
test_package = os.path.join("bin", "test_package")
|
||||
self.run(test_package, run_environment=True)
|
||||
48
.conan/test_package/test_package.cpp
Normal file
48
.conan/test_package/test_package.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <uvw.hpp>
|
||||
#include <memory>
|
||||
|
||||
void listen(uvw::Loop &loop) {
|
||||
std::shared_ptr<uvw::TcpHandle> tcp = loop.resource<uvw::TcpHandle>();
|
||||
|
||||
tcp->once<uvw::ListenEvent>([](const uvw::ListenEvent &, uvw::TcpHandle &srv) {
|
||||
std::shared_ptr<uvw::TcpHandle> client = srv.loop().resource<uvw::TcpHandle>();
|
||||
|
||||
client->on<uvw::CloseEvent>([ptr = srv.shared_from_this()](const uvw::CloseEvent &, uvw::TcpHandle &) { ptr->close(); });
|
||||
client->on<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TcpHandle &client) { client.close(); });
|
||||
|
||||
srv.accept(*client);
|
||||
client->read();
|
||||
});
|
||||
|
||||
tcp->bind("127.0.0.1", 4242);
|
||||
tcp->listen();
|
||||
}
|
||||
|
||||
void conn(uvw::Loop &loop) {
|
||||
auto tcp = loop.resource<uvw::TcpHandle>();
|
||||
|
||||
tcp->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TcpHandle &) { /* handle errors */ });
|
||||
|
||||
tcp->once<uvw::ConnectEvent>([](const uvw::ConnectEvent &, uvw::TcpHandle &tcp) {
|
||||
auto dataWrite = std::unique_ptr<char[]>(new char[2]{ 'b', 'c' });
|
||||
tcp.write(std::move(dataWrite), 2);
|
||||
tcp.close();
|
||||
});
|
||||
|
||||
tcp->connect(std::string{"127.0.0.1"}, 4242);
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::cout << "Getting UVW loop ...\n";
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
std::cout << "Staring UVW listener ...\n";
|
||||
listen(*loop);
|
||||
std::cout << "Connecting ...\n";
|
||||
conn(*loop);
|
||||
loop->run();
|
||||
std::cout << "Done!\n";
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,3 +2,5 @@
|
||||
*.user
|
||||
|
||||
TODO
|
||||
|
||||
.conan/test_package/build
|
||||
15
.travis.yml
15
.travis.yml
@ -36,7 +36,20 @@ matrix:
|
||||
- pip install --user cpp-coveralls
|
||||
after_success:
|
||||
- coveralls --gcov gcov-6 --gcov-options '\-lp' --root ${TRAVIS_BUILD_DIR} --build-root ${TRAVIS_BUILD_DIR}/build --extension cpp --extension hpp --exclude deps --include src
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
sudo: true
|
||||
language: python
|
||||
python: "3.7"
|
||||
services:
|
||||
- docker
|
||||
env:
|
||||
- CONAN_GCC_VERSIONS=8
|
||||
- CONAN_DOCKER_IMAGE=conanio/gcc8
|
||||
install:
|
||||
- pip install conan_package_tools
|
||||
script:
|
||||
- python .conan/build.py
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
||||
@ -16,7 +16,7 @@ endif()
|
||||
# Project configuration
|
||||
#
|
||||
|
||||
project(uvw VERSION 1.11.2)
|
||||
project(uvw VERSION 1.11.3)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
|
||||
@ -6,10 +6,12 @@
|
||||
[](https://travis-ci.org/skypjack/uvw)
|
||||
[](https://ci.appveyor.com/project/skypjack/uvw)
|
||||
[](https://coveralls.io/github/skypjack/uvw?branch=master)
|
||||
[](https://bintray.com/skypjack/conan/uvw/_latestVersion)
|
||||
[](https://gitter.im/skypjack/uvw)
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=W2HF9FESD5LJY&lc=IT&item_name=Michele%20Caini¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)
|
||||
|
||||
[](https://www.patreon.com/bePatron?u=11330786)
|
||||
|
||||
<!--
|
||||
@endcond TURN_OFF_DOXYGEN
|
||||
-->
|
||||
|
||||
23
conanfile.py
Normal file
23
conanfile.py
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from conans import ConanFile
|
||||
|
||||
|
||||
class UVMConan(ConanFile):
|
||||
name = "uvw"
|
||||
description = "Header-only, event based, tiny and easy to use libuv wrapper in modern C++"
|
||||
homepage = "https://github.com/skypjack/uvw"
|
||||
url = homepage
|
||||
license = "MIT"
|
||||
author = "Michele Caini <michele.caini@gmail.com>"
|
||||
exports = "LICENSE"
|
||||
exports_sources = "src/*"
|
||||
no_copy_source = True
|
||||
requires = "libuv/1.23.2@bincrafters/stable"
|
||||
|
||||
def package(self):
|
||||
self.copy(pattern="LICENSE", dst="licenses")
|
||||
self.copy(pattern="*.hpp", dst="include", src="src")
|
||||
|
||||
def package_id(self):
|
||||
self.info.header_only()
|
||||
Loading…
Reference in New Issue
Block a user