Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1 | DESCRIPTION = "nodeJS Evented I/O for V8 JavaScript" |
| 2 | HOMEPAGE = "http://nodejs.org" |
| 3 | LICENSE = "MIT & BSD & Artistic-2.0" |
| 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=be4d5107c64dc3d7c57e3797e1a0674b" |
| 5 | |
| 6 | DEPENDS = "openssl" |
| 7 | DEPENDS_append_class-target = " nodejs-native" |
| 8 | |
| 9 | inherit pkgconfig python3native |
| 10 | |
| 11 | COMPATIBLE_MACHINE_armv4 = "(!.*armv4).*" |
| 12 | COMPATIBLE_MACHINE_armv5 = "(!.*armv5).*" |
| 13 | COMPATIBLE_MACHINE_mips64 = "(!.*mips64).*" |
| 14 | |
| 15 | COMPATIBLE_HOST_riscv64 = "null" |
| 16 | COMPATIBLE_HOST_riscv32 = "null" |
| 17 | |
| 18 | SRC_URI = "http://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \ |
| 19 | file://0001-Disable-running-gyp-files-for-bundled-deps.patch \ |
| 20 | file://0003-Install-both-binaries-and-use-libdir.patch \ |
| 21 | file://0004-v8-don-t-override-ARM-CFLAGS.patch \ |
| 22 | file://big-endian.patch \ |
| 23 | file://0001-build-allow-passing-multiple-libs-to-pkg_config.patch \ |
| 24 | file://0002-build-allow-use-of-system-installed-brotli.patch \ |
| 25 | file://mips-warnings.patch \ |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame^] | 26 | file://0001-deps-V8-backport-3f8dc4b2e5ba.patch \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 27 | " |
| 28 | SRC_URI_append_class-target = " \ |
| 29 | file://0002-Using-native-binaries.patch \ |
| 30 | " |
| 31 | |
| 32 | SRC_URI[md5sum] = "1c78a75f5c95321f533ecccca695e814" |
| 33 | SRC_URI[sha256sum] = "877b4b842318b0e09bc754faf7343f2f097f0fc4f88ab9ae57cf9944e88e7adb" |
| 34 | |
| 35 | S = "${WORKDIR}/node-v${PV}" |
| 36 | |
| 37 | # v8 errors out if you have set CCACHE |
| 38 | CCACHE = "" |
| 39 | |
| 40 | def map_nodejs_arch(a, d): |
| 41 | import re |
| 42 | |
| 43 | if re.match('i.86$', a): return 'ia32' |
| 44 | elif re.match('x86_64$', a): return 'x64' |
| 45 | elif re.match('aarch64$', a): return 'arm64' |
| 46 | elif re.match('(powerpc64|ppc64le)$', a): return 'ppc64' |
| 47 | elif re.match('powerpc$', a): return 'ppc' |
| 48 | return a |
| 49 | |
| 50 | ARCHFLAGS_arm = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', '--with-arm-float-abi=hard', '--with-arm-float-abi=softfp', d)} \ |
| 51 | ${@bb.utils.contains('TUNE_FEATURES', 'neon', '--with-arm-fpu=neon', \ |
| 52 | bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', '--with-arm-fpu=vfpv3-d16', \ |
| 53 | bb.utils.contains('TUNE_FEATURES', 'vfpv3', '--with-arm-fpu=vfpv3', \ |
| 54 | '--with-arm-fpu=vfp', d), d), d)}" |
| 55 | GYP_DEFINES_append_mipsel = " mips_arch_variant='r1' " |
| 56 | ARCHFLAGS ?= "" |
| 57 | |
| 58 | PACKAGECONFIG ??= "ares brotli icu libuv zlib" |
| 59 | PACKAGECONFIG[ares] = "--shared-cares,,c-ares" |
| 60 | PACKAGECONFIG[brotli] = "--shared-brotli,,brotli" |
| 61 | PACKAGECONFIG[icu] = "--with-intl=system-icu,--without-intl,icu" |
| 62 | PACKAGECONFIG[libuv] = "--shared-libuv,,libuv" |
| 63 | PACKAGECONFIG[nghttp2] = "--shared-nghttp2,,nghttp2" |
| 64 | PACKAGECONFIG[shared] = "--shared" |
| 65 | PACKAGECONFIG[zlib] = "--shared-zlib,,zlib" |
| 66 | |
| 67 | # We don't want to cross-compile during target compile, |
| 68 | # and we need to use the right flags during host compile, |
| 69 | # too. |
| 70 | EXTRA_OEMAKE = "\ |
| 71 | CC.host='${CC}' \ |
| 72 | CFLAGS.host='${CPPFLAGS} ${CFLAGS}' \ |
| 73 | CXX.host='${CXX}' \ |
| 74 | CXXFLAGS.host='${CPPFLAGS} ${CXXFLAGS}' \ |
| 75 | LDFLAGS.host='${LDFLAGS}' \ |
| 76 | AR.host='${AR}' \ |
| 77 | \ |
| 78 | builddir_name=./ \ |
| 79 | " |
| 80 | |
| 81 | python do_unpack() { |
| 82 | import shutil |
| 83 | |
| 84 | bb.build.exec_func('base_do_unpack', d) |
| 85 | |
| 86 | shutil.rmtree(d.getVar('S') + '/deps/openssl', True) |
| 87 | if 'ares' in d.getVar('PACKAGECONFIG'): |
| 88 | shutil.rmtree(d.getVar('S') + '/deps/cares', True) |
| 89 | if 'brotli' in d.getVar('PACKAGECONFIG'): |
| 90 | shutil.rmtree(d.getVar('S') + '/deps/brotli', True) |
| 91 | if 'libuv' in d.getVar('PACKAGECONFIG'): |
| 92 | shutil.rmtree(d.getVar('S') + '/deps/uv', True) |
| 93 | if 'nghttp2' in d.getVar('PACKAGECONFIG'): |
| 94 | shutil.rmtree(d.getVar('S') + '/deps/nghttp2', True) |
| 95 | if 'zlib' in d.getVar('PACKAGECONFIG'): |
| 96 | shutil.rmtree(d.getVar('S') + '/deps/zlib', True) |
| 97 | } |
| 98 | |
| 99 | # Node is way too cool to use proper autotools, so we install two wrappers to forcefully inject proper arch cflags to workaround gypi |
| 100 | do_configure () { |
| 101 | export LD="${CXX}" |
| 102 | GYP_DEFINES="${GYP_DEFINES}" export GYP_DEFINES |
| 103 | # $TARGET_ARCH settings don't match --dest-cpu settings |
| 104 | python3 configure.py --prefix=${prefix} --cross-compiling --without-snapshot --shared-openssl \ |
| 105 | --without-dtrace \ |
| 106 | --without-etw \ |
| 107 | --dest-cpu="${@map_nodejs_arch(d.getVar('TARGET_ARCH'), d)}" \ |
| 108 | --dest-os=linux \ |
| 109 | --libdir=${D}${libdir} \ |
| 110 | ${ARCHFLAGS} \ |
| 111 | ${PACKAGECONFIG_CONFARGS} |
| 112 | } |
| 113 | |
| 114 | do_compile () { |
| 115 | export LD="${CXX}" |
| 116 | oe_runmake BUILDTYPE=Release |
| 117 | } |
| 118 | |
| 119 | do_install () { |
| 120 | oe_runmake install DESTDIR=${D} |
| 121 | |
| 122 | # wasn't updated since 2009 and is the only thing requiring python2 in runtime |
| 123 | # ERROR: nodejs-12.14.1-r0 do_package_qa: QA Issue: /usr/lib/node_modules/npm/node_modules/node-gyp/gyp/samples/samples contained in package nodejs-npm requires /usr/bin/python, but no providers found in RDEPENDS_nodejs-npm? [file-rdeps] |
| 124 | rm -f ${D}${exec_prefix}/lib/node_modules/npm/node_modules/node-gyp/gyp/samples/samples |
| 125 | } |
| 126 | |
| 127 | do_install_append_class-native() { |
| 128 | # use node from PATH instead of absolute path to sysroot |
| 129 | # node-v0.10.25/tools/install.py is using: |
| 130 | # shebang = os.path.join(node_prefix, 'bin/node') |
| 131 | # update_shebang(link_path, shebang) |
| 132 | # and node_prefix can be very long path to bindir in native sysroot and |
| 133 | # when it exceeds 128 character shebang limit it's stripped to incorrect path |
| 134 | # and npm fails to execute like in this case with 133 characters show in log.do_install: |
| 135 | # updating shebang of /home/jenkins/workspace/build-webos-nightly/device/qemux86/label/open-webos-builder/BUILD-qemux86/work/x86_64-linux/nodejs-native/0.10.15-r0/image/home/jenkins/workspace/build-webos-nightly/device/qemux86/label/open-webos-builder/BUILD-qemux86/sysroots/x86_64-linux/usr/bin/npm to /home/jenkins/workspace/build-webos-nightly/device/qemux86/label/open-webos-builder/BUILD-qemux86/sysroots/x86_64-linux/usr/bin/node |
| 136 | # /usr/bin/npm is symlink to /usr/lib/node_modules/npm/bin/npm-cli.js |
| 137 | # use sed on npm-cli.js because otherwise symlink is replaced with normal file and |
| 138 | # npm-cli.js continues to use old shebang |
| 139 | sed "1s^.*^#\!/usr/bin/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js |
| 140 | |
| 141 | # Install the native binaries to provide it within sysroot for the target compilation |
| 142 | install -d ${D}${bindir} |
| 143 | install -m 0755 ${S}/out/Release/torque ${D}${bindir}/torque |
| 144 | install -m 0755 ${S}/out/Release/bytecode_builtins_list_generator ${D}${bindir}/bytecode_builtins_list_generator |
| 145 | if ${@bb.utils.contains('PACKAGECONFIG','icu','true','false',d)}; then |
| 146 | install -m 0755 ${S}/out/Release/gen-regexp-special-case ${D}${bindir}/gen-regexp-special-case |
| 147 | fi |
| 148 | install -m 0755 ${S}/out/Release/mkcodecache ${D}${bindir}/mkcodecache |
| 149 | install -m 0755 ${S}/out/Release/node_mksnapshot ${D}${bindir}/node_mksnapshot |
| 150 | } |
| 151 | |
| 152 | do_install_append_class-target() { |
| 153 | sed "1s^.*^#\!${bindir}/env node^g" -i ${D}${exec_prefix}/lib/node_modules/npm/bin/npm-cli.js |
| 154 | } |
| 155 | |
| 156 | PACKAGES =+ "${PN}-npm" |
| 157 | FILES_${PN}-npm = "${exec_prefix}/lib/node_modules ${bindir}/npm ${bindir}/npx" |
| 158 | RDEPENDS_${PN}-npm = "bash python3-core python3-shell python3-datetime \ |
| 159 | python3-misc python3-multiprocessing" |
| 160 | |
| 161 | PACKAGES =+ "${PN}-systemtap" |
| 162 | FILES_${PN}-systemtap = "${datadir}/systemtap" |
| 163 | |
| 164 | BBCLASSEXTEND = "native" |