Skip to content

Instantly share code, notes, and snippets.

@da1nerd
Last active April 30, 2021 03:42
Show Gist options
  • Save da1nerd/9e5b4fdd0f80d764e737d066e8cb224d to your computer and use it in GitHub Desktop.
Save da1nerd/9e5b4fdd0f80d764e737d066e8cb224d to your computer and use it in GitHub Desktop.
Tool for building electronite
echo off
set ELECTRONITE_REPO="https://github.com/unfoldingWord-dev/electronite"
set working_dir=%cd%
set GIT_CACHE_PATH=%userprofile%\.git_cache
set SCCACHE_BUCKET=electronjs-sccache
set SCCACHE_TWO_TIER=true
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
rem TODO: configure environment variables.
rem ------------------------
rem check command to execute
rem ------------------------
if %1.==. goto MissingArgs
rem -------------
rem start command
rem -------------
if "%1" == "get" goto Get
if "%1" == "build" goto Build
if "%1" == "release" goto Release
:Get
rem ####################
rem fetch code
rem ####################
if %2.==. goto MissingTag
set checkout_tag=%2
rem make sure depot_tools is clean
echo Preparing depot_tools
FOR /F "tokens=* USEBACKQ" %%F IN (`where gclient.bat`) DO (
set depot_tools_dir=%%~dpF
)
cd %depot_tools_dir% && call git reset HEAD --hard && echo depot_tools is ready
cd %working_dir%
rem fetch code
echo Fetching code. This will take a long time and download up to 16GB.
if exist electron-gn rmdir /Q /S electron-gn
mkdir electron-gn
cd electron-gn
call gclient config --name "src/electron" --unmanaged %ELECTRONITE_REPO%
call gclient sync --with_branch_heads --with_tags --nohooks --noprehooks
cd src\electron
echo Checking out %checkout_tag%
call git checkout %checkout_tag%
cd ..\..
echo Applying electron patches
call gclient sync --with_branch_heads --with_tags
goto End
:Build
rem ####################
rem build release
rem ####################
set build_32bit=false
if %2 == x86 set build_32bit=true
echo Building release
cd electron-gn\src
set CHROMIUM_BUILDTOOLS_PATH=%cd%\buildtools
if %build_32bit% == true (
echo Generating 32bit configuration...
call gn gen out/Release-x86 --args="target_cpu=\"x86\" import(\"//electron/build/args/release.gn\") cc_wrapper=\"%working_dir%/electron-gn/src/electron/external_binaries/sccache\""
call ninja -C out/Release-x86 electron
) else (
echo Generating configuration...
call gn gen out/Release --args="import(\"//electron/build/args/release.gn\") cc_wrapper=\"%working_dir%/electron-gn/src/electron/external_binaries/sccache\""
call ninja -C out/Release electron
)
goto End
:Release
rem ####################
rem create distributable
rem ####################
set release_32bit=false
if %2 == x86 set release_32bit=true
cd electron-gn\src
if %release_32bit% == true (
echo Creating 32bit distributable
electron\script\strip-binaries.py -d out\Release-x86
call ninja -C out\Release-x86 electron:electron_dist_zip
) else (
echo Creating distributable
electron\script\strip-binaries.py -d out\Release
call ninja -C out\Release electron:electron_dist_zip
)
goto End
rem ####################
rem help text
rem ####################
:MissingArgs
echo ***********************
echo * Electronite Tools *
echo ***********************
echo This is a set of tools for compiling electronite.
echo The source for electronite is at https://github.com/unfoldingWord-dev/electronite.
echo Usage: ./electronite-tools.sh ^<command^>
echo where ^<command^> is one of:
echo get ^<ref^> - fetches all of the code.
echo Where ^<ref^> is a branch or tag.
echo build [arch] - compiles electronite. The default arch is x64, but you can specify x86.
echo release [arch] - creates the distributable. The default arch is x64, but you can specify x86.
echo For detailed instructions on building Electron
echo see https://github.com/electron/electron/blob/master/docs/development/build-instructions-gn.md
goto End
:MissingTag
echo Missing the ^<ref^> to checkout. Please specify a tag or branch name.
goto End
:End
cd %working_dir%
@da1nerd
Copy link
Author

da1nerd commented Apr 30, 2021

Make sure to first install all dependencies https://github.com/electron/electron/blob/master/docs/development/build-instructions-windows.md#prerequisites

When you are installing dependencies, you must actually install Visual Studio 2017, not 2019 or anything else.
Then, during the vs install you must include the desktop development module for c++.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment