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