diff --git a/docs/development/Electronite/electronite-tools-goma-3.sh b/docs/development/Electronite/electronite-tools-goma-3.sh new file mode 100755 index 0000000000000..7650b6c07588a --- /dev/null +++ b/docs/development/Electronite/electronite-tools-goma-3.sh @@ -0,0 +1,171 @@ +#!/bin/bash +set -e +set -x + +# Base Build script to do one of: getting sources, building Electronite executable, packaging Electronite as dist.zip +# +# to troubleshoot build problems, do build logging by doing `set BUILD_EXTRAS=-vvvvv` before running +# +# to enable goma, do `export GOMA=cache-only` before running script + +FORK="unfoldingWord/electronite" +ELECTRONITE_REPO="https://github.com/$FORK" +COMMAND=$1 + +# Configure environment variables and paths +# export PATH=$PATH:~/.electron_build_tools/third_party/depot_tools:~/.electron_build_tools/src +echo "PATH = $PATH" +export GIT_CACHE_PATH=`pwd`/git_cache +mkdir -p "${GIT_CACHE_PATH}" + +export DATE=`date` +echo "$DATE" > "./start_time_$1_$2_$DATE.txt" + +# sccache no longer supported in Electron +# export SCCACHE_BUCKET="electronjs-sccache" +# export SCCACHE_TWO_TIER=true + +export NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] " +echo "GIT_CACHE_PATH=${GIT_CACHE_PATH}" +echo "SCCACHE_BUCKET=${SCCACHE_BUCKET}" + +if [ "${GOMA}" == "" ]; then + GOMA=none + echo "GOMA defaulting to ${GOMA}" +else + echo "GOMA is set to ${GOMA}" +fi + +########################## +# fetch code +########################## +if [ "$COMMAND" == "get" ]; then + if [ $# -ge 2 ]; then + BRANCH=$2 + else + echo "Missing the to checkout. Please specify a tag or branch name." + exit 0 + fi + + if [ -d ./src ]; then + echo "Deleting old work folders in the background. This may take a long time with about 49GB and 850K files." + mv src src.old + # run in background + rm -rf src.old& + fi + + echo "Fetching code. This can take hours and download over 20GB." + echo "Checking out $ELECTRONITE_REPO.git@origin/$BRANCH" + CONFIG_FILE=~/.electron_build_tools/configs/evm.x64.json + rm ${CONFIG_FILE} + + e init --root=. -o x64 x64 -i release --goma cache-only --fork ${FORK} --use-https -f + cp ${CONFIG_FILE} ${CONFIG_FILE}.old +# add branch to fork + sed "s|${FORK}.git|${FORK}.git@origin/${BRANCH}|g" ${CONFIG_FILE} > build_config.new + # replace generated config + cp build_config.new ${CONFIG_FILE} + + echo "Checking out branch and Applying electronite patches" + e sync + + echo "Identify checked out branch" + cd src/electron + git --version + git status + git describe --tags + cd ../.. + + # save in case graphite patch fails + export DATE=`date` + echo "$DATE" > "./end_time_$1_$2_$DATE.txt" + + echo "Applying graphite patches" + cd ./src + git apply --whitespace=warn ./electron/docs/development/Electronite/add_graphite_cpp_std_iterator.patch + cd .. + + export DATE=`date` + echo "$DATE" > "./end_time_$1_$2_$DATE.txt" + exit 0 +fi + +########################## +# build release +########################## +if [ "$COMMAND" == "build" ]; then + if [ $# -ge 2 ]; then + TARGET=$2 + echo "Building for \"${TARGET}\"" + else + echo "Building for default \"x64\"" + TARGET=x64 + fi + + CONFIG_FILE=~/.electron_build_tools/configs/evm.$TARGET.json + RELEASE_TARGET="-${TARGET}" + e init --root=. -o $TARGET $TARGET -i release --goma $GOMA --fork ${FORK} --use-https -f + # add target architecture to config + sed -I .orig 's|release.gn\\")"|release.gn\\")", "target_cpu = \\"'"$TARGET"'\\""|g' ${CONFIG_FILE} + + echo "Building Electronite..." + e build electron + + export DATE=`date` + echo "$DATE" > "./end_time_$1_$2_$DATE.txt" + exit 0 +fi + +########################## +# create distributable +########################## +if [ "$COMMAND" == "release" ]; then + if [ $# -ge 2 ]; then + TARGET=$2 + echo "Building for \"${TARGET}\"" + else + echo "Building for default \"x64\"" + TARGET=x64 + fi + + CONFIG_FILE=~/.electron_build_tools/configs/evm.$TARGET.json + RELEASE_TARGET="-${TARGET}" + e init --root=. -o $TARGET $TARGET -i release --goma $GOMA --fork ${FORK} --use-https -f + # add target architecture to config + sed -I .orig 's|release.gn\\")"|release.gn\\")", "target_cpu = \\"'"$TARGET"'\\""|g' ${CONFIG_FILE} + + echo "Creating Electronite Distributable..." + e build electron:dist + + export DATE=`date` + echo "$DATE" > "./end_time_$1_$2_$DATE.txt" + 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 + +where is one of: + + get - fetches all of the code. + Where is a branch or tag. + + build - compiles Electronite, target is optional, defaults to x64, + Could be arm64. + + release - creates the distributable. Use same target as + previous build. + +For detailed instructions on building Electron +see https://github.com/electron/electron/blob/master/docs/development/build-instructions-gn.md +" +fi diff --git a/docs/development/Electronite/meta_builds/build_all_goma_mac.sh b/docs/development/Electronite/meta_builds/build_all_goma_mac.sh new file mode 100755 index 0000000000000..f4c2d9bc553a8 --- /dev/null +++ b/docs/development/Electronite/meta_builds/build_all_goma_mac.sh @@ -0,0 +1,55 @@ +#!/bin/bash +set -e + +# Meta Build script to get sources, and then build for x64 and arm64 by calling build_target_mac.sh +# for each architecture. The dist.zip files are stored at $DEST +# +# to troubleshoot build problems, do build logging by doing `export BUILD_EXTRAS=-vvvvv` before running +# +# to enable goma, do `export GOMA=cache-only` before running script +# +# Example `./build_all_goma_mac.sh electronite-v21.3.3-beta results/mac/v21.3.3` + +BRANCH=$1 +DEST=$2 + +echo "Building $BRANCH to: $DEST" + +if [ ! -d src ]; then + echo "Getting sources from $BRANCH" + ./electronite-tools-goma-3.sh get $BRANCH +fi + +TARGET=x64 +DEST_FILE=$DEST/$TARGET/dist.zip +if [ -f $DEST_FILE ]; then + echo "Build $TARGET already exists: $DEST_FILE" +else + echo "Doing Build $TARGET" + ./build_target_goma_mac.sh $TARGET $DEST +fi + +if [ -f $DEST_FILE ]; then + echo "Distribution $TARGET built: $DEST_FILE" +else + echo "Distribution $TARGET failed: $DEST_FILE" + exit 10 +fi + +TARGET=arm64 +DEST_FILE=$DEST/$TARGET/dist.zip +if [ -f $DEST_FILE ]; then + echo "Build $TARGET already exists: $DEST_FILE" +else + echo "Doing Build $TARGET" + ./build_target_goma_mac.sh $TARGET $DEST +fi + +if [ -f $DEST_FILE ]; then + echo "Distribution $TARGET built: $DEST_FILE" +else + echo "Distribution $TARGET failed: $DEST_FILE" + exit 10 +fi + +echo "All builds completed to $DEST" diff --git a/docs/development/Electronite/meta_builds/build_target_goma_mac.sh b/docs/development/Electronite/meta_builds/build_target_goma_mac.sh new file mode 100755 index 0000000000000..28355ccf26b3a --- /dev/null +++ b/docs/development/Electronite/meta_builds/build_target_goma_mac.sh @@ -0,0 +1,82 @@ +#!/bin/bash +set -e + +# Build script to do build build and release for $TARGET if not present at $DEST +# +# to troubleshoot build problems, do build logging by doing `export BUILD_EXTRAS=-vvvvv` before running +# +# to enable goma, do `export GOMA=cache-only` before running script +# +# Example `./build_target_goma_mac.sh x64 results/mac/v22.0.0` + +TARGET=$1 +DEST=$2 + +echo "Building $TARGET to: $DEST" + +BUILD_TARGET=./src/out/$TARGET/Electron.app +if [ -d $BUILD_TARGET ]; then + echo "Build Target already exists: $BUILD_TARGET" +else + echo "Doing Build $TARGET to $BUILD_TARGET" + ./electronite-tools-goma-3.sh build $TARGET + echo "Finished Build $TARGET to $BUILD_TARGET" +fi + +if [ -d $BUILD_TARGET ]; then + echo "Target built: $BUILD_TARGET" +else + echo "Target failed: $BUILD_TARGET" + exit 1 +fi + +RELEASE_TARGET=./src/out/$TARGET/dist.zip +if [ -f $RELEASE_TARGET ]; then + echo "Release Target already exists: $RELEASE_TARGET" +else + echo "Doing Release $TARGET" + ./electronite-tools-goma-3.sh release $TARGET +fi + +if [ -f $RELEASE_TARGET ]; then + echo "Target released: $RELEASE_TARGET" +else + echo "Target failed: $RELEASE_TARGET" + exit 1 +fi + +DEST_FOLDER=$DEST/$TARGET +if [ -d $DEST_FOLDER ]; then + echo "Destination exists: $DEST_FOLDER" +else + echo "Creating Destination folder: $DEST_FOLDER" + mkdir -p $DEST_FOLDER +fi + +if [ -d $DEST_FOLDER ]; then + echo "Destination exists: $DEST_FOLDER" +else + echo "Error Creating Destination folder: $DEST_FOLDER" + exit 1 +fi + + +DEST_FILE=$DEST_FOLDER/dist.zip +echo "Copy from $RELEASE_TARGET to $DEST_FILE" +cp $RELEASE_TARGET $DEST_FILE +if [ -f $DEST_FILE ]; then + echo "Target copied: $DEST_FILE" +else + echo "Error moving dist.zip file to: $DEST_FILE" + exit 1 +fi + +TARGET_FOLDER=./src/out/$TARGET +echo "Remove $TARGET_FOLDER to free up space for later builds" +rm -rf $TARGET_FOLDER +if [ -d $TARGET_FOLDER ]; then + echo "Error removing $TARGET_FOLDER" + exit 1 +fi + +echo "Done copying build to $TARGET_FOLDER" diff --git a/docs/development/Electronite/meta_builds/build_target_linux.sh b/docs/development/Electronite/meta_builds/build_target_linux.sh index 4a5cdc7ac4810..8795db99e6780 100755 --- a/docs/development/Electronite/meta_builds/build_target_linux.sh +++ b/docs/development/Electronite/meta_builds/build_target_linux.sh @@ -5,7 +5,7 @@ set -e # # to troubleshoot build problems, do build logging by doing `export BUILD_EXTRAS=-vvvvv` before running # -# Example `./build_target_linux.sh x64 results` +# Example `./build_target_linux.sh x64 results/mac/v21.3.3` TARGET=$1 DEST=$2 diff --git a/docs/development/Electronite/meta_builds/build_target_mac.sh b/docs/development/Electronite/meta_builds/build_target_mac.sh index 4f86565db88ac..692df6aca52b7 100755 --- a/docs/development/Electronite/meta_builds/build_target_mac.sh +++ b/docs/development/Electronite/meta_builds/build_target_mac.sh @@ -5,7 +5,7 @@ set -e # # to troubleshoot build problems, do build logging by doing `export BUILD_EXTRAS=-vvvvv` before running # -# Example `./build_target_mac.sh x64 results` +# Example `./build_target_mac.sh x64 results/mac/v21.3.3` TARGET=$1 DEST=$2