Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zenoh-c-prebuilt Conan recipe #334

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
141 changes: 141 additions & 0 deletions conan-recipes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Conan specific
**/test_package/build/
**/test_package/build-*/
**/test_package/test_output/
conan.lock
conanbuildinfo.cmake
conanbuildinfo.txt
conaninfo.txt
graph_info.json
build/

# CMake
CMakeUserPresets.json

# IDEs
.idea
.vs
.vscode
.project
.pydevproject
.settings/
.ropeproject/
.devcontainer/
## emacs
*~

# Byte-compiled / optimized / DLL files / Cache
__pycache__/
**/test_package/__pycache__/
*.pyc
*.py[cod]
*$py.class
tmp/
.DS_Store

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# scons build files
*.dblite

# vim temp files
.*.sw?
.sw?
Session.vim
*~
.undodir
29 changes: 29 additions & 0 deletions conan-recipes/prebuilt/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
sources:
"0.10.1-rc":
"Windows":
"x86_64":
url: "https://github.com/eclipse-zenoh/zenoh-c/releases/download/0.10.1-rc/zenoh-c-0.10.1-rc-x86_64-pc-windows-msvc.zip"
sha256: "a59a4c33a160298409649f16bee5f32f14de52c03273fe29d4497934cf05789e"
"Linux":
"x86_64":
url: "https://github.com/eclipse-zenoh/zenoh-c/releases/download/0.10.1-rc/zenoh-c-0.10.1-rc-x86_64-unknown-linux-gnu.zip"
sha256: "0554b0fe753df3c023b09e005b309d654b1cc33ddc34190b5a5c370b72281c3b"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been thinking on this for a few days to figure out how to deal with tagged releases and Conan packages on a few of the uProtocol libraries I'm working on, and have a question:

What is the workflow for making a tagged release? It looks like a tag would first need to be added and all of the binaries built / published. Then a follow-up commit after the tagged commit would update the recipes so the Conan packages can be built from the new release. Is that correct?

That would mean that the tagged commit is not actually 100% the release because the recipes are wrong. But the tag can't be moved after the recipes are updated (maybe only in the build from source case?) without changing some of the hashes.

I'm sure I'm just missing a step somewhere 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, there is a bootstrap-like problem. It's something we have discussed internally and so far moving the tag and updating the hashes seems to be the way to go. This will be done as part of the release process.

"armv6":
url: "https://github.com/eclipse-zenoh/zenoh-c/releases/download/0.10.1-rc/zenoh-c-0.10.1-rc-arm-unknown-linux-gnueabi.zip"
sha256: "ca76eccb4dae25e0571f8724e161e26230137ee6134d8452548b94de174c9cb9"
"armv7hf":
url: "https://github.com/eclipse-zenoh/zenoh-c/releases/download/0.10.1-rc/zenoh-c-0.10.1-rc-armv7-unknown-linux-gnueabihf.zip"
sha256: "542099758e543abec289daeff2fcf8eef26dc997832de2f13ac7e15b0b05474f"
"armv8":
url: "https://github.com/eclipse-zenoh/zenoh-c/releases/download/0.10.1-rc/zenoh-c-0.10.1-rc-aarch64-unknown-linux-gnu.zip"
sha256: "1def0f7b7d7cd04ac6583d4c7ce96c82af7f2407422a54d778f658527da0e6ea"
"Macos":
"x86_64":
url: "https://github.com/eclipse-zenoh/zenoh-c/releases/download/0.10.1-rc/zenoh-c-0.10.1-rc-x86_64-apple-darwin.zip"
sha256: "bd44c88b8ba3d8245d97f780fe82873ed8ee87c09c37365509e2feae2a198e28"
"armv8":
url: "https://github.com/eclipse-zenoh/zenoh-c/releases/download/0.10.1-rc/zenoh-c-0.10.1-rc-aarch64-apple-darwin.zip"
sha256: "0df497b16cf1bd968deea36aca43d6c086a54d69ea78e3feaed309760e0dcaa4"
"license":
url: "https://github.com/eclipse-zenoh/zenoh-c/raw/0.10.1-rc/LICENSE"
sha256: "01a44774f7b1a453595c7c6d7f7308284ba6a1059dc49e14dad6647e1d44a338"
94 changes: 94 additions & 0 deletions conan-recipes/prebuilt/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#
# Copyright (c) 2024 ZettaScale Technology
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# ZettaScale Zenoh Team, <[email protected]>
#
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import copy, download, get
from conan.tools.scm import Version

