From 4a8afda052e31a59a685cbf106f775d215426e7c Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Fri, 28 Jun 2019 11:09:27 +0200
Subject: [PATCH] nodejs: update to 12.0.4 (current stable version).

This is a work in progress:

 - ppc64 big-endian patch needs to be adapted
 - the shared-http-parser option fails to link currently
 - the ssl option with libressl needs to be adapted

Tested on x86_64-musl.

[ci skip]
---
 srcpkgs/nodejs/patches/ppc64.patch | 41 ------------------------------
 srcpkgs/nodejs/template            | 31 +++++++---------------
 2 files changed, 9 insertions(+), 63 deletions(-)
 delete mode 100644 srcpkgs/nodejs/patches/ppc64.patch

diff --git a/srcpkgs/nodejs/patches/ppc64.patch b/srcpkgs/nodejs/patches/ppc64.patch
deleted file mode 100644
index 8190db1ce6f..00000000000
--- a/srcpkgs/nodejs/patches/ppc64.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-Taken from Adélie Linux, fixes node on big endian ELFv2.
---- deps/v8/src/ppc/assembler-ppc.h.old 2019-03-05 15:16:29.000000000 +0000
-+++ deps/v8/src/ppc/assembler-ppc.h     2019-04-02 07:05:25.977213735 +0000
-@@ -48,7 +48,8 @@
- #include "src/ppc/constants-ppc.h"
- 
- #if V8_HOST_ARCH_PPC && \
--    (V8_OS_AIX || (V8_TARGET_ARCH_PPC64 && V8_TARGET_BIG_ENDIAN))
-+    (V8_OS_AIX || (V8_TARGET_ARCH_PPC64 && \
-+      (V8_TARGET_BIG_ENDIAN && (!defined(_CALL_ELF) || _CALL_ELF == 1))))
- #define ABI_USES_FUNCTION_DESCRIPTORS 1
- #else
- #define ABI_USES_FUNCTION_DESCRIPTORS 0
-@@ -60,13 +61,15 @@
- #define ABI_PASSES_HANDLES_IN_REGS 0
- #endif
- 
--#if !V8_HOST_ARCH_PPC || !V8_TARGET_ARCH_PPC64 || V8_TARGET_LITTLE_ENDIAN
-+#if !V8_HOST_ARCH_PPC || !V8_TARGET_ARCH_PPC64 || \
-+    (V8_TARGET_LITTLE_ENDIAN || (defined(_CALL_ELF) && _CALL_ELF == 2))
- #define ABI_RETURNS_OBJECT_PAIRS_IN_REGS 1
- #else
- #define ABI_RETURNS_OBJECT_PAIRS_IN_REGS 0
- #endif
- 
--#if !V8_HOST_ARCH_PPC || (V8_TARGET_ARCH_PPC64 && V8_TARGET_LITTLE_ENDIAN)
-+#if !V8_HOST_ARCH_PPC || (V8_TARGET_ARCH_PPC64 && \
-+    (V8_TARGET_LITTLE_ENDIAN || (defined(_CALL_ELF) && _CALL_ELF == 2)))
- #define ABI_CALL_VIA_IP 1
- #else
- #define ABI_CALL_VIA_IP 0
-@@ -220,7 +220,8 @@
- // The following constants describe the stack frame linkage area as
- // defined by the ABI.  Note that kNumRequiredStackFrameSlots must
- // satisfy alignment requirements (rounding up if required).
--#if V8_TARGET_ARCH_PPC64 && V8_TARGET_LITTLE_ENDIAN
-+#if V8_TARGET_ARCH_PPC64 && (V8_TARGET_LITTLE_ENDIAN || \
-+    defined(_CALL_ELF) && _CALL_ELF == 2)
- // [0] back chain
- // [1] condition register save area
- // [2] link register save area
diff --git a/srcpkgs/nodejs/template b/srcpkgs/nodejs/template
index b6c0ee797bc..5ad402d67d5 100644
--- a/srcpkgs/nodejs/template
+++ b/srcpkgs/nodejs/template
@@ -1,23 +1,23 @@
 # Template file for 'nodejs'
 pkgname=nodejs
-version=11.14.0
+version=12.4.0
 revision=1
 wrksrc="node-v${version}"
 # Need these for host v8 for torque, see https://github.com/nodejs/node/pull/21079
 hostmakedepends="pkg-config python zlib-devel $(vopt_if icu icu-devel)
  $(vopt_if ssl libressl-devel) $(vopt_if libuv libuv-devel)
- $(vopt_if http_parser http-parser-devel) $(vopt_if nghttp2 nghttp2-devel)
- $(vopt_if cares c-ares-devel) $(vopt_if http_parser llhttp-devel)"
+ $(vopt_if http_parser 'http-parser-devel llhttp-devel')
+ $(vopt_if cares c-ares-devel) $(vopt_if nghttp2 nghttp2-devel)"
 makedepends="zlib-devel python-devel $(vopt_if icu icu-devel)
  $(vopt_if ssl libressl-devel) $(vopt_if libuv libuv-devel)
- $(vopt_if http_parser http-parser-devel) $(vopt_if nghttp2 nghttp2-devel)
- $(vopt_if cares c-ares-devel) $(vopt_if http_parser llhttp-devel)"
+ $(vopt_if http_parser 'http-parser-devel llhttp-devel')
+ $(vopt_if cares c-ares-devel) $(vopt_if nghttp2 nghttp2-devel)"
 short_desc="Evented I/O for V8 javascript"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="MIT"
 homepage="https://nodejs.org/"
 distfiles="${homepage}/dist/v${version}/node-v${version}.tar.gz"
-checksum=b903ba6dc8131b9357e7c5e26967a0f48aa460c708154244a6348d49a7d8ff9a
+checksum=cf39befb8ea486363cac6f297d8f451fd0d5dd8ad21dca51e9c2ea86b242baa0
 
 build_options="ssl libuv http_parser icu nghttp2 cares"
 desc_option_ssl="Enable shared libressl"
@@ -26,9 +26,8 @@ desc_option_http_parser="Enable shared http-parser and llhttp"
 desc_option_icu="Enable shared icu"
 desc_option_nghttp2="Enable shared nghttp2"
 desc_option_cares="Enable shared c-ares"
-build_options_default="libuv http_parser icu nghttp2 cares"
+build_options_default="cares icu libuv nghttp2"
 
-replaces="iojs>=0"
 conflicts="nodejs-lts"
 provides="nodejs-runtime-0_1"
 
@@ -59,23 +58,11 @@ do_configure() {
 		$(vopt_if nghttp2 --shared-nghttp2) \
 		$(vopt_if cares --shared-cares) ${_args}
 }
-
-post_configure() {
-	# Fix linking against llhttp
-	sed 's/http_parser/& -lllhttp/' \
-		-i out/cctest.target.mk \
-		-i out/node.target.mk
-}
-
 do_build() {
-	if [ "$CROSS_BUILD" ]; then
-		make LD="$CXX" LDFLAGS+=-ldl ${makejobs} PORTABLE=1 V=1
-	else
-		make LD="$CXX" LDFLAGS+=-ldl ${makejobs} V=1
-	fi
+	make LD="$CXX" ${CROSS_BUILD:+PORTABLE=1} ${makejobs}
 }
 do_install() {
-	make LD="$CXX" LDFLAGS+=-ldl DESTDIR="$DESTDIR" install
+	make LD="$CXX" DESTDIR="$DESTDIR" install
 	vlicense LICENSE
 	rm -r $DESTDIR/usr/include
 }
