From 716f91ad7c8e1cd75fa91401130a389a8081ce8f Mon Sep 17 00:00:00 2001 From: Michal Rus Date: Wed, 28 Feb 2024 12:10:46 +0100 Subject: [PATCH] =?UTF-8?q?[LW-9860]=20Don=E2=80=99t=20rely=20on=20`uname`?= =?UTF-8?q?=20(for=20cross-builds)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nix/internal/any-darwin.nix | 2 +- scripts/rebuild-native-modules.sh | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/nix/internal/any-darwin.nix b/nix/internal/any-darwin.nix index a6f75086f2..e8b0380fdd 100644 --- a/nix/internal/any-darwin.nix +++ b/nix/internal/any-darwin.nix @@ -81,7 +81,7 @@ in rec { patchShebangs . >/dev/null # a real lot of paths to patch, no need to litter logs # This is building against Node.js, not Electron, but it still will fail, unless: - ourArch="$(uname -m)" + ourArch="${__head (__split "-" targetSystem)}" for f in \ node_modules/usb/binding.gyp \ node_modules/usb/libusb.gypi \ diff --git a/scripts/rebuild-native-modules.sh b/scripts/rebuild-native-modules.sh index 6da56d41e1..4b2e089033 100755 --- a/scripts/rebuild-native-modules.sh +++ b/scripts/rebuild-native-modules.sh @@ -20,8 +20,9 @@ nix run -L .#internal."${system:-x86_64-darwin}".common.patchElectronRebuild # XXX: Electron 24.2 requires c++17, not 14 (or old 1y): sed -r 's,std=c\+\+(14|1y),std=c++17,g' -i node_modules/usb/binding.gyp -if [ "$(uname)" == "Darwin" ] ; then - ourArch="$(uname -m)" + +if [ "$(cut -d- -f2 <<<"${system:-x86_64-darwin}")" == "darwin" ] ; then + ourArch="$(cut -d- -f1 <<<"${system:-x86_64-darwin}")" for f in \ node_modules/usb/binding.gyp \ node_modules/usb/libusb.gypi \ @@ -37,7 +38,7 @@ electron-rebuild --force electron-rebuild -w usb-detection --force -s # -if [ "$(uname)" == "Linux" ] ; then +if [ "$(cut -d- -f2 <<<"${system:-x86_64-darwin}")" == "linux" ] ; then # We ship debug version because the release one has issues with Ledger Nano S electron-rebuild -w usb --force -s --debug fi @@ -76,6 +77,6 @@ tryLink "usb-detection" "detection.node" tryLink "utf-8-validate" "validation.node" tryLink "node-hid" "HID.node" -if [ "$(uname)" == "Linux" ] ; then +if [ "$(cut -d- -f2 <<<"${system:-x86_64-darwin}")" == "linux" ] ; then tryLink "node-hid" "HID_hidraw.node" fi