Skip to content

Commit 5341dc7

Browse files
committed
Conan support
1 parent 7e5fc8f commit 5341dc7

File tree

7 files changed

+202
-1
lines changed

7 files changed

+202
-1
lines changed

.conan/build.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import os
5+
import re
6+
from cpt.packager import ConanMultiPackager
7+
8+
9+
class BuilderSettings(object):
10+
@property
11+
def username(self):
12+
""" Set taocpp as package's owner
13+
"""
14+
return os.getenv("CONAN_USERNAME", "taocpp")
15+
16+
@property
17+
def upload(self):
18+
""" Set taocpp repository to be used on upload
19+
"""
20+
bintray_url = "https://api.bintray.com/conan/taocpp/public-conan"
21+
return os.getenv("CONAN_UPLOAD", bintray_url)
22+
23+
@property
24+
def upload_only_when_stable(self):
25+
""" Force to upload when running over tag branch
26+
"""
27+
return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True)
28+
29+
@property
30+
def stable_branch_pattern(self):
31+
""" Only upload the package the branch name is like a tag
32+
"""
33+
return os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"\d+\.\d+\.\d+")
34+
35+
@property
36+
def reference(self):
37+
""" Read project version from CMake file to create Conan referece
38+
"""
39+
pattern = re.compile(r"project \(taocpp-tuple VERSION (\d+\.\d+\.\d+) LANGUAGES CXX\)")
40+
version = None
41+
with open('CMakeLists.txt') as file:
42+
for line in file:
43+
result = pattern.match(line)
44+
if result:
45+
version = result.group(1)
46+
if not version:
47+
raise Exception("Could not find version in CMakeLists.txt")
48+
return os.getenv("CONAN_REFERENCE", "tuple/{}@taocpp/stable".format(version))
49+
50+
if __name__ == "__main__":
51+
settings = BuilderSettings()
52+
builder = ConanMultiPackager(
53+
reference=settings.reference,
54+
username=settings.username,
55+
upload=settings.upload,
56+
upload_only_when_stable=settings.upload_only_when_stable,
57+
stable_branch_pattern=settings.stable_branch_pattern,
58+
test_folder=os.path.join(".conan", "test_package"))
59+
builder.add()
60+
builder.run()

.conan/test_package/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
project(test_package CXX)
2+
cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR)
3+
4+
set(CMAKE_VERBOSE_MAKEFILE TRUE)
5+
6+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
7+
conan_basic_setup()
8+
9+
find_package(taocpp-tuple REQUIRED CONFIG)
10+
11+
add_executable(${PROJECT_NAME} test_package.cpp)
12+
target_link_libraries(${PROJECT_NAME} taocpp::tuple)

