From ef9e7d5d53c77224cd104715284077e62155541b Mon Sep 17 00:00:00 2001 From: Sudarsana Nagineni Date: Fri, 15 Apr 2016 11:21:06 +0300 Subject: [PATCH] soletta: Add Node.js bindings to soletta package This patch exports the needed variables to build Node.js bindings and add them to the soletta package. Signed-off-by: Sudarsana Nagineni --- recipes-soletta/soletta/soletta_git.bb | 58 +++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/recipes-soletta/soletta/soletta_git.bb b/recipes-soletta/soletta/soletta_git.bb index 224f804..f47f20b 100644 --- a/recipes-soletta/soletta/soletta_git.bb +++ b/recipes-soletta/soletta/soletta_git.bb @@ -4,7 +4,7 @@ DESCRIPTION = "Soletta library and modules" SECTION = "examples" -DEPENDS = "glib-2.0 libpcre pkgconfig python3-jsonschema-native icu curl libmicrohttpd mosquitto" +DEPENDS = "glib-2.0 libpcre pkgconfig python3-jsonschema-native icu curl libmicrohttpd mosquitto nodejs" DEPENDS += " ${@bb.utils.contains('DISTRO_FEATURES','systemd','systemd','',d)}" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE;md5=93888867ace35ffec2c845ea90b2e16b" @@ -23,6 +23,7 @@ inherit cml1 python3native PACKAGES = " \ ${PN}-staticdev \ + ${PN}-nodejs \ ${PN}-dev \ ${PN}-dbg \ ${PN} \ @@ -53,6 +54,10 @@ FILES_${PN} = " \ ${libdir}/soletta/soletta-image-hash \ " +FILES_${PN}-nodejs = " \ + ${libdir}/node_modules/soletta \ +" + # Setup what PACKAGES should be installed by default. # If a package should not being installed, use BAD_RECOMMENDS. RRECOMMENDS_${PN} = "\ @@ -81,7 +86,55 @@ do_configure_prepend() { export TARGETAR="${AR}" } + do_compile() { + # changing the home directory to the working directory, the .npmrc will be created in this directory + export HOME=${WORKDIR} + + # does not build dev packages + npm config set dev false + + # access npm registry using http + npm set strict-ssl false + npm config set registry http://registry.npmjs.org/ + + # configure http proxy if neccessary + if [ -n "${http_proxy}" ]; then + npm config set proxy ${http_proxy} + NODE_GYP_PROXY="--proxy=${http_proxy}" + fi + if [ -n "${HTTP_PROXY}" ]; then + npm config set proxy ${HTTP_PROXY} + NODE_GYP_PROXY="--proxy=${HTTP_PROXY}" + fi + + # configure cache to be in working directory + npm set cache ${WORKDIR}/npm_cache + + # clear local cache prior to each compile + npm cache clear + + case ${TARGET_ARCH} in + i?86) targetArch="ia32" + ;; + x86_64) targetArch="x64" + ;; + arm) targetArch="arm" + ;; + mips) targetArch="mips" + ;; + sparc) targetArch="sparc" + ;; + *) echo "unknown architecture" + exit 1 + ;; + esac + + # Export needed variables to build Node.js bindings + export CFLAGS="$CFLAGS -fPIC" + export CXXFLAGS="$CXXFLAGS -fPIC" + export NODE_GYP="${STAGING_DIR_TARGET}/${libdir}/node_modules/npm/bin/node-gyp-bin/node-gyp --arch=${targetArch} ${NODE_GYP_PROXY}" + oe_runmake CFLAGS="--sysroot=${STAGING_DIR_TARGET} -pthread -lpcre" TARGETCC="${CC}" TARGETAR="${AR}" } @@ -92,6 +145,9 @@ do_install() { ln -sf libsoletta.so ${WORKDIR}/image/usr/lib/libsoletta.so.0.0.1 COMMIT_ID=`git --git-dir=${WORKDIR}/git/.git rev-parse --verify HEAD` echo "Soletta: $COMMIT_ID" > ${D}/usr/lib/soletta/soletta-image-hash + + # Remove nan module as it is not needed. + rm -rf ${WORKDIR}/image/usr/lib/node_modules/soletta/node_modules/nan } do_install_append() {