├── .github └── workflows │ └── yocto-validation.yml ├── LICENSE.md ├── README.md ├── classes └── conan.bbclass ├── conf └── layer.conf └── recipes-devtools ├── python3-colorama_%.bbappend ├── python3-conan_2.12.2.bb ├── python3-fasteners_%.bbappend └── python3-patch-ng_1.18.1.bb /.github/workflows/yocto-validation.yml: -------------------------------------------------------------------------------- 1 | name: Yocto Layer Validation 2 | 3 | on: 4 | push: 5 | branches: [ 'conan2/*' ] 6 | paths: 7 | - '**' 8 | - '!README.md' 9 | - '!LICENSE.md' 10 | pull_request: 11 | branches: [ 'conan2/*' ] 12 | paths: 13 | - '**' 14 | - '!README.md' 15 | - '!LICENSE.md' 16 | 17 | jobs: 18 | validate-layer: 19 | runs-on: ubuntu-22.04 20 | 21 | steps: 22 | - name: Extract Yocto release name 23 | run: | 24 | BRANCH_NAME=${GITHUB_REF#refs/heads/} 25 | if [[ $BRANCH_NAME == "conan2/"* ]]; then 26 | YOCTO_RELEASE=$(echo $BRANCH_NAME | cut -d'/' -f2) 27 | else 28 | YOCTO_RELEASE=$(echo $GITHUB_BASE_REF | cut -d'/' -f2) 29 | fi 30 | echo "YOCTO_RELEASE=$YOCTO_RELEASE" >> $GITHUB_ENV 31 | 32 | - name: Checkout meta-conan 33 | uses: actions/checkout@v3 34 | with: 35 | path: meta-conan 36 | 37 | - name: Install dependencies 38 | env: 39 | DEBIAN_FRONTEND: noninteractive 40 | run: | 41 | sudo apt-get -qq update 42 | sudo apt-get -qq install -y --no-install-recommends --no-install-suggests \ 43 | gawk wget git diffstat unzip texinfo gcc build-essential \ 44 | chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils \ 45 | iputils-ping python3-git python3-jinja2 libegl1-mesa-dev libsdl1.2-dev pylint xterm 46 | 47 | - name: Clone Poky 48 | run: | 49 | git clone -b ${{ env.YOCTO_RELEASE }} --depth 1 git://git.yoctoproject.org/poky 50 | cd poky 51 | git checkout -q ${{ env.YOCTO_RELEASE }} 52 | 53 | - name: Clone meta-openembedded 54 | run: | 55 | git clone -b ${{ env.YOCTO_RELEASE }} --depth 1 git://git.openembedded.org/meta-openembedded 56 | cd meta-openembedded 57 | git checkout -q ${{ env.YOCTO_RELEASE }} 58 | 59 | - name: Add Conan Mosquitto example 60 | run: | 61 | mkdir recipes-example 62 | echo 'inherit conan' > recipes-example/conan-mosquitto_2.0.18.bb 63 | echo 'DESCRIPTION = "An open source MQTT broker"' >> recipes-example/conan-mosquitto_2.0.18.bb 64 | echo 'LICENSE = "EPL-1.0"' >> recipes-example/conan-mosquitto_2.0.18.bb 65 | echo 'CONAN_PKG = "mosquitto/2.0.18"' >> recipes-example/conan-mosquitto_2.0.18.bb 66 | 67 | - name: Setup build environment 68 | run: | 69 | source poky/oe-init-build-env build 70 | 71 | echo 'IMAGE_INSTALL:append = " conan-mosquitto"' >> ${{ github.workspace }}/build/conf/local.conf 72 | echo 'CONAN_BUILD_POLICY = "missing"' >> ${{ github.workspace }}/build/conf/local.conf 73 | 74 | bitbake-layers add-layer ../meta-openembedded/meta-oe 75 | bitbake-layers add-layer ../meta-openembedded/meta-python 76 | bitbake-layers add-layer ../meta-conan 77 | 78 | bitbake-layers show-layers 79 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2025 JFrog LTD 4 | 5 | 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | THE SOFTWARE. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Meta Conan: A Yocto layer for Conan client 2 | 3 | [![Yocto Layer Validation](https://github.com/conan-io/meta-conan/actions/workflows/yocto-validation.yml/badge.svg)](https://github.com/conan-io/meta-conan/actions/workflows/yocto-validation.yml) 4 | 5 | 6 | ## Introduction 7 | 8 | This layer collects recipes required to use the Conan Package Manager client in the Yocto builds. 9 | With this layer you can write simple Bitbake recipes to retrieve and deploy Conan packages from an Artifactory repository. 10 | 11 | *conan-mosquitto_2.0.18.bb* 12 | ``` 13 | inherit conan 14 | 15 | DESCRIPTION = "An open source MQTT broker" 16 | LICENSE = "EPL-1.0" 17 | 18 | CONAN_PKG = "mosquitto/2.0.18" 19 | ```` 20 | 21 | ## Conan 2.x support 22 | 23 | This current branch is **only** working with Conan 2.x. If you are using Conan 1.x, please use other branches without the `conan2` prefix. 24 | 25 | ## Documentation 26 | 27 | Read how to use this layer in the Conan documentation: https://docs.conan.io/en/latest/integrations/cross_platform/yocto.html 28 | 29 | **WARNING**: The current documentation is outdated and should not work properly 30 | 31 | ## Requirements 32 | 33 | This layer depends on the `meta-python` layer: https://layers.openembedded.org/layerindex/branch/thud/layer/meta-python/ 34 | 35 | ## Contributing 36 | 37 | Please submit any patches against the `meta-conan` layer by using the GitHub pull-request feature. Use the default branch (currently `conan2/scarthgap`) as base branch. 38 | 39 | ## License 40 | 41 | [MIT](https://github.com/conan-io/conan/blob/develop/LICENSE.md) 42 | -------------------------------------------------------------------------------- /classes/conan.bbclass: -------------------------------------------------------------------------------- 1 | # conan.bbclass 2 | # 3 | # Yocto Project bbclass for Conan.io package manager 4 | # 5 | # This bbclass provides the integration of Conan.io into the Yocto Project 6 | # 7 | # Please open an issue on the GitHub repository if you encounter any problems: 8 | # 9 | # GitHub Repository: https://github.com/conan-io/meta-conan 10 | # Issues: https://github.com/conan-io/meta-conan/issues 11 | 12 | PV = "0.3.0" 13 | LICENSE = "MIT" 14 | DEPENDS:append = " python3-conan-native" 15 | S = "${WORKDIR}" 16 | # INFO: Use /usr/local to avoid conflicts with system packages 17 | prefix = "${base_prefix}/usr/local" 18 | 19 | CONAN_HOME="${TMPDIR}/.conan2" 20 | CONAN_LOGLEVEL ?= "status" 21 | CONAN_DEFAULT_PROFILE="${CONAN_HOME}/profiles/meta_build" 22 | CONAN_REMOTE_URL ?= "" 23 | CONAN_REMOTE_NAME ?= "" 24 | CONAN_PROFILE_BUILD_PATH ?= "${CONAN_HOME}/profiles/meta_build" 25 | CONAN_PROFILE_HOST_PATH ?= "${CONAN_HOME}/profiles/meta_host" 26 | CONAN_SETTINGS_COMPILER_CPPSTD ?= "gnu17" 27 | CONAN_SETTINGS_COMPILER_LIBCXX ?= "libstdc++11" 28 | CONAN_CONFIG_URL ?= "" 29 | CONAN_PROFILE_HOST_OPTIONS ?= "*/*:shared=True" 30 | CONAN_BUILD_POLICY ?= "missing" 31 | CONAN_SETTINGS_BUILD_TYPE ?= "${@'Debug' if d.getVar('DEBUG_BUILD') == '1' else 'Release'}" 32 | CONAN_EXTRA_CFLAGS ?= "${TUNE_CCARGS}" 33 | CONAN_EXTRA_CXXFLAGS ?= "${TUNE_CCARGS}" 34 | CONAN_EXTRA_CONFIG ?= "" 35 | CONAN_CONF_SOURCES_DOWNLOAD_CACHE ?= "${CONAN_HOME}/download_cache" 36 | 37 | export CONAN_HOME 38 | export CONAN_LOG_LEVEL="${CONAN_LOGLEVEL}" 39 | export CONAN_DEFAULT_PROFILE 40 | 41 | def map_yocto_arch_to_conan_arch(d, arch_var): 42 | arch = d.getVar(arch_var) 43 | ret = {"aarch64": "armv8", 44 | "armv5e": "armv5el", 45 | "core2-64": "x86_64", 46 | "cortexa8hf-neon": "armv7hf", 47 | "arm": "armv7hf", 48 | "i586": "x86", 49 | "i686": "x86", 50 | "mips32r2": "mips", 51 | "mips64": "mips64", 52 | "ppc7400": "ppc32" 53 | }.get(arch, arch) 54 | bb.debug(1, f"INFO: Arch value '{arch}' from '{arch_var}' mapped to '{ret}'") 55 | return ret 56 | 57 | def convert_flags_to_list(d, flags): 58 | if not flags: 59 | return "[]" 60 | flag_list = flags.split() 61 | quoted_flags = [f'\\"{flag}\\"' for flag in flag_list] 62 | result = f'[{", ".join(quoted_flags)}]' 63 | return str(result) 64 | 65 | def convert_list_to_lines(d, list_var): 66 | if not list_var: 67 | return "" 68 | list_items = list_var.split() 69 | result = "\n".join(list_items) 70 | return str(result) 71 | 72 | do_configure[network] = "1" 73 | conan_do_configure() { 74 | bbnote "Creating Conan home directory: ${CONAN_HOME}" 75 | mkdir -p "${CONAN_HOME}" 76 | 77 | bbnote "Creating Conan configuration" 78 | printf "core:non_interactive=1\n" > "${CONAN_HOME}/conan.conf" 79 | printf "core:default_build_profile=${CONAN_PROFILE_BUILD_PATH}\n" >> "${CONAN_HOME}/conan.conf" 80 | printf "core:default_profile=${CONAN_PROFILE_HOST_PATH}\n" >> "${CONAN_HOME}/conan.conf" 81 | printf "core.sources:download_cache=${CONAN_CONF_SOURCES_DOWNLOAD_CACHE}\n" >> "${CONAN_HOME}/conan.conf" 82 | 83 | if [ -n "${CONAN_CONFIG_URL}" ]; then 84 | bbnote "Installing Conan configuration from: ${CONAN_CONFIG_URL}" 85 | conan config install "${CONAN_CONFIG_URL}" 86 | else 87 | bbnote "No Conan configuration URL provided, using Conan local cache." 88 | fi 89 | 90 | echo "INFO: Configuring Conan remotes" 91 | if [ -n "${CONAN_REMOTE_URL}" ]; then 92 | urls_size=$( echo ${CONAN_REMOTE_URL} | wc -w ) 93 | names_size=$( echo ${CONAN_REMOTE_NAME} | wc -w ) 94 | bbdebug 1 "Conan remote URLs size: ${urls_size}" 95 | bbdebug 1 "Conan remote names size: ${names_size}" 96 | if [ "${urls_size}" -ne "${names_size}" ]; then 97 | bbfatal "Number of CONAN_REMOTE_URL (${urls_size}) does not equal number of CONAN_REMOTE_NAME (${names_size}).\nPlease, use empty space as separator for both variables." 98 | exit 1 99 | fi 100 | awk 'BEGIN{split("${CONAN_REMOTE_NAME}",a) split("${CONAN_REMOTE_URL}", b); for (i in a) 101 | system("conan remote add --force --index=0 " a[i] " " b[i]) }' 102 | else 103 | bbnote "No Conan remotes provided (CONAN_REMOTE_URL), using Conan default remotes." 104 | fi 105 | cc_major=$(${CC} -dumpfullversion | cut -d'.' -f1) 106 | cc_name=$(echo ${CC} | cut -d' ' -f1) 107 | cxx_name=$(echo ${CXX} | cut -d' ' -f1) 108 | 109 | bbnote "Generating build profile for ${CONAN_PROFILE_BUILD_PATH}" 110 | conan profile detect -f --name="${CONAN_PROFILE_BUILD_PATH}" 111 | 112 | bbnote "Generating host profile for ${CONAN_PROFILE_HOST_PATH}" 113 | formatted_cflags="${@convert_flags_to_list(d, '${CONAN_EXTRA_CFLAGS}')}" 114 | formatted_cxxflags="${@convert_flags_to_list(d, '${CONAN_EXTRA_CXXFLAGS}')}" 115 | formatted_ldflags="${@convert_flags_to_list(d, '${LDFLAGS}')}" 116 | cat > "${CONAN_PROFILE_HOST_PATH}" < ${D}/etc/ld.so.conf.d/conan.conf 188 | } 189 | 190 | conan_do_clean() { 191 | if [ "${CLEAN_CONAN_CACHE}" = "1" ]; then 192 | bbnote "Cleaning Conan cache..." 193 | conan cache clean 194 | fi 195 | } 196 | 197 | FILES:${PN} += "${prefix}/lib/* ${prefix}/bin/*" 198 | EXPORT_FUNCTIONS do_configure do_compile do_install do_clean 199 | -------------------------------------------------------------------------------- /conf/layer.conf: -------------------------------------------------------------------------------- 1 | # We have a conf and classes directory, add to BBPATH 2 | BBPATH .= ":${LAYERDIR}" 3 | 4 | # We have recipes-* directories, add to BBFILES 5 | BBFILES += "${LAYERDIR}/recipes-*/*.bb \ 6 | ${LAYERDIR}/recipes-*/*.bbappend" 7 | 8 | BBFILE_COLLECTIONS += "meta-conan" 9 | BBFILE_PATTERN_meta-conan = "^${LAYERDIR}/" 10 | BBFILE_PRIORITY_meta-conan = "6" 11 | 12 | LAYERDEPENDS_meta-conan = "core meta-python" 13 | LAYERSERIES_COMPAT_meta-conan = "scarthgap gatesgarth dunfell kirkstone langdale" 14 | -------------------------------------------------------------------------------- /recipes-devtools/python3-colorama_%.bbappend: -------------------------------------------------------------------------------- 1 | BBCLASSEXTEND = "native nativesdk" 2 | -------------------------------------------------------------------------------- /recipes-devtools/python3-conan_2.12.2.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Conan C/C++ package manager" 2 | HOMEPAGE = "https://conan.io" 3 | AUTHOR = "JFrog LTD " 4 | LICENSE = "MIT" 5 | LIC_FILES_CHKSUM = "file://LICENSE.md;md5=1e486b3d16485847635c786d2b7bd32a" 6 | 7 | SRC_URI[md5sum] = "c818bd5e4979093ac9fc9c7c988976a8" 8 | SRC_URI[sha256sum] = "b09ff3d7fe8101e3ef55fd0785ae9ffbcd9237ac427da88c975e8c52908ed4f7" 9 | 10 | inherit setuptools3 python3-dir pypi update-alternatives 11 | 12 | # INFO: Overwrite the script to disable run-time dependency checking 13 | 14 | do_install:append(){ 15 | rm "${D}${bindir}/conan" 16 | cat >> "${D}${bindir}/conan" <