Skip to content

Commit 4c7ef49

Browse files
authored
Merge pull request #123 from Morwenn/conan
Support Conan package (fixes #121)
2 parents 207878f + 696705e commit 4c7ef49

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed

.travis.yml

+16
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,22 @@ matrix:
7070
env: BUILD_TYPE=Release VALGRIND=false SANITIZE='' CMAKE_GENERATOR="Xcode"
7171
compiler: clang
7272

73+
# Conan
74+
- os: linux
75+
sudo: required
76+
language: python
77+
python: "3.6"
78+
if: branch = master
79+
env: CC=clang CXX=clang++
80+
install:
81+
- pip install conan
82+
script:
83+
- conan create . morwenn/stable
84+
after_success:
85+
- conan remote add bintray https://api.bintray.com/conan/morwenn/cpp-sort
86+
- conan user -r bintray -p ${CONAN_PASSWORD} morwenn
87+
- conan upload --all -r bintray cpp-sort/1.0.0@morwenn/stable
88+
7389
before_install:
7490
- if [ `uname` = 'Darwin' ]; then
7591
brew update &&

conanfile.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from conans import ConanFile
2+
3+
4+
class CppSortConan(ConanFile):
5+
name = "cpp-sort"
6+
version = "1.0.0"
7+
settings = "compiler"
8+
license = "https://github.com/Morwenn/cpp-sort/blob/master/license.txt"
9+
url = "https://github.com/Morwenn/cpp-sort"
10+
author = "Morwenn <[email protected]>"
11+
description = "Additional sorting algorithms & related tools"
12+
exports_sources = "include/*"
13+
exports = "license.txt"
14+
no_copy_source = True
15+
16+
def configure(self):
17+
if self.settings.compiler == "Visual Studio":
18+
raise Exception("Visual Studio is not supported.")
19+
20+
def package(self):
21+
self.copy("license*", dst="licenses", ignore_case=True, keep_path=False)
22+
self.copy(pattern="*", src="include", dst="include")
23+
24+
def package_id(self):
25+
self.info.header_only()

test_package/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cmake_minimum_required(VERSION 2.8.12)
2+
3+
project(CppSortTest CXX)
4+
5+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
6+
conan_basic_setup()
7+
8+
add_executable(example cpp-sort-integrity.cpp)
9+
set_property(TARGET example PROPERTY CXX_STANDARD 14)

test_package/conanfile.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from conans import ConanFile, CMake, tools
2+
import os
3+
4+
class CppsortTestConan(ConanFile):
5+
settings = "os", "compiler", "build_type", "arch"
6+
generators = "cmake"
7+
8+
def build(self):
9+
cmake = CMake(self)
10+
cmake.configure()
11+
cmake.build()
12+
13+
def test(self):
14+
os.chdir("bin")
15+
self.run(".%sexample" % os.sep)

test_package/cpp-sort-integrity.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2018 Morwenn
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
#include <algorithm>
25+
#include <array>
26+
#include <cassert>
27+
#include <iostream>
28+
#include <iterator>
29+
#include <cpp-sort/sort.h>
30+
31+
int main()
32+
{
33+
std::array<int, 5u> arr = { 5, 8, 3, 2, 9 };
34+
cppsort::sort(arr);
35+
assert(std::is_sorted(std::begin(arr), std::end(arr)));
36+
37+
// prints 2 3 5 8 9
38+
for (int val: arr) {
39+
std::cout << val << ' ';
40+
}
41+
}

0 commit comments

Comments
 (0)