summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-devtools/nodejs/nodejs_22.22.0.bb
diff options
context:
space:
mode:
Diffstat (limited to 'meta-oe/recipes-devtools/nodejs/nodejs_22.22.0.bb')
-rw-r--r--meta-oe/recipes-devtools/nodejs/nodejs_22.22.0.bb219
1 files changed, 219 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_22.22.0.bb b/meta-oe/recipes-devtools/nodejs/nodejs_22.22.0.bb
new file mode 100644
index 0000000000..443cdc430d
--- /dev/null
+++ b/meta-oe/recipes-devtools/nodejs/nodejs_22.22.0.bb
@@ -0,0 +1,219 @@
1DESCRIPTION = "nodeJS Evented I/O for V8 JavaScript"
2HOMEPAGE = "http://nodejs.org"
3LICENSE = "MIT & ISC & BSD-2-Clause & BSD-3-Clause & Artistic-2.0 & Apache-2.0"
4LIC_FILES_CHKSUM = "file://LICENSE;md5=1fdf4f79da4006c3b5183fddc768f1c8"
5
6CVE_PRODUCT = "nodejs node.js"
7
8DEPENDS = "openssl openssl-native file-replacement-native python3-packaging-native"
9DEPENDS:append:class-target = " qemu-native"
10DEPENDS:append:class-native = " c-ares-native"
11
12inherit pkgconfig python3native qemu ptest siteinfo
13
14COMPATIBLE_MACHINE:armv4 = "(!.*armv4).*"
15COMPATIBLE_MACHINE:armv5 = "(!.*armv5).*"
16COMPATIBLE_MACHINE:mips64 = "(!.*mips64).*"
17
18COMPATIBLE_HOST:riscv64 = "null"
19COMPATIBLE_HOST:riscv32 = "null"
20COMPATIBLE_HOST:powerpc = "null"
21COMPATIBLE_HOST:powerpc64le = "null"
22
23SRC_URI = "https://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \
24 file://0001-Do-not-use-glob-in-deps.patch \
25 file://0001-Disable-running-gyp-files-for-bundled-deps.patch \
26 file://0004-v8-don-t-override-ARM-CFLAGS.patch \
27 file://system-c-ares.patch \
28 file://0001-liftoff-Correct-function-signatures.patch \
29 file://libatomic.patch \
30 file://0001-deps-disable-io_uring-support-in-libuv.patch \
31 file://0001-positional-args.patch \
32 file://0001-custom-env.patch \
33 file://0001-build-remove-redundant-mXX-flags-for-V8.patch \
34 file://run-ptest \
35 "
36SRC_URI:append:class-target = " \
37 file://0001-Using-native-binaries.patch \
38 "
39SRC_URI:append:toolchain-clang:powerpc64le = " \
40 file://0001-ppc64-Do-not-use-mminimal-toc-with-clang.patch \
41 "
42SRC_URI[sha256sum] = "4c138012bb5352f49822a8f3e6d1db71e00639d0c36d5b6756f91e4c6f30b683"
43
44S = "${UNPACKDIR}/node-v${PV}"
45
46# v8 errors out if you have set CCACHE
47CCACHE = ""
48
49# Use '-flax-vector-conversions' to permit conversions between vectors
50# with differing element types or numbers of subparts
51CFLAGS:append:toolchain-gcc:arm = " -flax-vector-conversions"
52
53def map_nodejs_arch(a, d):
54 import re
55
56 if re.match('i.86$', a): return 'ia32'
57 elif re.match('x86_64$', a): return 'x64'
58 elif re.match('aarch64$', a): return 'arm64'
59 elif re.match('(powerpc64|powerpc64le|ppc64le)$', a): return 'ppc64'
60 elif re.match('powerpc$', a): return 'ppc'
61 return a
62
63ARCHFLAGS:arm = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', '--with-arm-float-abi=hard', '--with-arm-float-abi=softfp', d)} \
64 ${@bb.utils.contains('TUNE_FEATURES', 'neon', '--with-arm-fpu=neon', \
65 bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', '--with-arm-fpu=vfpv3-d16', \
66 bb.utils.contains('TUNE_FEATURES', 'vfpv3', '--with-arm-fpu=vfpv3', \
67 '--with-arm-fpu=vfp', d), d), d)}"
68ARCHFLAGS:append:mips = " --v8-lite-mode"
69ARCHFLAGS:append:mipsel = " --v8-lite-mode"
70ARCHFLAGS ?= ""
71
72PACKAGECONFIG ??= "ares brotli icu zlib"
73
74PACKAGECONFIG[ares] = "--shared-cares,,c-ares c-ares-native"
75PACKAGECONFIG[brotli] = "--shared-brotli,,brotli brotli-native"
76PACKAGECONFIG[icu] = "--with-intl=system-icu,--without-intl,icu icu-native"
77PACKAGECONFIG[libuv] = "--shared-libuv,,libuv"
78PACKAGECONFIG[nghttp2] = "--shared-nghttp2,,nghttp2"
79PACKAGECONFIG[shared] = "--shared"
80PACKAGECONFIG[zlib] = "--shared-zlib,,zlib"
81
82EXTRANATIVEPATH += "file-native"
83
84python prune_sources() {
85 import shutil
86
87 shutil.rmtree(d.getVar('S') + '/deps/openssl')
88 if 'ares' in d.getVar('PACKAGECONFIG'):
89 shutil.rmtree(d.getVar('S') + '/deps/cares')
90 if 'brotli' in d.getVar('PACKAGECONFIG'):
91 shutil.rmtree(d.getVar('S') + '/deps/brotli')
92 if 'libuv' in d.getVar('PACKAGECONFIG'):
93 shutil.rmtree(d.getVar('S') + '/deps/uv')
94 if 'nghttp2' in d.getVar('PACKAGECONFIG'):
95 shutil.rmtree(d.getVar('S') + '/deps/nghttp2')
96 if 'zlib' in d.getVar('PACKAGECONFIG'):
97 shutil.rmtree(d.getVar('S') + '/deps/zlib')
98}
99do_unpack[postfuncs] += "prune_sources"
100
101# V8's JIT infrastructure requires binaries such as mksnapshot and
102# mkpeephole to be run in the host during the build. However, these
103# binaries must have the same bit-width as the target (e.g. a x86_64
104# host targeting ARMv6 needs to produce a 32-bit binary).
105# 1. If host and target have the different bit width, run those
106# binaries for the target and run them on the host with QEMU.
107# 2. If host and target have the same bit width, enable upstream
108# cross compile support and no QEMU
109python do_create_v8_qemu_wrapper () {
110 """Creates a small wrapper that invokes QEMU to run some target V8 binaries
111 on the host."""
112 qemu_libdirs = [d.expand('${STAGING_DIR_HOST}${libdir}'),
113 d.expand('${STAGING_DIR_HOST}${base_libdir}')]
114 qemu_cmd = qemu_wrapper_cmdline(d, d.getVar('STAGING_DIR_HOST'),
115 qemu_libdirs)
116
117 if d.getVar("HOST_AND_TARGET_SAME_WIDTH") == "1":
118 qemu_cmd = ""
119
120 wrapper_path = d.expand('${B}/v8-qemu-wrapper.sh')
121 with open(wrapper_path, 'w') as wrapper_file:
122 wrapper_file.write("""#!/bin/sh
123
124# This file has been generated automatically.
125# It invokes QEMU to run binaries built for the target in the host during the
126# build process.
127
128%s "$@"
129""" % qemu_cmd)
130 os.chmod(wrapper_path, 0o755)
131}
132
133do_create_v8_qemu_wrapper[dirs] = "${B}"
134addtask create_v8_qemu_wrapper after do_configure before do_compile
135
136LDFLAGS:append:x86 = " -latomic"
137
138export CC_host
139export CFLAGS_host
140export CXX_host
141export CXXFLAGS_host
142export LDFLAGS_host
143export AR_host
144export HOST_AND_TARGET_SAME_WIDTH
145
146CROSS_FLAGS = "--cross-compiling"
147CROSS_FLAGS:class-native = "--no-cross-compiling"
148
149# Node is way too cool to use proper autotools, so we install two wrappers to forcefully inject proper arch cflags to workaround gypi
150do_configure () {
151 GYP_DEFINES="${GYP_DEFINES}" export GYP_DEFINES
152 # $TARGET_ARCH settings don't match --dest-cpu settings
153 python3 configure.py --verbose --prefix=${prefix} \
154 --shared-openssl \
155 --dest-cpu="${@map_nodejs_arch(d.getVar('TARGET_ARCH'), d)}" \
156 --dest-os=linux \
157 --libdir=${baselib} \
158 ${CROSS_FLAGS} \
159 ${ARCHFLAGS} \
160 ${PACKAGECONFIG_CONFARGS}
161}
162
163do_compile () {
164 install -D ${RECIPE_SYSROOT_NATIVE}/etc/ssl/openssl.cnf ${B}/deps/openssl/nodejs-openssl.cnf
165 install -D ${B}/v8-qemu-wrapper.sh ${B}/out/Release/v8-qemu-wrapper.sh
166 oe_runmake BUILDTYPE=Release
167}
168
169do_install () {
170 oe_runmake install DESTDIR=${D}
171}
172
173do_install_ptest () {
174 cp -r ${B}/out/Release/cctest ${D}${PTEST_PATH}/
175 cp -r ${B}/test ${D}${PTEST_PATH}
176 chown -R root:root ${D}${PTEST_PATH}
177}
178
179PACKAGES =+ "${PN}-npm"
180FILES:${PN}-npm = "${nonarch_libdir}/node_modules ${bindir}/npm ${bindir}/npx ${bindir}/corepack"
181RDEPENDS:${PN}-npm = "bash python3-core python3-shell python3-datetime \
182 python3-misc python3-multiprocessing"
183
184PACKAGES =+ "${PN}-systemtap"
185FILES:${PN}-systemtap = "${datadir}/systemtap"
186
187do_configure[prefuncs] += "set_gyp_variables"
188do_compile[prefuncs] += "set_gyp_variables"
189do_install[prefuncs] += "set_gyp_variables"
190python set_gyp_variables () {
191 if d.getVar("HOST_AND_TARGET_SAME_WIDTH") == "0":
192 # We don't want to cross-compile during target compile,
193 # and we need to use the right flags during host compile,
194 # too.
195 d.setVar("CC_host", d.getVar("CC") + " -pie -fPIE")
196 d.setVar("CFLAGS_host", d.getVar("CFLAGS"))
197 d.setVar("CXX_host", d.getVar("CXX") + " -pie -fPIE")
198 d.setVar("CXXFLAGS_host", d.getVar("CXXFLAGS"))
199 d.setVar("LDFLAGS_host", d.getVar("LDFLAGS"))
200 d.setVar("AR_host", d.getVar("AR"))
201 elif d.getVar("HOST_AND_TARGET_SAME_WIDTH") == "1":
202 # Enable upstream cross compile support
203 d.setVar("CC_host", d.getVar("BUILD_CC"))
204 d.setVar("CFLAGS_host", d.getVar("BUILD_CFLAGS"))
205 d.setVar("CXX_host", d.getVar("BUILD_CXX"))
206 d.setVar("CXXFLAGS_host", d.getVar("BUILD_CXXFLAGS"))
207 d.setVar("LDFLAGS_host", d.getVar("BUILD_LDFLAGS"))
208 d.setVar("AR_host", d.getVar("BUILD_AR"))
209}
210
211python __anonymous () {
212 # 32 bit target and 64 bit host (x86-64 or aarch64) have different bit width
213 if d.getVar("SITEINFO_BITS") == "32" and "64" in d.getVar("BUILD_ARCH"):
214 d.setVar("HOST_AND_TARGET_SAME_WIDTH", "0")
215 else:
216 d.setVar("HOST_AND_TARGET_SAME_WIDTH", "1")
217}
218
219BBCLASSEXTEND = "native"