From 4562017be00c45b5b2ae29cd0b68be7305f569b4 Mon Sep 17 00:00:00 2001 From: Marc Mattmueller Date: Wed, 10 Mar 2021 11:44:17 +0100 Subject: [PATCH] recipe-tools: changed the recipes for libnmapp and sys-mon After a short analysis I have noticed that the library and the app are not build as intended. To build the app and the lib also from command line using an SDK, the make files needed to be updated. This commit then adapted the recipes accordingly to build the correct versions BugzID: 69904 Signed-off-by: Marc Mattmueller --- classes/unittests.bbclass | 33 ++++-------------- recipes-tools/libnmapp/libnmapp_git.bb | 46 +++++++++++++++++++++++--- recipes-tools/sys-mon/sys-mon_git.bb | 37 +++++++++++++++++++-- 3 files changed, 82 insertions(+), 34 deletions(-) diff --git a/classes/unittests.bbclass b/classes/unittests.bbclass index bcddf16..0368ec3 100644 --- a/classes/unittests.bbclass +++ b/classes/unittests.bbclass @@ -4,42 +4,21 @@ DEPENDS_class-native += "cpputest" BUILD_CFLAGS +="-I${CPPUTEST_HOME}/include" BUILD_CPPFLAGS +="-I${CPPUTEST_HOME}/include" -TEST_LIBRARY ?= "0" -do_compile_append_class-native () { +do_compile_append_class-native() { + bbplain "building UNIT TEST ${BPN}..." export CPPUTEST_HOME="${base_prefix}/usr/lib/cpputest/" export CPPUTEST_ADDITIONAL_CFLAGS=" ${BUILD_CFLAGS}" export CPPUTEST_ADDITIONAL_CPPFLAGS=" ${BUILD_CPPFLAGS}" export CPPUTEST_ADDITIONAL_CXXFLAGS=" ${BUILD_CXXFLAGS}" export CPPUTEST_ADDITIONAL_LDFLAGS=" ${BUILD_LDFLAGS}" - export UNITTEST_OUTPUT_XML=1 - export BUILD_CONFIG="test" + export UNITTEST_OUTPUT_XML=0 + export USE_INITSYS_DUMMY=1 + export BUILD_CONFIG="utest" export BUILD_TARGET="host" + export SYSROOT=${STAGING_DIR_HOST} export SILENCE="" oe_runmake -f Makefile.utest.mk - - if [ "${TEST_LIBRARY}" = "1" ]; then - export BUILD_TARGET=host - export BUILD_CONFIG=test - oe_runmake -f Makefile.host.mk - fi -} - -do_install_append_class-native () { - if [ "${TEST_LIBRARY}" = "1" ]; then - # Install headers - libname=$(ls ${D}${includedir}) - install -d ${D}${includedir}/$libname-test - install -d ${D}${includedir}/$libname-test/mocks - install -d ${D}${includedir}/$libname-test/utils - - cp -r ${S}/src/* ${D}${includedir}/$libname-test - cp -r ${S}/tests/mocks/* ${D}${includedir}/$libname-test/mocks - cp -r ${S}/tests/utils/* ${D}${includedir}/$libname-test/utils - - # Install test library - install -m 644 ${B}/test/host/*.a ${D}${libdir} - fi } BBCLASSEXTEND = "native nativesdk" diff --git a/recipes-tools/libnmapp/libnmapp_git.bb b/recipes-tools/libnmapp/libnmapp_git.bb index 8ea2058..bd31a90 100644 --- a/recipes-tools/libnmapp/libnmapp_git.bb +++ b/recipes-tools/libnmapp/libnmapp_git.bb @@ -13,20 +13,29 @@ LIB_PKG_NAME = "libnmapp.a" DEPENDS_append = " libevent" DEPENDS_class-target += "systemd" +# performs the unit test of the library +inherit unittests # Required to add the libary to the SDK. # ${PN}-dev depends on ${PN} which is empty because # only the static library is built ALLOW_EMPTY_${PN} = "1" -inherit unittests -TEST_LIBRARY = "1" - S = "${WORKDIR}/git" B = "${S}/build" -do_install() { +do_compile_class-target() { + bbplain "building TARGET ${BPN}..." + export SILENCE="" + export BUILD_TARGET=target + export BUILD_CONFIG=rls + export USE_INITSYS_DUMMY=0 + export SYSROOT=${STAGING_DIR_TARGET} + oe_runmake -f Makefile +} + +do_install_class-target() { install -d ${D}${libdir} install -m 644 ${B}/rls/target/${LIB_PKG_NAME} ${D}${libdir} @@ -34,3 +43,32 @@ do_install() { cp -r ${S}/include/${LIB_SHORT_NAME}/* ${D}${includedir}/${LIB_SHORT_NAME} } + + +do_compile_class-native() { + bbplain "building NATIVE ${BPN} (test version)..." + export SILENCE="" + export USE_INITSYS_DUMMY=1 + export BUILD_TARGET=host + export BUILD_CONFIG=test + export SYSROOT=${STAGING_DIR_HOST} + oe_runmake -f Makefile.host.mk +} + +do_install_class-native() { + # Setup directories + install -d ${D}${includedir}/${LIB_SHORT_NAME} + install -d ${D}${includedir}/${LIB_SHORT_NAME}-test + install -d ${D}${includedir}/${LIB_SHORT_NAME}-test/mocks + install -d ${D}${includedir}/${LIB_SHORT_NAME}-test/utils + install -d ${D}${libdir} + + # Install headers + cp -r ${S}/include/${LIB_SHORT_NAME}/* ${D}${includedir}/${LIB_SHORT_NAME} + cp -r ${S}/src/* ${D}${includedir}/${LIB_SHORT_NAME}-test + cp -r ${S}/tests/mocks/* ${D}${includedir}/${LIB_SHORT_NAME}-test/mocks + cp -r ${S}/tests/utils/* ${D}${includedir}/${LIB_SHORT_NAME}-test/utils + + # Install rls and test library + install -m 644 ${B}/test/host/*.a ${D}${libdir} +} diff --git a/recipes-tools/sys-mon/sys-mon_git.bb b/recipes-tools/sys-mon/sys-mon_git.bb index ff60aa4..5119678 100644 --- a/recipes-tools/sys-mon/sys-mon_git.bb +++ b/recipes-tools/sys-mon/sys-mon_git.bb @@ -12,23 +12,38 @@ SRC_URI_append = " \ PV = "0.0.1+git${SRCPV}" -inherit systemd -inherit unittests DEPENDS_append = " libnmapp" +inherit systemd + +# performs the unit test of the app +inherit unittests + + S = "${WORKDIR}/git/apps/sys-mon" B = "${S}/build" SYSTEMD_SERVICE_${PN} = "sys-mon.service" +do_compile_class-target() { + bbplain "building TARGET ${BPN}..." + export SILENCE="" + export BUILD_TARGET=target + export BUILD_CONFIG=rls + export SYSROOT=${STAGING_DIR_TARGET} + export SYSROOT_HOST=${STAGING_DIR_HOST} + oe_runmake -f Makefile +} + + FILES_${PN} += " \ ${bindir}/sys-mon \ ${systemd_system_unitdir}/sys-mon.service \ ${sysconfdir}/default/sys-mon.conf \ " -do_install () { +do_install() { bbplain "Installing ${BPN} to ${bindir}..." install -d ${D}${bindir} install -m 555 ${B}/rls/${BPN} ${D}${bindir} @@ -38,3 +53,19 @@ do_install () { install -d ${D}${systemd_system_unitdir} install -m 644 ${WORKDIR}/${BPN}.service ${D}${systemd_system_unitdir} } + + + +do_compile_class-native() { + bbplain "building NATIVE ${BPN}..." + export SILENCE="" + export USE_INITSYS_DUMMY=1 + export BUILD_TARGET=host + export BUILD_CONFIG=rls + export SYSROOT=${STAGING_DIR_HOST} + oe_runmake -f Makefile.host.mk +} + +do_install_class-native() { + bbplain "Skipping native installation of ${BPN}..." +}