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