Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1 | DESCRIPTION = "nodeJS Evented I/O for V8 JavaScript" |
| 2 | HOMEPAGE = "http://nodejs.org" |
| 3 | LICENSE = "MIT & BSD & Artistic-2.0" |
Andrew Geissler | 72956ed | 2021-01-08 16:11:14 -0600 | [diff] [blame] | 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=8c66ff8861d9f96076a7cb61e3d75f54" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 5 | |
| 6 | DEPENDS = "openssl" |
| 7 | DEPENDS_append_class-target = " nodejs-native" |
| 8 | |
| 9 | inherit pkgconfig python3native |
| 10 | |
| 11 | COMPATIBLE_MACHINE_armv4 = "(!.*armv4).*" |
| 12 | COMPATIBLE_MACHINE_armv5 = "(!.*armv5).*" |
| 13 | COMPATIBLE_MACHINE_mips64 = "(!.*mips64).*" |
| 14 | |
| 15 | COMPATIBLE_HOST_riscv64 = "null" |
| 16 | COMPATIBLE_HOST_riscv32 = "null" |
| 17 | |
| 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 \ |
| 20 | file://0003-Install-both-binaries-and-use-libdir.patch \ |
| 21 | file://0004-v8-don-t-override-ARM-CFLAGS.patch \ |
| 22 | file://big-endian.patch \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 23 | file://mips-warnings.patch \ |
Andrew Geissler | 4b7c115 | 2020-11-30 19:55:29 -0600 | [diff] [blame] | 24 | file://0001-Remove-use-of-register-r7-because-llvm-now-issues-an.patch \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 25 | " |
| 26 | SRC_URI_append_class-target = " \ |
| 27 | file://0002-Using-native-binaries.patch \ |
| 28 | " |
Andrew Geissler | 32b1199 | 2021-03-31 13:37:05 -0500 | [diff] [blame] | 29 | SRC_URI[sha256sum] = "052f37ace6f569b513b5a1154b2a45d3c4d8b07d7d7c807b79f1566db61e979d" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [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' |
Andrew Geissler | 32b1199 | 2021-03-31 13:37:05 -0500 | [diff] [blame] | 42 | elif re.match('(powerpc64|powerpc64le)$', a): return 'ppc64' |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 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 | |
Andrew Geissler | bffdb3e | 2020-08-21 16:13:29 -0500 | [diff] [blame] | 54 | PACKAGECONFIG ??= "ares brotli icu zlib" |
| 55 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 56 | PACKAGECONFIG[ares] = "--shared-cares,,c-ares" |
| 57 | PACKAGECONFIG[brotli] = "--shared-brotli,,brotli" |
| 58 | PACKAGECONFIG[icu] = "--with-intl=system-icu,--without-intl,icu" |
| 59 | PACKAGECONFIG[libuv] = "--shared-libuv,,libuv" |
| 60 | PACKAGECONFIG[nghttp2] = "--shared-nghttp2,,nghttp2" |
| 61 | PACKAGECONFIG[shared] = "--shared" |
| 62 | PACKAGECONFIG[zlib] = "--shared-zlib,,zlib" |
| 63 | |
| 64 | # We don't want to cross-compile during target compile, |
| 65 | # and we need to use the right flags during host compile, |
| 66 | # too. |
| 67 | EXTRA_OEMAKE = "\ |
| 68 | CC.host='${CC}' \ |
| 69 | CFLAGS.host='${CPPFLAGS} ${CFLAGS}' \ |
| 70 | CXX.host='${CXX}' \ |
| 71 | CXXFLAGS.host='${CPPFLAGS} ${CXXFLAGS}' \ |
| 72 | LDFLAGS.host='${LDFLAGS}' \ |
| 73 | AR.host='${AR}' \ |
| 74 | \ |
| 75 | builddir_name=./ \ |
| 76 | " |
| 77 | |
| 78 | python do_unpack() { |
| 79 | import shutil |
| 80 | |
| 81 | bb.build.exec_func('base_do_unpack', d) |
| 82 | |
| 83 | shutil.rmtree(d.getVar('S') + '/deps/openssl', True) |
| 84 | if 'ares' in d.getVar('PACKAGECONFIG'): |
| 85 | shutil.rmtree(d.getVar('S') + '/deps/cares', True) |
| 86 | if 'brotli' in d.getVar('PACKAGECONFIG'): |
| 87 | shutil.rmtree(d.getVar('S') + '/deps/brotli', True) |
| 88 | if 'libuv' in d.getVar('PACKAGECONFIG'): |
| 89 | shutil.rmtree(d.getVar('S') + '/deps/uv', True) |
| 90 | if 'nghttp2' in d.getVar('PACKAGECONFIG'): |
| 91 | shutil.rmtree(d.getVar('S') + '/deps/nghttp2', True) |
| 92 | if 'zlib' in d.getVar('PACKAGECONFIG'): |
| 93 | shutil.rmtree(d.getVar('S') + '/deps/zlib', True) |
| 94 | } |
| 95 | |
| 96 | # Node is way too cool to use proper autotools, so we install two wrappers to forcefully inject proper arch cflags to workaround gypi |
| 97 | do_configure () { |
| 98 | export LD="${CXX}" |
| 99 | GYP_DEFINES="${GYP_DEFINES}" export GYP_DEFINES |
| 100 | # $TARGET_ARCH settings don't match --dest-cpu settings |
| 101 | python3 configure.py --prefix=${prefix} --cross-compiling --without-snapshot --shared-openssl \ |
| 102 | --without-dtrace \ |
| 103 | --without-etw \ |
| 104 | --dest-cpu="${@map_nodejs_arch(d.getVar('TARGET_ARCH'), d)}" \ |
| 105 | --dest-os=linux \ |
| 106 | --libdir=${D}${libdir} \ |
| 107 | ${ARCHFLAGS} \ |
| 108 | ${PACKAGECONFIG_CONFARGS} |
| 109 | } |
| 110 | |
| 111 | do_compile () { |
| 112 | export LD="${CXX}" |
| 113 | oe_runmake BUILDTYPE=Release |
| 114 | } |
| 115 | |
| 116 | do_install () { |
| 117 | oe_runmake install DESTDIR=${D} |
| 118 | |
| 119 | # wasn't updated since 2009 and is the only thing requiring python2 in runtime |
| 120 | # ERROR: nodejs-12.14.1-r0 do_package_qa: QA Issue: /usr/lib/node_modules/npm/node_modules/node-gyp/gyp/samples/samples contained in package nodejs-npm requires /usr/bin/python, but no providers found in RDEPENDS_nodejs-npm? [file-rdeps] |
| 121 | rm -f ${D}${exec_prefix}/lib/node_modules/npm/node_modules/node-gyp/gyp/samples/samples |
| 122 | } |
| 123 | |
| 124 | do_install_append_class-native() { |
| 125 | # use node from PATH instead of absolute path to sysroot |
| 126 | # node-v0.10.25/tools/install.py is using: |
| 127 | # shebang = os.path.join(node_prefix, 'bin/node') |
| 128 | # update_shebang(link_path, shebang) |
| 129 | # and node_prefix can be very long path to bindir in native sysroot and |
| 130 | # when it exceeds 128 character shebang limit it's stripped to incorrect path |
| 131 | # and npm fails to execute like in this case with 133 characters show in log.do_install: |
| 132 | # 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 |
| 133 | # /usr/bin/npm is symlink to /usr/lib/node_modules/npm/bin/npm-cli.js |
| 134 | # use sed on npm-cli.js because otherwise symlink is replaced with normal file and |
| 135 | # npm-cli.js continues to use old shebang |
| 136 | sed "1s^.*^#\!/usr/bin/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js |
| 137 | |
| 138 | # Install the native binaries to provide it within sysroot for the target compilation |
| 139 | install -d ${D}${bindir} |
| 140 | install -m 0755 ${S}/out/Release/torque ${D}${bindir}/torque |
| 141 | install -m 0755 ${S}/out/Release/bytecode_builtins_list_generator ${D}${bindir}/bytecode_builtins_list_generator |
| 142 | if ${@bb.utils.contains('PACKAGECONFIG','icu','true','false',d)}; then |
| 143 | install -m 0755 ${S}/out/Release/gen-regexp-special-case ${D}${bindir}/gen-regexp-special-case |
| 144 | fi |
| 145 | install -m 0755 ${S}/out/Release/mkcodecache ${D}${bindir}/mkcodecache |
| 146 | install -m 0755 ${S}/out/Release/node_mksnapshot ${D}${bindir}/node_mksnapshot |
| 147 | } |
| 148 | |
| 149 | do_install_append_class-target() { |
| 150 | sed "1s^.*^#\!${bindir}/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js |
| 151 | } |
| 152 | |
| 153 | PACKAGES =+ "${PN}-npm" |
| 154 | FILES_${PN}-npm = "${exec_prefix}/lib/node_modules ${bindir}/npm ${bindir}/npx" |
| 155 | RDEPENDS_${PN}-npm = "bash python3-core python3-shell python3-datetime \ |
| 156 | python3-misc python3-multiprocessing" |
| 157 | |
| 158 | PACKAGES =+ "${PN}-systemtap" |
| 159 | FILES_${PN}-systemtap = "${datadir}/systemtap" |
| 160 | |
| 161 | BBCLASSEXTEND = "native" |