/build.sh
Shell | 293 lines | 212 code | 30 blank | 51 comment | 35 complexity | 728ccba70fe4b3162496fc2c7dbcf363 MD5 | raw file
Possible License(s): LGPL-2.1
1#!/bin/sh 2 3# This is a the master build script - it is intended to be run by parabuild 4# It is called by a wrapper script in the shared repository which sets up 5# the environment from the various BuildParams files and does all the build 6# result post-processing. 7# 8# PLEASE NOTE: 9# 10# * This script is interpreted on three platforms, including windows and cygwin 11# Cygwin can be tricky.... 12# * The special style in which python is invoked is intentional to permit 13# use of a native python install on windows - which requires paths in DOS form 14# * This script relies heavily on parameters defined in BuildParams 15# * The basic convention is that the build name can be mapped onto a mercurial URL, 16# which is also used as the "branch" name. 17 18build_dir_Darwin() 19{ 20 echo build-darwin-i386 21} 22 23build_dir_Linux() 24{ 25 echo build-linux-i686 26} 27 28build_dir_CYGWIN() 29{ 30 echo build-vc100 31} 32 33installer_Darwin() 34{ 35 ls -1td "$(build_dir_Darwin ${last_built_variant:-Release})/newview/"*.dmg 2>/dev/null | sed 1q 36} 37 38installer_Linux() 39{ 40 ls -1td "$(build_dir_Linux ${last_built_variant:-Release})/newview/"*.tar.bz2 2>/dev/null | sed 1q 41} 42 43installer_CYGWIN() 44{ 45 v=${last_built_variant:-Release} 46 d=$(build_dir_CYGWIN $v) 47 if [ -r "$d/newview/$v/touched.bat" ] 48 then 49 p=$(sed 's:.*=::' "$d/newview/$v/touched.bat") 50 echo "$d/newview/$v/$p" 51 fi 52} 53 54pre_build() 55{ 56 local variant="$1" 57 begin_section "Pre$variant" 58 [ -n "$master_message_template_checkout" ] \ 59 && [ -r "$master_message_template_checkout/message_template.msg" ] \ 60 && template_verifier_master_url="-DTEMPLATE_VERIFIER_MASTER_URL=file://$master_message_template_checkout/message_template.msg" 61 62 "$AUTOBUILD" configure -c $variant -- \ 63 -DPACKAGE:BOOL=ON \ 64 -DRELEASE_CRASH_REPORTING:BOOL=ON \ 65 -DVIEWER_CHANNEL:STRING="\"$viewer_channel\"" \ 66 -DVIEWER_LOGIN_CHANNEL:STRING="\"$viewer_login_channel\"" \ 67 -DGRID:STRING="\"$viewer_grid\"" \ 68 -DLL_TESTS:BOOL="$run_tests" \ 69 -DTEMPLATE_VERIFIER_OPTIONS:STRING="$template_verifier_options" $template_verifier_master_url 70 end_section "Pre$variant" 71} 72 73build() 74{ 75 local variant="$1" 76 if $build_viewer 77 then 78 begin_section "Viewer$variant" 79 if "$AUTOBUILD" build --no-configure -c $variant 80 then 81 echo true >"$build_dir"/build_ok 82 else 83 echo false >"$build_dir"/build_ok 84 fi 85 end_section "Viewer$variant" 86 fi 87} 88 89# This is called from the branch independent script upon completion of all platform builds. 90build_docs() 91{ 92 begin_section Docs 93 # Stub code to generate docs 94 echo Hello world > documentation.txt 95 upload_item docs documentation.txt text/plain 96 end_section Docs 97} 98 99 100# Check to see if we were invoked from the wrapper, if not, re-exec ourselves from there 101if [ "x$arch" = x ] 102then 103 top=`hg root` 104 if [ -x "$top/../buildscripts/hg/bin/build.sh" ] 105 then 106 exec "$top/../buildscripts/hg/bin/build.sh" "$top" 107 else 108 cat <<EOF 109This script, if called in a development environment, requires that the branch 110independent build script repository be checked out next to this repository. 111This repository is located at http://hg.lindenlab.com/parabuild/buildscripts 112EOF 113 exit 1 114 fi 115fi 116 117# Check to see if we're skipping the platform 118eval '$build_'"$arch" || pass 119 120# Run the version number update script 121# File no longer exists in code-sep branch, so let's make sure it exists in order to use it. 122if test -f scripts/update_version_files.py ; then 123 begin_section UpdateVer 124 eval $(python scripts/update_version_files.py \ 125 --channel="$viewer_channel" \ 126 --server_channel="$server_channel" \ 127 --revision=$revision \ 128 --verbose \ 129 | sed -n -e "s,Setting viewer channel/version: '\([^']*\)' / '\([^']*\)',VIEWER_CHANNEL='\1';VIEWER_VERSION='\2',p")\ 130 || fail update_version_files.py 131 echo "{\"Type\":\"viewer\",\"Version\":\"${VIEWER_VERSION}\"}" > summary.json 132 end_section UpdateVer 133fi 134 135# Now retrieve the version for use in the version manager 136# First three parts only, $revision will be appended automatically. 137build_viewer_update_version_manager_version=`python scripts/get_version.py --viewer-version | sed 's/\.[0-9]*$//'` 138 139if [ -z "$AUTOBUILD" ] 140then 141 export autobuild_dir="$here/../../../autobuild/bin/" 142 if [ -d "$autobuild_dir" ] 143 then 144 export AUTOBUILD="$autobuild_dir"autobuild 145 if [ -x "$AUTOBUILD" ] 146 then 147 # *HACK - bash doesn't know how to pass real pathnames to native windows python 148 case "$arch" in 149 CYGWIN) AUTOBUILD=$(cygpath -u $AUTOBUILD.cmd) ;; 150 esac 151 else 152 record_failure "Not executable: $AUTOBUILD" 153 exit 1 154 fi 155 else 156 record_failure "Not found: $autobuild_dir" 157 exit 1 158 fi 159fi 160 161# load autbuild provided shell functions and variables 162# Merov: going back to the previous code that passes even if it fails catching a failure 163# TODO: use the correct code here under and fix the llbase import in python code 164#if "$AUTOBUILD" source_environment > source_environment 165#then 166# . source_environment 167#else 168 # dump environment variables for debugging 169# env|sort 170# record_failure "autobuild source_environment failed" 171# cat source_environment >&3 172# exit 1 173#fi 174eval "$("$AUTOBUILD" source_environment)" 175 176# dump environment variables for debugging 177env|sort 178 179 180# Install packages. 181"$AUTOBUILD" install --skip-license-check 182 183# Now run the build 184succeeded=true 185build_processes= 186last_built_variant= 187for variant in $variants 188do 189 eval '$build_'"$variant" || continue 190 eval '$build_'"$arch"_"$variant" || continue 191 192 # Only the last built arch is available for upload 193 last_built_variant="$variant" 194 195 begin_section "Do$variant" 196 build_dir=`build_dir_$arch $variant` 197 build_dir_stubs="$build_dir/win_setup/$variant" 198 rm -rf "$build_dir" 199 mkdir -p "$build_dir" 200 mkdir -p "$build_dir/tmp" 201 #export TMP="$build_dir/tmp" 202 if pre_build "$variant" "$build_dir" >> "$build_log" 2>&1 203 then 204 if $build_link_parallel 205 then 206 begin_section BuildParallel 207 ( build "$variant" "$build_dir" > "$build_dir/build.log" 2>&1 ) & 208 build_processes="$build_processes $!" 209 end_section BuildParallel 210 else 211 begin_section "Build$variant" 212 build "$variant" "$build_dir" 2>&1 | tee -a "$build_log" | sed -n 's/^ *\(##teamcity.*\)/\1/p' 213 if `cat "$build_dir/build_ok"` 214 then 215 echo so far so good. 216 else 217 record_failure "Build of \"$variant\" failed." 218 fi 219 end_section "Build$variant" 220 fi 221 else 222 record_failure "Build Prep for \"$variant\" failed." 223 fi 224 end_section "Do$variant" 225done 226 227# If we are building variants in parallel, wait, then collect results. 228# This requires that the build dirs are variant specific 229if $build_link_parallel && [ x"$build_processes" != x ] 230then 231 begin_section WaitParallel 232 wait $build_processes 233 for variant in $variants 234 do 235 eval '$build_'"$variant" || continue 236 eval '$build_'"$arch"_"$variant" || continue 237 238 begin_section "Build$variant" 239 build_dir=`build_dir_$arch $variant` 240 build_dir_stubs="$build_dir/win_setup/$variant" 241 tee -a $build_log < "$build_dir/build.log" | sed -n 's/^ *\(##teamcity.*\)/\1/p' 242 if `cat "$build_dir/build_ok"` 243 then 244 echo so far so good. 245 else 246 record_failure "Parallel build of \"$variant\" failed." 247 fi 248 end_section "Build$variant" 249 done 250 end_section WaitParallel 251fi 252 253# check status and upload results to S3 254if $succeeded 255then 256 if $build_viewer 257 then 258 begin_section Upload 259 # Upload installer - note that ONLY THE FIRST ITEM uploaded as "installer" 260 # will appear in the version manager. 261 package=$(installer_$arch) 262 if [ x"$package" = x ] || test -d "$package" 263 then 264 # Coverity doesn't package, so it's ok, anything else is fail 265 succeeded=$build_coverity 266 else 267 upload_item installer "$package" binary/octet-stream 268 upload_item quicklink "$package" binary/octet-stream 269 [ -f summary.json ] && upload_item installer summary.json text/plain 270 271 # Upload crash reporter files. 272 case "$last_built_variant" in 273 Release) 274 for symbolfile in $symbolfiles 275 do 276 upload_item symbolfile "$build_dir/$symbolfile" binary/octet-stream 277 done 278 ;; 279 esac 280 281 # Upload stub installers 282 upload_stub_installers "$build_dir_stubs" 283 fi 284 end_section Upload 285 else 286 echo skipping viewer 287 fi 288else 289 echo skipping upload of build results due to failed build. 290fi 291 292# The branch independent build.sh script invoking this script will finish processing 293$succeeded || exit 1