From b6c42f6aa646b92e27ba1e11381ff8be31d5ebc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garci=CC=81a?= Date: Mon, 8 Jul 2024 16:31:40 +0200 Subject: [PATCH] Bundle the desktop_proxy file --- apps/desktop/desktop_native/.gitignore | 1 + apps/desktop/desktop_native/build.js | 34 ++++++++++++++------------ apps/desktop/electron-builder.json | 21 +++++++++++++--- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/apps/desktop/desktop_native/.gitignore b/apps/desktop/desktop_native/.gitignore index 96e7a71e1b0..1cfa7dafc20 100644 --- a/apps/desktop/desktop_native/.gitignore +++ b/apps/desktop/desktop_native/.gitignore @@ -4,3 +4,4 @@ index.node **/.DS_Store npm-debug.log* *.node +dist diff --git a/apps/desktop/desktop_native/build.js b/apps/desktop/desktop_native/build.js index 81519bb709a..fdad80df8d9 100644 --- a/apps/desktop/desktop_native/build.js +++ b/apps/desktop/desktop_native/build.js @@ -25,32 +25,36 @@ if (!crossPlatform) { let targets = []; switch (process.platform) { case "win32": - targets = ["i686-pc-windows-msvc", "x86_64-pc-windows-msvc", "aarch64-pc-windows-msvc"]; + targets = [ + ["i686-pc-windows-msvc", 'ia32'], + ["x86_64-pc-windows-msvc", 'x64'], + ["aarch64-pc-windows-msvc", 'arm64'] + ]; break; case "darwin": - targets = ["x86_64-apple-darwin", "aarch64-apple-darwin"]; + targets = [ + ["x86_64-apple-darwin", 'x64'], + ["aarch64-apple-darwin", 'arm64'] + ]; break; default: - targets = ['x86_64-unknown-linux-musl']; + targets = [ + ['x86_64-unknown-linux-musl', 'x64'] + ]; + process.env["PKG_CONFIG_ALLOW_CROSS"] = "1"; process.env["PKG_CONFIG_ALL_STATIC"] = "1"; break; } -targets.forEach(target => { +fs.mkdirSync(path.join(__dirname, "dist"), { recursive: true }); + +targets.forEach(([target, nodeArch]) => { buildNapiModule(target); buildProxyBin(target); + + const ext = process.platform === "win32" ? ".exe" : ""; + fs.copyFileSync(path.join(__dirname, "target", target, "release", `desktop_proxy${ext}`), path.join(__dirname, "dist", `desktop_proxy.${process.platform}-${nodeArch}${ext}`)); }); - -if (process.platform === "darwin") { - fs.mkdirSync(path.join(__dirname, "target", "darwin-universal"), { recursive: true }); - - let command = `lipo -create -output ${path.join(__dirname, "target", "darwin-universal", "desktop_proxy")} `; - targets.forEach(target => { - command += `${path.join(__dirname, "target", target, "release", "desktop_proxy")} `; - }); - child_process.execSync(command, { stdio: 'inherit', cwd: __dirname}); - -} diff --git a/apps/desktop/electron-builder.json b/apps/desktop/electron-builder.json index aff5e993d71..80336349ea4 100644 --- a/apps/desktop/electron-builder.json +++ b/apps/desktop/electron-builder.json @@ -11,7 +11,6 @@ "output": "dist", "app": "build" }, - "afterSign": "scripts/after-sign.js", "asarUnpack": ["**/*.node"], "files": [ "**/*", @@ -72,6 +71,12 @@ "CFBundleDevelopmentRegion": "en" }, "singleArchFiles": "node_modules/@bitwarden/desktop-napi/desktop_napi.darwin-*.node", + "extraFiles": [ + { + "from": "desktop_native/dist/desktop_proxy.${platform}-${arch}", + "to": "desktop_proxy" + } + ], "target": ["dmg", "zip"] }, "win": { @@ -83,16 +88,24 @@ "from": "../../node_modules/regedit/vbs", "to": "regedit/vbs", "filter": ["**/*"] - }, + } + ], + "extraFiles": [ { - "from": "desktop_native/target/release/desktop_proxy", - "to": "desktop_proxy" + "from": "desktop_native/dist/desktop_proxy.${platform}-${arch}.exe", + "to": "desktop_proxy.exe" } ] }, "linux": { "category": "Utility", "synopsis": "A secure and free password manager for all of your devices.", + "extraFiles": [ + { + "from": "desktop_native/dist/desktop_proxy.${platform}-${arch}", + "to": "desktop_proxy" + } + ], "target": ["deb", "freebsd", "rpm", "AppImage", "snap"], "desktop": { "Name": "Bitwarden",