Update build script

This commit is contained in:
Andrew Morgan 2019-07-15 15:44:00 +01:00
parent 98cd405f2c
commit da69384772
2 changed files with 80 additions and 47 deletions

View File

@ -21,44 +21,20 @@ the microphone in a call) and is ONLY enabled during a call and while setting
the keybinding in settings. the keybinding in settings.
If you would like to rebuild the module yourself and replace the downloaded If you would like to rebuild the module yourself and replace the downloaded
binaries, then first make sure you have [iohook's binaries, then first make sure you have the following dependencies. Then
dependencies](https://wilix-team.github.io/iohook/manual-build.html#ubuntu-16) simply execute `build-native-modules.sh` with the following flags:
installed. Then execute the following commands from Riot's root directory:
```bash ```bash
cd electron_app ./scripts/build-native-modules.sh -e 4.2.6 -a 69 -i
yarn
cd node_modules
rm -rf iohook
git clone https://github.com/matrix-org/iohook
cd iohook
npm i
rm -rf builds/* # Delete any downloaded binaries
npm run build # This builds libuiohook
node build.js --runtime electron --version 4.1.3 --abi 69 --no-upload # This builds the module for the current OS
``` ```
You then need to copy the built module to the correct folder depending on the operating system and architecture you're building for: `-e` specifies the electron version, `-a` specifies the electron ABI version,
and `-i` tells the script to build iohook and then install it.
If you'd just like to build the module without installing it, use `-I` instead.
```bash ```bash
# Run one of the following depending on your architecture: ./scripts/build-native-modules.sh -e 4.2.6 -a 69 -I
# 64-bit
osarch="64"
# 32-bit
osarch="32"
# Run one of the following depending on your operating system:
# Windows
ostype="win32"
# Linux
ostype="linux"
# MacOS
ostype="darwin"
# Finally, copy the module:
folder="electron-v69-$ostype-x$osarch"
mkdir -p builds/$folder/build/Release
cp build/Release/iohook.node builds/$folder/build/Release/
``` ```
The electron version of Riot can then be built normally according to the [build instructions](../README.md#running-as-a-desktop-app). To then start Electron, use `npx electron .`. To package, use `build -wml -ia32 --x64`.

View File

@ -1,24 +1,77 @@
#!/bin/bash #!/bin/bash
# #
# Builds and installs iohook for Push-to-Talk functionality # Builds and installs native node modules
# #
# Dependencies # Dependencies
# #
# Common: # iohook
# - npm, yarn # Common:
# - npm, yarn
# #
# Linux: # Linux:
# - apt install build-essentials cmake # - apt install build-essentials cmake
# #
# MacOS: # MacOS:
# - Xcode developer tools # - Xcode developer tools
# - brew # - brew
# - brew install cmake automake libtool pkg-config # - brew install cmake automake libtool pkg-config
#
# Windows:
# - unsupported
set -ex set -ex
electron_version="4.2.6" usage() {
abi="69" echo "Usage: $0 -e <electron_version> -a <electron_abi> [-i] [-I]"
echo
echo "version: Electron version to use. Ex: 4.2.6"
echo
echo "electron_abi: ABI of the chosen electron version."
echo "Electron v4.2.6's ABI is 69"
echo
echo "i: Build the iohook native node module for Push-to-Talk functionality"
echo "I: Same as -i, but just output the node module in the current directory"
}
while getopts "e:a:i" opt; do
case $opt in
e)
electron_version=$OPTARG
;;
a)
electron_abi=$OPTARG
;;
i)
iohook=1
;;
I)
iohook_export=1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
exit
;;
esac
done
if [ -z ${electron_version+x} ]; then
echo "No Electron version supplied"
usage
exit 1
fi
if [ -z ${electron_abi+x} ]; then
echo "No Electron ABI supplied"
usage
exit 1
fi
if [ -z ${iohook+x} ] || [ -z ${iohook_export+x} ]; then
echo "Please specify a module to build"
usage
exit 1
fi
echo "Detecting OS..." echo "Detecting OS..."
case "$OSTYPE" in case "$OSTYPE" in
@ -27,7 +80,11 @@ case "$OSTYPE" in
ostype="darwin" ostype="darwin"
;; ;;
msys*) msys*)
echo "Windows is unsupported at this time" if [ -z ${iohook+x} ] || [ -z ${iohook_export+x} ]; then
echo "Building iohook on Windows is unsupported at this time"
exit 1
fi
ostype="win"
;; ;;
*) *)
echo "Found Linux." echo "Found Linux."
@ -66,8 +123,8 @@ git clone https://github.com/matrix-org/iohook
cd iohook cd iohook
npm i || echo "Ignoring broken pre-build packages" npm i || echo "Ignoring broken pre-build packages"
rm -rf builds/* rm -rf builds/*
npm run build npm run build # This builds libuiohook
node build.js --runtime electron --version $electron_version --abi $abi --no-upload node build.js --runtime electron --version $electron_version --abi $abi --no-upload # Builds the module for the current OS/node version
# Install # Install
echo "Installing built package" echo "Installing built package"