-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add conan recipe * Add workflow files * Disable preprocess in test_package * Remove msvc 19.1, since it seems to struggle * Run tests as part of building packages
- Loading branch information
Showing
12 changed files
with
721 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
name: Linux GCC | ||
|
||
on: [push, workflow_dispatch] | ||
|
||
env: | ||
CONAN_UPLOAD: ${{ secrets.CONAN_URL }} | ||
CONAN_PASSWORD_SINTEF: ${{ secrets.CONAN_PASSWORD }} | ||
CONAN_LOGIN_USERNAME_SINTEF: ${{ secrets.CONAN_USER }} | ||
CONFIG_URL: https://github.com/sintef-ocean/conan-configs.git | ||
|
||
jobs: | ||
conan-with-gcc: | ||
name: Conan | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
version: [cci.20230615] | ||
build_type: [Debug, Release] | ||
profile: [gcc] | ||
compiler_version: [10, 11, 12] | ||
channel: ["${{ (github.head_ref || github.ref_name) == 'master' && 'stable' || 'testing' }}"] | ||
container: | ||
image: conanio/gcc${{ matrix.compiler_version }}-ubuntu18.04 | ||
options: -u 0 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install prerequisites | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y jq | ||
pip3 install --upgrade setuptools pip | ||
pip3 install --upgrade conan~=2.0 | ||
- name: Configure Conan and package name | ||
run: | | ||
conan remote add sintef ${{ env.CONAN_UPLOAD }} | ||
echo "pkg_name=$(conan inspect -f json . | jq .name -r)" >> $GITHUB_ENV | ||
- name: Conan create | ||
run: | | ||
git config --global --add safe.directory '*' | ||
conan config install ${{ env.CONFIG_URL }} --type git -sf conan2.0 | ||
conan config install ${{ env.CONFIG_URL }} --type git -sf profiles -tf profiles | ||
conan create -s build_type=${{ matrix.build_type }} \ | ||
-s compiler.version=${{ matrix.compiler_version }} \ | ||
-pr:b=${{ matrix.profile }} -pr:h=${{ matrix.profile }} \ | ||
--conf tools.build:skip_test=False \ | ||
--version ${{ matrix.version }} --user sintef --channel ${{ matrix.channel }} \ | ||
-b missing -b outdated -b ${{ env.pkg_name }}* . | ||
- name: Conan upload | ||
run: conan upload --confirm -r sintef ${{ env.pkg_name }}* --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
name: Windows MSVC | ||
|
||
on: [push, workflow_dispatch] | ||
|
||
env: | ||
CONAN_UPLOAD: ${{ secrets.CONAN_URL }} | ||
CONAN_PASSWORD_SINTEF: ${{ secrets.CONAN_PASSWORD }} | ||
CONAN_LOGIN_USERNAME_SINTEF: ${{ secrets.CONAN_USER }} | ||
CONFIG_URL: https://github.com/sintef-ocean/conan-configs.git | ||
|
||
jobs: | ||
conan-with-msvc: | ||
name: Conan | ||
runs-on: windows-2022 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
version: [cci.20230615] | ||
build_type: [Debug, Release] | ||
profile: [msvc17] | ||
compiler_version: [192, 193] | ||
channel: ["${{ (github.head_ref || github.ref_name) == 'master' && 'stable' || 'testing' }}"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install prerequisites | ||
run: | | ||
pip3 install --upgrade setuptools pip | ||
pip3 install --upgrade conan~=2.0 | ||
- name: Configure Conan | ||
run: | | ||
conan remote add sintef ${{ env.CONAN_UPLOAD }} | ||
$pkg_name=conan inspect -f json . | jq .name -r | ||
echo "pkg_name=$pkg_name" >> $Env:GITHUB_ENV | ||
- name: Conan create | ||
run: | | ||
conan config install ${{ env.CONFIG_URL }} --type git -sf conan2.0 | ||
conan config install ${{ env.CONFIG_URL }} --type git -sf profiles -tf profiles | ||
conan create -s build_type=${{ matrix.build_type }} ` | ||
-s compiler.version=${{ matrix.compiler_version }} ` | ||
-pr:b=${{ matrix.profile }} -pr:h=${{ matrix.profile }} ` | ||
--conf tools.build:skip_test=False ` | ||
--version ${{ matrix.version }} --user sintef --channel ${{ matrix.channel }} ` | ||
-b missing -b outdated -b ${{ env.pkg_name }}* . | ||
- name: Conan upload | ||
run: conan upload --confirm -r sintef ${{ env.pkg_name }}* --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*~ | ||
test_package/build/ | ||
*.pyc | ||
*.swp | ||
*.swo | ||
__pycache__ | ||
temp/ | ||
CMakeUserPresets.json | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
[![Linux GCC](https://github.com/sintef-ocean/conan-xtypes/workflows/Linux%20GCC/badge.svg)](https://github.com/sintef-ocean/conan-xtypes/actions?query=workflow%3A"Linux+GCC") | ||
[![Windows MSVC](https://github.com/sintef-ocean/conan-xtypes/workflows/Windows%20MSVC/badge.svg)](https://github.com/sintef-ocean/conan-xtypes/actions?query=workflow%3A"Windows+MSVC") | ||
|
||
[Conan.io](https://conan.io) recipe for [eprosima xtypes](https://github.com/eProsima/xtypes). | ||
|
||
## How to use this package | ||
|
||
1. Add remote to conan's package [remotes](https://docs.conan.io/2/reference/commands/remote.html) | ||
|
||
```bash | ||
$ conan remote add sintef https://artifactory.smd.sintef.no/artifactory/api/conan/conan-local | ||
``` | ||
|
||
2. Using [*conanfile.txt*](https://docs.conan.io/2/reference/conanfile_txt.html) and *cmake* in your project. | ||
|
||
Add *conanfile.txt*: | ||
``` | ||
[requires] | ||
eprosima-xtypes/cci.20230615@sintef/stable | ||
[options] | ||
eprosima-xtypes:with_tools=True | ||
[tool_requires] | ||
cmake/[>=3.25.0] | ||
[layout] | ||
cmake_layout | ||
[generators] | ||
CMakeDeps | ||
CMakeToolchain | ||
VirtualBuildEnv | ||
``` | ||
Insert into your *CMakeLists.txt* something like the following lines: | ||
```cmake | ||
cmake_minimum_required(VERSION 3.15) | ||
project(TheProject CXX) | ||
find_package(xtypes REQUIRED) | ||
add_executable(the_executor code.cpp) | ||
target_link_libraries(the_executor eprosima::xtypes) | ||
``` | ||
Install and build e.g. a Release configuration (linux): | ||
```bash | ||
$ conan install . -s build_type=Release -pr:b=default | ||
$ source build/Release/generators/conanbuild.sh | ||
$ cmake --preset conan-release | ||
$ cmake --build build/Release | ||
$ source build/Release/generators/deactivate_conanbuild.sh | ||
``` | ||
|
||
## Package options | ||
|
||
| Option | Allowed values | Default | | ||
|---------------------------------|-------------------|---------| | ||
| with_exceptions | [True, False] | True | | ||
| with_tools | [True, False] | False | | ||
|
||
To build and run tests, set `tools.build:skip_test=False` in `global.conf`, in `[conf]` or | ||
`--conf` as part of `conan install`. | ||
|
||
## Known recipe issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
sources: | ||
"cci.20230615": | ||
commit: "16eb3fed587c2c670096c109e76f9faea1bd80e8" | ||
url: "https://github.com/eProsima/xtypes.git" | ||
patches: | ||
"cci.20230615": | ||
- patch_file: "patches/cci.20230615-001-use-conan-dependency-cpp-peglib.patch" | ||
patch_description: "Use cpp-peglib from conan instead of downloading in CMake" | ||
patch_type: "conan" | ||
- patch_file: "patches/cci.20230615-002-key-annotation.patch" | ||
patch-description: "Hack to allow key annotations through idl parsing" | ||
patch_type: "bugfix" | ||
patch_source: "https://github.com/eProsima/xtypes/issues/114" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
import os | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.microsoft import is_msvc | ||
from conan.tools.files import apply_conandata_patches, export_conandata_patches, copy | ||
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout | ||
from conan.tools.env import Environment | ||
from conan.tools.scm import Git, Version | ||
|
||
required_conan_version = ">=2.0" | ||
|
||
|
||
class PackageConan(ConanFile): | ||
name = "eprosima-xtypes" | ||
description = "Header-only OMG DDS-XTYPES standard implementation" | ||
license = "Apache-2.0" | ||
url = "https://github.com/sintef-ocean/conan-xtypes" | ||
homepage = "https://github.com/eProsima/xtypes" | ||
topics = ("dds-xtypes", "omg standard", "dds") | ||
package_type = "header-library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
no_copy_source = False # True if no patch | ||
options = { | ||
"with_exceptions": [True, False], | ||
"with_tools": [True, False], | ||
} | ||
default_options = { | ||
"with_exceptions": True, | ||
"with_tools": False, | ||
} | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 17 | ||
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"msvc": "14.2", | ||
"gcc": "7", | ||
"clang": "6", | ||
"apple-clang": "10", | ||
} | ||
|
||
@property | ||
def _build_tests(self): | ||
return not self.conf.get("tools.build:skip_test", default=True) | ||
|
||
@property | ||
def _build_needed(self): | ||
return self.options.with_tools or self._build_tests | ||
|
||
def export_sources(self): | ||
export_conandata_patches(self) | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def requirements(self): | ||
self.requires("cpp-peglib/1.8.4", transitive_headers=True) | ||
|
||
def package_id(self): | ||
if not self.info.options.with_tools: | ||
self.info.settings.compiler.clear() | ||
else: | ||
self.info.settings.clear() | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
check_min_cppstd(self, self._min_cppstd) | ||
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) | ||
if minimum_version and Version(self.settings.compiler.version) < minimum_version: | ||
raise ConanInvalidConfiguration( | ||
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." | ||
) | ||
|
||
def build_requirements(self): | ||
if self._build_tests: | ||
self.test_requires("gtest/1.13.0") | ||
if self._build_needed: | ||
if is_msvc(self): | ||
self.tool_requires("cmake/[>=3.22.0 <4]") | ||
else: | ||
self.tool_requires("cmake/[>=3.16.0 <4]") | ||
|
||
def source(self): | ||
git = Git(self) | ||
git.clone(self.conan_data["sources"][self.version]["url"], target=".") | ||
git.checkout(self.conan_data["sources"][self.version]["commit"]) | ||
|
||
def generate(self): | ||
|
||
if not self._build_needed: | ||
return | ||
|
||
tc = CMakeToolchain(self) | ||
tc.variables["XTYPES_EXCEPTIONS"] = self.options.with_exceptions | ||
tc.variables["XTYPES_BUILD_TOOLS"] = self.options.with_tools | ||
tc.variables["XTYPES_BUILD_TESTS"] = self._build_tests | ||
tc.variables["XTYPES_EXAMPLES"] = False | ||
tc.variables["XTYPES_PEGLIB_VERSION"] = f"v{str(self.dependencies['cpp-peglib'].ref.version)}" | ||
tc.generate() | ||
|
||
deps = CMakeDeps(self) | ||
if self._build_tests: | ||
deps.build_context_activated = ["gtest"] | ||
|
||
deps.generate() | ||
|
||
def build(self): | ||
apply_conandata_patches(self) | ||
|
||
if not (self.options.with_tools or self._build_tests): | ||
return | ||
|
||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
if self._build_tests: | ||
env = Environment() | ||
env.define("CTEST_OUTPUT_ON_FAILURE", "ON") | ||
with env.vars(self).apply(): | ||
cmake.test() | ||
|
||
def package(self): | ||
|
||
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) | ||
copy( | ||
self, | ||
pattern="xtypes_idl_validator*", | ||
dst=os.path.join(self.package_folder, "bin"), | ||
src=self.build_folder, | ||
keep_path=False | ||
) | ||
copy( | ||
self, | ||
pattern="*.hpp", | ||
dst=os.path.join(self.package_folder, "include"), | ||
src=os.path.join(self.source_folder, "include"), | ||
keep_path=True | ||
) | ||
|
||
def package_info(self): | ||
self.cpp_info.bindirs = ["bin"] if self.options.with_tools else [] | ||
self.cpp_info.libdirs = [] | ||
|
||
if self.options.with_exceptions: | ||
self.cpp_info.defines.append("XTYPES_EXCEPTIONS") | ||
|
||
self.cpp_info.set_property("cmake_file_name", "xtypes") | ||
self.cpp_info.set_property("cmake_target_name", "eprosima::xtypes") | ||
|
||
# Missing: set_target_properties(xtypes PROPERTIES INTERFACE_COMPILE_FEATURES "cxx_std_17;cxx_variadic_macros") | ||
# TODO: how to handle this properly. Add own cmake module, which is auto-included with find_package? | ||
|
||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs = ["pthread"] | ||
self.cpp_info.cxxflags.append("-pthread") | ||
self.cpp_info.exelinkflags.append("-pthread") | ||
self.cpp_info.sharedlinkflags.append("-pthread") | ||
if is_msvc(self): | ||
self.cpp_info.cxxflags.append("/Zc:__cplusplus") | ||
self.cpp_info.cxxflags.append("/Zc:preprocessor /execution-charset:UTF-8") |
Oops, something went wrong.