|
| 1 | +'use strict' |
| 2 | +const fs = require('fs') |
| 3 | +const path = require('path') |
| 4 | +const { exec: execNode } = require("child_process") |
| 5 | +const util = require('util') |
| 6 | + |
| 7 | +const exec = util.promisify(execNode) |
| 8 | + |
| 9 | +// interface AfterPackContext { |
| 10 | +// outDir: string |
| 11 | +// appOutDir: string |
| 12 | +// packager: PlatformPackager<any> |
| 13 | +// electronPlatformName: string |
| 14 | +// arch: Arch |
| 15 | +// targets: Array<Target> |
| 16 | +// } |
| 17 | + |
| 18 | +/** |
| 19 | + * |
| 20 | + * @param {AfterPackContext} context |
| 21 | + */ |
| 22 | +const afterPack = async (context) => { |
| 23 | + // Workaround to remove debug information from production binaries on Linux (Electron#32669). |
| 24 | + if (context.packager.platform.name === 'linux') { |
| 25 | + console.log('[afterPack] Removing Electron debug information on Linux') |
| 26 | + |
| 27 | + const { appOutDir } = context |
| 28 | + const chromeCrashpadHandlerPath = path.join(appOutDir, 'chrome_crashpad_handler') |
| 29 | + const libvkPath = path.join(appOutDir, 'libvk_swiftshader.so') |
| 30 | + |
| 31 | + if (fs.existsSync(chromeCrashpadHandlerPath)) { |
| 32 | + const { err } = await exec(`strip "${chromeCrashpadHandlerPath}"`) |
| 33 | + if (err) { |
| 34 | + console.log('[afterPack] Unable to strip "chrome_crashpad_handler".') |
| 35 | + } |
| 36 | + } else { |
| 37 | + console.log(`[afterPack] "chrome_crashpad_handler" doesn't exists: "${chromeCrashpadHandlerPath}".`) |
| 38 | + } |
| 39 | + |
| 40 | + if (fs.existsSync(libvkPath)) { |
| 41 | + const { err } = await exec(`strip "${libvkPath}"`) |
| 42 | + if (err) { |
| 43 | + console.log('[afterPack] Unable to strip "libvk_swiftshader.so".') |
| 44 | + } |
| 45 | + } else { |
| 46 | + console.log(`[afterPack] "libvk_swiftshader.so" doesn't exists: "${libvkPath}".`) |
| 47 | + } |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +exports.default = afterPack |
0 commit comments