d0f8055ae95a325ea01bdaa353b346bd223d61c3
[AGL/meta-agl.git] / meta-app-framework / classes / aglwgt.bbclass
1 #
2 # aglwgt bbclass
3 #
4 # Jan-Simon Moeller, jsmoeller@linuxfoundation.org
5 #
6 # This class expects a "make package" target in the makefile
7 # which creates the wgt files in the package/ subfolder.
8 # The makefile needs to use wgtpkg-pack.
9 #
10
11
12 # 'wgtpkg-pack' in af-main-native is required.
13 DEPENDS_append = " af-main-native"
14
15 # for bindings  af-binder is required.
16 DEPENDS_append = " af-binder"
17
18 # for bindings  that use the cmake-apps-module
19 DEPENDS_append = " cmake-apps-module-native"
20
21 # for hal bindings genskel is required.
22 DEPENDS_append = " af-binder-devtools-native"
23
24 EXTRA_OECMAKE_append_agl-ptest = " -DBUILD_TEST_WGT=TRUE"
25
26 # FIXME: Remove once CMake+ninja issues are resolved
27 OECMAKE_GENERATOR = "Unix Makefiles"
28
29 do_aglwgt_package()  {
30
31     mkdir -p ${S}/build-test
32     mkdir -p ${S}/build-debug
33     mkdir -p ${S}/build-coverage
34
35     cd ${B}
36     ${S}/autobuild/agl/autobuild package BUILD_DIR=${B} DEST=${S}/widgets VERBOSE=TRUE || \
37     ( ${S}/conf.d/autobuild/agl/autobuild package BUILD_DIR=${B} DEST=${B}/package VERBOSE=TRUE && \
38         ( bbwarn "OBSOLETE: Your autobuild script should be located in :" ; \
39         bbwarn "autobuild/agl/ from the project root source folder"; \
40         bbwarn "and generate a .wgt file using wgtpack in the build"; \
41         bbwarn "root folder calling:" ; \
42         bbwarn "./autobuild/agl/autobuild package DEST=<BUILDDIR>" ; \
43         bbwarn "See: https://wiki.automotivelinux.org/troubleshooting/app-recipes" \
44         )
45     ) ||
46     ( bbwarn "OBSOLETE: You must have an autobuild script located in:" ; \
47         bbwarn "autobuild/agl/ from the project root source folder"; \
48         bbwarn "with filename autobuild which should generate"; \
49         bbwarn "a .wgt file using wgtpack in the build"; \
50         bbwarn "root folder calling:" ; \
51         bbwarn "./autobuild/agl/autobuild package DEST=<BUILDDIR>" ; \
52         bbwarn "Fix your package as it will not work within the SDK" ; \
53         bbwarn "See: https://wiki.automotivelinux.org/troubleshooting/app-recipes"; \
54         make package)
55
56     cd ${S}/build-test
57         ${S}/autobuild/agl/autobuild package-test BUILD_DIR=${S}/build-test DEST=${S}/widgets VERBOSE=TRUE || \
58         ( bbwarn "Target: package-test failed")
59
60     cd ${S}/build-debug
61         ${S}/autobuild/agl/autobuild package-debug BUILD_DIR=${S}/build-debug DEST=${S}/widgets VERBOSE=TRUE || \
62         ( bbwarn "Target: package-debug failed")
63
64     cd ${S}/build-coverage
65         ${S}/autobuild/agl/autobuild package-coverage BUILD_DIR=${S}/build-coverage DEST=${S}/widgets VERBOSE=TRUE || \
66         ( bbwarn "Target: package-coverage failed")
67 }
68
69 python () {
70     d.setVarFlag('do_aglwgt_deploy', 'fakeroot', '1')
71 }
72
73
74 POST_INSTALL_LEVEL ?= "10"
75 POST_INSTALL_SCRIPT ?= "${POST_INSTALL_LEVEL}-${PN}.sh"
76
77 EXTRA_WGT_POSTINSTALL ?= ""
78
79 do_aglwgt_deploy() {
80     TEST_WGT="*-test.wgt"
81     DEBUG_WGT="*-debug.wgt"
82     COVERAGE_WGT="*-coverage.wgt"
83     if [ "${AGLWGT_AUTOINSTALL_${PN}}" = "0" ]
84         then
85             install -d ${D}/usr/AGL/apps/manualinstall
86             install -m 0644 ${B}/*.wgt ${D}/usr/AGL/apps/manualinstall || \
87             install -m 0644 ${B}/package/*.wgt ${D}/usr/AGL/apps/manualinstall 
88         else
89             install -d ${D}/usr/AGL/apps/autoinstall
90             install -m 0644 ${B}/*.wgt ${D}/usr/AGL/apps/autoinstall || \
91             install -m 0644 ${B}/package/*.wgt ${D}/usr/AGL/apps/autoinstall
92
93             install -m 0644 ${S}/widgets/*.wgt ${D}/usr/AGL/apps/autoinstall || \
94             ( bbwarn "no package found in widget directory")
95
96         if [ "$(find ${D}/usr/AGL/apps/autoinstall -name ${TEST_WGT})" ]
97         then
98                 install -d ${D}/usr/AGL/apps/testwgt
99             mv ${D}/usr/AGL/apps/autoinstall/*-test.wgt ${D}/usr/AGL/apps/testwgt
100         fi
101
102         if [ "$(find ${D}/usr/AGL/apps/autoinstall -name ${DEBUG_WGT})" ]
103         then
104                 install -d ${D}/usr/AGL/apps/debugwgt
105             mv ${D}/usr/AGL/apps/autoinstall/*-debug.wgt ${D}/usr/AGL/apps/debugwgt
106         fi
107
108         if [ "$(find ${D}/usr/AGL/apps/autoinstall -name ${COVERAGE_WGT})" ]
109         then
110                 install -d ${D}/usr/AGL/apps/coveragewgt
111             mv ${D}/usr/AGL/apps/autoinstall/*-coverage.wgt ${D}/usr/AGL/apps/coveragewgt
112         fi
113
114     fi
115
116     APP_FILES=""
117     for file in ${D}/usr/AGL/apps/autoinstall/*.wgt;do
118         APP_FILES="${APP_FILES} $(basename $file)";
119     done
120     install -d ${D}/${sysconfdir}/agl-postinsts
121     cat > ${D}/${sysconfdir}/agl-postinsts/${POST_INSTALL_SCRIPT} <<EOF
122 #!/bin/sh -e
123 for file in ${APP_FILES}; do
124     /usr/bin/afm-install install /usr/AGL/apps/autoinstall/\$file
125 done
126 sync
127 ${EXTRA_WGT_POSTINSTALL}
128 EOF
129     chmod a+x ${D}/${sysconfdir}/agl-postinsts/${POST_INSTALL_SCRIPT}
130 }
131
132 FILES_${PN} += "/usr/AGL/apps/autoinstall/*.wgt \
133     /usr/AGL/apps/manualinstall/*.wgt \
134     /usr/AGL/apps/testwgt/*.wgt \
135     /usr/AGL/apps/debugwgt/*.wgt \
136     /usr/AGL/apps/coveragewgt/*.wgt \
137     ${sysconfdir}/agl-postinsts/${POST_INSTALL_SCRIPT} \
138     "
139
140 do_install() {
141 }
142
143 addtask aglwgt_deploy  before do_package after do_install
144 addtask aglwgt_package before do_aglwgt_deploy after do_compile
145
146