.conan/test_package/conanfile.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
from conans import ConanFile, CMake, tools, RunEnvironment
5+
import os
6+
7+
class TestPackageConan(ConanFile):
8+
settings = "os", "compiler", "build_type", "arch"
9+
generators = "cmake"
10+
11+
def build(self):
12+
cmake = CMake(self)
13+
cmake.configure()
14+
cmake.build()
15+
16+
def test(self):
17+
with tools.environment_append(RunEnvironment(self).vars):
18+
bin_path = os.path.join("bin", "test_package")
19+
self.run('{}'.format(bin_path))
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// The Art of C++ / Tuple
2+
// Copyright (c) 2015-2018 Daniel Frey
3+
// Please see LICENSE for license or visit https://github.com/taocpp/operators/
4+
5+
#include <tao/tuple/tuple.hpp>
6+
7+
#include <cassert>
8+
#include <type_traits>
9+
10+
int main()
11+
{
12+
using namespace tao;
13+
14+
auto t = tuple< int, double, int >();
15+
auto t2 = tuple< int, double, int >( 1, 2, 3 );
16+
auto t3( t2 );
17+
18+
auto t4 = tuple< int, double, int >( 1, 2, 2 );
19+
auto t5 = tuple< int, double, int >( 1, 2, 4 );
20+
21+
static_assert( tuple_size< decltype( t ) >::value == 3, "oops" );
22+
static_assert( tuple_size< decltype( t2 ) >::value == 3, "oops" );
23+
static_assert( tuple_size< decltype( t3 ) >::value == 3, "oops" );
24+
25+
assert( get< 0 >( t2 ) == 1 );
26+
assert( get< 1 >( t2 ) == 2 );
27+
assert( get< 2 >( t2 ) == 3 );
28+
29+
assert( get< double >( t2 ) == 2 );
30+
31+
assert( get< 0 >( t3 ) == 1 );
32+
assert( get< 1 >( t3 ) == 2 );
33+
assert( get< 2 >( t3 ) == 3 );
34+
35+
assert( get< double >( t3 ) == 2 );
36+
37+
assert( t2 == t3 );
38+
assert( t2 != t4 );
39+
assert( t2 > t4 );
40+
assert( t2 < t5 );
41+
assert( t2 >= t3 );
42+
assert( t2 <= t3 );
43+
assert( t2 >= t4 );
44+
assert( t2 <= t5 );
45+
46+
assert( tuple<>() == tuple<>() );
47+
assert( !( tuple<>() < tuple<>() ) );
48+
49+
assert( make_tuple( 0 ) == make_tuple( 0 ) );
50+
51+
assert( make_tuple( 1, 2, 3 ) > make_tuple( 1, 2, 2 ) );
52+
assert( make_tuple( 1, 2, 3 ) < make_tuple( 1, 2, 4 ) );
53+
54+
assert( ( tuple< int, int, int >( std::allocator_arg, 5, 1, 2, 3 ) < make_tuple( 1, 2, 4 ) ) );
55+
56+
#if( __cplusplus >= 201402L )
57+
58+
static_assert( tuple<>() == tuple<>(), "oops" );
59+
static_assert( make_tuple() == make_tuple(), "oops" );
60+
static_assert( make_tuple( 0 ) == make_tuple( 0 ), "oops" );
61+
62+
static_assert( make_tuple( 1, 2, 3 ) > make_tuple( 1, 2, 2 ), "oops" );
63+
static_assert( make_tuple( 1, 2, 3 ) < make_tuple( 1, 2, 4 ), "oops" );
64+
65+
// TODO: More constexpr checks
66+
67+
#endif
68+
}

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ matrix:
160160
env:
161161
- CXX=clang++
162162

163+
- language: python
164+
python:
165+
- "3.6"
166+
sudo: required
167+
install:
168+
- pip install conan conan-package-tools
169+
env:
170+
- CONAN_GCC_VERSIONS=7
171+
- CONAN_DOCKER_IMAGE=lasote/conangcc7
172+
script:
173+
- python .conan/build.py
174+
163175
- compiler: gcc
164176
addons:
165177
apt:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# The Art of C++ / Tuple
22

33
[![Release](https://img.shields.io/github/release/taocpp/tuple.svg)](https://github.com/taocpp/tuple/releases/latest)
4+
[![Download](https://api.bintray.com/packages/taocpp/public-conan/tuple%3Ataocpp/images/download.svg)](https://bintray.com/taocpp/public-conan/tuple%3Ataocpp/_latestVersion)
45
[![TravisCI](https://travis-ci.org/taocpp/tuple.svg)](https://travis-ci.org/taocpp/tuple)
5-
[![AppVeyor](https://ci.appveyor.com/api/projects/status/9opt30ae579kw19b/branch/master?svg=true)](https://ci.appveyor.com/project/taocpp/tuple)
6+
[![AppVeyor](https://ci.appveyor.com/api/projects/status/github/taocpp/tuple?svg=true)](https://ci.appveyor.com/project/taocpp/tuple)
67

78
[The Art of C++](https://taocpp.github.io/) / Tuple is a C++11 header-only reference implementation of
89
[`std::tuple`](http://en.cppreference.com/w/cpp/utility/tuple).

conanfile.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
from conans import ConanFile, CMake
4+
5+
class TupleConan(ConanFile):
6+
name = "tuple"
7+
description = "C++11 header-only reference implementation of std::tuple"
8+
homepage = "https://github.com/taocpp/tuple"
9+
url = homepage
10+
license = "MIT"
11+
author = "[email protected]"
12+
exports = "LICENSE"
13+
exports_sources = "include/*", "CMakeLists.txt"
14+
no_copy_source = True
15+
16+
def build(self):
17+
pass
18+
19+
def package(self):
20+
cmake = CMake(self)
21+
22+
cmake.definitions["TAOCPP_TUPLE_BUILD_TESTS"] = "OFF"
23+
cmake.definitions["TAOCPP_TUPLE_INSTALL_DOC_DIR"] = "licenses"
24+
25+
cmake.configure()
26+
cmake.install()
27+
28+
def package_id(self):
29+
self.info.header_only()

0 commit comments

Comments
 (0)