From 859653e111f765ba9170301bb5b2f7fb67624fc2 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Wed, 8 Mar 2023 02:35:24 -0800 Subject: [PATCH] Build Linux executable Summary: Currently, Flipper server cannot be used with Flipper Launcher on Linux because there is no `flipper` binary in the root of the directory. Adding a quick shell script bridges the call from the checked-in node binary and the server JS file. Reviewed By: ardavank Differential Revision: D43837781 fbshipit-source-id: d954ae21d5330aa549d4bc76aefb1d76af8e2c84 --- desktop/scripts/build-flipper-server-release.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/desktop/scripts/build-flipper-server-release.tsx b/desktop/scripts/build-flipper-server-release.tsx index ecd44b63e..7f19db3c2 100644 --- a/desktop/scripts/build-flipper-server-release.tsx +++ b/desktop/scripts/build-flipper-server-release.tsx @@ -42,6 +42,12 @@ enum BuildPlatform { MAC_X64 = 'mac-x64', } +const LINUX_STARTUP_SCRIPT = `#!/bin/sh +THIS_DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )" +cd "$THIS_DIR" +./node ./server "$@" +`; + const argv = yargs .usage('yarn build-flipper-server [args]') .version(false) @@ -466,6 +472,13 @@ async function installNodeBinary(outputPath: string, platform: BuildPlatform) { await fs.chmod(outputPath, 0o755); } +async function setUpLinuxBundle(outputDir: string) { + console.log(`⚙️ Creating Linux startup script in ${outputDir}/flipper`); + await fs.writeFile(path.join(outputDir, 'flipper'), LINUX_STARTUP_SCRIPT); + // Give the script +x + await fs.chmod(path.join(outputDir, 'flipper'), 0o755); +} + async function setUpMacBundle( outputDir: string, versionNumber: string, @@ -525,6 +538,8 @@ async function bundleServerReleaseForPlatform( // to be in different places from Linux/Windows bundles. if (platform === BuildPlatform.MAC_X64) { outputPaths = await setUpMacBundle(outputDir, versionNumber); + } else if (platform === BuildPlatform.LINUX) { + await setUpLinuxBundle(outputDir); } console.log(`⚙️ Copying from ${dir} to ${outputPaths.resourcesPath}`);