Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1 | DEPENDS_prepend = "nodejs-native " |
| 2 | S = "${WORKDIR}/npmpkg" |
| 3 | |
| 4 | NPM_INSTALLDIR = "${D}${libdir}/node_modules/${PN}" |
| 5 | |
| 6 | npm_do_compile() { |
| 7 | # changing the home directory to the working directory, the .npmrc will |
| 8 | # be created in this directory |
| 9 | export HOME=${WORKDIR} |
| 10 | npm config set dev false |
| 11 | npm set cache ${WORKDIR}/npm_cache |
| 12 | # clear cache before every build |
| 13 | npm cache clear |
| 14 | # Install pkg into ${S} without going to the registry |
| 15 | npm --arch=${TARGET_ARCH} --production --no-registry install |
| 16 | } |
| 17 | |
| 18 | npm_do_install() { |
| 19 | mkdir -p ${NPM_INSTALLDIR}/ |
| 20 | cp -a ${S}/* ${NPM_INSTALLDIR}/ --no-preserve=ownership |
| 21 | } |
| 22 | |
| 23 | python populate_packages_prepend () { |
| 24 | instdir = d.expand('${D}${libdir}/node_modules/${PN}') |
| 25 | extrapackages = oe.package.npm_split_package_dirs(instdir) |
| 26 | pkgnames = extrapackages.keys() |
| 27 | d.prependVar('PACKAGES', '%s ' % ' '.join(pkgnames)) |
| 28 | for pkgname in pkgnames: |
| 29 | pkgrelpath, pdata = extrapackages[pkgname] |
| 30 | pkgpath = '${libdir}/node_modules/${PN}/' + pkgrelpath |
| 31 | # package names can't have underscores but npm packages sometimes use them |
| 32 | oe_pkg_name = pkgname.replace('_', '-') |
| 33 | expanded_pkgname = d.expand(oe_pkg_name) |
| 34 | d.setVar('FILES_%s' % expanded_pkgname, pkgpath) |
| 35 | if pdata: |
| 36 | version = pdata.get('version', None) |
| 37 | if version: |
| 38 | d.setVar('PKGV_%s' % expanded_pkgname, version.encode("utf8")) |
| 39 | description = pdata.get('description', None) |
| 40 | if description: |
| 41 | d.setVar('SUMMARY_%s' % expanded_pkgname, description.replace(u"\u2018", "'").replace(u"\u2019", "'").encode("utf8")) |
| 42 | d.appendVar('RDEPENDS_%s' % d.getVar('PN', True), ' %s' % ' '.join(pkgnames).replace('_', '-')) |
| 43 | } |
| 44 | |
| 45 | FILES_${PN} += " \ |
| 46 | ${libdir}/node_modules/${PN} \ |
| 47 | " |
| 48 | |
| 49 | EXPORT_FUNCTIONS do_compile do_install |