Skip to content

Commit

Permalink
update electronite version
Browse files Browse the repository at this point in the history
  • Loading branch information
PhotoNomad0 committed Jul 22, 2023
1 parent c4b0ff4 commit a3ab943
Show file tree
Hide file tree
Showing 44 changed files with 22,542 additions and 0 deletions.
17 changes: 17 additions & 0 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ vars = {
'0e5d146ba13101a1302d59ea6e6e0b3cace4ae38',

'pyyaml_version': '3.12',
'graphite_version': '92f59dcc52f73ce747f1cdc831579ed2546884aa',

'chromium_git': 'https://chromium.googlesource.com',
'electron_git': 'https://github.com/electron',
'nodejs_git': 'https://github.com/nodejs',
'yaml_git': 'https://github.com/yaml',
'squirrel_git': 'https://github.com/Squirrel',
'graphite_git': 'https://github.com/silnrsi',

# KEEP IN SYNC WITH utils.js FILE
'yarn_version': '1.15.2',
Expand All @@ -32,6 +34,7 @@ vars = {
'checkout_node': True,
'checkout_nan': True,
'checkout_pgo_profiles': True,
'checkout_graphite': True,

# It's only needed to parse the native tests configurations.
'checkout_pyyaml': False,
Expand Down Expand Up @@ -82,6 +85,10 @@ deps = {
'url': (Var("yaml_git")) + '/pyyaml.git@' + (Var("pyyaml_version")),
'condition': 'checkout_pyyaml and process_deps',
},
'src/third_party/graphite/graphite2': {
'url': (Var("graphite_git")) + '/graphite.git@' + (Var("graphite_version")),
'condition': 'checkout_graphite and process_deps',
},
'src/third_party/squirrel.mac': {
'url': Var("squirrel_git") + '/Squirrel.Mac.git@' + Var("squirrel.mac_version"),
'condition': 'process_deps',
Expand Down Expand Up @@ -145,6 +152,16 @@ hooks = [
'import os, subprocess; os.chdir(os.path.join("src", "electron")); subprocess.check_call(["python3", "script/lib/npx.py", "yarn@' + (Var("yarn_version")) + '", "install", "--frozen-lockfile"]);',
],
},
{
'name': 'setup_graphite',
'condition': 'checkout_graphite and apply_patches and process_deps',
'pattern': 'src/electron',
'action': [
'python3',
'-c',
'import os; os.makedirs(os.path.join("src", "electron", "third_party", "graphite"));',
],
},
]

recursedeps = [
Expand Down
Binary file not shown.
45 changes: 45 additions & 0 deletions docs/development/Electronite/ElectroniteBuildNotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Electronite Build Notes

Electronite is a version of Electron that is patched to support rendering [graphite](https://github.com/silnrsi/graphite) enabled fonts.

Based on wiki notes for `electronite-v12.0.5` from: https://github.com/unfoldingWord/electronite/wiki

# Updating

When updating the code, the standard is to create new branches like `electronite-v12.0.5`. These eventually get pushed up to the server and tagged for the release.

## Graphite

For minor graphite updates you can simply change the version of graphite needed in `/DEPS`.

For example, this updates graphite from [1.3.13](https://github.com/silnrsi/graphite/releases/tag/1.3.13) to [1.3.14](https://github.com/silnrsi/graphite/releases/tag/1.3.14).
```diff
-'graphite_version': 'b45f9b271214b95f3b42e5c9863eae4b0bfb7fd7',
+'graphite_version': '92f59dcc52f73ce747f1cdc831579ed2546884aa',
```

If there are larger changes to the graphite API you may need to do some patching in the Electron code see [[Graphite Patch]].

## Patching Electron

The simplest way to update Electronite is to pull down the branch from upstream and re-apply the [[Graphite Patch]]. This avoids merge conflicts and an ugly commit history.

Updating Electronite is pretty straight forward.
1. Get the version of Electron that you want to update to, e.g. `git checkout upstream v12.0.5`.
2. Create new electronite branch from Electron `git checkout -b electronite-v12.0.5`
3. Apply the [Graphite Patch](https://github.com/unfoldingWord/electronite/wiki/Graphite-Patch) `git am add-graphite-to-electron.patch` (you might need to manually apply it if there are conflicting changes from upstream).
4. Build and test the Electronite branch (see below).
5. If everything is working properly, push the branch and tag the release using the proper naming convention, and create a new release based on your new tag with the compiled binaries attached to it.
6. Upload a patched version of `electron.d.ts` to the release as well for easy reference. See https://github.com/unfoldingWord-dev/electronite-cli/blob/master/README.md#development for details.

# Building

[Build Notes](ElectroniteCurrentVersionBuildNotes.md)

# Other Electronite Steps

Will need to update and publish these packages:
- https://github.com/unfoldingWord-dev/electronite-cli
- look at the README.md
- https://github.com/unfoldingWord-box3/electronite-packager
- this doesn't have notes yet - for now just merged in master branch from Electron to update version to latest `15.4.0`
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Electronite Build Notes

Electronite is a version of Electron that is patched to support rendering [graphite](https://github.com/silnrsi/graphite) enabled fonts.

Based on wiki notes for `electronite-v12.0.5` from: https://github.com/unfoldingWord/electronite/wiki

# Building

- [Windows build notes](WindowsBuildNotes.md)
- [MacOS build notes](MacBuildNotes.md)
- [Linux build notes](LinuxBuildNotes.md)

Running the scripts without arguments will display the following commands which you will generally want to execute in order:
1. `get <ref>` fetches all of the code. Where `<ref>` is a branch or tag.
2. `build [target]` compiles Electronite for target (default is x64)
3. `release [target]` creates the distributable (default is x64)

Also, you'll want to build code from a properly tagged release because [other tooling](https://github.com/topics/electronite) expects a specific naming convention.
When tagging a new release of Electronite use the same naming convention as Electron with the addition of a `-graphite` suffix. For example if Electron has a `v7.2.3` release, Electronite will have a corresponding `v7.2.3-graphite` release.

> Note: When building Electronite you will need to download about 20 gb of source code.
After running the above commands you will have a zipped file at `./electron-gn/src/out/Release/dist.zip`. You can rename this file and upload it as an artifact to the proper release on Github. Here's the naming convention:

* `electronite-<version>-win32-x64.zip`
* `electronite-<version>-win32-ia32.zip`
* `electronite-<version>-linux-x64.zip`
* `electronite-<version>-darwin-x64.zip`

Where `<version>` is the tagged release without the `-graphite` suffix. e.g. `electronite-v7.2.3-linux-x64.zip`

> You must compile Electronite on a Linux, Windows, and macOS in order to generate the three distributables above.
> Cross compilation for different OS is not possible.
## Troubleshooting

#### Delete cached repository
If you encounter errors while fetching the source code (this includes chromium) you may need to delete one of the cached repositories, or a lock file. Look through the console output to identify the repository that was being fetched when the download failed. Delete the identified repository from your `.git_cache` and also delete any `.lock` files. Re-run the download and it should succeed.

#### Disable your VPN
This problem has only been seen on some Linux systems.
It is necessary to disable any active VPNs on the computer in order to successfully download the source code. If you do not, you may get errors about not being able to reach one of the source code servers. If this occurs, delete the affected cached repository if any and try again after turning off your VPN.

#### Select Xcode build tools

If you get an error like the following:
```
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
```

You need to select the Xcode application
```
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
```

## Help!

Check out this [Electronite playlist](https://www.youtube.com/playlist?list=PLf7IRQ2kP73kmC8y8gLQoHs4I26LzrRrq) on YouTube if you need some help using the scripts.

# Testing

Once you have a compiled Electronite binary you can test it by visiting this page https://scripts.sil.org/cms/scripts/page.php?site_id=projects&item_id=graphite_fontdemo.

* Run Electronite
* Open the developer console in the running Electronite instance.
* execute `window.location="the test url above"`
* Ensure all the tests pass by visually inspecting the rendered fonts and comparing against the image samples on the site.

## Troubleshooting

Some font elements need to be enabled via css flags, and these flags are specific to each browser.
On the test page mentioned above, the padauk font uses a Mozilla specific css flag, but since Electronite is based on chromium those don't work. Therefore, it is necessary to tweak the css a little.


```diff
.padauk_ttf {
font-family: PadaukT, sans-serif;
font-size: 150%;
- -moz-font-feature-settings: "wtri=1";
- -moz-font-feature-settings: "wtri" 1;
+ font-feature-settings: "wtri" 1;
}
```

See [this issue](https://github.com/unfoldingWord/translationCore/issues/6879#issuecomment-624429380) for a detailed explaination.
69 changes: 69 additions & 0 deletions docs/development/Electronite/LinuxBuildNotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
## Building Electronite on Linux
### Setup Build Envirnonment on Clean Linux VM
- Configured my VM using these notes as a reference: [build-instructions-linux](../build-instructions-linux.md)
- Make sure the VM has a lot of disk space - I ran out of disk space with 60GB of storage configured. Rather than starting over with a new VM. I added a second Virtual Hard Drive with 100GB and then used that drive for the builds.
- to create `arm64` and `arm` builds, you must have installed the arm dependencies mentioned in the Linux build instructions above. Then run:
- Make sure you have a valid python3. Check by `python3 --version` .
- make sure there is a default Python installed by `python --version`. Should report 2.x.x, but If it reports 3.x.x it may work.

- use node v16 (had build problems with latest v18)
- installed build-tools (https://github.com/electron/build-tools). First cd to build folder and run:
```
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
```
- note 32-bit builds for Linux no longer supported.

### Build Electronite
- first make sure you have downloaded the current version of electronite-tools-3.sh. There may have been changes from other electronite versions.

#### Build x64
- get the Electronite source code for branch (this can take many hours the first time as the git cache is loaded). Open new terminal window, cd to the build folder and then run:
```
export PATH=$(pwd)/depot_tools:$PATH
./electronite-tools-3.sh get electronite-v23.3.10-beta
```

- Do build (takes a long time)
```
./electronite-tools-3.sh build x64
./electronite-tools-3.sh release x64
```

- Test the build.
- Do `cd src/out/Release-x64` and then `./electron "https://scripts.sil.org/cms/scripts/page.php?site_id=projects&item_id=graphite_fontdemo"` .
- Open the developer console by typing`Control-Shift-I`.
- if it didn't open to test page, then in console execute `window.location="https://scripts.sil.org/cms/scripts/page.php?site_id=projects&item_id=graphite_fontdemo"`
- Ensure all the tests pass by visually inspecting the rendered fonts and comparing against the image samples on the site.
- The example for Padauk from server will not be correct with the triangles. So need to:
Open elements tab, select body of html, do Control-F to search, and search for `padauk_ttf`, and apply attribute `font-feature-settings: "wtri" 1;`. The triangles should now be rendered correctly.

- The release is at ~/Develop/Electronite-Build/src/out/Release-x64/dist.zip

#### Build Arm64
- open terminal and initialize build configuration (note that if you have a slow or unreliable internet connection, it is better to change the goma setting from `cache-only` to `none`):
```
sudo apt-get install binutils-aarch64-linux-gnu
```

- if Electronite source already checked out, then skip to `Build Init` step.

- get the Electronite source code for branch (this can take many hours the first time as the git cache is loaded):
```
export PATH=$(pwd)/depot_tools:$PATH
./electronite-tools-3.sh get electronite-v23.3.10-beta
```

- Build Init: to create `arm64` builds, you must have installed the arm64 dependencies mentioned in the Linux build instructions above. Then run:
```
cd ./src
build/linux/sysroot_scripts/install-sysroot.py --arch=arm64
cd ..
```

- Do build (takes a long time)
```
./electronite-tools-3.sh build arm64
./electronite-tools-3.sh release arm64
```

- The release is at ~/Develop/Electronite-Build/src/out/Release-arm64/dist.zip
42 changes: 42 additions & 0 deletions docs/development/Electronite/LinuxBuildNotesChromeTools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## Building Electronite on Linux
### Setup on Linux VM
- Configured my VM using these notes as a reference: [build-instructions-linux](../build-instructions-linux.md){
- Make sure the VM has a lot of disk space - I ran out of disk space with 60GB of storage configured. Rather than starting over with a new VM. I added a second Virtual Hard Drive with 100GB and then used that drive for the builds.

### Build Electronite
- open terminal and cd to the folder you will use for build
- install the depot_tools here: `git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git`
- download build script to this folder from: [electronite-tools](electronite-tools.sh)
- set execute permission on script: `chmod +x ./electronite-tools.sh`
- before build do: `export PATH=/path/to/depot_tools:$PATH`
- get source files (this can take several hours the first time as the git cache is loaded): `./electronite-tools.sh get <<build-tag>>`
- to create `arm64` builds, you must have installed the arm64 dependencies mentioned in the Linux build instructions above. After doing `e sync` run:
```
cd electron-gn/src
build/linux/sysroot_scripts/install-sysroot.py --arch=arm64
cd ../..
```
- to create `arm` builds, you must have installed the arm dependencies mentioned in the Linux build instructions above. After doing `e sync` run:
```
cd electron-gn/src
build/linux/sysroot_scripts/install-sysroot.py --arch=arm
cd ../..
```
- builds can take over 20 hours on a VM.
- build Electronite for Intel 64-bit:
- build for 64-bit: `./electronite-tools.sh build x64`
- create release for 64-bit: `./electronite-tools.sh release x64`

- build Electronite for Intel 32-bit:
- initialize build configuration: `sudo apt-get install ia32-libs-gtk ia32-libs`
- build for 32-bit: `./electronite-tools.sh build x86`
- create release for 32-bit: `./electronite-tools.sh release x86`

- build Electronite for Arm 64-bit:
- build for arm 64-bit: `./electronite-tools.sh build arm64`
- create release for arm 64-bit: `./electronite-tools.sh release arm64`

- build Electronite for Arm:
- build for arm: `./electronite-tools.sh build arm`
- create release for arm: `./electronite-tools.sh release arm`

73 changes: 73 additions & 0 deletions docs/development/Electronite/MacBuildNotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
## Building Electronite on MacOS
### Setup Build Environment on MacOS Monterey
- Configured using these notes as a reference: [build-instructions-macos](../build-instructions-macos.md)
- Can build on Monterey
- Make sure you have a lot of free disk space - need over 150GB free.
- if you have trouble building with these notes, you could try the older Chromium Build tools: [MacBuildNotesChromeTools](MacBuildNotesChromeTools.md)
- Used xcode 13.3.1

- installed node using nvm
- install nvm: `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash`
- restart terminal
- install v16 (had build problems with latest v18):
```
nvm install v16
nvm use v16
node --version
```
- installed homebrew: `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"`
- Installed Python 3.10. Can install using brew `brew install [email protected]`, or download from `https://www.python.org/downloads/` . Check by `python3 --version` .
- make sure there is a default Python installed by `python --version`. Should report 2.x.x, but If it reports 3.x.x it may work. Can install 2.7.18 from https://www.python.org/ftp/python/2.7.18/python-2.7.18-macosx10.9.pkg
- configured Python:
```
pip3 install --user --upgrade pip
pip3 install --user pyobjc
pip3 install importlib-metadata
```
- installed build-tools (https://github.com/electron/build-tools). First cd to build folder and run:
```
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
```

### Build Electronite
- first make sure you have downloaded the current version of electronite-tools-3.sh. There may have been changes from other electronite versions.

#### Build Intel x64
- get the Electronite source code for branch (this can take many hours the first time as the git cache is loaded). Open new terminal window , cd to the build folder and then run:
```
export PATH=$(pwd)/depot_tools:$PATH
./electronite-tools-3.sh get electronite-v23.3.10-beta
```

- Do build (takes a long time)
```
./electronite-tools-3.sh build x64
./electronite-tools-3.sh release x64
```

- Test the build.
- Do `cd src/out/Release-x64` and then `open ./Electron.app "https://scripts.sil.org/cms/scripts/page.php?site_id=projects&item_id=graphite_fontdemo"`)
- Open the developer console by typing`Command-Alt-I`.
- in console execute `window.location="https://scripts.sil.org/cms/scripts/page.php?site_id=projects&item_id=graphite_fontdemo"`
- Ensure all the tests pass by visually inspecting the rendered fonts and comparing against the image samples on the site.
- The example for Padauk from server will not be correct with the triangles. So need to:
Open elements tab, select body of html, do command-F to search, and search for `padauk_ttf`, and apply attribute `font-feature-settings: "wtri" 1;`. The triangles should now be rendered correctly.

- The release is at ~/Develop/Electronite-Build/src/out/Release-x64/dist.zip

#### Build Arm64
- if Electronite source already checked out, then skip to `Do build` step:

- get the Electronite source code for branch (this can take many hours the first time as the git cache is loaded):
```
export PATH=$(pwd)/depot_tools:$PATH
./electronite-tools-3.sh get electronite-v23.3.10-beta
```

- Do build (takes a long time)
```
./electronite-tools-3.sh build arm64
./electronite-tools-3.sh release arm64
```

- The release is at ~/Develop/Electronite-Build/src/out/Release-arm64/dist.zip
Loading

0 comments on commit a3ab943

Please sign in to comment.