diff options
Diffstat (limited to 'meta-oe/recipes-devtools/nodejs/nodejs_20.12.2.bb')
-rw-r--r-- | meta-oe/recipes-devtools/nodejs/nodejs_20.12.2.bb | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_20.12.2.bb b/meta-oe/recipes-devtools/nodejs/nodejs_20.12.2.bb new file mode 100644 index 000000000..d86c38f2f --- /dev/null +++ b/meta-oe/recipes-devtools/nodejs/nodejs_20.12.2.bb | |||
@@ -0,0 +1,182 @@ | |||
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=9a7fcce64128730251dbc58aa41b4674" | ||
5 | |||
6 | CVE_PRODUCT = "nodejs node.js" | ||
7 | |||
8 | DEPENDS = "openssl 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 | ||
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 | |||
22 | SRC_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://run-ptest \ | ||
28 | " | ||
29 | |||
30 | SRC_URI:append:class-target = " \ | ||
31 | file://0001-Using-native-binaries.patch \ | ||
32 | " | ||
33 | SRC_URI:append:toolchain-clang:x86 = " \ | ||
34 | file://libatomic.patch \ | ||
35 | " | ||
36 | SRC_URI:append:toolchain-clang:powerpc64le = " \ | ||
37 | file://0001-ppc64-Do-not-use-mminimal-toc-with-clang.patch \ | ||
38 | " | ||
39 | SRC_URI[sha256sum] = "d7cbcc5fbfb31e9001f3f0150bbeda59abe5dd7137aaa6273958cd59ce35ced7" | ||
40 | |||
41 | S = "${WORKDIR}/node-v${PV}" | ||
42 | |||
43 | CVE_PRODUCT += "node.js" | ||
44 | |||
45 | # v8 errors out if you have set CCACHE | ||
46 | CCACHE = "" | ||
47 | |||
48 | def map_nodejs_arch(a, d): | ||
49 | import re | ||
50 | |||
51 | if re.match('i.86$', a): return 'ia32' | ||
52 | elif re.match('x86_64$', a): return 'x64' | ||
53 | elif re.match('aarch64$', a): return 'arm64' | ||
54 | elif re.match('(powerpc64|powerpc64le|ppc64le)$', a): return 'ppc64' | ||
55 | elif re.match('powerpc$', a): return 'ppc' | ||
56 | return a | ||
57 | |||
58 | ARCHFLAGS:arm = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', '--with-arm-float-abi=hard', '--with-arm-float-abi=softfp', d)} \ | ||
59 | ${@bb.utils.contains('TUNE_FEATURES', 'neon', '--with-arm-fpu=neon', \ | ||
60 | bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', '--with-arm-fpu=vfpv3-d16', \ | ||
61 | bb.utils.contains('TUNE_FEATURES', 'vfpv3', '--with-arm-fpu=vfpv3', \ | ||
62 | '--with-arm-fpu=vfp', d), d), d)}" | ||
63 | ARCHFLAGS:append:mips = " --v8-lite-mode" | ||
64 | ARCHFLAGS:append:mipsel = " --v8-lite-mode" | ||
65 | ARCHFLAGS ?= "" | ||
66 | |||
67 | PACKAGECONFIG ??= "ares brotli icu zlib" | ||
68 | |||
69 | PACKAGECONFIG[ares] = "--shared-cares,,c-ares" | ||
70 | PACKAGECONFIG[brotli] = "--shared-brotli,,brotli" | ||
71 | PACKAGECONFIG[icu] = "--with-intl=system-icu,--without-intl,icu" | ||
72 | PACKAGECONFIG[libuv] = "--shared-libuv,,libuv" | ||
73 | PACKAGECONFIG[nghttp2] = "--shared-nghttp2,,nghttp2" | ||
74 | PACKAGECONFIG[shared] = "--shared" | ||
75 | PACKAGECONFIG[zlib] = "--shared-zlib,,zlib" | ||
76 | |||
77 | # We don't want to cross-compile during target compile, | ||
78 | # and we need to use the right flags during host compile, | ||
79 | # too. | ||
80 | EXTRA_OEMAKE = "\ | ||
81 | CC.host='${CC} -pie -fPIE' \ | ||
82 | CFLAGS.host='${CPPFLAGS} ${CFLAGS}' \ | ||
83 | CXX.host='${CXX} -pie -fPIE' \ | ||
84 | CXXFLAGS.host='${CPPFLAGS} ${CXXFLAGS}' \ | ||
85 | LDFLAGS.host='${LDFLAGS}' \ | ||
86 | AR.host='${AR}' \ | ||
87 | \ | ||
88 | builddir_name=./ \ | ||
89 | " | ||
90 | |||
91 | EXTRANATIVEPATH += "file-native" | ||
92 | |||
93 | python prune_sources() { | ||
94 | import shutil | ||
95 | |||
96 | shutil.rmtree(d.getVar('S') + '/deps/openssl') | ||
97 | if 'ares' in d.getVar('PACKAGECONFIG'): | ||
98 | shutil.rmtree(d.getVar('S') + '/deps/cares') | ||
99 | if 'brotli' in d.getVar('PACKAGECONFIG'): | ||
100 | shutil.rmtree(d.getVar('S') + '/deps/brotli') | ||
101 | if 'libuv' in d.getVar('PACKAGECONFIG'): | ||
102 | shutil.rmtree(d.getVar('S') + '/deps/uv') | ||
103 | if 'nghttp2' in d.getVar('PACKAGECONFIG'): | ||
104 | shutil.rmtree(d.getVar('S') + '/deps/nghttp2') | ||
105 | if 'zlib' in d.getVar('PACKAGECONFIG'): | ||
106 | shutil.rmtree(d.getVar('S') + '/deps/zlib') | ||
107 | } | ||
108 | do_unpack[postfuncs] += "prune_sources" | ||
109 | |||
110 | # V8's JIT infrastructure requires binaries such as mksnapshot and | ||
111 | # mkpeephole to be run in the host during the build. However, these | ||
112 | # binaries must have the same bit-width as the target (e.g. a x86_64 | ||
113 | # host targeting ARMv6 needs to produce a 32-bit binary). Instead of | ||
114 | # depending on a third Yocto toolchain, we just build those binaries | ||
115 | # for the target and run them on the host with QEMU. | ||
116 | python do_create_v8_qemu_wrapper () { | ||
117 | """Creates a small wrapper that invokes QEMU to run some target V8 binaries | ||
118 | on the host.""" | ||
119 | qemu_libdirs = [d.expand('${STAGING_DIR_HOST}${libdir}'), | ||
120 | d.expand('${STAGING_DIR_HOST}${base_libdir}')] | ||
121 | qemu_cmd = qemu_wrapper_cmdline(d, d.getVar('STAGING_DIR_HOST'), | ||
122 | qemu_libdirs) | ||
123 | wrapper_path = d.expand('${B}/v8-qemu-wrapper.sh') | ||
124 | with open(wrapper_path, 'w') as wrapper_file: | ||
125 | wrapper_file.write("""#!/bin/sh | ||
126 | |||
127 | # This file has been generated automatically. | ||
128 | # It invokes QEMU to run binaries built for the target in the host during the | ||
129 | # build process. | ||
130 | |||
131 | %s "$@" | ||
132 | """ % qemu_cmd) | ||
133 | os.chmod(wrapper_path, 0o755) | ||
134 | } | ||
135 | |||
136 | do_create_v8_qemu_wrapper[dirs] = "${B}" | ||
137 | addtask create_v8_qemu_wrapper after do_configure before do_compile | ||
138 | |||
139 | LDFLAGS:append:x86 = " -latomic" | ||
140 | |||
141 | CROSS_FLAGS = "--cross-compiling" | ||
142 | CROSS_FLAGS:class-native = "--no-cross-compiling" | ||
143 | |||
144 | # Node is way too cool to use proper autotools, so we install two wrappers to forcefully inject proper arch cflags to workaround gypi | ||
145 | do_configure () { | ||
146 | GYP_DEFINES="${GYP_DEFINES}" export GYP_DEFINES | ||
147 | # $TARGET_ARCH settings don't match --dest-cpu settings | ||
148 | python3 configure.py --verbose --prefix=${prefix} \ | ||
149 | --shared-openssl \ | ||
150 | --dest-cpu="${@map_nodejs_arch(d.getVar('TARGET_ARCH'), d)}" \ | ||
151 | --dest-os=linux \ | ||
152 | --libdir=${baselib} \ | ||
153 | ${CROSS_FLAGS} \ | ||
154 | ${ARCHFLAGS} \ | ||
155 | ${PACKAGECONFIG_CONFARGS} | ||
156 | } | ||
157 | |||
158 | do_compile () { | ||
159 | install -D ${RECIPE_SYSROOT_NATIVE}/etc/ssl/openssl.cnf ${B}/deps/openssl/nodejs-openssl.cnf | ||
160 | install -D ${B}/v8-qemu-wrapper.sh ${B}/out/Release/v8-qemu-wrapper.sh | ||
161 | oe_runmake BUILDTYPE=Release | ||
162 | } | ||
163 | |||
164 | do_install () { | ||
165 | oe_runmake install DESTDIR=${D} | ||
166 | } | ||
167 | |||
168 | do_install_ptest () { | ||
169 | cp -r ${B}/out/Release/cctest ${D}${PTEST_PATH}/ | ||
170 | cp -r ${B}/test ${D}${PTEST_PATH} | ||
171 | chown -R root:root ${D}${PTEST_PATH} | ||
172 | } | ||
173 | |||
174 | PACKAGES =+ "${PN}-npm" | ||
175 | FILES:${PN}-npm = "${nonarch_libdir}/node_modules ${bindir}/npm ${bindir}/npx ${bindir}/corepack" | ||
176 | RDEPENDS:${PN}-npm = "bash python3-core python3-shell python3-datetime \ | ||
177 | python3-misc python3-multiprocessing" | ||
178 | |||
179 | PACKAGES =+ "${PN}-systemtap" | ||
180 | FILES:${PN}-systemtap = "${datadir}/systemtap" | ||
181 | |||
182 | BBCLASSEXTEND = "native" | ||