-
Notifications
You must be signed in to change notification settings - Fork 3
[conan] Add header-only style conan support #9
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| 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 | ||
| 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 | ||
|
Fohlen marked this conversation as resolved.
|
||
| if which pyenv > /dev/null; then | ||
| eval "$(pyenv init -)" | ||
| fi | ||
| pyenv activate conan | ||
| fi | ||
|
|
||
| python build.py | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| repository: | ||
|
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/*" | ||
|
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: [] | ||
| 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 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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/channelBut I'm probably missing something.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory this could be done. However the |
||
| - ./.ci/install.sh | ||
|
|
||
| script: | ||
| - chmod +x .ci/run.sh | ||
| - ./.ci/run.sh | ||
This file was deleted.
| 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 | ||
|
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 | ||
| 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() |
| 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" | ||
|
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() | ||
| 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}) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/usr/bin/env python | ||
|
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")) | ||
| 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; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.