Переглянути джерело

Merge branch '157-conan_packaging'

main
offa 4 роки тому
джерело
коміт
97d5b88c4e
7 змінених файлів з 103 додано та 12 видалено
  1. +1
    -0
      .gitignore
  2. +44
    -0
      conanfile.py
  3. +0
    -8
      conanfile.txt
  4. +7
    -4
      script/ci_build.sh
  5. +14
    -0
      test_package/CMakeLists.txt
  6. +25
    -0
      test_package/conanfile.py
  7. +12
    -0
      test_package/example.cpp

+ 1
- 0
.gitignore Переглянути файл

@@ -1 +1,2 @@
build/*
test_package/build/*

+ 44
- 0
conanfile.py Переглянути файл

@@ -0,0 +1,44 @@
from conans import ConanFile, CMake


class ScopeguardConan(ConanFile):
name = "scope-guard"
version = "v0.3.4"
license = "MIT"
author = "offa <offa@github>"
url = "https://github.com.offa/scope-guard"
description = "Implementation of Scoped Guards and Unique Resource as proposed in P0052."
homepage = "https://github.com/offa/scope-guard"
topics = ("cpp", "cpp17", "p0052", "scope-guard",
"scope-exit", "scope-fail", "scope-success", "unique-resource", "cmake")
no_copy_source = True
_source_dir = "{}-{}".format(name, version)
scm = {
"type": "git",
"subfolder": _source_dir,
"url": "{}.git".format(homepage),
"revision": version
}
requires = (
"Catch2/2.11.0@catchorg/stable",
"trompeloeil/v35@rollbear/stable"
)
options = {
"unittest": ["ON", "OFF"],
"enable_compat_header": ["ON", "OFF"]
}
default_options = (
"unittest=ON",
"enable_compat_header=OFF"
)

def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["UNITTEST"] = self.options.unittest
cmake.definitions["ENABLE_COMPAT_HEADER"] = self.options.enable_compat_header
cmake.configure(source_folder=self._source_dir, build_folder="build")
return cmake

def package(self):
cmake = self._configure_cmake()
cmake.install()

+ 0
- 8
conanfile.txt Переглянути файл

@@ -1,8 +0,0 @@
[requires]
Catch2/2.9.2@catchorg/stable
trompeloeil/v35@rollbear/stable

[generators]
cmake_find_package
cmake_paths


+ 7
- 4
script/ci_build.sh Переглянути файл

@@ -5,18 +5,21 @@ set -ex
# Conan
apt-get install -y python3-pip
pip3 install conan
conan profile new default --detect

if [[ "${CXX}" == clang* ]]
then
export CXXFLAGS="-stdlib=libc++"
CONAN_STDLIB=libc++
else
CONAN_STDLIB=libstdc++11
conan profile update settings.compiler.libcxx=libstdc++11 default
fi

mkdir build && cd build
conan install -s compiler.libcxx=${CONAN_STDLIB} ..

conan install \
-g cmake_find_package \
-g cmake_paths \
..

cmake ..
make

+ 14
- 0
test_package/CMakeLists.txt Переглянути файл

@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.11)
project(PackageTest CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)


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

add_executable(example example.cpp)
target_link_libraries(example ${CONAN_LIBS})


+ 25
- 0
test_package/conanfile.py Переглянути файл

@@ -0,0 +1,25 @@
import os

from conans import ConanFile, CMake, tools


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

def build(self):
cmake = CMake(self)
# Current dir is "test_package/build/<build_id>" and CMakeLists.txt is
# in "test_package"
cmake.configure()
cmake.build()

def imports(self):
self.copy("*.dll", dst="bin", src="bin")
self.copy("*.dylib*", dst="bin", src="lib")
self.copy('*.so*', dst='bin', src='lib')

def test(self):
if not tools.cross_building(self.settings):
os.chdir("bin")
self.run(".%sexample" % os.sep)

+ 12
- 0
test_package/example.cpp Переглянути файл

@@ -0,0 +1,12 @@
#include <iostream>
#include <scope.h>

int main()
{
sr::scope_exit se{[]{}};
sr::scope_fail sf{[]{}};
sr::scope_success ss{[]{}};
sr::unique_resource ur{3, [](auto x){}};

return 0;
}

Завантаження…
Відмінити
Зберегти