/build.sh

https://bitbucket.org/lindenlab/viewer-beta/ · Shell · 293 lines · 212 code · 30 blank · 51 comment · 35 complexity · 728ccba70fe4b3162496fc2c7dbcf363 MD5 · raw file

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