Skip to content
Open
112 changes: 80 additions & 32 deletions classes/cmakebuilder.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,41 @@ OECMAKE_SOURCEPATH ??= "${S}"
DEPENDS_prepend = "cmake-native "
B = "${WORKDIR}/build"

# We need to unset CCACHE otherwise cmake gets too confused
CCACHE = ""

# What CMake generator to use.
# The supported options are "Unix Makefiles" or "Ninja".
OECMAKE_GENERATOR ?= "Ninja"

python() {
generator = d.getVar("OECMAKE_GENERATOR")
if generator == "Unix Makefiles":
args = "-G 'Unix Makefiles' -DCMAKE_MAKE_PROGRAM=" + d.getVar("MAKE")
if "Unix Makefiles" in generator:
args = "-G '" + generator + "' -DCMAKE_MAKE_PROGRAM=" + d.getVar("MAKE")
d.setVar("OECMAKE_GENERATOR_ARGS", args)
d.setVarFlag("do_compile", "progress", "percent")
elif generator == "Ninja":
elif "Ninja" in generator:
args = "-G '" + generator + "' -DCMAKE_MAKE_PROGRAM=ninja"
d.appendVar("DEPENDS", " ninja-native")
d.setVar("OECMAKE_GENERATOR_ARGS", "-G Ninja -DCMAKE_MAKE_PROGRAM=ninja")
d.setVarFlag("do_compile", "progress", "outof:^\[(\d+)/(\d+)\]\s+")
d.setVar("OECMAKE_GENERATOR_ARGS", args)
d.setVarFlag("do_compile", "progress", r"outof:^\[(\d+)/(\d+)\]\s+")
else:
bb.fatal("Unknown CMake Generator %s" % generator)

# C/C++ Compiler (without cpu arch/tune arguments)
if not d.getVar('OECMAKE_C_COMPILER'):
cc_list = d.getVar('CC').split()
if cc_list[0] == 'ccache':
d.setVar('OECMAKE_C_COMPILER_LAUNCHER', cc_list[0])
d.setVar('OECMAKE_C_COMPILER', cc_list[1])
else:
d.setVar('OECMAKE_C_COMPILER', cc_list[0])

if not d.getVar('OECMAKE_CXX_COMPILER'):
cxx_list = d.getVar('CXX').split()
if cxx_list[0] == 'ccache':
d.setVar('OECMAKE_CXX_COMPILER_LAUNCHER', cxx_list[0])
d.setVar('OECMAKE_CXX_COMPILER', cxx_list[1])
else:
d.setVar('OECMAKE_CXX_COMPILER', cxx_list[0])
}
# C/C++ Compiler (without cpu arch/tune arguments)
OECMAKE_C_COMPILER ?= "`echo ${CC} | sed 's/^\([^ ]*\).*/\1/'`"
OECMAKE_CXX_COMPILER ?= "`echo ${CXX} | sed 's/^\([^ ]*\).*/\1/'`"
OECMAKE_AR ?= "${AR}"

# Compiler flags
Expand All @@ -39,6 +51,9 @@ OECMAKE_CXX_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} ${LD
CXXFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}"
CFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}"

OECMAKE_C_COMPILER_LAUNCHER ?= ""
OECMAKE_CXX_COMPILER_LAUNCHER ?= ""

OECMAKE_RPATH ?= ""
OECMAKE_PERLNATIVE_DIR ??= ""
OECMAKE_EXTRA_ROOT_PATH ?= ""
Expand All @@ -48,23 +63,29 @@ OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM_class-native = "BOTH"

EXTRA_OECMAKE_append = " ${PACKAGECONFIG_CONFARGS}"

EXTRA_OECMAKE_BUILD_prepend_task-compile = "${PARALLEL_MAKE} "
EXTRA_OECMAKE_BUILD_prepend_task-install = "${PARALLEL_MAKEINST} "
export CMAKE_BUILD_PARALLEL_LEVEL
CMAKE_BUILD_PARALLEL_LEVEL_task-compile = "${@oe.utils.parallel_make(d, False)}"
CMAKE_BUILD_PARALLEL_LEVEL_task-install = "${@oe.utils.parallel_make(d, True)}"

OECMAKE_TARGET_COMPILE ?= "all"
OECMAKE_TARGET_INSTALL ?= "install"

