improve script to use case statements as appropriate and fail correctly for unsupported usage

This commit is contained in:
Vincent Sanders 2013-05-11 10:45:19 +01:00
parent 29086c377f
commit e6eecc098b
1 changed files with 211 additions and 118 deletions

View File

@ -20,19 +20,17 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. # THE SOFTWARE.
# NetSurf continuius integration build script for jenkins # NetSurf continuous integration build script for jenkins
# #
# This script is executed by jenkins to build netsurf itself # This script is executed by jenkins to build netsurf itself
# #
# Usage: jenkins-build.sh # Usage: jenkins-build.sh
# #
# TARGET is set to the frontend target to build
# label is set to the identifier of the toolchain doing the building
# TARGET must be in the environment and set correctly ################# Parameter and environment setup #####################
if [ "x${TARGET}" = "x" ];then
echo "TARGET unset"
exit 1
fi
#identifier for this specific build #identifier for this specific build
IDENTIFIER="$CC-${BUILD_JS}-${BUILD_NUMBER}" IDENTIFIER="$CC-${BUILD_JS}-${BUILD_NUMBER}"
@ -40,135 +38,216 @@ IDENTIFIER="$CC-${BUILD_JS}-${BUILD_NUMBER}"
# default atari architecture - bletch # default atari architecture - bletch
ATARIARCH=68020-60 ATARIARCH=68020-60
if [ "${TARGET}" = "riscos" ];then # Ensure the combination of target and toolchain works and set build
# specific parameters too
case ${TARGET} in
"riscos")
case ${label} in
"arm-unknown-riscos")
ARTIFACT_TARGET=riscos
;;
ARTIFACT_TARGET=riscos *)
PKG_SRC=netsurf echo "Target \"${TARGET}\" cannot be built on \"${label})\""
PKG_SFX=.zip exit 1
;;
elif [ "${TARGET}" = "windows" ];then esac
ARTIFACT_TARGET=windows PKG_SRC=netsurf
PKG_SRC=netsurf-installer PKG_SFX=.zip
PKG_SFX=.exe ;;
elif [ "${TARGET}" = "cocoa" ];then
if [ "${label}" = "i686-apple-darwin10" ]; then
ARTIFACT_TARGET=Darwin
IDENTIFIER="${label}-${IDENTIFIER}"
elif [ "${label}" = "powerpc-apple-darwin9" ]; then
ARTIFACT_TARGET=powerpc-apple-darwin9
IDENTIFIER="${ARTIFACT_TARGET}-${IDENTIFIER}"
else
echo "Bad cocoa label"
exit 1
fi
PKG_SRC=NetSurf
PKG_SFX=.dmg
elif [ "${TARGET}" = "amiga" ];then
ARTIFACT_TARGET=amiga
PKG_SRC=NetSurf_Amiga/netsurf
PKG_SFX=.lha
elif [ "${TARGET}" = "atari" ];then "windows")
case ${label} in
"i686-w64-mingw32")
ARTIFACT_TARGET=windows
;;
if [ "${label}" = "m68k-atari-mint" ]; then *)
ARTIFACT_TARGET=m68k-atari-mint echo "Target \"${TARGET}\" cannot be built on \"${label})\""
IDENTIFIER="${ARTIFACT_TARGET}-${IDENTIFIER}" exit 1
PKG_SRC=ns020 ;;
PKG_SFX=.zip
elif [ "${label}" = "m5475-atari-mint" ]; then esac
ARTIFACT_TARGET=m5475-atari-mint
export GCCSDK_INSTALL_ENV=/opt/netsurf/m5475-atari-mint/env
export GCCSDK_INSTALL_CROSSBIN=/opt/netsurf/m5475-atari-mint/cross/bin
ATARIARCH=v4e
IDENTIFIER="${ARTIFACT_TARGET}-${IDENTIFIER}"
PKG_SRC=nsv4e
PKG_SFX=.zip
else PKG_SRC=netsurf-installer
PKG_SFX=.exe
echo "Bad atari label" ;;
exit 1
fi
elif [ "${TARGET}" = "gtk" ];then
ARTIFACT_TARGET=Linux
PKG_SRC=nsgtk
PKG_SFX=
elif [ "${TARGET}" = "framebuffer" ];then
ARTIFACT_TARGET=Linux "cocoa")
PKG_SRC=nsfb case ${label} in
PKG_SFX= "i686-apple-darwin10")
ARTIFACT_TARGET=Darwin
IDENTIFIER="${label}-${IDENTIFIER}"
;;
elif [ "${TARGET}" = "monkey" ];then "powerpc-apple-darwin9")
ARTIFACT_TARGET=powerpc-apple-darwin9
IDENTIFIER="${ARTIFACT_TARGET}-${IDENTIFIER}"
;;
if [ "${label}" = "linux" ]; then *)
ARTIFACT_TARGET=Linux echo "Target \"${TARGET}\" cannot be built on \"${label})\""
exit 1
;;
elif [ "${label}" = "i686-apple-darwin10" ]; then esac
ARTIFACT_TARGET=Darwin
elif [ "${label}" = "powerpc-apple-darwin9" ]; then PKG_SRC=NetSurf
ARTIFACT_TARGET=powerpc-apple-darwin9 PKG_SFX=.dmg
;;
elif [ "${label}" = "arm-unknown-riscos" ]; then
ARTIFACT_TARGET=riscos
export GCCSDK_INSTALL_ENV=/opt/netsurf/${label}/env
export GCCSDK_INSTALL_CROSSBIN=/opt/netsurf/${label}/cross/bin
elif [ "${label}" = "m68k-atari-mint" ]; then "amiga")
ARTIFACT_TARGET=m68k-atari-mint case ${label} in
export GCCSDK_INSTALL_ENV=/opt/netsurf/${label}/env "ppc-amigaos")
export GCCSDK_INSTALL_CROSSBIN=/opt/netsurf/${label}/cross/bin ARTIFACT_TARGET=amiga
;;
elif [ "${label}" = "m5475-atari-mint" ]; then *)
ATARIARCH=v4e echo "Target \"${TARGET}\" cannot be built on \"${label})\""
ARTIFACT_TARGET=m5475-atari-mint exit 1
export GCCSDK_INSTALL_ENV=/opt/netsurf/${label}/env ;;
export GCCSDK_INSTALL_CROSSBIN=/opt/netsurf/${label}/cross/bin
elif [ "${label}" = "i686-w64-mingw32" ]; then esac
ARTIFACT_TARGET=windows
export GCCSDK_INSTALL_ENV=/opt/netsurf/${label}/env
export GCCSDK_INSTALL_CROSSBIN=/opt/netsurf/${label}/cross/bin
elif [ "${label}" = "ppc-amigaos" ]; then PKG_SRC=NetSurf_Amiga/netsurf
ARTIFACT_TARGET=amiga PKG_SFX=.lha
export GCCSDK_INSTALL_ENV=/opt/netsurf/${label}/env ;;
export GCCSDK_INSTALL_CROSSBIN=/opt/netsurf/${label}/cross/bin
else
echo "Bad monkey label"
exit 1
fi
IDENTIFIER="${label}-${IDENTIFIER}" "atari")
PKG_SRC=nsmonkey case ${label} in
PKG_SFX= "m68k-atari-mint")
ARTIFACT_TARGET=m68k-atari-mint
PKG_SRC=ns020
PKG_SFX=.zip
;;
else "m5475-atari-mint")
ARTIFACT_TARGET=m5475-atari-mint
# unkown target export GCCSDK_INSTALL_ENV=/opt/netsurf/m5475-atari-mint/env
exit 1 export GCCSDK_INSTALL_CROSSBIN=/opt/netsurf/m5475-atari-mint/cross/bin
ATARIARCH=v4e
PKG_SRC=nsv4e
PKG_SFX=.zip
;;
fi *)
echo "Target \"${TARGET}\" cannot be built on \"${label})\""
exit 1
;;
########### Build from source ################## esac
IDENTIFIER="${ARTIFACT_TARGET}-${IDENTIFIER}"
;;
"gtk")
case ${label} in
"linux")
ARTIFACT_TARGET=Linux
;;
*)
echo "Target \"${TARGET}\" cannot be built on \"${label})\""
exit 1
;;
esac
PKG_SRC=nsgtk
PKG_SFX=
;;
"framebuffer")
case ${label} in
"linux")
ARTIFACT_TARGET=Linux
;;
*)
echo "Target \"${TARGET}\" cannot be built on \"${label})\""
exit 1
;;
esac
PKG_SRC=nsfb
PKG_SFX=
;;
"monkey")
# monkey target can be built on most of the supported architectures
case ${label} in
"linux")
ARTIFACT_TARGET=Linux
;;
"i686-apple-darwin10")
ARTIFACT_TARGET=Darwin
;;
"powerpc-apple-darwin9")
ARTIFACT_TARGET=powerpc-apple-darwin9
;;
"arm-unknown-riscos")
ARTIFACT_TARGET=riscos
export GCCSDK_INSTALL_ENV=/opt/netsurf/${label}/env
export GCCSDK_INSTALL_CROSSBIN=/opt/netsurf/${label}/cross/bin
;;
"m68k-atari-mint")
ARTIFACT_TARGET=m68k-atari-mint
export GCCSDK_INSTALL_ENV=/opt/netsurf/${label}/env
export GCCSDK_INSTALL_CROSSBIN=/opt/netsurf/${label}/cross/bin
;;
"m5475-atari-mint")
ATARIARCH=v4e
ARTIFACT_TARGET=m5475-atari-mint
export GCCSDK_INSTALL_ENV=/opt/netsurf/${label}/env
export GCCSDK_INSTALL_CROSSBIN=/opt/netsurf/${label}/cross/bin
;;
"i686-w64-mingw32")
ARTIFACT_TARGET=windows
export GCCSDK_INSTALL_ENV=/opt/netsurf/${label}/env
export GCCSDK_INSTALL_CROSSBIN=/opt/netsurf/${label}/cross/bin
;;
"ppc-amigaos")
ARTIFACT_TARGET=amiga
export GCCSDK_INSTALL_ENV=/opt/netsurf/${label}/env
export GCCSDK_INSTALL_CROSSBIN=/opt/netsurf/${label}/cross/bin
;;
*)
echo "Target \"${TARGET}\" cannot be built on \"${label})\""
exit 1
;;
esac
IDENTIFIER="${label}-${IDENTIFIER}"
PKG_SRC=nsmonkey
PKG_SFX=
;;
*)
# TARGET must be in the environment and set correctly
echo "Unkown TARGET \"${TARGET}\""
exit 1
;;
esac
# setup environment # setup environment
export PREFIX=${JENKINS_HOME}/artifacts-${ARTIFACT_TARGET} export PREFIX=${JENKINS_HOME}/artifacts-${ARTIFACT_TARGET}
@ -176,27 +255,37 @@ export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PREFIX}/lib export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PREFIX}/lib
export PATH=${PATH}:${PREFIX}/bin export PATH=${PATH}:${PREFIX}/bin
# disable ccache for clang # configure ccache for clang
if [ "${CC}" = "clang" ];then if [ "${CC}" = "clang" ];then
export CCACHE_CPP2=yes export CCACHE_CPP2=yes
export CC="clang -Qunused-arguments" export CC="clang -Qunused-arguments"
fi fi
# convert javascript parameters # convert javascript parameters
if [ "${BUILD_JS}" = "json" ];then if [ "${BUILD_JS}" = "json" ];then
BUILD_MOZJS=NO BUILD_MOZJS=NO
BUILD_JS=YES BUILD_JS=YES
else else
BUILD_JS=NO BUILD_JS=NO
BUILD_MOZJS=NO BUILD_MOZJS=NO
fi fi
########### Build from source ##################
# Clean first
make NETSURF_USE_JS=${BUILD_JS} NETSURF_USE_MOZJS=${BUILD_MOZJS} clean make NETSURF_USE_JS=${BUILD_JS} NETSURF_USE_MOZJS=${BUILD_MOZJS} clean
# Do the Build # Do the Build
make -k NETSURF_USE_JS=${BUILD_JS} NETSURF_USE_MOZJS=${BUILD_MOZJS} CI_BUILD=${BUILD_NUMBER} ATARIARCH=${ATARIARCH} Q= make -k NETSURF_USE_JS=${BUILD_JS} NETSURF_USE_MOZJS=${BUILD_MOZJS} CI_BUILD=${BUILD_NUMBER} ATARIARCH=${ATARIARCH} Q=
############ Package artifact construction and deployment ################
############ Package artifact construction ################
#destination for package artifacts #destination for package artifacts
DESTDIR=/srv/ci.netsurf-browser.org/html/builds/${TARGET}/ DESTDIR=/srv/ci.netsurf-browser.org/html/builds/${TARGET}/
@ -209,10 +298,14 @@ if [ ! -f "${PKG_SRC}${PKG_SFX}" ]; then
exit 1 exit 1
fi fi
############ Package artifact deployment ################
# copy the file into the output - always use scp as it works local or remote # copy the file into the output - always use scp as it works local or remote
scp "${PKG_SRC}${PKG_SFX}" netsurf@ci.netsurf-browser.org:${DESTDIR}/NetSurf-${IDENTIFIER}${PKG_SFX} scp "${PKG_SRC}${PKG_SFX}" netsurf@ci.netsurf-browser.org:${DESTDIR}/NetSurf-${IDENTIFIER}${PKG_SFX}
# remove the package file # remove the package file
rm -f "${PKG_SRC}${PKG_SFX}" rm -f "${PKG_SRC}${PKG_SFX}"
# setup latest link # setup latest link