git: b4056c50abab - main - net-im/libsignal-node: fix build on powerpc64*

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Fri, 01 Jul 2022 06:17:11 UTC
The branch main has been updated by pkubaj:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b4056c50ababae5927076dcbf42bc9e0870f5674

commit b4056c50ababae5927076dcbf42bc9e0870f5674
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2022-07-01 01:35:09 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2022-07-01 06:17:09 +0000

    net-im/libsignal-node: fix build on powerpc64*
    
    Properly set CARGO_ARCH. Since nodejs sets ppc64 target_arch for both powerpc64* architectures,
    create separate patches for both.
    
    Also modify do-install target to account for powerpc64*.
---
 net-im/libsignal-node/Makefile                            |  8 +++++++-
 .../libsignal-node/files/powerpc64-patch-node_binding.gyp | 15 +++++++++++++++
 .../files/powerpc64le-patch-node_binding.gyp              | 15 +++++++++++++++
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/net-im/libsignal-node/Makefile b/net-im/libsignal-node/Makefile
index 3e0acd1e7368..7b6b23727b70 100644
--- a/net-im/libsignal-node/Makefile
+++ b/net-im/libsignal-node/Makefile
@@ -259,6 +259,12 @@ USE_LDCONFIG=		yes
 
 PLIST_FILES=	lib/libsignal_node.so
 
+.include <bsd.port.options.mk>
+
+.if ${ARCH:Mpowerpc64*}
+EXTRA_PATCHES=	${FILESDIR}/${ARCH}-patch-node_binding.gyp
+.endif
+
 post-patch:
 	${REINPLACE_CMD} "s#python3#${PYTHON_CMD}#" \
 		${WRKSRC}/node/binding.gyp
@@ -271,7 +277,7 @@ do-build:
 		${SETENV} ${MAKE_ENV} yarn tsc
 
 do-install:
-	${INSTALL_DATA} ${WRKSRC}/node/build/Release/obj.target/libsignal_client_freebsd_x64.node/geni/rust/x86_64-unknown-freebsd/release/libsignal_node.so \
+	${INSTALL_DATA} ${WRKSRC}/node/build/Release/obj.target/libsignal_client_freebsd_${ARCH:S/amd64/x64/:C/powerpc64.*/ppc64/}.node/geni/rust/${ARCH:S/amd64/x86_64/}-unknown-freebsd/release/libsignal_node.so \
 		${STAGEDIR}${PREFIX}/lib/
 
 create-caches-tarball:
diff --git a/net-im/libsignal-node/files/powerpc64-patch-node_binding.gyp b/net-im/libsignal-node/files/powerpc64-patch-node_binding.gyp
new file mode 100644
index 000000000000..792299ec4618
--- /dev/null
+++ b/net-im/libsignal-node/files/powerpc64-patch-node_binding.gyp
@@ -0,0 +1,15 @@
+--- node/binding.gyp.orig	2022-05-13 21:30:30 UTC
++++ node/binding.gyp
+@@ -6,11 +6,12 @@
+ {
+     'conditions': [
+         ['OS=="mac"', {'variables': {'NODE_OS_NAME': 'darwin', 'CARGO_TARGET_SUFFIX': 'apple-darwin'}},
+          'OS=="win"', {'variables': {'NODE_OS_NAME': 'win32', 'CARGO_TARGET_SUFFIX': 'pc-windows-msvc'}},
+          'OS=="linux"', {'variables': {'NODE_OS_NAME': 'linux', 'CARGO_TARGET_SUFFIX': 'unknown-linux-gnu'}},
+          {'variables': {'NODE_OS_NAME': '<(OS)'}}],
+         ['target_arch=="ia32"', {'variables': {'CARGO_ARCH': 'i686'}},
+          'target_arch=="x64"', {'variables': {'CARGO_ARCH': 'x86_64'}},
++         'target_arch=="ppc64"', {'variables': {'CARGO_ARCH': 'powerpc64'}},
+          'target_arch=="arm64"', {'variables': {'CARGO_ARCH': 'aarch64'}}]
+     ],
+     'targets': [
diff --git a/net-im/libsignal-node/files/powerpc64le-patch-node_binding.gyp b/net-im/libsignal-node/files/powerpc64le-patch-node_binding.gyp
new file mode 100644
index 000000000000..d4a1ffe0b623
--- /dev/null
+++ b/net-im/libsignal-node/files/powerpc64le-patch-node_binding.gyp
@@ -0,0 +1,15 @@
+--- node/binding.gyp.orig	2022-05-13 21:30:30 UTC
++++ node/binding.gyp
+@@ -6,11 +6,12 @@
+ {
+     'conditions': [
+         ['OS=="mac"', {'variables': {'NODE_OS_NAME': 'darwin', 'CARGO_TARGET_SUFFIX': 'apple-darwin'}},
+          'OS=="win"', {'variables': {'NODE_OS_NAME': 'win32', 'CARGO_TARGET_SUFFIX': 'pc-windows-msvc'}},
+          'OS=="linux"', {'variables': {'NODE_OS_NAME': 'linux', 'CARGO_TARGET_SUFFIX': 'unknown-linux-gnu'}},
+          {'variables': {'NODE_OS_NAME': '<(OS)'}}],
+         ['target_arch=="ia32"', {'variables': {'CARGO_ARCH': 'i686'}},
+          'target_arch=="x64"', {'variables': {'CARGO_ARCH': 'x86_64'}},
++         'target_arch=="ppc64"', {'variables': {'CARGO_ARCH': 'powerpc64le'}},
+          'target_arch=="arm64"', {'variables': {'CARGO_ARCH': 'aarch64'}}]
+     ],
+     'targets': [