4dd3feca76416e691cea7da95e1397331c95c70c
[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 # 'wgtpkg-pack' in af-main-native is required.
12 DEPENDS_append = " af-main-native"
13
14 # for bindings af-binder is required.
15 DEPENDS_append = " af-binder"
16
17 # for bindings that use the cmake-apps-module
18 DEPENDS_append = " cmake-apps-module-native"
19
20 # for hal bindings genskel is required.
21 DEPENDS_append = " af-binder-devtools-native"
22
23 # Re-enable strip for qmake based projects (default value is "echo")
24 OE_QMAKE_STRIP = "${STRIP}"
25
26 # Extra build arguments passed to the autobuild script invocations
27 AGLWGT_EXTRA_BUILD_ARGS ?= 'VERBOSE=TRUE BUILD_ARGS="${PARALLEL_MAKE}"'
28
29 # CMake based widgets that inherit cmake.bbclass will have the
30 # following automatically appended to AGLWGT_EXTRA_BUILD_ARGS as
31 # the value of CONFIGURE_FLAGS.  This definition may need to be
32 # extended to include more of what is passed in cmake.bbclass's
33 # do_configure if it is found insufficient.  Using the generated
34 # toolchain.cmake file does fix issues with respect to finding the
35 # Qt5 CMake modules that seem difficult to fix otherwise, so at the
36 # very minimum it should be present.
37 AGLWGT_CMAKE_CONFIGURE_ARGS ?= "-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake ${EXTRA_OECMAKE}"
38
39 # Only widgets with recipe names starting with agl-service- are
40 # assumed to have tests by default, set this to "1" to force
41 # building/packaging of the test widget for other widgets.
42 AGLWGT_HAVE_TESTS ?= "0"
43
44 # Warning on missing test/debug/coverage packages disabled by default
45 # for now to reduce build output clutter.
46 AGLWGT_PACKAGE_WARN ?= "0"
47
48 # Whether the widget should be auto-installed on first boot
49 AGLWGT_AUTOINSTALL ?= "1"
50
51 # Signature keys
52 # These are default keys for development purposes !
53 # Change it for production.
54 WGTPKG_AUTOSIGN_0_agl-sign-wgts ??= "${WORKDIR}/recipe-sysroot-native/usr/share/afm/keys/developer.key.pem:${WORKDIR}/recipe-sysroot-native/usr/share/afm/certs/developer.cert.pem"
55 WGTPKG_AUTOSIGN_1_agl-sign-wgts ??= "${WORKDIR}/recipe-sysroot-native/usr/share/afm/keys/platform.key.pem:${WORKDIR}/recipe-sysroot-native/usr/share/afm/certs/platform.cert.pem"
56
57 export WGTPKG_AUTOSIGN_0
58 export WGTPKG_AUTOSIGN_1
59
60 python __anonymous () {
61     # NOTE: AGLWGT_CMAKE_CONFIGURE_ARGS is not updated directly here,
62     #       but via the prefunc below to avoid issues around anonymous
63     #       python ordering conflicts with e.g. externalsrc.bbclass.
64     if bb.data.inherits_class("cmake", d):
65         d.appendVarFlag('do_compile', 'prefuncs', ' aglwgt_cmake_configure')
66 }
67
68 python aglwgt_cmake_configure () {
69     # Define CONFIGURE_FLAGS appropriately if cmake.bbclass has been
70     # inherited, see description of AGLWGT_CMAKE_CONFIGURE_ARGS above
71     # for more details.
72     cmake_config_args = d.getVar("AGLWGT_CMAKE_CONFIGURE_ARGS")
73     if bb.data.inherits_class("cmake", d) and cmake_config_args:
74         d.appendVar("AGLWGT_EXTRA_BUILD_ARGS", ' CONFIGURE_ARGS="' + cmake_config_args + '"')
75         d.appendVarFlag("AGLWGT_EXTRA_BUILD_ARGS", "vardeps", " AGLWGT_CMAKE_CONFIGURE_ARGS")
76 }
77
78 do_configure[noexec] = "1"
79
80 aglwgt_do_compile() {
81     bldcmd=${S}/autobuild/agl/autobuild
82     if [ ! -x "$bldcmd" ]; then
83         bbfatal "Missing autobuild/agl/autobuild script"
84     fi
85
86     if [ "${S}" != "${B}" ]; then
87         rm -rf ${B}
88         mkdir -p ${B}
89         cd ${B}
90     fi
91
92     if ! $bldcmd package BUILD_DIR=${B}/build-release ${AGLWGT_EXTRA_BUILD_ARGS}; then
93         bbwarn "Target: package failed"
94     fi
95
96     if ! $bldcmd package-debug BUILD_DIR_DEBUG=${B}/build-debug ${AGLWGT_EXTRA_BUILD_ARGS}; then
97         bbwarn "Target: package-debug failed"
98     fi
99
100     if echo ${BPN} | grep -q '^agl-service-' || [ "${AGLWGT_HAVE_TESTS}" = "1" ]; then
101         if ! $bldcmd package-test BUILD_DIR_TEST=${B}/build-test ${AGLWGT_EXTRA_BUILD_ARGS}; then
102             bbwarn "Target: package-test failed"
103         fi
104
105         if ! $bldcmd package-coverage BUILD_DIR_COVERAGE=${B}/build-coverage ${AGLWGT_EXTRA_BUILD_ARGS}; then
106             bbwarn "Target: package-coverage failed"
107         fi
108     fi
109 }
110
111 POST_INSTALL_LEVEL ?= "10"
112 POST_INSTALL_SCRIPT ?= "${POST_INSTALL_LEVEL}-${PN}.sh"
113
114 EXTRA_WGT_POSTINSTALL ?= ""
115
116 aglwgt_do_install() {
117     DEST=release
118     if [ "${AGLWGT_AUTOINSTALL_${PN}}" = "0" ]; then
119         DEST=manualinstall
120     fi
121
122     if [ "$(find ${B}/build-release -name '*.wgt' -maxdepth 1)" ]; then
123         install -d ${D}/usr/AGL/apps/$DEST
124         install -m 0644 ${B}/build-release/*.wgt ${D}/usr/AGL/apps/$DEST/
125     else
126         bbfatal "no package found in widget directory"
127     fi
128
129     for t in test debug coverage; do
130         if [ "$(find ${B}/build-${t} -name *-${t}.wgt -maxdepth 1)" ]; then
131             install -d ${D}/usr/AGL/apps/${t}
132             install -m 0644 ${B}/build-${t}/*-${t}.wgt ${D}/usr/AGL/apps/${t}/
133         elif [ "${AGLWGT_PACKAGE_WARN}" = "1" ]; then
134             if [ "$t" != "test" -a "$t" != "coverage" ]; then
135                 bbwarn "no package found in ${t} widget directory"
136             elif echo ${BPN} | grep -q '^agl-service-' || [ "${AGLWGT_HAVE_TESTS}" = "1" ]; then
137                 bbwarn "no package found in ${t} widget directory"
138             fi
139         fi
140     done
141
142     if [ "${AGLWGT_AUTOINSTALL}" != "0" ]; then
143         # For now assume autoinstall of the release versions
144         rm -rf ${D}/usr/AGL/apps/autoinstall
145         ln -sf release ${D}/usr/AGL/apps/autoinstall
146
147         APP_FILES=""
148         for file in ${D}/usr/AGL/apps/autoinstall/*.wgt; do
149             APP_FILES="${APP_FILES} $(basename $file)";
150         done
151         install -d ${D}/${sysconfdir}/agl-postinsts
152         cat > ${D}/${sysconfdir}/agl-postinsts/${POST_INSTALL_SCRIPT} <<EOF
153 #!/bin/sh -e
154 for file in ${APP_FILES}; do
155     /usr/bin/afm-install install /usr/AGL/apps/autoinstall/\$file
156 done
157 sync
158 ${EXTRA_WGT_POSTINSTALL}
159 EOF
160         chmod a+x ${D}/${sysconfdir}/agl-postinsts/${POST_INSTALL_SCRIPT}
161     fi
162 }
163
164 PACKAGES += "${PN}-test ${PN}-debug ${PN}-coverage"
165
166 FILES_${PN} += " \
167     /usr/AGL/apps/release/*.wgt \
168     /usr/AGL/apps/autoinstall \
169     /usr/AGL/apps/manualinstall \
170     ${sysconfdir}/agl-postinsts/${POST_INSTALL_SCRIPT} \
171 "
172 FILES_${PN}-test = "/usr/AGL/apps/test/*.wgt"
173 FILES_${PN}-debug = "/usr/AGL/apps/debug/*.wgt"
174 FILES_${PN}-coverage = "/usr/AGL/apps/coverage/*.wgt"
175
176 # Test widgets need the parent widget and the test framework
177 RDEPENDS_${PN}-test = "${PN} afb-test"
178
179 EXPORT_FUNCTIONS do_compile do_install