Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: possible node-gyp-native cleanup #465

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions meta-luneos/classes/npmhelper.bbclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Imported from meta-sca as-is in:
# https://github.com/priv-kweihmann/meta-sca/commit/7b7cbb1db7a7d8238d5ba597491e1f8569635606

## SPDX-License-Identifier: BSD-2-Clause & MIT
## Copyright (c) 2020, Konrad Weihmann + OpenEmbedded

DEPENDS += "nodejs-native"

NPM_LIBDIR ?= "${D}${libdir}"
NPM_EXTRA_ARGS = "--prefer-offline --no-registry"
NPM_PKGNAME ?= "${BPN}"

S = "${WORKDIR}/package"
B = "${WORKDIR}/build"

def clean_npm_pkgname(name):
for k,v in {"@": "", "/": "-", "_": "-"}.items():
name = name.replace(k,v)
return name

NPM_PKGNAME_CLEAN = "${@clean_npm_pkgname(d.getVar('NPM_PKGNAME'))}"

def clean_npm_pkgname_regex(name):
import re
return re.escape(name)

UPSTREAM_CHECK_URI ?= "https://www.npmjs.com/package/${NPM_PKGNAME}?activeTab=versions"
UPSTREAM_CHECK_REGEX ?= "${@clean_npm_pkgname_regex(d.getVar('NPM_PKGNAME'))}/v/(?P<pver>(\d+\.\d+\.\d+))$"

# This function is originated from poky's npm.bbclass
def npm_oe_arch_map(target_arch, d):
import re
if re.match('p(pc|owerpc)(|64)', target_arch): return 'ppc'
elif re.match('i.86$', target_arch): return 'ia32'
elif re.match('x86_64$', target_arch): return 'x64'
elif re.match('arm64$', target_arch): return 'arm'
return target_arch

NPM_ARCH ?= "${@npm_oe_arch_map(d.getVar('TARGET_ARCH'), d)}"

# FIXME -> find out why devshell isn't working
#do_install[depends] += "${PN}:do_devshell"

npmhelper_do_install() {
export HOME=${S}
cd ${WORKDIR}
tar -zcvf ${B}/${NPM_PKGNAME_CLEAN}-${PV}.tgz $(basename ${S})
cd -
install -d ${D}${libdir}/node_modules
npm install --prefix ${D}${prefix} -g ${NPM_EXTRA_ARGS} --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --production ${B}/${NPM_PKGNAME_CLEAN}-${PV}.tgz
}

EXPORT_FUNCTIONS do_install
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Imported from meta-sca as-is in:
# https://github.com/priv-kweihmann/meta-sca/commit/e8dba8bfd1ec4320bbc256427504f25271867492

SUMMARY = "NPM: node-gyp-build"
DESCRIPTION = "Build tool and bindings loader for node-gyp that supports prebuilds"
HOMEPAGE = "https://github.com/prebuild/node-gyp-build"

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=bb7eae1c2fbb280c72665db9a1efc896"

DEPENDS = ""

SRC_URI = "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.3.0.tgz"
SRC_URI[md5sum] = "e4925983abc8c997941bea15db423826"
SRC_URI[sha256sum] = "d9ffa0c0935751c786490d34fc8ee708a14404c760ebaaf248271f1b2ebb7bdd"

NPM_PKGNAME = "node-gyp-build"

inherit npmhelper
inherit native
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DESCRIPTION = "Node.js native addon build tool"
HOMEPAGE = "https://github.com/TooTallNate/node-gyp"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=694e396551033371686c80d3a1a69e88"
DEPENDS = "nodejs-native node-gyp-packages-native"
DEPENDS = "nodejs-native"

PV = "10.0.1+git"
SRCREV = "da19158e7a02c574d4f6d3d367ee264cb08d47ec"
Expand Down
Binary file not shown.
385 changes: 0 additions & 385 deletions meta-luneos/recipes-upstreamable/nodejs/node-gyp-packages-native.inc

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ inherit pkgconfig

do_configure() {
export GYP_DEFINES="sysroot=${STAGING_DIR_HOST}"
${WEBOS_NODE_GYP} configure
node-gyp-build
}

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

WEBOS_NODE = "webos.node"
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ do_configure() {
cd src
sh -c "xxd -i pmloglib.js > pmloglib.js.h"
cd ..
${WEBOS_NODE_GYP} configure
node-gyp-build --arch ${TARGET_ARCH} --nodedir "${WORKDIR}/node-v${NODE_VERSION}" configure
}

do_compile() {
${WEBOS_NODE_GYP} build
node-gyp-build --arch ${TARGET_ARCH} build
}

WEBOS_NODE = "pmloglib.node"
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ do_configure() {
export GYP_DEFINES="sysroot=${STAGING_DIR_HOST}"
# used by binding.gyp
export webos_servicesdir="${webos_servicesdir}" webos_prefix="${webos_prefix}"
${WEBOS_NODE_GYP} configure
node-gyp-build --arch ${TARGET_ARCH} --nodedir "${WORKDIR}/node-v${NODE_VERSION}" configure
}

do_compile() {
export GYP_DEFINES="sysroot=${STAGING_DIR_HOST}"
# used by binding.gyp
export webos_servicesdir="${webos_servicesdir}" webos_prefix="${webos_prefix}"
${WEBOS_NODE_GYP} build
node-gyp-build --arch ${TARGET_ARCH} build
}

WEBOS_NODE = "webos-sysbus.node"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SECTION = "webos/nodejs/module"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"

DEPENDS = "node-gyp-native"
DEPENDS = "npm-node-gyp-build-native"

inherit webos_public_repo
inherit webos_enhanced_submissions
Expand Down