FILES_${PN}-dev += "${libdir}/cmake ${datadir}/cmake"
def map_host_os_to_system_name(host_os):
if host_os.startswith('mingw'):
return 'Windows'
if host_os.startswith('linux'):
return 'Linux'
return host_os

# CMake expects target architectures in the format of uname(2),
# which do not always match TARGET_ARCH, so all the necessary
# conversions should happen here.
def map_target_arch_to_uname_arch(target_arch):
if target_arch == "powerpc":
def map_host_arch_to_uname_arch(host_arch):
if host_arch == "powerpc":
return "ppc"
if target_arch == "powerpc64":
if host_arch == "powerpc64":
return "ppc64"
return target_arch
return host_arch

cmakebuilder_do_generate_toolchain_file() {
if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then
Expand All @@ -74,10 +95,12 @@ cmakebuilder_do_generate_toolchain_file() {
# CMake system name must be something like "Linux".
# This is important for cross-compiling.
$cmake_crosscompiling
set( CMAKE_SYSTEM_NAME `echo ${TARGET_OS} | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` )
set( CMAKE_SYSTEM_PROCESSOR ${@map_target_arch_to_uname_arch(d.getVar('TARGET_ARCH'))} )
set( CMAKE_SYSTEM_NAME ${@map_host_os_to_system_name(d.getVar('HOST_OS'))} )
set( CMAKE_SYSTEM_PROCESSOR ${@map_host_arch_to_uname_arch(d.getVar('HOST_ARCH'))} )
set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} )
set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} )
set( CMAKE_C_COMPILER_LAUNCHER ${OECMAKE_C_COMPILER_LAUNCHER} )
set( CMAKE_CXX_COMPILER_LAUNCHER ${OECMAKE_CXX_COMPILER_LAUNCHER} )
set( CMAKE_ASM_COMPILER ${OECMAKE_C_COMPILER} )
set( CMAKE_AR ${OECMAKE_AR} CACHE FILEPATH "Archiver" )
set( CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "CFLAGS" )
Expand All @@ -92,11 +115,12 @@ set( CMAKE_CXX_LINK_FLAGS "${OECMAKE_CXX_LINK_FLAGS}" CACHE STRING "LDFLAGS" )
# only search in the paths provided so cmake doesnt pick
# up libraries and tools from the native build machine
# BC modify: it makes more sense to put OECMAKE_EXTRA_ROOT_PATH first in the list order matters for cmake, and we should prefer custom paths for libraries/executables/includes search.
set( CMAKE_FIND_ROOT_PATH ${OECMAKE_EXTRA_ROOT_PATH} ${STAGING_DIR_HOST} ${STAGING_DIR_NATIVE} ${CROSS_DIR} ${OECMAKE_PERLNATIVE_DIR} ${EXTERNAL_TOOLCHAIN})
set( CMAKE_FIND_ROOT_PATH ${OECMAKE_EXTRA_ROOT_PATH} ${STAGING_DIR_HOST} ${STAGING_DIR_NATIVE} ${CROSS_DIR} ${OECMAKE_PERLNATIVE_DIR} ${EXTERNAL_TOOLCHAIN} ${HOSTTOOLS_DIR})
set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ${OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM} )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
set( CMAKE_PROGRAM_PATH "/" )

# Use qt.conf settings
set( ENV{QT_CONF_PATH} ${WORKDIR}/qt.conf )
Expand All @@ -105,12 +129,19 @@ set( ENV{QT_CONF_PATH} ${WORKDIR}/qt.conf )
# directory as rpath by default
set( CMAKE_INSTALL_RPATH ${OECMAKE_RPATH} )

# Use native cmake modules
# Use RPATHs relative to build directory for reproducibility
set( CMAKE_BUILD_RPATH_USE_ORIGIN ON )

# Use our cmake modules
list(APPEND CMAKE_MODULE_PATH "${STAGING_DATADIR}/cmake/Modules/")

# add for non /usr/lib libdir, e.g. /usr/lib64
set( CMAKE_LIBRARY_PATH ${libdir} ${base_libdir})

# add include dir to implicit includes in case it differs from /usr/include
list(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES ${includedir})
list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES ${includedir})

EOF
}

