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 | f103a7f | 2021-05-07 16:09:40 -0500 | [diff] [blame^] | 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=85bf260d8b6de1588f57abc5dc66587c" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 5 | |
| 6 | DEPENDS = "openssl" |
Andrew Geissler | f103a7f | 2021-05-07 16:09:40 -0500 | [diff] [blame^] | 7 | DEPENDS_append_class-target = " qemu-native" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 8 | |
Andrew Geissler | f103a7f | 2021-05-07 16:09:40 -0500 | [diff] [blame^] | 9 | inherit pkgconfig python3native qemu |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 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 | f103a7f | 2021-05-07 16:09:40 -0500 | [diff] [blame^] | 24 | file://v8-call-new-ListFormatter-createInstance.patch \ |
| 25 | file://mips-less-memory.patch \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 26 | " |
| 27 | SRC_URI_append_class-target = " \ |
| 28 | file://0002-Using-native-binaries.patch \ |
| 29 | " |
Andrew Geissler | f103a7f | 2021-05-07 16:09:40 -0500 | [diff] [blame^] | 30 | SRC_URI_append_toolchain-clang_x86 = " \ |
| 31 | file://libatomic.patch \ |
| 32 | " |
| 33 | SRC_URI[sha256sum] = "e44adbbed6756c2c1a01258383e9f00df30c147b36e438f6369b5ef1069abac3" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 34 | |
| 35 | S = "${WORKDIR}/node-v${PV}" |
| 36 | |
| 37 | # v8 errors out if you have set CCACHE |
| 38 | CCACHE = "" |
| 39 | |
| 40 | def map_nodejs_arch(a, d): |
| 41 | import re |
| 42 | |
| 43 | if re.match('i.86$', a): return 'ia32' |
| 44 | elif re.match('x86_64$', a): return 'x64' |
| 45 | elif re.match('aarch64$', a): return 'arm64' |
Andrew Geissler | c2a772f | 2021-04-01 10:06:38 -0500 | [diff] [blame] | 46 | elif re.match('(powerpc64|powerpc64le|ppc64le)$', a): return 'ppc64' |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 47 | elif re.match('powerpc$', a): return 'ppc' |
| 48 | return a |
| 49 | |
| 50 | ARCHFLAGS_arm = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', '--with-arm-float-abi=hard', '--with-arm-float-abi=softfp', d)} \ |
| 51 | ${@bb.utils.contains('TUNE_FEATURES', 'neon', '--with-arm-fpu=neon', \ |
| 52 | bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', '--with-arm-fpu=vfpv3-d16', \ |
| 53 | bb.utils.contains('TUNE_FEATURES', 'vfpv3', '--with-arm-fpu=vfpv3', \ |
| 54 | '--with-arm-fpu=vfp', d), d), d)}" |
| 55 | GYP_DEFINES_append_mipsel = " mips_arch_variant='r1' " |
| 56 | ARCHFLAGS ?= "" |
| 57 | |
Andrew Geissler | bffdb3e | 2020-08-21 16:13:29 -0500 | [diff] [blame] | 58 | PACKAGECONFIG ??= "ares brotli icu zlib" |
| 59 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 60 | PACKAGECONFIG[ares] = "--shared-cares,,c-ares" |
| 61 | PACKAGECONFIG[brotli] = "--shared-brotli,,brotli" |
| 62 | PACKAGECONFIG[icu] = "--with-intl=system-icu,--without-intl,icu" |
| 63 | PACKAGECONFIG[libuv] = "--shared-libuv,,libuv" |
| 64 | PACKAGECONFIG[nghttp2] = "--shared-nghttp2,,nghttp2" |
| 65 | PACKAGECONFIG[shared] = "--shared" |
| 66 | PACKAGECONFIG[zlib] = "--shared-zlib,,zlib" |
| 67 | |
| 68 | # We don't want to cross-compile during target compile, |
| 69 | # and we need to use the right flags during host compile, |
| 70 | # too. |
| 71 | EXTRA_OEMAKE = "\ |
| 72 | CC.host='${CC}' \ |
| 73 | CFLAGS.host='${CPPFLAGS} ${CFLAGS}' \ |
| 74 | CXX.host='${CXX}' \ |
| 75 | CXXFLAGS.host='${CPPFLAGS} ${CXXFLAGS}' \ |
| 76 | LDFLAGS.host='${LDFLAGS}' \ |
| 77 | AR.host='${AR}' \ |
| 78 | \ |
| 79 | builddir_name=./ \ |
| 80 | " |
| 81 | |
| 82 | python do_unpack() { |
| 83 | import shutil |
| 84 | |
| 85 | bb.build.exec_func('base_do_unpack', d) |
| 86 | |
| 87 | shutil.rmtree(d.getVar('S') + '/deps/openssl', True) |
| 88 | if 'ares' in d.getVar('PACKAGECONFIG'): |
| 89 | shutil.rmtree(d.getVar('S') + '/deps/cares', True) |
| 90 | if 'brotli' in d.getVar('PACKAGECONFIG'): |
| 91 | shutil.rmtree(d.getVar('S') + '/deps/brotli', True) |
| 92 | if 'libuv' in d.getVar('PACKAGECONFIG'): |
| 93 | shutil.rmtree(d.getVar('S') + '/deps/uv', True) |
| 94 | if 'nghttp2' in d.getVar('PACKAGECONFIG'): |
| 95 | shutil.rmtree(d.getVar('S') + '/deps/nghttp2', True) |
| 96 | if 'zlib' in d.getVar('PACKAGECONFIG'): |
| 97 | shutil.rmtree(d.getVar('S') + '/deps/zlib', True) |
| 98 | } |
| 99 | |
Andrew Geissler | f103a7f | 2021-05-07 16:09:40 -0500 | [diff] [blame^] | 100 | # V8's JIT infrastructure requires binaries such as mksnapshot and |
| 101 | # mkpeephole to be run in the host during the build. However, these |
| 102 | # binaries must have the same bit-width as the target (e.g. a x86_64 |
| 103 | # host targeting ARMv6 needs to produce a 32-bit binary). Instead of |
| 104 | # depending on a third Yocto toolchain, we just build those binaries |
| 105 | # for the target and run them on the host with QEMU. |
| 106 | python do_create_v8_qemu_wrapper () { |
| 107 | """Creates a small wrapper that invokes QEMU to run some target V8 binaries |
| 108 | on the host.""" |
| 109 | qemu_libdirs = [d.expand('${STAGING_DIR_HOST}${libdir}'), |
| 110 | d.expand('${STAGING_DIR_HOST}${base_libdir}')] |
| 111 | qemu_cmd = qemu_wrapper_cmdline(d, d.getVar('STAGING_DIR_HOST', True), |
| 112 | qemu_libdirs) |
| 113 | wrapper_path = d.expand('${B}/v8-qemu-wrapper.sh') |
| 114 | with open(wrapper_path, 'w') as wrapper_file: |
| 115 | wrapper_file.write("""#!/bin/sh |
| 116 | |
| 117 | # This file has been generated automatically. |
| 118 | # It invokes QEMU to run binaries built for the target in the host during the |
| 119 | # build process. |
| 120 | |
| 121 | %s "$@" |
| 122 | """ % qemu_cmd) |
| 123 | os.chmod(wrapper_path, 0o755) |
| 124 | } |
| 125 | |
| 126 | do_create_v8_qemu_wrapper[dirs] = "${B}" |
| 127 | addtask create_v8_qemu_wrapper after do_configure before do_compile |
| 128 | |
| 129 | LDFLAGS_append_x86 = " -latomic" |
| 130 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 131 | # Node is way too cool to use proper autotools, so we install two wrappers to forcefully inject proper arch cflags to workaround gypi |
| 132 | do_configure () { |
| 133 | export LD="${CXX}" |
| 134 | GYP_DEFINES="${GYP_DEFINES}" export GYP_DEFINES |
| 135 | # $TARGET_ARCH settings don't match --dest-cpu settings |
Andrew Geissler | f103a7f | 2021-05-07 16:09:40 -0500 | [diff] [blame^] | 136 | python3 configure.py --prefix=${prefix} --cross-compiling --shared-openssl \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 137 | --without-dtrace \ |
| 138 | --without-etw \ |
| 139 | --dest-cpu="${@map_nodejs_arch(d.getVar('TARGET_ARCH'), d)}" \ |
| 140 | --dest-os=linux \ |
| 141 | --libdir=${D}${libdir} \ |
| 142 | ${ARCHFLAGS} \ |
| 143 | ${PACKAGECONFIG_CONFARGS} |
| 144 | } |
| 145 | |
| 146 | do_compile () { |
| 147 | export LD="${CXX}" |
Andrew Geissler | f103a7f | 2021-05-07 16:09:40 -0500 | [diff] [blame^] | 148 | install -Dm 0755 ${B}/v8-qemu-wrapper.sh ${B}/out/Release/v8-qemu-wrapper.sh |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 149 | oe_runmake BUILDTYPE=Release |
| 150 | } |
| 151 | |
| 152 | do_install () { |
| 153 | oe_runmake install DESTDIR=${D} |
| 154 | |
| 155 | # wasn't updated since 2009 and is the only thing requiring python2 in runtime |
| 156 | # 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] |
| 157 | rm -f ${D}${exec_prefix}/lib/node_modules/npm/node_modules/node-gyp/gyp/samples/samples |
| 158 | } |
| 159 | |
| 160 | do_install_append_class-native() { |
| 161 | # use node from PATH instead of absolute path to sysroot |
| 162 | # node-v0.10.25/tools/install.py is using: |
| 163 | # shebang = os.path.join(node_prefix, 'bin/node') |
| 164 | # update_shebang(link_path, shebang) |
| 165 | # and node_prefix can be very long path to bindir in native sysroot and |
| 166 | # when it exceeds 128 character shebang limit it's stripped to incorrect path |
| 167 | # and npm fails to execute like in this case with 133 characters show in log.do_install: |
| 168 | # 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 |
| 169 | # /usr/bin/npm is symlink to /usr/lib/node_modules/npm/bin/npm-cli.js |
| 170 | # use sed on npm-cli.js because otherwise symlink is replaced with normal file and |
| 171 | # npm-cli.js continues to use old shebang |
| 172 | sed "1s^.*^#\!/usr/bin/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js |
| 173 | |
| 174 | # Install the native binaries to provide it within sysroot for the target compilation |
| 175 | install -d ${D}${bindir} |
| 176 | install -m 0755 ${S}/out/Release/torque ${D}${bindir}/torque |
| 177 | install -m 0755 ${S}/out/Release/bytecode_builtins_list_generator ${D}${bindir}/bytecode_builtins_list_generator |
| 178 | if ${@bb.utils.contains('PACKAGECONFIG','icu','true','false',d)}; then |
| 179 | install -m 0755 ${S}/out/Release/gen-regexp-special-case ${D}${bindir}/gen-regexp-special-case |
| 180 | fi |
| 181 | install -m 0755 ${S}/out/Release/mkcodecache ${D}${bindir}/mkcodecache |
| 182 | install -m 0755 ${S}/out/Release/node_mksnapshot ${D}${bindir}/node_mksnapshot |
| 183 | } |
| 184 | |
| 185 | do_install_append_class-target() { |
| 186 | sed "1s^.*^#\!${bindir}/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js |
| 187 | } |
| 188 | |
| 189 | PACKAGES =+ "${PN}-npm" |
| 190 | FILES_${PN}-npm = "${exec_prefix}/lib/node_modules ${bindir}/npm ${bindir}/npx" |
| 191 | RDEPENDS_${PN}-npm = "bash python3-core python3-shell python3-datetime \ |
| 192 | python3-misc python3-multiprocessing" |
| 193 | |
| 194 | PACKAGES =+ "${PN}-systemtap" |
| 195 | FILES_${PN}-systemtap = "${datadir}/systemtap" |
| 196 | |
| 197 | BBCLASSEXTEND = "native" |