Sometimes if prebuilt binaries of electron are not available for your platform or if you want to modify the electron source to customize to your need, you are at the right place.
I had a requirement to have a <webview> tag inside another <webview> tag. Seems it is not supported out of the box.
As per the suggestion provided in the above link, I thought I could modify a couple of lines and see if it works. Coincidentally I am running Kubuntu arm64 build on M1 mac via parallels. So I wanted a aarch64 (a.k.a arm64) build.
So I provisioned a t4g.medium (2vCPU , 4 GB RAM) with Ubuntu 22.04 LTS. I tried checking out the code as mentioned below. But within 30 mins I ran out of CPU credits and had to switch to r6g.large (2vCPU , 16 GB RAM).
Code was checked out pretty fast (fast for 50GB of code). Yes you will need at least 60GB of disk. Ok, lets go through the steps for checking out and compiling.Step-1: Prepare the build environment
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install build-essential clang libdbus-1-dev libgtk-3-dev \
libnotify-dev libasound2-dev libcap-dev \
libcups2-dev libxtst-dev \
libxss1 libnss3-dev gcc-multilib g++-multilib curl \
gperf bison python3-dbusmock openjdk-8-jre
sudo apt-get install npm
sudo npm i -g yarn
sudo npm i -g @electron/build-tools
You may not find gcc-multilib g++-multilib for arm64 Ubuntu. So you can skip them; more on that later. Now run e -help to see if you are getting any output or error. If you are getting help instructions, skip the next line.sudo npm remove @electron/build-tools
git clone https://github.com/electron/build-tools ~/.electron_build_tools
cd ~/.electron_build_tools
npm install
e –help
Step-2: download codebase and sync
e sync -v
You will get the following error.husky@8.0.1: The engine "node" is incompatible with this module. Expected version ">=14". Got "12.22.9"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
nvm list-remote
nvm install v18.12.1
nvm use v18.12.1
You can uninstall the old node versionsudo apt-get remove nodejs --purge
Then run,
e sync -v
Step-3: Build
e build
This command will fail because you can't compile chromium or electron on arm64 machine as per this. You can only cross compile arm64 on x64. I realized it later.So I provisioned r6a.large.
Install the following to cross compile for arm64 along with instructions given in Step-1
sudo apt-get install libc6-dev-arm64-cross linux-libc-dev-arm64-cross \
g++-aarch64-linux-gnu
Add the following to configure the build for arm64cd ~/electron/src
build/linux/sysroot_scripts/install-sysroot.py --arch=arm64
buildtools/linux64/gn gen out/Testing --args="import(\"//electron/build/args/testing.gn\")"
append the following line to electron/build/args/testing.gn
target_cpu = "arm64"
Run the build command again.e build
Voilà ! build is successful. To create a dist file, run the following command.
e build electron:dist
Copy the file from /home/ubuntu/electron/src/out/Testing/dist.zip
That's all folks!
Comments
Post a Comment