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