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

Add zeus branch with latest nodejs versions #98

Closed
wants to merge 21 commits into from
Closed
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
48 changes: 25 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ meta-nodejs <img src="https://github.com/nodejs/nodejs.org/raw/master/static/ima
===========

OpenEmbedded layer for latest [Node.js](https://nodejs.org/ "Node.js") releases.

:information_source: *As an official extension of this layer, installing [`meta-nodejs-contrib`](https://github.com/imyller/meta-nodejs-contrib) is highly recommended for community contributed Node.js based package recipes and Bitbake helper classes.*

## Node.js releases

* ![Current 7](https://img.shields.io/badge/Node.js%20Current-7.10.0-green.svg)
* ![LTS 6](https://img.shields.io/badge/Node.js%20LTS-6.10.3-blue.svg)
* ![Maintenance 4](https://img.shields.io/badge/Node.js%20Maintenance-4.8.3-B0C4DE.svg)
* ![End of life 0.12](https://img.shields.io/badge/Node.js%20End%20of%20Life-0.12.18-lightgray.svg)
* ![End of life 0.10](https://img.shields.io/badge/Node.js%20End%20of%20Life-0.10.48-lightgray.svg)
* ![End of life 0.8](https://img.shields.io/badge/Node.js%20End%20of%20Life-0.8.28-lightgrey.svg)
* ![Current 13](https://img.shields.io/badge/Node.js%20Current-13.6.0-green.svg)
* ![Active LTS 12](https://img.shields.io/badge/Node.js%20LTS-12.14.1-blue.svg)

![LTS Schedule](https://github.com/nodejs/LTS/raw/master/schedule.png)
![LTS Schedule](https://github.com/nodejs/Release/blob/master/schedule.svg)

## Dependencies

Expand Down Expand Up @@ -53,15 +49,15 @@ Installation
Layer installation varies depending on your OpenEmbedded distribution. These instructions are generic.

1. Fetch `meta-nodejs` layer from `https://github.com/imyller/meta-nodejs.git`

2. Add `meta-nodejs` layer to `EXTRALAYERS` in `conf/bblayers.conf`. For example:

```bitbake
EXTRALAYERS +=" \
${TOPDIR}/sources/meta-nodejs \
"
```
```bitbake
EXTRALAYERS +=" \
${TOPDIR}/sources/meta-nodejs \
"
```

## Recommended layers

As an official extension of this layer, installing [`meta-nodejs-contrib`](https://github.com/imyller/meta-nodejs-contrib) is highly recommended for community contributed Node.js based package recipes and Bitbake helper classes.
Expand All @@ -74,41 +70,47 @@ Usage
To build latest stable Node.js package:

```shell
bitbake nodejs
bitbake nodejs
```

To select your preferred nodejs version, set the following variable in your local.conf:

```
PREFERRED_VERSION_nodejs = "12.x.x"
```

### Node.js as a dependency

Add Node.js as a dependency in recipe with `RDEPENDS` (for runtime) or `DEPENDS` (for build):

```bitbake
DEPENDS += " nodejs"
RDEPENDS_${PN} += " nodejs"
DEPENDS += " nodejs"
RDEPENDS_${PN} += " nodejs"
```

### `npm install` buildable recipes

Inherit `npm-install` build task class in your recipe.

Bitbake classes
Bitbake classes
===============

`meta-nodejs` layer adds few Node.js related helper classes.

## `npm-base` class

`npm-base` class defines following functions:

* `oe_runnpm`: call cross-compiling `npm`
* `oe_runnpm_native`: call native-compiling `npm`

For example:

```bitbake
inherit npm-base

do_install() {
oe_runnpm install # Installs dependencies defined in package.json
oe_runnpm install # Installs dependencies defined in package.json
}
```

Expand All @@ -134,7 +136,7 @@ You can disable one or more of these build tasks in the recipe with `do_<tasknam

### Variables

* `NPM_INSTALL_FLAGS`: Extra command line arguments for `npm` calls made in `npm_install` task
* `NPM_INSTALL_FLAGS`: Extra command line arguments for `npm` calls made in `npm_install` task
* `NPM_INSTALL`: Parameters for `npm install` command (such as specific package names)

## `npm-install-global` class
Expand Down
142 changes: 82 additions & 60 deletions classes/npm-base.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ NPM_REGISTRY ?= "https://registry.npmjs.org/"
NPM_IGNORE = "${WORKDIR}/.npmignore"

NPM ?= "npm"
NPM_CACHE_DIR = "${TMPDIR}/npm_cache/${PF}"
NPM_HOME_DIR = "${TMPDIR}/npm_home/${PF}"
NPM_ARCH ?= "${@nodejs_map_dest_cpu(d.getVar('TARGET_ARCH', True), d)}"
NPM_LD ?= "${CXX}"
Expand All @@ -23,52 +22,63 @@ NPM_FLAGS_append_class-nativesdk = " --unsafe-perm"

oe_runnpm() {

if [ "${NPM_ARCH}" != "allarch" ]; then
ARCH_FLAGS="--arch=${NPM_ARCH} --target_arch=${NPM_ARCH}"
else
ARCH_FLAGS=""
fi
if [ "${NPM_ARCH}" != "allarch" ]; then
ARCH_FLAGS="--arch=${NPM_ARCH} --target_arch=${NPM_ARCH}"
else
ARCH_FLAGS=""
fi

echo "/temp/" >> "${NPM_IGNORE}"
echo "/pseudo/" >> "${NPM_IGNORE}"
echo "/sstate*/" >> "${NPM_IGNORE}"
echo "/license-destdir/" >> "${NPM_IGNORE}"
echo "/image/" >> "${NPM_IGNORE}"
echo "/patches/" >> "${NPM_IGNORE}"
echo ".npmignore" >> "${NPM_IGNORE}"
echo "/.*/" >> "${NPM_IGNORE}"
echo "/temp/" >> "${NPM_IGNORE}"
echo "/pseudo/" >> "${NPM_IGNORE}"
echo "/sstate*/" >> "${NPM_IGNORE}"
echo "/license-destdir/" >> "${NPM_IGNORE}"
echo "/image/" >> "${NPM_IGNORE}"
echo "/patches/" >> "${NPM_IGNORE}"
echo ".npmignore" >> "${NPM_IGNORE}"
echo "/.*/" >> "${NPM_IGNORE}"

mkdir -p "${NPM_HOME_DIR}"
mkdir -p "${NPM_HOME_DIR}"

export NPM_CONFIG_CACHE="${NPM_CACHE_DIR}"
export NPM_CONFIG_DEV="false"
export NPM_VERSION="$(${NPM} --v)"
export NPM_CACHE_CMD="clean --force"

bbnote NPM target architecture: ${NPM_ARCH}
bbnote NPM home directory: ${NPM_HOME_DIR}
bbnote NPM cache directory: ${NPM_CONFIG_CACHE}
bbnote NPM registry: ${NPM_REGISTRY}
bbnote NPM workdir .npmignore: ${NPM_IGNORE}
if [ "${NPM_CACHE_DIR}" = "" ]; then
export NPM_CONFIG_CACHE="${DL_DIR}/npm_v${NPM_VERSION}_${TARGET_ARCH}_cache/${PF}"
else
export NPM_CONFIG_CACHE=${NPM_CACHE_DIR}
fi

bbnote ${NPM} --registry=${NPM_REGISTRY} ${ARCH_FLAGS} ${NPM_FLAGS} "$@"
export NPM_CONFIG_DEV="false"

export JOBS=${@oe.utils.cpu_count()}
bbnote NPM version: $NPM_VERSION
bbnote NPM target architecture: ${NPM_ARCH}
bbnote NPM home directory: ${NPM_HOME_DIR}
bbnote NPM cache directory: ${NPM_CONFIG_CACHE}
bbnote NPM registry: ${NPM_REGISTRY}
bbnote NPM workdir .npmignore: ${NPM_IGNORE}

export http_proxy="${http_proxy}"
export https_proxy="${https_proxy}"
export no_proxy="${no_proxy}"
bbnote ${NPM} --registry=${NPM_REGISTRY} ${ARCH_FLAGS} ${NPM_FLAGS} "$@"

export HOME="${NPM_HOME_DIR}"
export JOBS="${@oe.utils.cpu_count()}"

${NPM} cache clean || die "oe_runnpm failed (cache clean)"
export http_proxy="${http_proxy}"
export https_proxy="${https_proxy}"
export no_proxy="${no_proxy}"

LD="${NPM_LD}" ${NPM} --registry=${NPM_REGISTRY} ${ARCH_FLAGS} ${NPM_FLAGS} "$@" || die "oe_runnpm failed (install)"
export HOME="${NPM_HOME_DIR}"

if [ "$(echo ${NPM_VERSION} | cut -d. -f1)" = "5" ]; then
NPM_CACHE_CMD="verify"
fi

${NPM} cache $NPM_CACHE_CMD || die "oe_runnpm failed (cache $NPM_CACHE_CMD)"

LD="${NPM_LD}" ${NPM} --registry=${NPM_REGISTRY} ${ARCH_FLAGS} ${NPM_FLAGS} "$@" || die "oe_runnpm failed (install)"
}

# Native npm

NPM_NATIVE ?= "npm"
NPM_CACHE_DIR_NATIVE = "${TMPDIR}/npm_cache_native/${PF}"
NPM_HOME_DIR_NATIVE = "${TMPDIR}/npm_home_native/${PF}"
NPM_ARCH_NATIVE ?= "${@nodejs_map_dest_cpu(d.getVar('BUILD_ARCH', True), d)}"
NPM_LD_NATIVE ?= "${BUILD_CXX}"
Expand All @@ -78,44 +88,56 @@ NPM_FLAGS_NATIVE_append_class-nativesdk = " --unsafe-perm"

oe_runnpm_native() {

if [ "${NPM_ARCH_NATIVE}" != "allarch" ]; then
ARCH_FLAGS="--arch=${NPM_ARCH_NATIVE} --target_arch=${NPM_ARCH_NATIVE}"
else
ARCH_FLAGS=""
fi
if [ "${NPM_ARCH_NATIVE}" != "allarch" ]; then
ARCH_FLAGS="--arch=${NPM_ARCH_NATIVE} --target_arch=${NPM_ARCH_NATIVE}"
else
ARCH_FLAGS=""
fi

echo "/temp/" >> "${NPM_IGNORE}"
echo "/pseudo/" >> "${NPM_IGNORE}"
echo "/sstate*/" >> "${NPM_IGNORE}"
echo "/license-destdir/" >> "${NPM_IGNORE}"
echo "/image/" >> "${NPM_IGNORE}"
echo "/patches/" >> "${NPM_IGNORE}"
echo ".npmignore" >> "${NPM_IGNORE}"
echo "/.*/" >> "${NPM_IGNORE}"

mkdir -p "${NPM_HOME_DIR_NATIVE}"

echo "/temp/" >> "${NPM_IGNORE}"
echo "/pseudo/" >> "${NPM_IGNORE}"
echo "/sstate*/" >> "${NPM_IGNORE}"
echo "/license-destdir/" >> "${NPM_IGNORE}"
echo "/image/" >> "${NPM_IGNORE}"
echo "/patches/" >> "${NPM_IGNORE}"
echo ".npmignore" >> "${NPM_IGNORE}"
echo "/.*/" >> "${NPM_IGNORE}"
export NPM_VERSION="$(${NPM} --v)"
export NPM_CACHE_CMD="clean --force"

mkdir -p "${NPM_HOME_DIR_NATIVE}"
if [ "${NPM_CACHE_DIR_NATIVE}" = "" ]; then
export NPM_CONFIG_CACHE="${DL_DIR}/npm_v${NPM_VERSION}_${TARGET_ARCH}_native/${PF}"
else
export NPM_CONFIG_CACHE=${NPM_CACHE_DIR_NATIVE}
fi

export NPM_CONFIG_CACHE="${NPM_CACHE_DIR_NATIVE}"
export NPM_CONFIG_DEV="false"
export NPM_CONFIG_DEV="false"

bbnote NPM native architecture: ${NPM_ARCH_NATIVE}
bbnote NPM home directory: ${NPM_HOME_DIR_NATIVE}
bbnote NPM cache directory: ${NPM_CONFIG_CACHE}
bbnote NPM registry: ${NPM_REGISTRY}
bbnote NPM workdir .npmignore: ${NPM_IGNORE}
bbnote NPM version: $NPM_VERSION
bbnote NPM native architecture: ${NPM_ARCH_NATIVE}
bbnote NPM home directory: ${NPM_HOME_DIR_NATIVE}
bbnote NPM cache directory: ${NPM_CONFIG_CACHE}
bbnote NPM registry: ${NPM_REGISTRY}
bbnote NPM workdir .npmignore: ${NPM_IGNORE}

bbnote ${NPM_NATIVE} --registry=${NPM_REGISTRY} ${ARCH_FLAGS} ${NPM_FLAGS_NATIVE} "$@"
bbnote ${NPM_NATIVE} --registry=${NPM_REGISTRY} ${ARCH_FLAGS} ${NPM_FLAGS_NATIVE} "$@"

export JOBS=${@oe.utils.cpu_count()}
export JOBS="${@oe.utils.cpu_count()}"

export http_proxy="${http_proxy}"
export https_proxy="${https_proxy}"
export no_proxy="${no_proxy}"
export http_proxy="${http_proxy}"
export https_proxy="${https_proxy}"
export no_proxy="${no_proxy}"

export HOME="${NPM_HOME_DIR_NATIVE}"
export HOME="${NPM_HOME_DIR_NATIVE}"

${NPM} cache clean || die "oe_runnpm_native failed (cache clean)"
if [ "$(echo ${NPM_VERSION} | cut -d. -f1)" = "5" ]; then
NPM_CACHE_CMD="verify"
fi

LD="${NPM_LD_NATIVE}" ${NPM_NATIVE} --registry=${NPM_REGISTRY} ${ARCH_FLAGS} ${NPM_FLAGS_NATIVE} "$@" || die "oe_runnpm_native failed (install)"
${NPM_NATIVE} cache $NPM_CACHE_CMD || die "oe_runnpm_native failed (cache $NPM_CACHE_CMD)"

LD="${NPM_LD_NATIVE}" ${NPM_NATIVE} --registry=${NPM_REGISTRY} ${ARCH_FLAGS} ${NPM_FLAGS_NATIVE} "$@" || die "oe_runnpm_native failed (install)"
}
4 changes: 2 additions & 2 deletions classes/npm-install-global.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ NPM_INSTALL_FLAGS ?= ""

# Install the local dependencies and make the package ready for installation
do_configure() {
oe_runnpm ${NPM_INSTALL_FLAGS} install --verbose
oe_runnpm ${NPM_INSTALL_FLAGS} install --verbose
}

# Install the package globally
do_install() {
oe_runnpm ${NPM_INSTALL_FLAGS} install -g --prefix=${D}${prefix} --verbose
oe_runnpm ${NPM_INSTALL_FLAGS} install -g --prefix=${D}${prefix} --verbose
}

FILES_${PN} += "${prefix}"
Expand Down
19 changes: 13 additions & 6 deletions classes/npm-install.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@ B="${S}"

NPM_INSTALL ?= ""
NPM_INSTALL_FLAGS ?= ""
NPM_AUDIT_FLAGS ?= ""

do_npm_install() {
cd ${S}
oe_runnpm ${NPM_INSTALL_FLAGS} install ${NPM_INSTALL}
cd ${S}
oe_runnpm ${NPM_INSTALL_FLAGS} install ${NPM_INSTALL}
}

do_npm_shrinkwrap() {
cd ${S}
oe_runnpm shrinkwrap
cd ${S}
oe_runnpm shrinkwrap
}

do_npm_dedupe() {
cd ${S}
oe_runnpm dedupe
cd ${S}
oe_runnpm dedupe
}

do_npm_audit() {
cd ${S}
oe_runnpm audit fix ${NPM_AUDIT_FLAGS}
}

#
Expand All @@ -28,3 +34,4 @@ INSANE_SKIP_${PN}-dbg += " host-user-contaminated"
addtask npm_install after do_compile before do_npm_dedupe
addtask npm_shrinkwrap after do_npm_install before do_npm_dedupe
addtask npm_dedupe after do_npm_shrinkwrap before do_install
addtask npm_audit after do_npm_install before do_npm_dedupe
Loading