Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
24 changes: 24 additions & 0 deletions .ci/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -ex

if [[ "$(uname -s)" == 'Darwin' ]]; then
Comment thread
Fohlen marked this conversation as resolved.
brew update || brew update
brew outdated pyenv || brew upgrade pyenv
brew install pyenv-virtualenv
brew install cmake || true

if which pyenv > /dev/null; then
eval "$(pyenv init -)"
fi

pyenv install 3.7.1
pyenv virtualenv 3.7.1 conan
pyenv rehash
pyenv activate conan
fi

pip install conan --upgrade
pip install conan_package_tools bincrafters_package_tools

conan user
12 changes: 12 additions & 0 deletions .ci/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -ex

if [[ "$(uname -s)" == 'Darwin' ]]; then
Comment thread
Fohlen marked this conversation as resolved.
if which pyenv > /dev/null; then
eval "$(pyenv init -)"
fi
pyenv activate conan
fi

python build.py
42 changes: 42 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
repository:
Comment thread
Fohlen marked this conversation as resolved.
Outdated
# See https://developer.github.com/v3/repos/#edit for all available settings.

# Either `true` to enable issues for this repository, `false` to disable them.
has_issues: false

# Either `true` to enable the wiki for this repository, `false` to disable it.
has_wiki: false

# Either `true` to enable the wiki for this repository, `false` to disable it.
has_projects: false

branches:
- name: "stable/*"
Comment thread
Fohlen marked this conversation as resolved.
Outdated
# https://developer.github.com/v3/repos/branches/#update-branch-protection
# Branch Protection settings. Set to null to disable
protection:
# Required. Require at least one approving review on a pull request, before merging. Set to null to disable.
required_pull_request_reviews:
# The number of approvals required. (1-6)
required_approving_review_count: 1
# Dismiss approved reviews automatically when a new commit is pushed.
dismiss_stale_reviews: false
# Blocks merge until code owners have reviewed.
require_code_owner_reviews: false
# Specify which users and teams can dismiss pull request reviews. Pass an empty dismissal_restrictions object to disable. User and team dismissal_restrictions are only available for organization-owned repositories. Omit this parameter for personal repositories.
dismissal_restrictions:
users: []
teams: []

# Required. Require status checks to pass before merging. Set to null to disable
required_status_checks:
# Required. Require branches to be up to date before merging.
strict: true
# Required. The list of status checks to require in order to merge into this branch
contexts: []
# Required. Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to null to disable.
enforce_admins: false
# Required. Restrict who can push to this branch. Team and user restrictions are only available for organization-owned repositories. Set to null to disable.
restrictions:
users: []
teams: []
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
linux: &linux
os: linux
sudo: required
language: python
python: "3.6"
services:
- docker
matrix:
include:
- <<: *linux
env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=conanio/clang50

install:
- chmod +x .ci/install.sh
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'm still learning conan and travis, but it seems like it would be simpler (and less fraught with license complications) to do this without the shell scripts. Something like:

language: cpp
os: linux
dist: trusty
sudo: required
addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - g++-8
env: CC=gcc-8 CXX=g++-8
before_install: pip install conan
install: conan user
script: conan create . user/channel

But I'm probably missing something.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In theory this could be done. However the xenial and trusty images comes with libstdc5 (or earlier) and it is cumbersome and error prone to upgrade to any more recent version (which is needed for C++17). Using a pre-backed docker with all the tools makes life much easier.

- ./.ci/install.sh

script:
- chmod +x .ci/run.sh
- ./.ci/run.sh
14 changes: 0 additions & 14 deletions CMakeLists.txt

This file was deleted.

19 changes: 19 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
build: false

environment:
PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.15"
PYTHON_ARCH: "32"

matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
Comment thread
Fohlen marked this conversation as resolved.
Outdated
CONAN_VISUAL_VERSIONS: 15

install:
- set PATH=%PYTHON%;%PYTHON%/Scripts/;%PATH%
- pip.exe install conan --upgrade
- pip.exe install conan_package_tools bincrafters_package_tools
- conan user # It creates the conan data directory

test_script:
- python build.py
10 changes: 10 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from bincrafters import build_template_header_only

if __name__ == "__main__":

builder = build_template_header_only.get_builder()

builder.run()
65 changes: 41 additions & 24 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
from conans import ConanFile, CMake, tools

class GraphConan(ConanFile):
name = "Graph"
version = "0.1"
settings = "os", "compiler", "arch", "build_type"
exports_sources = "include/*", "CMakeLists.txt" #, "test/*"
no_copy_source = True

requires = "range-v3/0.4.0@ericniebler/stable"
build_requires = "Catch2/2.5.0@catchorg/stable"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
# if tools.get_env("CONAN_RUN_TESTS", True):
# cmake.test()

def package(self):
self.copy("*.h")

def package_id(self):
self.info.header_only()
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from conans import ConanFile, tools
import os

class GraphConan(ConanFile):
name = "graph"
version = "0.1.0"
description = "Efficient, header-only graph library for C++17 with a pleasant interface."
topics = ("graph-algorithms", "generic", "graph")
url = "https://github.com/cbbowen/graph/"
homepage = "https://github.com/cbbowen/graph/"
author = "Christian Bowen"
Comment thread
Fohlen marked this conversation as resolved.
Outdated
license = "MIT"
no_copy_source = True

# Packages the license for the conanfile.py
exports = ["LICENSE.md"]

# Requirements
requires = "range-v3/0.4.0@ericniebler/stable"

# Custom attributes for Bincrafters recipe conventions
_source_subfolder = "source_subfolder"

def source(self):
source_url = "https://github.com/cbbowen/graph/"
tools.get("{0}/archive/v{1}.tar.gz".format(source_url, self.version), sha256="Please-provide-a-checksum")
extracted_dir = self.name + "-" + self.version

#Rename to "source_folder" is a convention to simplify later steps
os.rename(extracted_dir, self._source_subfolder)

def package(self):
include_folder = os.path.join(self._source_subfolder, "include")
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
self.copy(pattern="include/*", dst="include", src=include_folder)

def package_id(self):
self.info.header_only()
12 changes: 12 additions & 0 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
project(test_package)
cmake_minimum_required(VERSION 2.8.11)

set(CMAKE_VERBOSE_MAKEFILE TRUE)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

file(GLOB SOURCE_FILES *.cpp)

add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
19 changes: 19 additions & 0 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python
Comment thread
Fohlen marked this conversation as resolved.
# -*- coding: utf-8 -*-

from conans import ConanFile, CMake, tools, RunEnvironment
import os


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

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

def test(self):
with tools.environment_append(RunEnvironment(self).vars):
self.run(os.path.join("bin", "test_package"))
31 changes: 31 additions & 0 deletions test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <graph/Out_adjacency_list.hpp>
using namespace graph;

int main(int argc, char* argv[])
{
// Build a random graph
std::mt19937_64 random;
Out_adjacency_list g;

for (int i = 0; i < 8; ++i)
g.insert_vert();

for (int i = 0; i < 32; ++i) {
auto u = g.random_vert(random), v = g.random_vert(random);
g.insert_edge(u, v);
}

// Assign edge weights
auto weight = g.edge_map<double>();
for (auto e : g.edges())
weight[e] = std::uniform_real_distribution(1.0, 2.0)(random);

// Run Dijkstra's algorithm
auto [tree, distance] = g.shortest_paths_from(g.random_vert(random), weight);

// Output result in dot format
using namespace graph::attributes; // for `_of_vert`
std::cout << tree.dot_format("distance"_of_vert = distance) << std::endl;

return 0;
}