Expand All @@ -122,6 +153,7 @@ cmakebuilder_do_configure() {
if [ "${OECMAKE_BUILDPATH}" ]; then
bbnote "cmake.bbclass no longer uses OECMAKE_BUILDPATH. The default behaviour is now out-of-tree builds with B=WORKDIR/build."
fi

if [ "${S}" != "${B}" ]; then
rm -rf ${B}
mkdir -p ${B}
Expand All @@ -142,30 +174,46 @@ cmakebuilder_do_configure() {
$oecmake_sitefile \
${OECMAKE_SOURCEPATH} \
-DCMAKE_INSTALL_PREFIX:PATH=${prefix} \
-DCMAKE_INSTALL_BINDIR:PATH=${@os.path.relpath(d.getVar('bindir'), d.getVar('prefix'))} \
-DCMAKE_INSTALL_SBINDIR:PATH=${@os.path.relpath(d.getVar('sbindir'), d.getVar('prefix'))} \
-DCMAKE_INSTALL_LIBEXECDIR:PATH=${@os.path.relpath(d.getVar('libexecdir'), d.getVar('prefix'))} \
-DCMAKE_INSTALL_BINDIR:PATH=${@os.path.relpath(d.getVar('bindir'), d.getVar('prefix') + '/')} \
-DCMAKE_INSTALL_SBINDIR:PATH=${@os.path.relpath(d.getVar('sbindir'), d.getVar('prefix') + '/')} \
-DCMAKE_INSTALL_LIBEXECDIR:PATH=${@os.path.relpath(d.getVar('libexecdir'), d.getVar('prefix') + '/')} \
-DCMAKE_INSTALL_SYSCONFDIR:PATH=${sysconfdir} \
-DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=${@os.path.relpath(d.getVar('sharedstatedir'), d. getVar('prefix'))} \
-DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=${@os.path.relpath(d.getVar('sharedstatedir'), d. getVar('prefix') + '/')} \
-DCMAKE_INSTALL_LOCALSTATEDIR:PATH=${localstatedir} \
-DCMAKE_INSTALL_LIBDIR:PATH=${@os.path.relpath(d.getVar('libdir'), d.getVar('prefix'))} \
-DCMAKE_INSTALL_INCLUDEDIR:PATH=${@os.path.relpath(d.getVar('includedir'), d.getVar('prefix'))} \
-DCMAKE_INSTALL_DATAROOTDIR:PATH=${@os.path.relpath(d.getVar('datadir'), d.getVar('prefix'))} \
-DCMAKE_INSTALL_LIBDIR:PATH=${@os.path.relpath(d.getVar('libdir'), d.getVar('prefix') + '/')} \
-DCMAKE_INSTALL_INCLUDEDIR:PATH=${@os.path.relpath(d.getVar('includedir'), d.getVar('prefix') + '/')} \
-DCMAKE_INSTALL_DATAROOTDIR:PATH=${@os.path.relpath(d.getVar('datadir'), d.getVar('prefix') + '/')} \
-DPYTHON_EXECUTABLE:PATH=${PYTHON} \
-DPython_EXECUTABLE:PATH=${PYTHON} \
-DPython3_EXECUTABLE:PATH=${PYTHON} \
-DLIB_SUFFIX=${@d.getVar('baselib').replace('lib', '')} \
-DCMAKE_INSTALL_SO_NO_EXE=0 \
-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \
-DCMAKE_VERBOSE_MAKEFILE=1 \
-DCMAKE_NO_SYSTEM_FROM_IMPORTED=1 \
${EXTRA_OECMAKE} \
-Wno-dev
}

# To disable verbose cmake logs for a given recipe or globally config metadata e.g. local.conf
# add following
#
# CMAKE_VERBOSE = ""
#

CMAKE_VERBOSE ??= "VERBOSE=1"

# Then run do_compile again
cmake_runcmake_build() {
bbnote ${DESTDIR:+DESTDIR=${DESTDIR} }VERBOSE=1 cmake --build '${B}' "$@" -- ${EXTRA_OECMAKE_BUILD}
eval ${DESTDIR:+DESTDIR=${DESTDIR} }VERBOSE=1 cmake --build '${B}' "$@" -- ${EXTRA_OECMAKE_BUILD}
bbnote ${DESTDIR:+DESTDIR=${DESTDIR} }${CMAKE_VERBOSE} cmake --build '${B}' "$@" -- ${EXTRA_OECMAKE_BUILD}
eval ${DESTDIR:+DESTDIR=${DESTDIR} }${CMAKE_VERBOSE} cmake --build '${B}' "$@" -- ${EXTRA_OECMAKE_BUILD}
}

cmakebuilder_do_compile() {
cmake_runcmake_build --target ${OECMAKE_TARGET_COMPILE}
}

# cmakebuilder_do_install() {
# DESTDIR='${D}' cmake_runcmake_build --target ${OECMAKE_TARGET_INSTALL}
# }

EXPORT_FUNCTIONS do_configure do_compile do_generate_toolchain_file
2 changes: 1 addition & 1 deletion conf/layer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ BBFILES := "${BBFILES} ${LAYERDIR}/recipes-*/*/*/*.bb ${LAYERDIR}/recipes-*/*/*/
BBFILE_COLLECTIONS += "bc"
BBFILE_PATTERN_bc := "^${LAYERDIR}/"
BBFILE_PRIORITY_bc := "5"
LAYERSERIES_COMPAT_bc = "sumo"
LAYERSERIES_COMPAT_bc = "dunfell"

LICENSE_FLAGS_WHITELIST="commercial_libav"

Expand Down
50 changes: 12 additions & 38 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
FROM debian:9

ARG YOCTO_VERSION=sumo
ARG BITBAKE_TARGET=linphone-sdk
FROM debian:buster

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && apt-get -y upgrade

# Required Packages for the Host Development System
# http://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#required-packages-for-the-host-development-system
RUN apt-get install -y gawk wget git-core diffstat unzip texinfo gcc-multilib g++-multilib \
build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \
apt-utils tmux xz-utils debianutils iputils-ping libncurses5-dev devscripts
# RUN apt-get install -y gawk wget git-core diffstat unzip texinfo gcc-multilib g++-multilib \
# build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \
# apt-utils tmux xz-utils debianutils iputils-ping libncurses5-dev devscripts

# https://docs.yoctoproject.org/ref-manual/system-requirements.html#ubuntu-and-debian
RUN apt-get install -y gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev


# Additional host packages required by poky/scripts/wic
RUN apt-get install -y curl dosfstools mtools parted syslinux tree zip

# Create a non-root user that will perform the actual build
RUN id build 2>/dev/null || useradd --uid 30000 --create-home build
RUN apt-get install -y sudo
RUN echo "build ALL=(ALL) NOPASSWD: ALL" | tee -a /etc/sudoers

# Fix error "Please use a locale setting which supports utf-8."
# See https://wiki.yoctoproject.org/wiki/TipsAndTricks/ResolvingLocaleIssues
RUN apt-get install -y locales
Expand All @@ -34,33 +29,12 @@ ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8

# Create a non-root user that will perform the actual build
RUN id build 2>/dev/null || useradd --uid 1000 --create-home build
RUN apt-get install -y sudo
RUN echo "build ALL=(ALL) NOPASSWD: ALL" | tee -a /etc/sudoers

USER build
WORKDIR /home/build

RUN git clone -b "${YOCTO_VERSION}" git://git.yoctoproject.org/poky

WORKDIR poky

RUN git clone -b "${YOCTO_VERSION}" git://git.openembedded.org/meta-openembedded

RUN git clone -b "yocto-${YOCTO_VERSION}" https://gitlab.linphone.org/BC/public/meta-bc.git

RUN git clone -b "${YOCTO_VERSION}" git://git.yoctoproject.org/meta-raspberrypi

#Add here additional clone of custom/BSP layers

WORKDIR /home/build/poky

RUN mkdir -p /home/build/poky/build

RUN mkdir -p /home/build/poky/build/conf

COPY --chown=build local.conf /home/build/poky/build/conf/

COPY --chown=build bblayers.conf /home/build/poky/build/conf/

RUN chown -R build:build /home/build/poky/build

#CMD "source oe-init-build-env && bitbake ${BITBAKE_TARGET}"

CMD bash
2 changes: 1 addition & 1 deletion recipes-bc/flexisip/flexisip/flexisip.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ INC_PR = "r0"
PROVIDES = "flexisip flexisip-proxy flexisip-presence flexisip-conference"

DEPENDS = "libsofia-sip-ua-bc linphone-sdk mariadb redis"
RDEPENDS_${PN} = "lsb"
# RDEPENDS_${PN} = "lsb" # Removed in yocto 3.0
S = "${WORKDIR}/git"

inherit cmake systemd
Expand Down
6 changes: 3 additions & 3 deletions recipes-bc/linphone-sdk/linphone-sdk/linphone-sdk.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SECTION_linphonec = "console/network"

INC_PR = "r0"

DEPENDS = "git-native doxygen-native mariadb pulseaudio alsa-lib virtual/gettext sqlite3 mariadb zlib perl-native ${VERSION_DEPENDENT_DEPENDS}"
DEPENDS = "git-native doxygen-native python3-native python3-pystache-native python3-six-native pulseaudio alsa-lib virtual/gettext sqlite3 zlib perl-native"

PROVIDES = "linphone-sdk"

Expand Down Expand Up @@ -40,7 +40,7 @@ python () {
print(d.getVar('SRCREV', True))
}

SRC_URI = "gitsm://gitlab.linphone.org/BC/public/linphone-sdk.git;protocol=https;branch=${LINPHONE_SDK_BRANCH};"
SRC_URI = "gitsm://gitlab.linphone.org/BC/public/linphone-sdk.git;protocol=https;branch=release/5.0;"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=ff3103b5db8ba4e2c66c511b7a73e407"

PACKAGECONFIG ??= "sqlite zlib bzrtp ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'video', '', d)}"
Expand All @@ -51,7 +51,7 @@ PACKAGECONFIG[bzrtp]= " -DENABLE_BZRTP=YES, -DENABLE_BZRTP=NO"
PACKAGECONFIG[mdns]= "-DENABLE_MDNS=YES,-DENABLE_MDNS=NO"

EXTRA_OECMAKE ??= " "
EXTRA_OECMAKE += " -DENABLE_CONSOLE_UI=NO -DENABLE_GTK_UI=NO -DENABLE_CXX_WRAPPER=YES -DENABLE_VCARD=YES -DENABLE_VPX=NO -DENABLE_XML2=NO -DENABLE_SQLITE=NO -DENABLE_ZLIB=NO -DENABLE_SOCI_MYSQL=YES -DENABLE_LDAP=NO"
EXTRA_OECMAKE += " -DENABLE_CONSOLE_UI=NO -DENABLE_GTK_UI=NO -DENABLE_CXX_WRAPPER=YES -DENABLE_VCARD=YES -DENABLE_VPX=NO -DENABLE_XML2=NO -DENABLE_SQLITE=YES -DENABLE_ZLIB=NO -DENABLE_SOCI_MYSQL=NO -DENABLE_LDAP=NO -DENABLE_DAEMON=YES"

EXTRA_OECMAKE += " -DENABLE_UNIT_TESTS=YES -DENABLE_TESTS=YES"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Same as the "4.5.x" recipe for the moment, this recipe must always evolve to
# work with the last stable linphone-sdk version.
# Used on the release 4.5 branch, for a stable version please use the "latest" recipe
VERSION_DEPENDENT_DEPENDS="python3-native python3-pystache-native python3-six-native"
VERSION_DEPENDENT_INHERIT="python3native"

# The default commit sha used if LINPHONE_SDK_REV is not set and LATEST_REVISIONS disabled
# 5.0.0-alpha
DEFAULT_COMMIT="7320211a738ff5004fbe21e5bf37fb72181cc1f9"
# 4.5.14
DEFAULT_COMMIT="d4d6356a615e2eec7ea1a957ec40f6fd143f6006"

require linphone-sdk.inc

inherit gitpkgv

PR = "${INC_PR}.0"
PV = "latest"
PKGV = "${GITPKGVTAG}"
PV = "4.4.x"
PKGV = "${GITPKGVTAG}"

16 changes: 16 additions & 0 deletions recipes-bc/linphone-sdk/linphone-sdk/linphone-sdk_5.0.x.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Used on the release 4.5 branch, for a stable version please use the "latest" recipe
VERSION_DEPENDENT_DEPENDS="python3-native python3-pystache-native python3-six-native"
VERSION_DEPENDENT_INHERIT="python3native"

# The default commit sha used if LINPHONE_SDK_REV is not set and LATEST_REVISIONS disabled
# 5.0.27
DEFAULT_COMMIT="9e732013075c578fa4d54b4e535757af196212d7"

require linphone-sdk.inc

inherit gitpkgv

PR = "${INC_PR}.0"
PV = "5.0.x"
PKGV = "${GITPKGVTAG}"