summaryrefslogtreecommitdiffstats
path: root/meta/classes/npm.bbclass
AgeCommit message (Collapse)Author
2021-02-12npm.bbclass: avoid building target nodejs for native npm recipesYoann Congal
The current recipe unconditionally RDEPENDS on nodejs (the target one). When building on the "-native recipe" of "BBCLASSEXTEND native" recipe, the target nodejs is unnecessarily built. This patch fixes this by only RDEPENDS on nodejs when building for the target. Signed-off-by: Yoann Congal <yoann.congal@smile.fr> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-01-30npm.bbclass: use python3 for npm configVyacheslav Yurkov
python2-native executable is not available in sysroot anymore, which causes compilation of some nodejs modules to fail. Switch to python3 as a default python version. Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-01-16npm.bbclass: make shrinkwrap file optionalKamel Bouhara
Some packages don't have shrinkwrap file which means no npmsw uri is provided in the recipe. Signed-off-by: Kamel Bouhara <kamel.bouhara@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-01-27classes/npm: force to rebuild the prebuild addonsJean-Marie LEMETAYER
This commit forces to rebuild the prebuild addons which are using node-gyp-build. https://www.npmjs.com/package/node-gyp-build Signed-off-by: Jean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-01-27classes/npm: use the native pythonJean-Marie LEMETAYER
When building addons, the node-gyp build tool is looking for python. It is available in the native directory but not directly in the PATH. This commit configures npm to use the native python executable. Signed-off-by: Jean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-01-27classes/npm: use the local node headersJean-Marie LEMETAYER
When building addons, the node headers are needed to be able to compile properly. Usually they are downloaded by npm but network access in the do_compile task are unauthorized. Hopefully the local node headers are available in the native sysroot so lets use them. Signed-off-by: Jean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-01-27classes/npm: restrict the build to be offlineJean-Marie LEMETAYER
After the do_fetch task, every other tasks must not access the network. In order to ensure this point every npm command must use the offline configuration. In addition setting an invalid proxy is used as a safety. Signed-off-by: Jean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-01-27classes/npm: refactor the npm classJean-Marie LEMETAYER
This commit splits the npm build in three steps: 1. With the new npmsw fetcher, the sources and dependencies of the package have been fetched and unpacked. As sources can also be patched, a local cache must be configured to use these modified sources. 2. Next, the installation process is run using the local cache only. Some packages may need to be compiled. 3. The final installation filters the previously installed files to avoid unnecessary files. This new version also fixes multiple issues related to npm dependencies badly handled: package names, scope packages, installation directories Signed-off-by: Jean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-21npm: remove some temporary build filesJean-Marie LEMETAYER
Fixes [YOCTO #11028] When dealing with node modules which use "node-gyp" [1] to build native addons to node. Some temporary build files stay in the image: object files, static library files, dependency files, ... This commit does not keep only the required files, but remove the files which can leads to QA issues (staticdev with static library files). [1]: https://github.com/nodejs/node-gyp Signed-off-by: Jean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-21npm: fix node and npm default directory conflictJean-Marie LEMETAYER
Fixes [YOCTO #13349] When dealing with node modules which have declared "bin" files [1], npm will create a link in '/usr/bin' with a relative link to '../lib/node_modules/<module bin file>'. The commits e9270af4296ce2af292059617a717e42fc17425c and 2713d9bcc39c712ef34003ce8424416441be558e explicitely use '/usr/lib/node/' as install directory, but does not care about the "bin" symbolic linked files. In order to keep valid links, and to keep it as simple as possible, the path '/usr/lib/node_modules/' is used as install directory for npm. And a symbolic link is created to have a valid '/usr/lib/node/' path, needed for node. [1]: https://docs.npmjs.com/files/package.json#bin Signed-off-by: Jean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-21npm: get npm package name from npm packJean-Marie LEMETAYER
Fixes [YOCTO #12534] When using npm packages with exotic names, like "JSONSelect" (with uppercase) or "@angular/cli" (with at sign and slash), there are three different names: - the recipe name ("jsonselect" or "angular-cli") - the npm module name ("JSONSelect" or "@angular/cli") - the npm pack name ("JSONSelect" or "angular-cli") The commit fa9c077068a2acea04389fa2b44eb2e93548fce2 allow to have different recipe name and npm module name by setting the NPMPN variable. This commit allows to have yet another npm pack name. The pack filename is now dynamically retrieved from the 'npm pack' command. Signed-off-by: Jean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-10-25npm.bbclass: allow overriding NPM_INSTALL_DEVJef Driesen
Commit b1f10b18eaf6c8009e86863ca4a26f429de97082 added the NPM_INSTALL_DEV variable. But due to the use of simple assignment, a recipe can't override its value. Signed-off-by: Jef Driesen <jef.driesen@niko.eu> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-10-23npm: change install directory to upstream defaultRichard Purdie
The node binary searches for packages in a number of locations, the last of which is $PREFIX/lib/node (here: /usr/lib/node) from the list of GLOBAL_FOLDERS [1]. So change the installation directory for all packages depending on npm.bbclass to that location. This removes the need to define the NODE_PATH variable to the non-standard /usr/lib/node_modules value. While the Tips for Package Managers [2] discusses installing packages to /usr/lib/node_modules/<name>/<version>, this has several drawbacks: * it does not work for the REPL as mentioned in the documentation * it also does not work for any code _not_ installed as a global package under /usr/lib/node_modules (e.g. /usr/share/foo.js will not find any packages below /usr/lib) * using the non-default location and then having to set NODE_PATH barely saves any time: there are only two file-system lookups (to the legacy $HOME/.node_modules and $HOME/.node_libraries) directories before the library would be found And the suggestion was made in the context of deduping the node_modules tree by installing all packages in a flat hierarchy and using symlinks to the correct version of each dependency. This is not what OpenEmbedded does, so none of those benefits (deduping, cleaner packages) are being had by shifting the installation directory to /usr/lib/node_modules. The choice of a "proper" installation path is not helped by npm installing to /usr/lib/node_modules if asked to install globally. Still, using the location expected by nodejs (/usr/lib/node) seems the right choice. [1]: https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders [2]: https://nodejs.org/api/modules.html#modules_addenda_package_manager_tips Signed-off-by: Olaf Mandel <o.mandel@menlosystems.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-10-20npm: change install directory to upstream defaultOlaf Mandel
The node binary searches for packages in a number of locations, the last of which is $PREFIX/lib/node (here: /usr/lib/node) from the list of GLOBAL_FOLDERS [1]. Change the installation directory for all packages depending on npm.bbclass to that location. This removes the need to define the NODE_PATH variable to the non-standard /usr/lib/node_modules value. While the Tips for Package Managers [2] discusses installing packages to /usr/lib/node_modules/<name>/<version>, this has several drawbacks: * it does not work for the REPL as mentioned in the documentation * it also does not work for any code _not_ installed as a global package under /usr/lib/node_modules (e.g. /usr/share/foo.js will not find any packages below /usr/lib) * using the non-default location and then having to set NODE_PATH barely saves any time: there are only two file-system lookups (to the legacy $HOME/.node_modules and $HOME/.node_libraries) directories before the library would be found And the suggestion was made in the context of deduping the node_modules tree by installing all packages in a flat hierarchy and using symlinks to the correct version of each dependency. This is not what OpenEmbedded does, so none of those benefits (deduping, cleaner packages) are being had by shifting the installation directory to /usr/lib/node_modules. [1]: https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders [2]: https://nodejs.org/api/modules.html#modules_addenda_package_manager_tips Signed-off-by: Olaf Mandel <o.mandel@menlosystems.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-02-06npm.bbclass: Node module name and recipe name can be differentBöszörményi Zoltán
Some NPM modules have the same name as their low level dependencies. To prevent recipe naming conflicts, allow node module recipe names to start with the "node-" prefix. Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu> Signed-off-by: Ross Burton <ross.burton@intel.com>
2018-02-06npm.bbclass: Fix building node modules with npm@5Böszörményi Zoltán
npm cache clear throws an error with npm@5 and suggests to use npm cache verify instead. But our cache is actually empty, so use npm cache clear --force. npm install in the source directory creates symlinks with npm@5. Use a combination of npm pack and npm install module-version.tgz that works the same way with older and new npm versions and is guaranteed to create actual copies instead of directory symlinks. This change allows using nodejs 8.x LTS, tested with 8.9.4. Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu> Signed-off-by: Ross Burton <ross.burton@intel.com>
2017-03-21classes/npm: allow installation of devDependenciesAnders Darander
Often, eg when using angular2, there's a need to install also the devDependencies. The default is to keep the old behaviour, to not install devDependencies. Signed-off-by: Anders Darander <anders@chargestorm.se> Signed-off-by: Ross Burton <ross.burton@intel.com>
2017-02-07classes/npm: set HOME during do_installPaul Eggleton
In do_compile we set HOME so that ~/.npm* only get created in the work directory; we need to do the same in do_install as well or they'll go into the user's home directory which we do not want. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-12-16meta: remove True option to getVar callsJoshua Lock
getVar() now defaults to expanding by default, thus remove the True option from getVar() calls with a regex search and replace. Search made with the following regex: getVar ?\(( ?[^,()]*), True\) Signed-off-by: Joshua Lock <joshua.g.lock@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-11-06classes/npm: use npm install to do installationPaul Eggleton
Using "npm install" instead of "cp -a" is the more correct thing to be doing here, and ensures that symlinks for executable scripts are put into ${prefix}/bin. (I'd prefer ${bindir}, but npm does not allow specifying paths at that level - only a prefix.) Fixes [YOCTO #10460]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-09-08recipetool: create: support node.js code outside of npmPaul Eggleton
If you have your own node.js application you may not publish it (or at least not immediately) in an npm registry - it might just be in a repository on github or on your local machine. Add support to recipetool create for creating recipes to build such applications - extract their dependencies, fetch them, and add corresponding npm:// URLs to SRC_URI, and ensure that LICENSE / LIC_FILES_CHKSUM are updated to match. For example, you can now run: recipetool create https://github.com/diversario/node-ssdp (I had to borrow some code from bitbake/lib/bb/fetch2/npm.py to implement this functionality; this should be refactored out but now isn't the time to do that refactoring.) Part of the fix for [YOCTO #9537]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2016-08-17npm: npm.bbclass now adds nodejs to RDEPENDSHenry Bruce
We expect that any package that uses the npm bbclass will have a runtime dependency on node.js Signed-off-by: Henry Bruce <henry.bruce@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-06-12npm.bbclass: avoid str/byte conversion problems for PKGV and SUMMARYPatrick Ohly
In Python3, str.encode() returns byte strings, which later are not converted back to strings automatically, leading to "TypeError: Can't convert 'bytes' object to str implicitly" in code which reads PKGV and SUMMARY and expects to find strings there. The npm.bbclass must use values for d.setVar() that meet that expectation, and thus the redundant (and in Python3, harmful) .encode() gets removed. Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-05-30npm: add target_arch flag to npmBrendan Le Foll
npm takes a target_arch flag which needs to be set to do some gyp compilations correctly. It also doesn't use the same mapping as OE for target arch so a small function is required to make the mapping work. Function is taken from meta-nodejs Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-04-14npm.bbclass: Stop packagenames containing underscores from being generatedBrendan Le Foll
Package names cannot contain underscores yet some npm modules use them as part of the name, replace them with hyphens in the package name. Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-03-23devtool: add: delete externalsrc files on npm recipe do_installPaul Eggleton
The npm class just installs whatever is in ${S}; if you're using externalsrc in conjunction with it the symlinks (oe-workdir and oe-logs by default) plus singletask.lock will end up in the final package, which isn't really right. Introduce a variable so we know the path the files will be installed into within npm.bbclass, and append to do_install within the workspace bbappend to delete the files. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-03-09recipetool: create: split npm module dependencies into packagesPaul Eggleton
Rather than rolling all of an npm module's dependencies into the same package, split them into one module per package, setting the SUMMARY and PKGV values from the package.json file for each package. Additionally, mark each package with the appropriate license using the license scanning we already do, falling back to the license stated in the package.json file for the module if unknown. All of this is mostly in aid of ensuring all modules and their licenses now show up in the manifests for the image. Additionally we set the main LICENSE value more concretely once we've calculated the per-package licenses, since we have more information at that point. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-02-28npm.bbclass: Add npm class to match fetcherBrendan Le Foll
npm class supports the npm fetcher, helping doing the basic compile/install stages of an npm package Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>