blob: 97865c933859726bca937721c25491c572ea886c [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY_${PN}-ptest ?= "${SUMMARY} - Package test files"
2DESCRIPTION_${PN}-ptest ?= "${DESCRIPTION} \
3This package contains a test directory ${PTEST_PATH} for package test purposes."
4
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005PTEST_PATH ?= "${libdir}/${BPN}/ptest"
Brad Bishop19323692019-04-05 15:28:33 -04006PTEST_BUILD_HOST_FILES ?= "Makefile"
7PTEST_BUILD_HOST_PATTERN ?= ""
8
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009FILES_${PN}-ptest = "${PTEST_PATH}"
10SECTION_${PN}-ptest = "devel"
11ALLOW_EMPTY_${PN}-ptest = "1"
12PTEST_ENABLED = "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '1', '0', d)}"
13PTEST_ENABLED_class-native = ""
14PTEST_ENABLED_class-nativesdk = ""
15PTEST_ENABLED_class-cross-canadian = ""
16RDEPENDS_${PN}-ptest_class-native = ""
17RDEPENDS_${PN}-ptest_class-nativesdk = ""
18RRECOMMENDS_${PN}-ptest += "ptest-runner"
19
20PACKAGES =+ "${@bb.utils.contains('PTEST_ENABLED', '1', '${PN}-ptest', '', d)}"
21
22do_configure_ptest() {
23 :
24}
25
26do_configure_ptest_base() {
27 do_configure_ptest
28}
29
30do_compile_ptest() {
31 :
32}
33
34do_compile_ptest_base() {
35 do_compile_ptest
36}
37
38do_install_ptest() {
39 :
40}
41
42do_install_ptest_base() {
43 if [ -f ${WORKDIR}/run-ptest ]; then
44 install -D ${WORKDIR}/run-ptest ${D}${PTEST_PATH}/run-ptest
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -050046 if grep -q install-ptest: Makefile; then
47 oe_runmake DESTDIR=${D}${PTEST_PATH} install-ptest
48 fi
49 do_install_ptest
50 chown -R root:root ${D}${PTEST_PATH}
Brad Bishop19323692019-04-05 15:28:33 -040051
52 # Strip build host paths from any installed Makefile
53 for filename in ${PTEST_BUILD_HOST_FILES}; do
54 for installed_ptest_file in $(find ${D}${PTEST_PATH} -type f -name $filename); do
55 bbnote "Stripping host paths from: $installed_ptest_file"
56 sed -e 's#${HOSTTOOLS_DIR}/*##g' \
57 -e 's#${WORKDIR}/*=#.=#g' \
58 -e 's#${WORKDIR}/*##g' \
59 -i $installed_ptest_file
60 if [ -n "${PTEST_BUILD_HOST_PATTERN}" ]; then
61 sed -E '/${PTEST_BUILD_HOST_PATTERN}/d' \
62 -i $installed_ptest_file
63 fi
64 done
65 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050066}
67
68do_configure_ptest_base[dirs] = "${B}"
69do_compile_ptest_base[dirs] = "${B}"
70do_install_ptest_base[dirs] = "${B}"
71do_install_ptest_base[cleandirs] = "${D}${PTEST_PATH}"
72
73addtask configure_ptest_base after do_configure before do_compile
74addtask compile_ptest_base after do_compile before do_install
75addtask install_ptest_base after do_install before do_package do_populate_sysroot
76
77python () {
78 if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050079 d.setVarFlag('do_install_ptest_base', 'fakeroot', '1')
Brad Bishopa5c52ff2018-11-23 10:55:50 +130080 d.setVarFlag('do_install_ptest_base', 'umask', '022')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050081
82 # Remove all '*ptest_base' tasks when ptest is not enabled
Brad Bishop6e60e8b2018-02-01 10:27:11 -050083 if not(d.getVar('PTEST_ENABLED') == "1"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084 for i in ['do_configure_ptest_base', 'do_compile_ptest_base', 'do_install_ptest_base']:
85 bb.build.deltask(i, d)
86}