Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1 | DESCRIPTION = "nodeJS Evented I/O for V8 JavaScript" |
| 2 | HOMEPAGE = "http://nodejs.org" |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 3 | LICENSE = "MIT & ISC & BSD-2-Clause & BSD-3-Clause & Artistic-2.0 & Apache-2.0" |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame^] | 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=bc1f9ebe76be76f163e3b675303ad9cd" |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 5 | |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 6 | CVE_PRODUCT = "nodejs node.js" |
| 7 | |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 8 | DEPENDS = "openssl file-replacement-native" |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 9 | DEPENDS:append:class-target = " qemu-native" |
| 10 | DEPENDS:append:class-native = " c-ares-native" |
| 11 | |
Andrew Geissler | c5535c9 | 2023-01-27 16:10:19 -0600 | [diff] [blame] | 12 | inherit pkgconfig python3native qemu ptest |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 13 | |
| 14 | COMPATIBLE_MACHINE:armv4 = "(!.*armv4).*" |
| 15 | COMPATIBLE_MACHINE:armv5 = "(!.*armv5).*" |
| 16 | COMPATIBLE_MACHINE:mips64 = "(!.*mips64).*" |
| 17 | |
| 18 | COMPATIBLE_HOST:riscv64 = "null" |
| 19 | COMPATIBLE_HOST:riscv32 = "null" |
| 20 | COMPATIBLE_HOST:powerpc = "null" |
| 21 | |
| 22 | SRC_URI = "http://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \ |
| 23 | file://0001-Disable-running-gyp-files-for-bundled-deps.patch \ |
| 24 | file://0004-v8-don-t-override-ARM-CFLAGS.patch \ |
| 25 | file://big-endian.patch \ |
| 26 | file://mips-less-memory.patch \ |
| 27 | file://system-c-ares.patch \ |
| 28 | file://0001-liftoff-Correct-function-signatures.patch \ |
| 29 | file://0001-mips-Use-32bit-cast-for-operand-on-mips32.patch \ |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 30 | file://run-ptest \ |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 31 | " |
Andrew Geissler | c5535c9 | 2023-01-27 16:10:19 -0600 | [diff] [blame] | 32 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 33 | SRC_URI:append:class-target = " \ |
| 34 | file://0001-Using-native-binaries.patch \ |
| 35 | " |
| 36 | SRC_URI:append:toolchain-clang:x86 = " \ |
| 37 | file://libatomic.patch \ |
| 38 | " |
| 39 | SRC_URI:append:toolchain-clang:powerpc64le = " \ |
| 40 | file://0001-ppc64-Do-not-use-mminimal-toc-with-clang.patch \ |
| 41 | " |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame^] | 42 | SRC_URI[sha256sum] = "80c0faadf5ea39c213ccb9aa5c2432977a0f1b5a0b766852abd0de06f2770406" |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 43 | |
| 44 | S = "${WORKDIR}/node-v${PV}" |
| 45 | |
| 46 | # v8 errors out if you have set CCACHE |
| 47 | CCACHE = "" |
| 48 | |
| 49 | def map_nodejs_arch(a, d): |
| 50 | import re |
| 51 | |
| 52 | if re.match('i.86$', a): return 'ia32' |
| 53 | elif re.match('x86_64$', a): return 'x64' |
| 54 | elif re.match('aarch64$', a): return 'arm64' |
| 55 | elif re.match('(powerpc64|powerpc64le|ppc64le)$', a): return 'ppc64' |
| 56 | elif re.match('powerpc$', a): return 'ppc' |
| 57 | return a |
| 58 | |
| 59 | ARCHFLAGS:arm = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', '--with-arm-float-abi=hard', '--with-arm-float-abi=softfp', d)} \ |
| 60 | ${@bb.utils.contains('TUNE_FEATURES', 'neon', '--with-arm-fpu=neon', \ |
| 61 | bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', '--with-arm-fpu=vfpv3-d16', \ |
| 62 | bb.utils.contains('TUNE_FEATURES', 'vfpv3', '--with-arm-fpu=vfpv3', \ |
| 63 | '--with-arm-fpu=vfp', d), d), d)}" |
| 64 | ARCHFLAGS:append:mips = " --v8-lite-mode" |
| 65 | ARCHFLAGS:append:mipsel = " --v8-lite-mode" |
| 66 | ARCHFLAGS ?= "" |
| 67 | |
| 68 | PACKAGECONFIG ??= "ares brotli icu zlib" |
| 69 | |
| 70 | PACKAGECONFIG[ares] = "--shared-cares,,c-ares" |
| 71 | PACKAGECONFIG[brotli] = "--shared-brotli,,brotli" |
| 72 | PACKAGECONFIG[icu] = "--with-intl=system-icu,--without-intl,icu" |
| 73 | PACKAGECONFIG[libuv] = "--shared-libuv,,libuv" |
| 74 | PACKAGECONFIG[nghttp2] = "--shared-nghttp2,,nghttp2" |
| 75 | PACKAGECONFIG[shared] = "--shared" |
| 76 | PACKAGECONFIG[zlib] = "--shared-zlib,,zlib" |
| 77 | |
| 78 | # We don't want to cross-compile during target compile, |
| 79 | # and we need to use the right flags during host compile, |
| 80 | # too. |
| 81 | EXTRA_OEMAKE = "\ |
Andrew Geissler | 8f84068 | 2023-07-21 09:09:43 -0500 | [diff] [blame] | 82 | CC.host='${CC} -pie -fPIE' \ |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 83 | CFLAGS.host='${CPPFLAGS} ${CFLAGS}' \ |
Andrew Geissler | 8f84068 | 2023-07-21 09:09:43 -0500 | [diff] [blame] | 84 | CXX.host='${CXX} -pie -fPIE' \ |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 85 | CXXFLAGS.host='${CPPFLAGS} ${CXXFLAGS}' \ |
| 86 | LDFLAGS.host='${LDFLAGS}' \ |
| 87 | AR.host='${AR}' \ |
| 88 | \ |
| 89 | builddir_name=./ \ |
| 90 | " |
| 91 | |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 92 | EXTRANATIVEPATH += "file-native" |
| 93 | |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 94 | python prune_sources() { |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 95 | import shutil |
| 96 | |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 97 | shutil.rmtree(d.getVar('S') + '/deps/openssl') |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 98 | if 'ares' in d.getVar('PACKAGECONFIG'): |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 99 | shutil.rmtree(d.getVar('S') + '/deps/cares') |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 100 | if 'brotli' in d.getVar('PACKAGECONFIG'): |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 101 | shutil.rmtree(d.getVar('S') + '/deps/brotli') |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 102 | if 'libuv' in d.getVar('PACKAGECONFIG'): |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 103 | shutil.rmtree(d.getVar('S') + '/deps/uv') |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 104 | if 'nghttp2' in d.getVar('PACKAGECONFIG'): |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 105 | shutil.rmtree(d.getVar('S') + '/deps/nghttp2') |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 106 | if 'zlib' in d.getVar('PACKAGECONFIG'): |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 107 | shutil.rmtree(d.getVar('S') + '/deps/zlib') |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 108 | } |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 109 | do_unpack[postfuncs] += "prune_sources" |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 110 | |
| 111 | # V8's JIT infrastructure requires binaries such as mksnapshot and |
| 112 | # mkpeephole to be run in the host during the build. However, these |
| 113 | # binaries must have the same bit-width as the target (e.g. a x86_64 |
| 114 | # host targeting ARMv6 needs to produce a 32-bit binary). Instead of |
| 115 | # depending on a third Yocto toolchain, we just build those binaries |
| 116 | # for the target and run them on the host with QEMU. |
| 117 | python do_create_v8_qemu_wrapper () { |
| 118 | """Creates a small wrapper that invokes QEMU to run some target V8 binaries |
| 119 | on the host.""" |
| 120 | qemu_libdirs = [d.expand('${STAGING_DIR_HOST}${libdir}'), |
| 121 | d.expand('${STAGING_DIR_HOST}${base_libdir}')] |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 122 | qemu_cmd = qemu_wrapper_cmdline(d, d.getVar('STAGING_DIR_HOST'), |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 123 | qemu_libdirs) |
| 124 | wrapper_path = d.expand('${B}/v8-qemu-wrapper.sh') |
| 125 | with open(wrapper_path, 'w') as wrapper_file: |
| 126 | wrapper_file.write("""#!/bin/sh |
| 127 | |
| 128 | # This file has been generated automatically. |
| 129 | # It invokes QEMU to run binaries built for the target in the host during the |
| 130 | # build process. |
| 131 | |
| 132 | %s "$@" |
| 133 | """ % qemu_cmd) |
| 134 | os.chmod(wrapper_path, 0o755) |
| 135 | } |
| 136 | |
| 137 | do_create_v8_qemu_wrapper[dirs] = "${B}" |
| 138 | addtask create_v8_qemu_wrapper after do_configure before do_compile |
| 139 | |
| 140 | LDFLAGS:append:x86 = " -latomic" |
| 141 | |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 142 | CROSS_FLAGS = "--cross-compiling" |
| 143 | CROSS_FLAGS:class-native = "--no-cross-compiling" |
| 144 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 145 | # Node is way too cool to use proper autotools, so we install two wrappers to forcefully inject proper arch cflags to workaround gypi |
| 146 | do_configure () { |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 147 | GYP_DEFINES="${GYP_DEFINES}" export GYP_DEFINES |
| 148 | # $TARGET_ARCH settings don't match --dest-cpu settings |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 149 | python3 configure.py --verbose --prefix=${prefix} \ |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 150 | --shared-openssl \ |
| 151 | --without-dtrace \ |
| 152 | --without-etw \ |
| 153 | --dest-cpu="${@map_nodejs_arch(d.getVar('TARGET_ARCH'), d)}" \ |
| 154 | --dest-os=linux \ |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 155 | --libdir=${baselib} \ |
| 156 | ${CROSS_FLAGS} \ |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 157 | ${ARCHFLAGS} \ |
| 158 | ${PACKAGECONFIG_CONFARGS} |
| 159 | } |
| 160 | |
| 161 | do_compile () { |
Andrew Geissler | c5535c9 | 2023-01-27 16:10:19 -0600 | [diff] [blame] | 162 | install -D ${RECIPE_SYSROOT_NATIVE}/etc/ssl/openssl.cnf ${B}/deps/openssl/nodejs-openssl.cnf |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 163 | install -D ${B}/v8-qemu-wrapper.sh ${B}/out/Release/v8-qemu-wrapper.sh |
| 164 | oe_runmake BUILDTYPE=Release |
| 165 | } |
| 166 | |
| 167 | do_install () { |
| 168 | oe_runmake install DESTDIR=${D} |
| 169 | } |
| 170 | |
Andrew Geissler | c5535c9 | 2023-01-27 16:10:19 -0600 | [diff] [blame] | 171 | do_install_ptest () { |
| 172 | cp -r ${B}/out/Release/cctest ${D}${PTEST_PATH}/ |
| 173 | cp -r ${B}/test ${D}${PTEST_PATH} |
| 174 | chown -R root:root ${D}${PTEST_PATH} |
| 175 | } |
| 176 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 177 | PACKAGES =+ "${PN}-npm" |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 178 | FILES:${PN}-npm = "${nonarch_libdir}/node_modules ${bindir}/npm ${bindir}/npx ${bindir}/corepack" |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 179 | RDEPENDS:${PN}-npm = "bash python3-core python3-shell python3-datetime \ |
| 180 | python3-misc python3-multiprocessing" |
| 181 | |
| 182 | PACKAGES =+ "${PN}-systemtap" |
| 183 | FILES:${PN}-systemtap = "${datadir}/systemtap" |
| 184 | |
| 185 | BBCLASSEXTEND = "native" |