1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7inherit ptest
8
9FILESEXTRAPATHS:prepend := "${COREBASE}/meta/files:"
10
11SRC_URI += "file://ptest-perl/run-ptest"
12
13do_install_ptest_perl() {
14	install -d ${D}${PTEST_PATH}
15	if [ ! -f ${D}${PTEST_PATH}/run-ptest ]; then
16		install -m 0755 ${WORKDIR}/ptest-perl/run-ptest ${D}${PTEST_PATH}
17	fi
18	cp -r ${B}/t ${D}${PTEST_PATH}
19	chown -R root:root ${D}${PTEST_PATH}
20}
21
22FILES:${PN}-ptest:prepend = "${PTEST_PATH}/t/* ${PTEST_PATH}/run-ptest "
23
24RDEPENDS:${PN}-ptest:prepend = "perl "
25
26addtask install_ptest_perl after do_install_ptest_base before do_package
27
28python () {
29    if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
30        d.setVarFlag('do_install_ptest_perl', 'fakeroot', '1')
31
32    # Remove all '*ptest_perl' tasks when ptest is not enabled
33    if not(d.getVar('PTEST_ENABLED') == "1"):
34        for i in ['do_install_ptest_perl']:
35            bb.build.deltask(i, d)
36}
37