Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
37 changes: 5 additions & 32 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,6 @@ stages:
- build
- deploy

bionic-build:
stage: build
image: pllee4/ubuntu-ci:18.04
variables:
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- apt-get install -y libeigen3-dev
script:
- mkdir build && cd build
- cmake ..
- cmake --build .

bionic-staging:
stage: deploy
only:
- master
image: pllee4/ubuntu-ci:18.04
variables:
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- apt-get install -y libeigen3-dev
- conan remote add gitlab https://gitlab.com/api/v4/packages/conan
script:
# build conan package
- conan create . pinloon+public+algorithm/devel
- CONAN_LOGIN_USERNAME=ci_user CONAN_PASSWORD=${CI_JOB_TOKEN} conan upload algorithm/0.3.1@pinloon+public+algorithm/devel --all --remote=gitlab
dependencies:
- bionic-build

focal-build:
stage: build
image: pllee4/ubuntu-ci:20.04
Expand All @@ -52,10 +23,12 @@ focal-staging:
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- apt-get install -y libeigen3-dev
- conan remote add gitlab https://gitlab.com/api/v4/packages/conan
# Conan 2 only works with the project-level registry, not the instance-level one
- conan remote add gitlab ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/conan
script:
# build conan package
- conan create . pinloon+public+algorithm/devel
- CONAN_LOGIN_USERNAME=ci_user CONAN_PASSWORD=${CI_JOB_TOKEN} conan upload algorithm/0.3.1@pinloon+public+algorithm/devel --all --remote=gitlab
- conan profile detect
- conan create . --user=pinloon+public+algorithm --channel=devel --build=missing
- CONAN_LOGIN_USERNAME=ci_user CONAN_PASSWORD=${CI_JOB_TOKEN} conan upload "algorithm/*@pinloon+public+algorithm/devel" --remote=gitlab -c
dependencies:
- focal-build
50 changes: 40 additions & 10 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.files import collect_libs


class AlgorithmConan(ConanFile):
name = "algorithm"
Expand All @@ -8,22 +10,50 @@ class AlgorithmConan(ConanFile):
author = "Pin Loon Lee"
url = "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/pllee4/algorithm"
description = "Algorithm"
# CMakeLists.txt hardcodes STATIC, so there is no shared variant to offer
package_type = "static-library"

# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
default_options = {"shared": False}
generators = "CMakeToolchain", "CMakeDeps"
exports_sources = "*"
options = {"fPIC": [True, False]}
default_options = {"fPIC": True}

# Sources are located in the same place as this recipe, copy them to the recipe
# cmake/ holds algorithmConfig.cmake.in, third_party/ only satisfies the googletest check
exports_sources = "CMakeLists.txt", "cmake/*", "src/*", "include/*", "third_party/*"

def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")

def requirements(self):
# Public headers include <Eigen/Core>, and algorithmConfig.cmake calls find_package(Eigen3)
self.requires("eigen/3.4.0", transitive_headers=True)

def layout(self):
self.cpp.package.includedirs = ["include"]
self.cpp.package.libs = ["algorithm"]
cmake_layout(self)

def build(self, variables=["-DALGO_PACK=true"]):
def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
# Skip tests and coverage flags when packaging
tc.cache_variables["ALGO_PACK"] = True
tc.generate()

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

def package(self):
cmake = CMake(self)
cmake.configure()
cmake.install()
cmake.install()

def package_info(self):
# CMakeDeps writes algorithm-config.cmake into the consumer's install folder,
# so a consumer only needs that folder on CMAKE_PREFIX_PATH
self.cpp_info.set_property("cmake_file_name", "algorithm")
self.cpp_info.set_property("cmake_target_name", "pllee4::algorithm")
# Picks up whatever archives CMake installed, instead of hardcoding them
self.cpp_info.libs = collect_libs(self)
Loading