From d9d6862e4b8fc32b32fa73aa561fc863e2bbbe66 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sun, 26 May 2024 18:01:56 +0200 Subject: [PATCH] odr test package (#1) --- .github/workflows/build.yml | 11 ++++++-- recipes/odrcore/all/conanfile.py | 7 ++++- .../odrcore/all/test_package/CMakeLists.txt | 7 +++++ recipes/odrcore/all/test_package/conanfile.py | 26 +++++++++++++++++++ .../odrcore/all/test_package/test_package.cpp | 5 ++++ 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 recipes/odrcore/all/test_package/CMakeLists.txt create mode 100644 recipes/odrcore/all/test_package/conanfile.py create mode 100644 recipes/odrcore/all/test_package/test_package.cpp diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 14d2da3..c4a3fba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,7 @@ name: build_test on: + workflow_dispatch: push: branches: - main @@ -88,15 +89,21 @@ jobs: ${{ matrix.config.os }}-${{ matrix.config.compiler }}- - name: conan install - run: conan install ${{ matrix.package.conanfile }} --version ${{ matrix.package.version }} --build=missing + run: conan install ${{ matrix.package.conanfile }} --version ${{ matrix.package.version }} --build missing - name: conan source run: conan source ${{ matrix.package.conanfile }} --version ${{ matrix.package.version }} - name: conan build run: conan build ${{ matrix.package.conanfile }} --version ${{ matrix.package.version }} - name: conan export run: conan export ${{ matrix.package.conanfile }} --version ${{ matrix.package.version }} + - name: conan export-pkg + run: conan export-pkg ${{ matrix.package.conanfile }} --version ${{ matrix.package.version }} - # test_package + - name: conan test + run: | + test_conanfile=$(dirname ${{ matrix.package.conanfile }})/test_package/conanfile.py + conan test $test_conanfile ${{ matrix.package.package_version }} --build missing - name: conan upload + if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' run: conan upload "*" --check --confirm --remote odr diff --git a/recipes/odrcore/all/conanfile.py b/recipes/odrcore/all/conanfile.py index 39db286..612ded9 100644 --- a/recipes/odrcore/all/conanfile.py +++ b/recipes/odrcore/all/conanfile.py @@ -102,4 +102,9 @@ def package(self): cmake.install() def package_info(self): - self.cpp_info.libs = ["odr"] + if Version(self.version) <= "1.0.0": + self.cpp_info.libs = ["odrlib"] + elif Version(self.version) <= "2.0.0": + self.cpp_info.libs = ["odr-static"] + else: + self.cpp_info.libs = ["odr"] diff --git a/recipes/odrcore/all/test_package/CMakeLists.txt b/recipes/odrcore/all/test_package/CMakeLists.txt new file mode 100644 index 0000000..9f00050 --- /dev/null +++ b/recipes/odrcore/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(odrcore REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE odrcore::odrcore) diff --git a/recipes/odrcore/all/test_package/conanfile.py b/recipes/odrcore/all/test_package/conanfile.py new file mode 100644 index 0000000..93cd04f --- /dev/null +++ b/recipes/odrcore/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +import os +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/odrcore/all/test_package/test_package.cpp b/recipes/odrcore/all/test_package/test_package.cpp new file mode 100644 index 0000000..0e004b5 --- /dev/null +++ b/recipes/odrcore/all/test_package/test_package.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + return 0; +}