nodejs_18.0.0.bb 6.3 KB

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