Skip to content

Add Yocto example: Consume mosquitto via meta-conan #178

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions examples/cross_build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
### [Use Android NDK to cross-build](android/ndk_basic)

- Learn how to cross-build packages for Android. [Docs](https://docs.conan.io/2/examples/cross_build/android.html)

### [Use Conan to install Yocto dependencies](yocto)

- Use meta-conan to install mosquitto as Yocto dependency. [Docs](https://docs.conan.io/2/integrations/yocto.html)
56 changes: 56 additions & 0 deletions examples/cross_build/yocto/ci_test_example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

set -ex

if [ "$(uname)" != "Linux" ]; then
echo "INFO: Skipping Yocto build on non-Linux platform."
exit 0
fi

yocto_release=scarthgap

echo "- Yocto - Consume Mosquitto from Conan -"

rm -rf poky

echo "INFO: Cloning Yocto layers"
git clone --branch ${yocto_release} --depth 1 https://git.yoctoproject.org/poky.git poky
git clone --branch ${yocto_release} --depth 1 https://github.com/openembedded/meta-openembedded.git poky/meta-openembedded
git clone --branch conan2/${yocto_release} https://github.com/conan-io/meta-conan.git poky/meta-conan

mkdir -p poky/meta-conan/recipes-example
cp conan-mosquitto_2.0.18.bb poky/meta-conan/recipes-example/conan-mosquitto_2.0.18.bb

cd poky/
source oe-init-build-env

if [ -n "${CONAN_YOCTO_BUILD_MOSQUITTO}" ]; then

echo "INFO: Adding layers"
bitbake-layers add-layer ../meta-openembedded/meta-oe
bitbake-layers add-layer ../meta-openembedded/meta-python
bitbake-layers add-layer ../meta-conan

echo "INFO: Present layers"
bitbake-layers show-layers


echo 'IMAGE_INSTALL:append = " conan-mosquitto"' >> conf/local.conf

echo "INFO: Fetching mosquitto"
bitbake -v -c fetch conan-mosquitto

echo "INFO: Building mosquitto"
bitbake -v -c configure conan-mosquitto
bitbake -v -c compile conan-mosquitto
bitbake -v -c package conan-mosquitto
else:
echo "INFO: Skipping mosquitto build due large time. Set the environment variable CONAN_YOCTO_BUILD_MOSQUITTO to build mosquitto."
fi

if [ -n "${CONAN_YOCTO_BUILD_IMAGE}" ]; then
echo "INFO: Building core-image-minimal"
bitbake -v core-image-minimal
else:
echo "INFO: Skipping image build due large time. Set the environment variable CONAN_YOCTO_BUILD_IMAGE to build image."
fi
5 changes: 5 additions & 0 deletions examples/cross_build/yocto/conan-mosquitto_2.0.18.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
inherit conan

DESCRIPTION = "An open source MQTT broker"
LICENSE = "EPL-1.0"
CONAN_PKG = "mosquitto/2.0.18"