Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | DESCRIPTION = "nodeJS Evented I/O for V8 JavaScript" |
| 2 | HOMEPAGE = "http://nodejs.org" |
| 3 | LICENSE = "MIT & BSD & Artistic-2.0" |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=be980eb7ccafe287cb438076a65e888c" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5 | |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 6 | DEPENDS = "openssl" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 7 | DEPENDS_append_class-target = " nodejs-native" |
| 8 | |
Brad Bishop | 87b3cb8 | 2019-11-15 16:35:37 -0500 | [diff] [blame] | 9 | inherit pkgconfig pythonnative |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 10 | |
| 11 | COMPATIBLE_MACHINE_armv4 = "(!.*armv4).*" |
| 12 | COMPATIBLE_MACHINE_armv5 = "(!.*armv5).*" |
| 13 | COMPATIBLE_MACHINE_mips64 = "(!.*mips64).*" |
| 14 | |
Brad Bishop | c1d3433 | 2019-09-09 14:56:00 -0400 | [diff] [blame] | 15 | COMPATIBLE_HOST_riscv64 = "null" |
| 16 | COMPATIBLE_HOST_riscv32 = "null" |
| 17 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 18 | SRC_URI = "http://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \ |
| 19 | file://0001-Disable-running-gyp-files-for-bundled-deps.patch \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 20 | file://0004-Make-compatibility-with-gcc-4.8.patch \ |
Brad Bishop | 87b3cb8 | 2019-11-15 16:35:37 -0500 | [diff] [blame] | 21 | file://0007-v8-don-t-override-ARM-CFLAGS.patch \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 22 | " |
| 23 | SRC_URI_append_class-target = " \ |
Brad Bishop | 8410d61 | 2019-11-25 09:40:59 -0500 | [diff] [blame] | 24 | file://0005-Link-atomic-library.patch \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 25 | file://0002-Using-native-torque.patch \ |
| 26 | " |
| 27 | |
Brad Bishop | 868407c | 2019-11-04 13:24:47 -0500 | [diff] [blame] | 28 | SRC_URI[md5sum] = "d5a56d0abf764a91f627f0690cd4b9f3" |
| 29 | SRC_URI[sha256sum] = "412667d76bd5273c07cb69c215998109fd5bb35c874654f93e6a0132d666c58e" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 30 | |
| 31 | S = "${WORKDIR}/node-v${PV}" |
| 32 | |
| 33 | # v8 errors out if you have set CCACHE |
| 34 | CCACHE = "" |
| 35 | |
| 36 | def map_nodejs_arch(a, d): |
| 37 | import re |
| 38 | |
| 39 | if re.match('i.86$', a): return 'ia32' |
| 40 | elif re.match('x86_64$', a): return 'x64' |
| 41 | elif re.match('aarch64$', a): return 'arm64' |
| 42 | elif re.match('(powerpc64|ppc64le)$', a): return 'ppc64' |
| 43 | elif re.match('powerpc$', a): return 'ppc' |
| 44 | return a |
| 45 | |
| 46 | ARCHFLAGS_arm = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', '--with-arm-float-abi=hard', '--with-arm-float-abi=softfp', d)} \ |
| 47 | ${@bb.utils.contains('TUNE_FEATURES', 'neon', '--with-arm-fpu=neon', \ |
| 48 | bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', '--with-arm-fpu=vfpv3-d16', \ |
| 49 | bb.utils.contains('TUNE_FEATURES', 'vfpv3', '--with-arm-fpu=vfpv3', \ |
| 50 | '--with-arm-fpu=vfp', d), d), d)}" |
| 51 | GYP_DEFINES_append_mipsel = " mips_arch_variant='r1' " |
| 52 | ARCHFLAGS ?= "" |
| 53 | |
Brad Bishop | 868407c | 2019-11-04 13:24:47 -0500 | [diff] [blame] | 54 | PACKAGECONFIG ??= "ares icu libuv zlib" |
| 55 | PACKAGECONFIG[ares] = "--shared-cares,,c-ares" |
Brad Bishop | 87b3cb8 | 2019-11-15 16:35:37 -0500 | [diff] [blame] | 56 | PACKAGECONFIG[gyp] = ",,gyp-py2-native" |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 57 | PACKAGECONFIG[icu] = "--with-intl=system-icu,--without-intl,icu" |
Brad Bishop | 868407c | 2019-11-04 13:24:47 -0500 | [diff] [blame] | 58 | PACKAGECONFIG[libuv] = "--shared-libuv,,libuv" |
Brad Bishop | 2f97392 | 2019-11-11 07:58:48 -0500 | [diff] [blame] | 59 | PACKAGECONFIG[nghttp2] = "--shared-nghttp2,,nghttp2" |
Brad Bishop | 868407c | 2019-11-04 13:24:47 -0500 | [diff] [blame] | 60 | PACKAGECONFIG[zlib] = "--shared-zlib,,zlib" |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 61 | |
Brad Bishop | 87b3cb8 | 2019-11-15 16:35:37 -0500 | [diff] [blame] | 62 | # We don't want to cross-compile during target compile, |
| 63 | # and we need to use the right flags during host compile, |
| 64 | # too. |
| 65 | EXTRA_OEMAKE = "\ |
| 66 | CC.host='${CC}' \ |
| 67 | CFLAGS.host='${CPPFLAGS} ${CFLAGS}' \ |
| 68 | CXX.host='${CXX}' \ |
| 69 | CXXFLAGS.host='${CPPFLAGS} ${CXXFLAGS}' \ |
| 70 | LDFLAGS.host='${LDFLAGS}' \ |
| 71 | AR.host='${AR}' \ |
| 72 | \ |
| 73 | builddir_name=./ \ |
| 74 | " |
| 75 | |
| 76 | python do_unpack() { |
| 77 | import shutil |
| 78 | |
| 79 | bb.build.exec_func('base_do_unpack', d) |
| 80 | |
| 81 | shutil.rmtree(d.getVar('S') + '/deps/openssl', True) |
| 82 | if 'ares' in d.getVar('PACKAGECONFIG'): |
| 83 | shutil.rmtree(d.getVar('S') + '/deps/cares', True) |
| 84 | if 'gyp' in d.getVar('PACKAGECONFIG'): |
| 85 | shutil.rmtree(d.getVar('S') + '/tools/gyp', True) |
| 86 | if 'libuv' in d.getVar('PACKAGECONFIG'): |
| 87 | shutil.rmtree(d.getVar('S') + '/deps/uv', True) |
| 88 | if 'nghttp2' in d.getVar('PACKAGECONFIG'): |
| 89 | shutil.rmtree(d.getVar('S') + '/deps/nghttp2', True) |
| 90 | if 'zlib' in d.getVar('PACKAGECONFIG'): |
| 91 | shutil.rmtree(d.getVar('S') + '/deps/zlib', True) |
| 92 | } |
| 93 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 94 | # Node is way too cool to use proper autotools, so we install two wrappers to forcefully inject proper arch cflags to workaround gypi |
| 95 | do_configure () { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 96 | export LD="${CXX}" |
| 97 | GYP_DEFINES="${GYP_DEFINES}" export GYP_DEFINES |
| 98 | # $TARGET_ARCH settings don't match --dest-cpu settings |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 99 | ./configure --prefix=${prefix} --without-snapshot --shared-openssl \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 100 | --dest-cpu="${@map_nodejs_arch(d.getVar('TARGET_ARCH'), d)}" \ |
| 101 | --dest-os=linux \ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 102 | ${ARCHFLAGS} \ |
| 103 | ${PACKAGECONFIG_CONFARGS} |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | do_compile () { |
| 107 | export LD="${CXX}" |
| 108 | oe_runmake BUILDTYPE=Release |
| 109 | } |
| 110 | |
| 111 | do_install () { |
| 112 | oe_runmake install DESTDIR=${D} |
| 113 | } |
| 114 | |
| 115 | do_install_append_class-native() { |
| 116 | # use node from PATH instead of absolute path to sysroot |
| 117 | # node-v0.10.25/tools/install.py is using: |
| 118 | # shebang = os.path.join(node_prefix, 'bin/node') |
| 119 | # update_shebang(link_path, shebang) |
| 120 | # and node_prefix can be very long path to bindir in native sysroot and |
| 121 | # when it exceeds 128 character shebang limit it's stripped to incorrect path |
| 122 | # and npm fails to execute like in this case with 133 characters show in log.do_install: |
| 123 | # updating shebang of /home/jenkins/workspace/build-webos-nightly/device/qemux86/label/open-webos-builder/BUILD-qemux86/work/x86_64-linux/nodejs-native/0.10.15-r0/image/home/jenkins/workspace/build-webos-nightly/device/qemux86/label/open-webos-builder/BUILD-qemux86/sysroots/x86_64-linux/usr/bin/npm to /home/jenkins/workspace/build-webos-nightly/device/qemux86/label/open-webos-builder/BUILD-qemux86/sysroots/x86_64-linux/usr/bin/node |
| 124 | # /usr/bin/npm is symlink to /usr/lib/node_modules/npm/bin/npm-cli.js |
| 125 | # use sed on npm-cli.js because otherwise symlink is replaced with normal file and |
| 126 | # npm-cli.js continues to use old shebang |
| 127 | sed "1s^.*^#\!/usr/bin/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js |
| 128 | |
| 129 | # Install the native torque to provide it within sysroot for the target compilation |
| 130 | install -d ${D}${bindir} |
| 131 | install -m 0755 ${S}/out/Release/torque ${D}${bindir}/torque |
| 132 | } |
| 133 | |
| 134 | do_install_append_class-target() { |
| 135 | sed "1s^.*^#\!${bindir}/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js |
| 136 | } |
| 137 | |
| 138 | PACKAGES =+ "${PN}-npm" |
| 139 | FILES_${PN}-npm = "${exec_prefix}/lib/node_modules ${bindir}/npm ${bindir}/npx" |
Brad Bishop | 90ca747 | 2019-08-20 09:15:15 -0400 | [diff] [blame] | 140 | RDEPENDS_${PN}-npm = "bash python-core python-shell python-datetime python-subprocess python-textutils \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 141 | python-compiler python-misc python-multiprocessing" |
| 142 | |
| 143 | PACKAGES =+ "${PN}-systemtap" |
| 144 | FILES_${PN}-systemtap = "${datadir}/systemtap" |
| 145 | |
| 146 | |
| 147 | BBCLASSEXTEND = "native" |