2018-03-06 16:50:09 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# This script is a work in progress
|
|
|
|
|
|
|
|
#### Constants ####
|
2018-03-16 23:41:43 +00:00
|
|
|
ERR=0
|
2018-03-06 16:50:09 +00:00
|
|
|
|
|
|
|
#### User variables ####
|
2019-05-15 08:02:48 +00:00
|
|
|
BUILD="$(pwd)/build"
|
2019-05-14 05:57:43 +00:00
|
|
|
QMAKE_CONF=$*
|
2019-05-15 08:02:48 +00:00
|
|
|
ROOT_DIR=$(pwd)
|
2018-03-06 16:50:09 +00:00
|
|
|
|
2020-12-16 10:59:23 +00:00
|
|
|
check_rizin() {
|
|
|
|
rizin -v >/dev/null 2>&1
|
2018-12-14 11:47:49 +00:00
|
|
|
if [ $? = 0 ]; then
|
2020-12-16 10:59:23 +00:00
|
|
|
RZCOMMIT=$(rizin -v | tail -n1 | sed "s,commit: \\(.*\\) build.*,\\1,")
|
|
|
|
SUBMODULE=$(git submodule | grep "rizin" | awk '{print $1}')
|
|
|
|
if [ "$RZCOMMIT" = "$SUBMODULE" ]; then
|
2018-12-14 11:47:49 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
return 1
|
|
|
|
}
|
2018-03-06 16:50:09 +00:00
|
|
|
|
2018-12-14 11:47:49 +00:00
|
|
|
find_qmake() {
|
2019-05-15 08:02:48 +00:00
|
|
|
qmakepath=$(command -v qmake-qt5)
|
2018-12-14 11:47:49 +00:00
|
|
|
if [ -z "$qmakepath" ]; then
|
2019-05-15 08:02:48 +00:00
|
|
|
qmakepath=$(command -v qmake)
|
2018-12-14 11:47:49 +00:00
|
|
|
fi
|
|
|
|
if [ -z "$qmakepath" ]; then
|
|
|
|
echo "You need qmake to build Cutter."
|
|
|
|
echo "Please make sure qmake is in your PATH environment variable."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "$qmakepath"
|
|
|
|
}
|
2018-12-13 12:23:03 +00:00
|
|
|
|
2019-03-27 08:16:48 +00:00
|
|
|
find_lrelease() {
|
2019-05-15 08:02:48 +00:00
|
|
|
lreleasepath=$(command -v lrelease-qt5)
|
2019-03-27 08:16:48 +00:00
|
|
|
if [ -z "$lreleasepath" ]; then
|
2019-05-15 08:02:48 +00:00
|
|
|
lreleasepath=$(command -v lrelease)
|
2019-03-27 08:16:48 +00:00
|
|
|
fi
|
|
|
|
if [ -z "$lreleasepath" ]; then
|
|
|
|
echo "You need lrelease to build Cutter."
|
|
|
|
echo "Please make sure lrelease is in your PATH environment variable."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "$lreleasepath"
|
|
|
|
}
|
|
|
|
|
2018-12-14 11:47:49 +00:00
|
|
|
find_gmake() {
|
2019-05-15 08:02:48 +00:00
|
|
|
gmakepath=$(command -v gmake)
|
2018-12-14 11:47:49 +00:00
|
|
|
if [ -z "$gmakepath" ]; then
|
2019-05-15 08:02:48 +00:00
|
|
|
gmakepath=$(command -v make)
|
2018-12-14 11:47:49 +00:00
|
|
|
fi
|
2018-12-13 12:23:03 +00:00
|
|
|
|
2018-12-14 11:47:49 +00:00
|
|
|
${gmakepath} --help 2>&1 | grep -q gnu
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "You need GNU make to build Cutter."
|
|
|
|
echo "Please make sure gmake is in your PATH environment variable."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "$gmakepath"
|
|
|
|
}
|
2018-03-06 16:50:09 +00:00
|
|
|
|
2019-04-09 07:44:44 +00:00
|
|
|
prepare_breakpad() {
|
2019-05-15 08:02:48 +00:00
|
|
|
OS="$(uname -s)"
|
|
|
|
if [ -z "$OS" ]; then
|
2019-05-14 05:57:43 +00:00
|
|
|
echo "Could not identify OS, OSTYPE var is empty. You can try to disable breakpad to avoid this error."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-05-15 08:02:48 +00:00
|
|
|
if [ "$OS" = "Linux" ]; then
|
2019-05-14 05:57:43 +00:00
|
|
|
. $ROOT_DIR/scripts/prepare_breakpad_linux.sh
|
2019-04-09 07:44:44 +00:00
|
|
|
export PKG_CONFIG_PATH="$CUSTOM_BREAKPAD_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
|
2019-05-15 08:02:48 +00:00
|
|
|
elif [ "$OS" = "Darwin" ]; then
|
2019-05-14 05:57:43 +00:00
|
|
|
. $ROOT_DIR/scripts/prepare_breakpad_macos.sh
|
2019-04-09 07:44:44 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-12-16 10:59:23 +00:00
|
|
|
# Build rizin
|
|
|
|
check_rizin
|
2018-12-14 11:47:49 +00:00
|
|
|
if [ $? -eq 1 ]; then
|
2020-12-16 10:59:23 +00:00
|
|
|
printf "A (new?) version of rizin will be installed. Do you agree? [Y/n] "
|
2019-05-15 08:02:48 +00:00
|
|
|
read -r answer
|
|
|
|
if [ -z "$answer" ] || [ "$answer" = "Y" ] || [ "$answer" = "y" ]; then
|
2020-12-16 10:59:23 +00:00
|
|
|
RZPREFIX=${1:-"/usr"}
|
2018-12-13 12:23:03 +00:00
|
|
|
git submodule init && git submodule update
|
2020-12-16 10:59:23 +00:00
|
|
|
cd rizin || exit 1
|
|
|
|
./sys/install.sh "$RZPREFIX"
|
2018-12-13 12:23:03 +00:00
|
|
|
cd ..
|
|
|
|
else
|
|
|
|
echo "Sorry but this script won't work otherwise. Read the README."
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-03-06 16:50:09 +00:00
|
|
|
else
|
2020-12-16 10:59:23 +00:00
|
|
|
echo "Correct rizin version found, skipping..."
|
2018-03-06 16:50:09 +00:00
|
|
|
fi
|
|
|
|
|
2019-03-27 08:16:48 +00:00
|
|
|
# Create translations
|
|
|
|
$(find_lrelease) ./src/Cutter.pro
|
|
|
|
|
2018-03-06 16:50:09 +00:00
|
|
|
# Build
|
2019-05-15 08:02:48 +00:00
|
|
|
if [ "${QMAKE_CONF#*CUTTER_ENABLE_CRASH_REPORTS=true}" != "$QMAKE_CONF" ]; then
|
2019-05-14 05:57:43 +00:00
|
|
|
prepare_breakpad
|
|
|
|
fi
|
2018-11-29 09:16:52 +00:00
|
|
|
mkdir -p "$BUILD"
|
2018-03-06 16:50:09 +00:00
|
|
|
cd "$BUILD" || exit 1
|
2019-05-15 08:02:48 +00:00
|
|
|
$(find_qmake) ../src/Cutter.pro "$QMAKE_CONF"
|
2018-12-14 11:47:49 +00:00
|
|
|
$(find_gmake) -j4
|
2018-03-16 23:41:43 +00:00
|
|
|
ERR=$((ERR+$?))
|
2018-10-31 16:07:53 +00:00
|
|
|
|
|
|
|
# Move translations
|
2019-05-15 08:02:48 +00:00
|
|
|
mkdir -p "$(pwd)/translations"
|
|
|
|
find "$ROOT_DIR/src/translations" -maxdepth 1 -type f | grep "cutter_..\.qm" | while read -r SRC_FILE; do
|
|
|
|
mv "$SRC_FILE" "$(pwd)/translations"
|
2018-10-31 16:07:53 +00:00
|
|
|
done
|
|
|
|
|
2018-12-14 11:47:49 +00:00
|
|
|
# Finish
|
2018-03-16 23:41:43 +00:00
|
|
|
if [ ${ERR} -gt 0 ]; then
|
2018-12-13 12:23:03 +00:00
|
|
|
echo "Something went wrong!"
|
2018-03-16 23:41:43 +00:00
|
|
|
else
|
2018-12-14 11:47:49 +00:00
|
|
|
echo "Build complete."
|
|
|
|
printf "This build of Cutter will be installed. Do you agree? [Y/n] "
|
2019-05-15 08:02:48 +00:00
|
|
|
read -r answer
|
|
|
|
if [ -z "$answer" ] || [ "$answer" = "Y" ] || [ "$answer" = "y" ]; then
|
2018-12-14 11:47:49 +00:00
|
|
|
$(find_gmake) install
|
|
|
|
else
|
|
|
|
echo "Binary available at $BUILD/Cutter"
|
|
|
|
fi
|
2018-03-16 23:41:43 +00:00
|
|
|
fi
|
2018-03-06 16:50:09 +00:00
|
|
|
|
2018-12-14 11:47:49 +00:00
|
|
|
cd ..
|