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

npm-base: Move cache dir to persistent location #70

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ 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)
* ![Current 7](https://img.shields.io/badge/Node.js%20Current-7.10.1-green.svg)
* ![LTS 6](https://img.shields.io/badge/Node.js%20LTS-6.11.2-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)
Expand Down Expand Up @@ -53,15 +53,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 \
"
```

## 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 Down Expand Up @@ -90,18 +90,18 @@ Add Node.js as a dependency in recipe with `RDEPENDS` (for runtime) or `DEPENDS`

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
Expand Down Expand Up @@ -134,7 +134,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
18 changes: 14 additions & 4 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 Down Expand Up @@ -40,7 +39,13 @@ oe_runnpm() {

mkdir -p "${NPM_HOME_DIR}"

export NPM_CONFIG_CACHE="${NPM_CACHE_DIR}"
if [ "${NPM_CACHE_DIR}" == "" ]; then
NPM_VERSION=`${NPM} -v`
export NPM_CONFIG_CACHE="${DL_DIR}/npm_v${NPM_VERSION}_${TARGET_ARCH}_cache/${PF}"
else
export NPM_CONFIG_CACHE=${NPM_CACHE_DIR}
fi

export NPM_CONFIG_DEV="false"

bbnote NPM target architecture: ${NPM_ARCH}
Expand Down Expand Up @@ -68,7 +73,6 @@ oe_runnpm() {
# 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 @@ -95,7 +99,13 @@ oe_runnpm_native() {

mkdir -p "${NPM_HOME_DIR_NATIVE}"

export NPM_CONFIG_CACHE="${NPM_CACHE_DIR_NATIVE}"
if [ "${NPM_CACHE_DIR_NATIVE}" == "" ]; then
NPM_VERSION=`${NPM} -v`
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_DEV="false"

bbnote NPM native architecture: ${NPM_ARCH_NATIVE}
Expand Down
9 changes: 0 additions & 9 deletions recipes-devtools/nodejs/nodejs_6.10.3.bb

This file was deleted.

9 changes: 9 additions & 0 deletions recipes-devtools/nodejs/nodejs_6.11.2.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require nodejs_6.inc
require nodejs_lts.inc

INC_PR = "r1"

LIC_FILES_CHKSUM = "file://LICENSE;md5=41a3a0ccf7f515cac3377389dd8faac8"

SRC_URI[src.md5sum] = "d560f0d09e54364933f8d179aa5fc5bd"
SRC_URI[src.sha256sum] = "20146ed51b638404665737ed8a25cc06e96d7d7259eb90a4bdec4730a78002a6"
9 changes: 0 additions & 9 deletions recipes-devtools/nodejs/nodejs_7.10.0.bb

This file was deleted.

8 changes: 8 additions & 0 deletions recipes-devtools/nodejs/nodejs_7.10.1.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require nodejs_7.inc

INC_PR = "r1"

LIC_FILES_CHKSUM = "file://LICENSE;md5=d29463feca32ea5977af7b6c7d62c14a"

SRC_URI[src.md5sum] = "652fc03608e00dc9e5688331328ef62f"
SRC_URI[src.sha256sum] = "baf060e5d3abb8fdebb8c2b28c4d8cde05d43acfd9fc687f21f4b7a3ff69745e"