Last active
April 24, 2020 05:05
-
-
Save da1nerd/95a95297310dd7e4c0b87a9093f999d8 to your computer and use it in GitHub Desktop.
Tools to build electronite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
ELECTRONITE_REPO="https://github.com/unfoldingWord-dev/electronite" | |
COMMAND=$1 | |
# Configure environment variables and paths | |
export GIT_CACHE_PATH="${HOME}/.git_cache" | |
mkdir -p "${GIT_CACHE_PATH}" | |
export SCCACHE_BUCKET="electronjs-sccache" | |
export SCCACHE_TWO_TIER=true | |
########################## | |
# fetch code | |
########################## | |
if [ "$COMMAND" == "get" ]; then | |
if [ $# -ge 2 ]; then | |
BRANCH=$2 | |
else | |
echo "Missing the <ref> to checkout. Please specify a tag or branch name." | |
exit 0 | |
fi | |
echo "Fetching code. This will take a long time and download up to 16GB." | |
rm -rf electron-gn | |
mkdir -p electron-gn | |
cd electron-gn | |
gclient config --name "src/electron" --unmanaged $ELECTRONITE_REPO | |
gclient sync --with_branch_heads --with_tags --nohooks --noprehooks | |
cd src/electron | |
echo "Checking out $BRANCH" | |
git checkout $BRANCH | |
cd - | |
echo "Applying electron patches" | |
gclient sync --with_branch_heads --with_tags | |
exit 0 | |
fi | |
########################## | |
# build release | |
########################## | |
if [ "$COMMAND" == "build" ]; then | |
echo "Building release" | |
cd electron-gn/src | |
export CHROMIUM_BUILDTOOLS_PATH=`pwd`/buildtools | |
export GN_EXTRA_ARGS="${GN_EXTRA_ARGS} cc_wrapper=\"${PWD}/electron/external_binaries/sccache\"" | |
echo "Generating configuration..." | |
gn gen out/Release --args="import(\"//electron/build/args/release.gn\") $GN_EXTRA_ARGS" | |
ninja -C out/Release electron | |
cd - | |
exit 0 | |
fi | |
########################## | |
# create distributable | |
########################## | |
if [ "$COMMAND" == "release" ]; then | |
echo "Creating distributable" | |
cd electron-gn/src | |
./electron/script/strip-binaries.py -d out/Release | |
ninja -C out/Release electron:electron_dist_zip | |
exit 0 | |
fi | |
########################## | |
# help | |
########################## | |
if [ "$COMMAND" == "" ]; then | |
echo "*********************** | |
* Electronite Tools * | |
*********************** | |
This is a set of tools for compiling electronite. | |
The source for electronite is at https://github.com/unfoldingWord-dev/electronite. | |
Usage: ./electronite-tools.sh <command> | |
where <command> is one of: | |
get <ref> - fetches all of the code. | |
Where <ref> is a branch or tag. | |
build - compiles electronite. | |
release - creates the distributable. | |
For detailed instructions on building Electron | |
see https://github.com/electron/electron/blob/master/docs/development/build-instructions-gn.md | |
" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment