瀏覽代碼

Conan: Add CI setup #163

Michele Caini 7 年之前
父節點
當前提交
72d4e947b6
共有 5 個文件被更改,包括 98 次插入3 次删除
  1. 36 1
      .travis.yml
  2. 4 2
      README.md
  3. 45 0
      conan/build.py
  4. 7 0
      conan/ci/build.sh
  5. 6 0
      conan/ci/install.sh

+ 36 - 1
.travis.yml

@@ -2,6 +2,38 @@ language: cpp
 dist: trusty
 sudo: false
 
+env:
+  global:
+    - CONAN_USERNAME="skypjack"
+    - CONAN_PACKAGE_NAME="entt"
+    - CONAN_HEADER_ONLY="True"
+    - NON_CONAN_DEPLOYMENT="True"
+
+conan-buildsteps: &conan-buildsteps
+  before_install:
+    # use this step if you desire to manipulate CONAN variables programmatically
+    - NON_CONAN_DEPLOYMENT="False"
+  install:
+    - chmod +x ./conan/ci/install.sh
+    - ./conan/ci/install.sh
+  script:
+    - chmod +x ./conan/ci/build.sh
+    - ./conan/ci/build.sh
+  # the following are dummies to overwrite default build steps
+  before_script:
+    - true
+  after_success:
+    - true
+  if: tag IS present
+conan-linux: &conan-linux
+  os: linux
+  sudo: required
+  language: python
+  python: "3.6"
+  services:
+    - docker
+  <<: *conan-buildsteps
+
 matrix:
   include:
   - os: linux
@@ -35,6 +67,9 @@ matrix:
       - pip install --user cpp-coveralls
     after_success:
       - coveralls --gcov gcov-7 --gcov-options '\-lp' --root ${TRAVIS_BUILD_DIR} --build-root ${TRAVIS_BUILD_DIR}/build --extension cpp --extension hpp --exclude deps --include src
+  # Conan testing and uploading
+  - <<: *conan-linux
+    env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
 
 notifications:
   email:
@@ -59,4 +94,4 @@ deploy:
   script: scripts/update_packages.sh $TRAVIS_TAG
   on:
     tags: true
-    condition: “$TRAVIS_BRANCH” = “$TRAVIS_TAG
+    condition: “$NON_CONAN_DEPLOYMENT = “True

+ 4 - 2
README.md

@@ -287,14 +287,16 @@ Note that benchmarks are not part of this set.
 
 `EnTT` is available for some of the most known packaging tools. In particular:
 
-* [`vcpkg`](https://github.com/Microsoft/vcpkg/tree/master/ports/entt),
-  Microsoft VC++ Packaging Tool.
+* [`Conan`](https://bintray.com/skypjack/conan/entt%3Askypjack/_latestVersion),
+  the C/C++ Package Manager for Developers.
 * [`Homebrew`](https://github.com/skypjack/homebrew-entt), the missing package
   manager for macOS.<br/>
   Available as a homebrew formula. Just type the following to install it:
   ```
   brew install skypjack/entt/entt
   ```
+* [`vcpkg`](https://github.com/Microsoft/vcpkg/tree/master/ports/entt),
+  Microsoft VC++ Packaging Tool.
 
 Consider this list a work in progress and help me to make it longer.
 

+ 45 - 0
conan/build.py

@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+from cpt.packager import ConanMultiPackager
+import os
+
+if __name__ == "__main__":
+    login_username = os.getenv("CONAN_LOGIN_USERNAME")
+    username = os.getenv("CONAN_USERNAME")
+    tag_version = os.getenv("CONAN_PACKAGE_VERSION", os.getenv("TRAVIS_TAG"))
+    package_version = tag_version.replace("v", "")
+    package_name_unset = "SET-CONAN_PACKAGE_NAME-OR-CONAN_REFERENCE"
+    package_name = os.getenv("CONAN_PACKAGE_NAME", package_name_unset)
+    reference = "{}/{}".format(package_name, package_version)
+    channel = os.getenv("CONAN_CHANNEL", "stable")
+    upload = os.getenv("CONAN_UPLOAD")
+    stable_branch_pattern = os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+.*")
+    test_folder = os.getenv("CPT_TEST_FOLDER", os.path.join("conan", "test_package"))
+    upload_only_when_stable = os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True)
+    header_only = os.getenv("CONAN_HEADER_ONLY", False)
+    pure_c = os.getenv("CONAN_PURE_C", False)
+
+    disable_shared = os.getenv("CONAN_DISABLE_SHARED_BUILD", "False")
+    if disable_shared == "True" and package_name == package_name_unset:
+        raise Exception("CONAN_DISABLE_SHARED_BUILD: True is only supported when you define CONAN_PACKAGE_NAME")
+
+    builder = ConanMultiPackager(username=username,
+                                 reference=reference,
+                                 channel=channel,
+                                 login_username=login_username,
+                                 upload=upload,
+                                 stable_branch_pattern=stable_branch_pattern,
+                                 upload_only_when_stable=upload_only_when_stable,
+                                 test_folder=test_folder)
+    if header_only == "False":
+        builder.add_common_builds(pure_c=pure_c)
+    else:
+        builder.add()
+
+    filtered_builds = []
+    for settings, options, env_vars, build_requires, reference in builder.items:
+        if disable_shared == "False" or not options["{}:shared".format(package_name)]:
+             filtered_builds.append([settings, options, env_vars, build_requires])
+    builder.builds = filtered_builds
+
+    builder.run()

+ 7 - 0
conan/ci/build.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -e
+set -x
+
+conan user
+python conan/build.py

+ 6 - 0
conan/ci/install.sh

@@ -0,0 +1,6 @@
+#!/bin/bash
+
+set -e
+set -x
+
+pip install -U conan_package_tools conan