Skip to content

Commit

Permalink
Updates to build script for PulsarNext:
Browse files Browse the repository at this point in the history
* Don't try to copy over `ppm` (the shell script version) on Windows.
* Bail if the user tries to build without having built `ppm`.
* Ensure we get an executable on Linux named `pulsar-next`. This allows us to safely assume that the name of the launch script matches the name of the executable.
  • Loading branch information
savetheclocktower committed Nov 2, 2024
1 parent 63dacc2 commit 6bc04bb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
15 changes: 3 additions & 12 deletions pulsar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ elif [ $OS == 'Linux' ]; then
# * `ATOM_EXECUTABLE_NAME` will refer to the executable we must run to launch
# it (`pulsar` or `pulsar-next`)

# We'll start out assuming that the executable name will match the name of
# this script (minus the `.sh`); this may or may not be true, but we'll make
# sure later.
ATOM_EXECUTABLE_NAME=$ATOM_BASE_NAME
if [ "$CHANNEL" == 'next' ]; then
ATOM_APP_NAME="PulsarNext"
Expand All @@ -231,19 +228,19 @@ elif [ $OS == 'Linux' ]; then
ATOM_APP="$(dirname "$(dirname "$SCRIPT")")"
PULSAR_PATH="$(realpath "$ATOM_APP")"

if [ ! -f "$PULSAR_PATH/${ATOM_EXECUTABLE_NAME}" ] && [ ! -f "$PULSAR_PATH/pulsar" ]; then
if [ ! -f "$PULSAR_PATH/${ATOM_EXECUTABLE_NAME}" ]; then
# If that path doesn't contain a `pulsar` executable, then it's not a
# valid path. We'll try something else.
unset ATOM_APP
unset PULSAR_PATH
fi

if [ -z "${PULSAR_PATH}" ]; then
if [ -f "/opt/${ATOM_APP_NAME}/${ATOM_EXECUTABLE_NAME}" ] || [ -f "/opt/${ATOM_APP_NAME}/pulsar" ]; then
if [ -f "/opt/${ATOM_APP_NAME}/${ATOM_EXECUTABLE_NAME}" ]; then
# Check the default installation directory for RPM and DEB
# distributions.
PULSAR_PATH="/opt/${ATOM_APP_NAME}"
elif [ -f "$TMPDIR/pulsar-build/${ATOM_APP_NAME}/${ATOM_EXECUTABLE_NAME}" ] || [ -f "$TMPDIR/pulsar-build/${ATOM_APP_NAME}/pulsar" ]; then
elif [ -f "$TMPDIR/pulsar-build/${ATOM_APP_NAME}/${ATOM_EXECUTABLE_NAME}" ]; then
# This is where Pulsar can be found during some CI build tasks.
PULSAR_PATH="$TMPDIR/pulsar-build/${ATOM_APP_NAME}"
else
Expand All @@ -253,13 +250,7 @@ elif [ $OS == 'Linux' ]; then
fi
fi

# If we make it through the conditional above, then we know the Pulsar path
# and we know the executable is named either `$ATOM_EXECUTABLE_NAME` or
# `pulsar`. Here we'll discover which one is present.
PULSAR_EXECUTABLE="$PULSAR_PATH/$ATOM_EXECUTABLE_NAME"
if [ ! -f "${PULSAR_EXECUTABLE}" ]; then
PULSAR_EXECUTABLE="$PULSAR_PATH/pulsar"
fi

# The name of the `ppm` binary we should run will be named according to the
# same convention as this script; that's how PPM itself knows which release
Expand Down
38 changes: 27 additions & 11 deletions script/electron-builder.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,29 @@ const { hideBin } = require('yargs/helpers')
const generateMetadata = require('./generate-metadata-for-builder')
const macBundleDocumentTypes = require("./mac-bundle-document-types.js");

// Ensure the user has initialized the `ppm` submodule before they try to build
// the app.
// Ensure the user has initialized and built the `ppm` submodule before they
// try to build the app.
if (!existsSync(Path.join('ppm', 'bin'))) {
console.error(dedent`
\`ppm\` not detected. Please run:
git submodule init
git submodule update
git submodule update --init
yarn run build:apm
`);
process.exit(2);
} else if (
!existsSync(
Path.join(
'ppm',
'bin',
process.platform === 'win32' ? 'node.exe' : 'node'
)
)
) {
console.error(dedent`
\`ppm\` not built. Please run:
yarn run build:apm
`);
process.exit(2);
}
Expand Down Expand Up @@ -208,11 +223,6 @@ let options = {
// intact.
to: 'app'
},
// This shell script is used on macOS and Linux; it doesn't hurt to include
// it on Windows, and it might even be consumed in WSL or Cygwin
// environments.
{ from: 'ppm/bin/ppm', to: `app/ppm/bin/${ppmBaseName}` },
{ from: 'ppm/bin/node', to: `app/ppm/bin/node` },
{ from: ICONS.png, to: 'pulsar.png' },
{ from: 'LICENSE.md', to: 'LICENSE.md' }
],
Expand All @@ -229,6 +239,7 @@ let options = {
},

linux: {
executableName: baseName,
// Giving a single PNG icon to electron-builder prevents the correct
// construction of the icon path, so we have to specify a folder containing
// multiple icons named each with its size.
Expand All @@ -249,7 +260,9 @@ let options = {
// (used only by desktops to show it on bar/switcher and app menus).
"from": ICONS.svg,
"to": "pulsar.svg"
}
},
{ from: 'ppm/bin/ppm', to: `app/ppm/bin/${ppmBaseName}` },
{ from: 'ppm/bin/node', to: `app/ppm/bin/node` }
]
},

Expand Down Expand Up @@ -280,7 +293,10 @@ let options = {
{ "CFBundleURLName": "Atom Shared Session Protocol" }
]
},
extraResources: []
extraResources: [
{ from: 'ppm/bin/ppm', to: `app/ppm/bin/${ppmBaseName}` },
{ from: 'ppm/bin/node', to: `app/ppm/bin/node` }
]
},

dmg: { sign: false },
Expand Down

0 comments on commit 6bc04bb

Please sign in to comment.