Bug 11028

Summary: devtool: source and object files are packaged when building npm gyp project
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Henry Bruce <henry.bruce>
Component: devtools / tool chainAssignee: Unassigned <unassigned>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: bluelightning, jeanmarie.lemetayer, meta.mr.watcher, meta.watcher
Version: 2.2   
Target Milestone: Future   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know
Bug Depends on:    
Bug Blocks: 10653    

Description Henry Bruce 2017-02-08 01:25:28 UTC
gyp is used to build platform specific components of node.js projects. NPM will download and build native code, which is then unnecessarily packaged.

Steps to re-create
------------------
$ git clone -b morty git://git.yoctoproject.org/poky
$ git clone -b morty git://git.openembedded.org/meta-openembedded
$ source poky/oe-init-build-env
$ bitbake-layers add-layer ../meta-openembedded/meta-oe
$ devtool add 'npm://registry.npmjs.org;name=mraa;version=1.5.1'
$ devtool build mraa

Observe that entire source and build directories are packaged


Expected behavior
-----------------
Only required files are packages (e.g. package.json, native node.js files etc.)
Comment 1 Jean-Marie Lemetayer 2020-05-17 05:04:18 UTC
This is fixed in the master. Now all the generated files (object, static libraries) are removed. Only the generated *.node file is kept.

As there is no way to know if a file in the package (ie not generated) is actually needed or not, source files and other unneeded files (like binding.gyp) are still packaged.

If this is a real issue, I suggest to create a do_install_append() to remove them as this is package specific.

% devtool add 'npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=latest'
% devtool build savoirfairelinux-node-server-example
% tree tmp/work/core2-64-poky-linux/savoirfairelinux-node-server-example/1.0.1-r0/image/
tmp/work/core2-64-poky-linux/savoirfairelinux-node-server-example/1.0.1-r0/image/
└── usr
    ├── bin
    │   └── node-server-example -> ../lib/node_modules/@savoirfairelinux/node-server-example/index.js
    └── lib
        ├── node -> node_modules
        └── node_modules
            └── @savoirfairelinux
                └── node-server-example
                    ├── binding.gyp
                    ├── build
                    │   └── Release
                    │       └── hello.node
                    ├── hello.c
                    ├── index.js
                    ├── LICENSE
                    ├── ...