Skip to content

Commit

Permalink
soletta: Add Node.js bindings to soletta package
Browse files Browse the repository at this point in the history
This patch exports the needed variables to build Node.js
bindings and add them to the soletta package.

Signed-off-by: Sudarsana Nagineni <[email protected]>
  • Loading branch information
Sudarsana Nagineni committed Apr 25, 2016
1 parent ef895cc commit ef9e7d5
Showing 1 changed file with 57 additions and 1 deletion.
58 changes: 57 additions & 1 deletion recipes-soletta/soletta/soletta_git.bb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -23,6 +23,7 @@ inherit cml1 python3native

PACKAGES = " \
${PN}-staticdev \
${PN}-nodejs \
${PN}-dev \
${PN}-dbg \
${PN} \
Expand Down Expand Up @@ -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} = "\
Expand Down Expand Up @@ -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}"
}

Expand All @@ -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() {
Expand Down

0 comments on commit ef9e7d5

Please sign in to comment.