diff options
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.bb | 211 |
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 @@ | |||
| 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=c83fcdcd43ab352be6429ee1fd8827a0" | ||
| 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 | |||
| 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://libatomic.patch \ | ||
| 28 | file://182d9c05e78.patch \ | ||
| 29 | file://run-ptest \ | ||
| 30 | " | ||
| 31 | SRC_URI:append:class-target = " \ | ||
| 32 | file://0001-Using-native-binaries.patch \ | ||
| 33 | " | ||
| 34 | SRC_URI:append:toolchain-clang:powerpc64le = " \ | ||
| 35 | file://0001-ppc64-Do-not-use-mminimal-toc-with-clang.patch \ | ||
| 36 | " | ||
| 37 | SRC_URI[sha256sum] = "69bf81b70f3a95ae0763459f02860c282d7e3a47567c8afaf126cc778176a882" | ||
| 38 | |||
| 39 | S = "${WORKDIR}/node-v${PV}" | ||
| 40 | |||
| 41 | CVE_PRODUCT += "node.js" | ||
| 42 | |||
| 43 | # v8 errors out if you have set CCACHE | ||
| 44 | CCACHE = "" | ||
| 45 | |||
| 46 | def 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 | |||
| 56 | ARCHFLAGS: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)}" | ||
| 61 | ARCHFLAGS:append:mips = " --v8-lite-mode" | ||
| 62 | ARCHFLAGS:append:mipsel = " --v8-lite-mode" | ||
| 63 | ARCHFLAGS ?= "" | ||
| 64 | |||
| 65 | PACKAGECONFIG ??= "ares brotli icu zlib" | ||
| 66 | |||
| 67 | PACKAGECONFIG[ares] = "--shared-cares,,c-ares c-ares-native" | ||
| 68 | PACKAGECONFIG[brotli] = "--shared-brotli,,brotli brotli-native" | ||
| 69 | PACKAGECONFIG[icu] = "--with-intl=system-icu,--without-intl,icu icu-native" | ||
| 70 | PACKAGECONFIG[libuv] = "--shared-libuv,,libuv" | ||
| 71 | PACKAGECONFIG[nghttp2] = "--shared-nghttp2,,nghttp2" | ||
| 72 | PACKAGECONFIG[shared] = "--shared" | ||
| 73 | PACKAGECONFIG[zlib] = "--shared-zlib,,zlib" | ||
| 74 | |||
| 75 | EXTRANATIVEPATH += "file-native" | ||
| 76 | |||
| 77 | python 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 | } | ||
| 92 | do_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 | ||
| 102 | python 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 | |||
| 126 | do_create_v8_qemu_wrapper[dirs] = "${B}" | ||
| 127 | addtask create_v8_qemu_wrapper after do_configure before do_compile | ||
| 128 | |||
| 129 | LDFLAGS:append:x86 = " -latomic" | ||
| 130 | |||
| 131 | export CC_host | ||
| 132 | export CFLAGS_host | ||
| 133 | export CXX_host | ||
| 134 | export CXXFLAGS_host | ||
| 135 | export LDFLAGS_host | ||
| 136 | export AR_host | ||
| 137 | export HOST_AND_TARGET_SAME_WIDTH | ||
| 138 | |||
| 139 | CROSS_FLAGS = "--cross-compiling" | ||
| 140 | CROSS_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 | ||
| 143 | do_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 | |||
| 156 | do_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 | |||
| 162 | do_install () { | ||
| 163 | oe_runmake install DESTDIR=${D} | ||
| 164 | } | ||
| 165 | |||
| 166 | do_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 | |||
| 172 | PACKAGES =+ "${PN}-npm" | ||
| 173 | FILES:${PN}-npm = "${nonarch_libdir}/node_modules ${bindir}/npm ${bindir}/npx ${bindir}/corepack" | ||
| 174 | RDEPENDS:${PN}-npm = "bash python3-core python3-shell python3-datetime \ | ||
| 175 | python3-misc python3-multiprocessing" | ||
| 176 | |||
| 177 | PACKAGES =+ "${PN}-systemtap" | ||
| 178 | FILES:${PN}-systemtap = "${datadir}/systemtap" | ||
| 179 | |||
| 180 | do_configure[prefuncs] += "set_gyp_variables" | ||
| 181 | do_compile[prefuncs] += "set_gyp_variables" | ||
| 182 | do_install[prefuncs] += "set_gyp_variables" | ||
| 183 | python 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 | } | ||
| 203 | python __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 | |||
| 211 | BBCLASSEXTEND = "native" | ||
