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
#
# Builds and installs native node modules
# Builds and installs native node modules. This script must be run from riot-web's
# root
#
# Dependencies
#
@ -19,7 +20,7 @@
# Windows:
# - unsupported
set -ex
set -e
usage() {
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"
}
while getopts "e:a:i" opt; do
while getopts "e:a:i:I" opt; do
case $opt in
e)
electron_version=$OPTARG
@ -67,7 +68,7 @@ if [ -z ${electron_abi+x} ]; then
exit 1
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"
usage
exit 1
@ -80,7 +81,7 @@ case "$OSTYPE" in
ostype="darwin"
;;
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"
exit 1
fi
@ -102,6 +103,7 @@ else
osarch="32"
fi
if ! [ -z ${iohook+x} ] || ! [ -z ${iohook_export+x} ]; then
# Get dependencies
echo "Getting dependencies..."
yarn
@ -126,10 +128,16 @@ rm -rf builds/*
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
if [ -z ${iohook_export} ]; then
# Install
echo "Installing built package"
folder="electron-v$abi-$ostype-x$osarch"
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!"