Cross compile package using crossscript in yocto for node-sqlite3?

Viewed 543

my yocto setup has nodejs recipe. Which works properly. I'm trying to cross-compile node-sqlite3 package by adding new recipe. node-sqlite3 depends on node-gyp script. script uses command node(machine-image).

Build setup trying to use HOST path instead of machine image path.

node-sqlite3.bb

SUMMARY = "Asynchronous, non-blocking SQLite3 bindings for Node.js"
SECTION = "nodejs/module"
LICENSE = "MIT"

SRC_URI = "https://github.com/mapbox/node-sqlite3/archive/v${PV}.tar.gz"

LIC_FILES_CHKSUM = "file://LICENSE;md5=79558839a9db3e807e4ae6f8cd100c1c"

SRC_URI[md5sum] = "c17036d0db2d147d9af8d7b7057c8c8c"
SRC_URI[sha256sum] = "80d58f84073e524f7d4a39e2ec7b77908862a5629b9a4d882127c807cc093597"

S = "${WORKDIR}/node-sqlite3-${PV}"

DEPENDS = "nodejs node-gyp sqlite3"

inherit nodejs-arch

EXTRA_OECONF = "--with-node=${STAGING_BINDIR_CROSS}/node"

do_configure() {
    export LD="${CXX}"
    export GYP_DEFINES="sysroot=${STAGING_DIR_HOST}"
    node-gyp --arch ${TARGET_ARCH} configure
}

do_compile() {
    export LD="${CXX}"
    export GYP_DEFINES="sysroot=${STAGING_DIR_HOST}"
    node-gyp --arch ${TARGET_ARCH} build
}

do_install() {
    install -d ${D}${libdir}/nodejs/sqlite3
    install ${S}/build/Release/node_sqlite3.node ${D}${libdir}/nodejs/
    install ${S}/lib/sqlite3.js ${D}${libdir}/nodejs/sqlite3/
    install ${S}/lib/index.js ${D}${libdir}/nodejs/sqlite3/
    install ${S}/lib/trace.js ${D}${libdir}/nodejs/sqlite3/
}

FILES_${PN} += "${libdir}/nodejs ${bindir}node-gyp"

cat node-gyp

#!/usr/bin/env sh
if [ "x$npm_config_node_gyp" = "x" ]; then
  node "`dirname "$0"`/../../node_modules/node-gyp/bin/node-gyp.js" "$@"
else
  "$npm_config_node_gyp" "$@"
fi

The following binary path should be considered for configuring, compiling.

  1. node-gyp script is used from hosttools not from image directory.
/poky/build/tmp-glibc/hosttools/node-gyp 

/poky/build/tmp-glibc/work/target-sdk/machine-image/1.0-r0/rootfs/usr/lib/node_modules/npm/bin/node-gyp-bin/node-gyp
  1. node-gyp script uses node command to compile scipts, build recipe fails to point to image binary path.
build/tmp-glibc/work/target-sdk/machine-image/1.0-r0/rootfs/usr/bin/node

But I'm getting the following error.

| build/tmp-glibc/work/armv7ahf-neon-oe-linux-gnueabi/node-sqlite3/4.0.8-r0/recipe-sysroot
| /usr/bin/env: ‘node’: No such file or directory

How to fix above issues? What steps need to correct or include in node-sqlite3.bb recipe?

0 Answers
Related