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