nodejs_22.16.0.bb 8.0 KB

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