Allow script to output to curr. dir

This commit is contained in:
Andrew Morgan 2019-07-15 15:54:10 +01:00
parent da69384772
commit 4a75b532d8
1 changed files with 38 additions and 30 deletions

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# Builds and installs native node modules # Builds and installs native node modules. This script must be run from riot-web's
# root
# #
# Dependencies # Dependencies
# #
@ -19,7 +20,7 @@
# Windows: # Windows:
# - unsupported # - unsupported
set -ex set -e
usage() { usage() {
echo "Usage: $0 -e <electron_version> -a <electron_abi> [-i] [-I]" echo "Usage: $0 -e <electron_version> -a <electron_abi> [-i] [-I]"
@ -33,7 +34,7 @@ usage() {
echo "I: Same as -i, but just output the node module in the current directory" echo "I: Same as -i, but just output the node module in the current directory"
} }
while getopts "e:a:i" opt; do while getopts "e:a:i:I" opt; do
case $opt in case $opt in
e) e)
electron_version=$OPTARG electron_version=$OPTARG
@ -67,7 +68,7 @@ if [ -z ${electron_abi+x} ]; then
exit 1 exit 1
fi fi
if [ -z ${iohook+x} ] || [ -z ${iohook_export+x} ]; then if [ -z ${iohook+x} ] && [ -z ${iohook_export+x} ]; then
echo "Please specify a module to build" echo "Please specify a module to build"
usage usage
exit 1 exit 1
@ -80,7 +81,7 @@ case "$OSTYPE" in
ostype="darwin" ostype="darwin"
;; ;;
msys*) msys*)
if [ -z ${iohook+x} ] || [ -z ${iohook_export+x} ]; then if ! [ -z ${iohook+x} ] || ! [ -z ${iohook_export+x} ]; then
echo "Building iohook on Windows is unsupported at this time" echo "Building iohook on Windows is unsupported at this time"
exit 1 exit 1
fi fi
@ -102,34 +103,41 @@ else
osarch="32" osarch="32"
fi fi
# Get dependencies if ! [ -z ${iohook+x} ] || ! [ -z ${iohook_export+x} ]; then
echo "Getting dependencies..." # Get dependencies
yarn echo "Getting dependencies..."
yarn
# Riot currently does not install the correct electron version, so collect it # Riot currently does not install the correct electron version, so collect it
# manually # manually
yarn add electron@v$electron_version yarn add electron@v$electron_version
# Build iohook # Build iohook
echo "Building iohook..." echo "Building iohook..."
cd electron_app cd electron_app
# iohook attempts to download a pre-built package for node ABI v72, which does # iohook attempts to download a pre-built package for node ABI v72, which does
# not exist # not exist
yarn || echo "Ignoring broken pre-build packages" yarn || echo "Ignoring broken pre-build packages"
cd node_modules cd node_modules
rm -rf iohook rm -rf iohook
git clone https://github.com/matrix-org/iohook 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 # This builds libuiohook npm run build # This builds libuiohook
node build.js --runtime electron --version $electron_version --abi $abi --no-upload # Builds the module for the current OS/node version node build.js --runtime electron --version $electron_version --abi $abi --no-upload # Builds the module for the current OS/node version
# Install if [ -z ${iohook_export} ]; then
echo "Installing built package" # Install
folder="electron-v$abi-$ostype-x$osarch" echo "Installing built package"
mkdir -p builds/$folder/build/Release folder="electron-v$abi-$ostype-x$osarch"
cp build/Release/iohook.node builds/$folder/build/Release/ mkdir -p builds/$folder/build/Release
cp build/Release/iohook.node builds/$folder/build/Release/
else
# Just export
cp build/Release/iohook.node ../../../iohook.node
fi
fi
echo "Done!" echo "Done!"