import platform
import os

required_conan_version = ">=1.53.0"

class ZenohCPackageConan(ConanFile):
name = "zenohc"
description = "C-API for Eclipse Zenoh: Zero Overhead Pub/Sub, Store/Query and Compute protocol"
tags = ["iot", "networking", "robotics", "messaging", "ros2", "edge-computing", "micro-controller", "pre-built"]
license = "EPL-2.0 OR Apache-2.0"
author = "ZettaScale Zenoh Team <[email protected]>"

url = "https://github.com/eclipse-zenoh/zenoh-c"
homepage = "https://github.com/eclipse-zenoh/zenoh-c"

package_type = "library"
settings = "os", "compiler", "build_type", "arch"

options = {
"shared": [True],
}
default_options = {
"shared": True,
}

@property
def _supported_platforms(self):
return [
("Windows", "x86_64"),
("Linux", "x86_64"),
("Linux", "armv6"),
("Linux", "armv7hf"),
("Linux", "armv8"),
("Macos", "x86_64"),
("Macos", "armv8"),
]

def layout(self):
pass

def configure(self):
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

def package_id(self):
del self.info.settings.compiler
del self.info.settings.build_type

def validate(self):
if (self.settings.os, self.settings.arch) not in self._supported_platforms:
raise ConanInvalidConfiguration("{}/{} target is not supported".format(self.settings.os, self.settings.arch))
if self.settings.os == "Linux":
libver = platform.libc_ver()
print(libver)
if libver[0] == "glibc" and Version(libver[1]) < '2.29':
raise ConanInvalidConfiguration("This library requires glibc >= 2.29")

def source(self):
pass

def build(self):
get(self, **self.conan_data["sources"][self.version][str(self.settings.os)][str(self.settings.arch)])
download(self, **self.conan_data["sources"][self.version]["license"], filename="LICENSE")

def package(self):
copy(self, "LICENSE", self.build_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "*", os.path.join(self.build_folder, "lib"), os.path.join(self.package_folder, "lib"))
copy(self, "*", os.path.join(self.build_folder, "include"), os.path.join(self.package_folder, "include"))

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "zenohc")
self.cpp_info.set_property("cmake_target_name", "zenohc::lib")

self.cpp_info.libs = ["zenohc"]
self.cpp_info.libdirs = ["lib"]
self.cpp_info.includedirs = ["include"]
8 changes: 8 additions & 0 deletions conan-recipes/prebuilt/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.16)

project(test_package LANGUAGES C)

find_package(zenohc REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE zenohc::lib)
31 changes: 31 additions & 0 deletions conan-recipes/prebuilt/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run


class ZenohCPackageTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.tool_requires("cmake/[>=3.16 <4]")
self.requires(self.tested_reference_str)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure why, but with conan 1.63 this didn't work for me. I had to move the tool_requires statement out of requirements(). The documentation indicates that either one should work.

Suggested change
test_type = "explicit"
def requirements(self):
self.tool_requires("cmake/[>=3.16 <4]")
self.requires(self.tested_reference_str)
test_type = "explicit"
tool_requires = "cmake/[>=3.16 <4]"
def requirements(self):
self.requires(self.tested_reference_str)

It is entirely possible this is just something I was doing wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gregmedd Thank you for testing it on 1.63, as I personally only tested with conan v2. I will look into this issue as soon as possible.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oteffahi Happy to help out. Thanks for getting these recipes put together, by the way - they're going to help a lot of uProtocol users and developers!

Let me know if you want me to pull this branch and test in my environment again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gregmedd The issue was happening because the tool_requires was being called in requirements instead of build_requirements. Conan2 does not raise an error in this case, but older versions do. Fixed in Move tool_requires to build_requirements function.


def layout(self):
cmake_layout(self)

def configure(self):
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

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

def test(self):
if can_run(self):
cmd = os.path.join(self.cpp.build.bindir, "test_package")
self.run(cmd, env="conanrun")
8 changes: 8 additions & 0 deletions conan-recipes/prebuilt/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "zenoh.h"

int main(int argc, char **argv) {
(void)argc;
(void)argv;
z_owned_config_t config = z_config_default();
return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions conan-recipes/prebuilt/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.10.1-rc":
folder: all
Loading