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