1
1
mirror of https://github.com/ariya/phantomjs.git synced 2024-09-19 16:48:07 +03:00
phantomjs/build.sh
Ariya Hidayat 59dbd77ef5 Ask for a confirmation before initiating the build.
Although it is mentioned in http://phantomjs.org/build.html, many people
are not aware this, they compile from source (even if a binary package
is available) and get shocked to realize the build takes ages.
The build script is thus modified to give the initial warning.

Unattended build is still possible, just use --confirm flag.

http://code.google.com/p/phantomjs/issues/detail?id=862
2012-11-10 00:11:14 -08:00

92 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
set -e
QT_CFG=''
BUILD_CONFIRM=0
COMPILE_JOBS=1
MAKEFLAGS_JOBS=''
if [[ "$MAKEFLAGS" != "" ]]; then
MAKEFLAGS_JOBS=$(echo $MAKEFLAGS | egrep -o '\-j[0-9]+' | egrep -o '[0-9]+')
fi
if [[ "$MAKEFLAGS_JOBS" != "" ]]; then
# user defined number of jobs in MAKEFLAGS, re-use that number
COMPILE_JOBS=$MAKEFLAGS_JOBS
elif [[ $OSTYPE = darwin* ]]; then
# We only support modern Mac machines, they are at least using
# hyperthreaded dual-core CPU.
COMPILE_JOBS=4
else
CPU_CORES=`grep -c ^processor /proc/cpuinfo`
if [[ "$CPU_CORES" -gt 1 ]]; then
COMPILE_JOBS=$CPU_CORES
if [[ "$COMPILE_JOBS" -gt 8 ]]; then
# Safety net.
COMPILE_JOBS=8
fi
fi
fi
until [ -z "$1" ]; do
case $1 in
"--qt-config")
shift
QT_CFG=" $1"
shift;;
"--qmake-args")
shift
QMAKE_ARGS=$1
shift;;
"--jobs")
shift
COMPILE_JOBS=$1
shift;;
"--confirm")
BUILD_CONFIRM=1
shift;;
"--help")
echo "Usage: $0 [--qt-config CONFIG] [--jobs NUM]"
echo
echo " --confirm Silently confirm the build."
echo " --qt-config CONFIG Specify extra config options to be used when configuring Qt"
echo " --jobs NUM How many parallel compile jobs to use. Defaults to 4."
echo
exit 0
;;
*)
echo "Unrecognised option: $1"
exit 1;;
esac
done
if [[ "$BUILD_CONFIRM" -eq 0 ]]; then
cat << EOF
----------------------------------------
WARNING
----------------------------------------
Building PhantomJS from source takes a very long time, anywhere from 30 minutes
to several hours (depending on the machine configuration). It is recommended to
use the premade binary packages on supported operating systems.
For details, please go the the web site: http://phantomjs.org/download.html.
EOF
echo "Do you want to continue (y/n)?"
read continue
if [[ "$continue" != "y" ]]; then
exit 1
fi
echo
echo
fi
cd src/qt && ./preconfig.sh --jobs $COMPILE_JOBS --qt-config "$QT_CFG" && cd ../..
src/qt/bin/qmake $QMAKE_ARGS
make -j$COMPILE_JOBS