summaryrefslogtreecommitdiffstats
path: root/meta-oe
diff options
context:
space:
mode:
authorTony Tascioglu <tony.tascioglu@windriver.com>2021-06-30 09:55:16 -0700
committerKhem Raj <raj.khem@gmail.com>2021-06-30 11:26:38 -0700
commitc1c9327af17c143498c5808576c672bf8133cf53 (patch)
tree9c542237a7ab8b4535e3cfdb870e79a5357a9460 /meta-oe
parentb86476b4f9644053aa3e64521863231cb3cb0c82 (diff)
downloadmeta-openembedded-c1c9327af17c143498c5808576c672bf8133cf53.tar.gz
libyang: create recipe for libyang
Add a new recipe, patches, and ptest coverage for libyang. The recipe follows from upstream, using the cmake build system. There were 2 small changes needed to get the package building: - Remove call to pcre2-config - Add missing import statement The recipe has a dependency on libpcre2, which satisfies the minimum requirements for libyang. In addition, for tests, cmocka is required during build and runtime, and valgrind is required in the runtime for some tests. Due to the way the library by default builds in a debug mode, release mode was specified. However, this disables building the built-in tests, so an EXTRA_OECMAKE was added based on whether or not ptests are enabled to specifiy the required extra flag. Binconfig-disabled is inherited since using pcre2-config directly is not suggested anymore. Cmocka as a dependency depends on whether ptests have been enabled. Since ptests are built with the main package, we need cmocka installed before the test are compiled if they are needed. Ptest coverage: The ptests come from the original tests included with the library. Ptests are in ctest format by default, so we compare the return code to print it in Yocto format. However, as each "test" target executable has multiple tests in it, the full stdout and stderr logs are saved for troubleshooting. Currently, several of the tests fail due to hardcoded paths in the executable binaries generated, this is an issue we will take upstream. For now, only the tests which work on a different target are enabled as the ptests. The list can be updated in the run-ptest script, which is portable shell compatible, without requiring bash. The recipe also has libyang-bin as a split package, which includes yanglint should it be needed. This recipe was tested using buildall-qemu as well as from within qemu in x86_64 and arm64. Signed-off-by: Tony Tascioglu <tony.tascioglu@windriver.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-oe')
-rw-r--r--meta-oe/recipes-extended/libyang/libyang/libyang-skip-pcre2-config-add-stdint-h.patch55
-rw-r--r--meta-oe/recipes-extended/libyang/libyang/run-ptest46
-rw-r--r--meta-oe/recipes-extended/libyang/libyang_2.0.7.bb37
3 files changed, 138 insertions, 0 deletions
diff --git a/meta-oe/recipes-extended/libyang/libyang/libyang-skip-pcre2-config-add-stdint-h.patch b/meta-oe/recipes-extended/libyang/libyang/libyang-skip-pcre2-config-add-stdint-h.patch
new file mode 100644
index 0000000000..e3b2d0e022
--- /dev/null
+++ b/meta-oe/recipes-extended/libyang/libyang/libyang-skip-pcre2-config-add-stdint-h.patch
@@ -0,0 +1,55 @@
1From c7f3e2a8fe530beec6103cb9071ccc41458879aa Mon Sep 17 00:00:00 2001
2From: Tony Tascioglu <tony.tascioglu@windriver.com>
3Date: Mon, 21 Jun 2021 12:34:22 -0400
4Subject: [PATCH] libyang: fix initial build errors
5
6This patch addresses build errors seen when integrating libyang as a
7recipe.
8
9The call to pcre2-config has been commented out. *-config calls are
10being replaced by pkgconfig, and we want to avoid the binary config
11calls. This call can safely be discarded since it is used to check
12the version of libpcre2 on the system, and all recent YP builds meet
13the minimum required version (v10.21).
14
15There is a missing include statement for stdint.h in utests.h which
16causes build problems. stdint.h is required to be imported by cmocka.h
17prior to the cmocka file. Adding the stdint allows it to build the
18tests correctly
19
20Upstream-Status: Pending
21
22Signed-off-by: Tony Tascioglu <tony.tascioglu@windriver.com>
23---
24 CMakeModules/FindPCRE2.cmake | 2 +-
25 tests/utests/utests.h | 1 +
26 2 files changed, 2 insertions(+), 1 deletion(-)
27
28diff --git a/CMakeModules/FindPCRE2.cmake b/CMakeModules/FindPCRE2.cmake
29index 8f60daa2..ad014f14 100644
30--- a/CMakeModules/FindPCRE2.cmake
31+++ b/CMakeModules/FindPCRE2.cmake
32@@ -12,7 +12,7 @@ FIND_PATH(PCRE2_INCLUDE_DIR pcre2.h)
33 FIND_LIBRARY(PCRE2_LIBRARY NAMES libpcre2.a pcre2-8)
34
35 # Check required version
36-execute_process(COMMAND pcre2-config --version OUTPUT_VARIABLE PCRE2_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
37+# execute_process(COMMAND pcre2-config --version OUTPUT_VARIABLE PCRE2_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
38
39 # Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
40 INCLUDE(FindPackageHandleStandardArgs)
41diff --git a/tests/utests/utests.h b/tests/utests/utests.h
42index 5bea0459..a256120c 100644
43--- a/tests/utests/utests.h
44+++ b/tests/utests/utests.h
45@@ -23,6 +23,7 @@
46 #include <stddef.h>
47 #include <stdlib.h>
48
49+#include <stdint.h>
50 #include <cmocka.h>
51
52 #include <string.h>
53--
542.32.0
55
diff --git a/meta-oe/recipes-extended/libyang/libyang/run-ptest b/meta-oe/recipes-extended/libyang/libyang/run-ptest
new file mode 100644
index 0000000000..1c9f8f47f7
--- /dev/null
+++ b/meta-oe/recipes-extended/libyang/libyang/run-ptest
@@ -0,0 +1,46 @@
1#!/bin/sh
2# Valid tests to run
3tests="utest_binary \
4 utest_bits \
5 utest_common \
6 utest_hash_table \
7 utest_inet_types \
8 utest_int8 \
9 utest_json \
10 utest_list \
11 utest_merge \
12 utest_metadata \
13 utest_parser_yang \
14 utest_parser_yin \
15 utest_pattern \
16 utest_printer_yang \
17 utest_printer_yin \
18 utest_range \
19 utest_schema \
20 utest_set \
21 utest_string \
22 utest_tree_data \
23 utest_tree_schema_compile \
24 utest_types \
25 utest_xml \
26 utest_xpath \
27 utest_yang_types \
28 utest_yanglib"
29
30# cd into right directory
31ptestdir=$(dirname "$(readlink -f "$0")")
32cd "$ptestdir"/tests || exit
33
34# Run specified tests
35for f in $tests
36do
37 if test -e ./"$f"; then
38 if ./"$f" > ./"$f".out 2> ./"$f".err; then
39 echo "PASS: $f"
40 else
41 echo "FAIL: $f"
42 fi
43 else
44 echo "SKIP: $f"
45 fi
46done
diff --git a/meta-oe/recipes-extended/libyang/libyang_2.0.7.bb b/meta-oe/recipes-extended/libyang/libyang_2.0.7.bb
new file mode 100644
index 0000000000..8e9e8cc02f
--- /dev/null
+++ b/meta-oe/recipes-extended/libyang/libyang_2.0.7.bb
@@ -0,0 +1,37 @@
1SUMMARY = "YANG data modeling language library"
2DESCRIPTION = "libyang is a YANG data modelling language parser and toolkit written (and providing API) in C."
3HOMEPAGE = "https://github.com/CESNET/libyang"
4SECTION = "libs"
5LICENSE = "BSD-3-Clause"
6
7LIC_FILES_CHKSUM = "file://LICENSE;md5=f3916d7d8d42a6508d0ea418cfff10ad"
8
9SRCREV = "69d9fff65abb58beb0bb6aa9ecacd572ca1dfc56"
10
11SRC_URI = "git://github.com/CESNET/libyang.git \
12 file://libyang-skip-pcre2-config-add-stdint-h.patch \
13 file://run-ptest \
14 "
15
16S = "${WORKDIR}/git"
17
18COMPATIBLE_HOST_riscv32 = "null"
19COMPATIBLE_HOST_armv5 = "null"
20COMPATIBLE_HOST_riscv64 = "null"
21
22# Main dependencies
23inherit cmake pkgconfig lib_package binconfig-disabled ptest
24DEPENDS = "libpcre2"
25DEPENDS += "${@bb.utils.contains('PTEST_ENABLED', '1', 'cmocka', '', d)}"
26BINCONFIG = "${bindir}/pcre2-config"
27
28# Ptest dependencies
29RDEPENDS_${PN}-ptest += "valgrind"
30
31EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release"
32EXTRA_OECMAKE += " ${@bb.utils.contains('PTEST_ENABLED', '1', '-DENABLE_BUILD_TESTS=ON', '', d)}"
33
34do_install_ptest () {
35 cp -fR ${B}/tests/ ${D}${PTEST_PATH}/
36}
37