PageRenderTime 64ms CodeModel.GetById 35ms RepoModel.GetById 0ms app.codeStats 0ms

/build.sh

https://github.com/HyangZhao/NaCl-main
Shell | 304 lines | 238 code | 23 blank | 43 comment | 30 complexity | 9318e39b5be9b8fbd1b2ebb638dc96a0 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 viewer-linux-i686-$(echo $1 | tr A-Z a-z)
  23. }
  24. build_dir_CYGWIN()
  25. {
  26. echo build-vc80
  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. d=$(build_dir_CYGWIN ${last_built_variant:-Release})
  39. p=$(sed 's:.*=::' "$d/newview/${last_built_variant:-Release}/touched.bat")
  40. echo "$d/newview/${last_built_variant:-Release}/$p"
  41. }
  42. pre_build()
  43. {
  44. local variant="$1"
  45. local build_dir="$2"
  46. begin_section "Pre$variant"
  47. #export PATH="/cygdrive/c/Program Files/Microsoft Visual Studio 8/Common7/IDE/:$PATH"
  48. python develop.py \
  49. --incredibuild \
  50. --unattended \
  51. -t $variant \
  52. -G "$cmake_generator" \
  53. configure \
  54. -DVIEWER_CHANNEL:STRING="$viewer_channel" \
  55. -DVIEWER_LOGIN_CHANNEL:STRING="$login_channel" \
  56. -DINSTALL_PROPRIETARY:BOOL=ON \
  57. -DLOCALIZESETUP:BOOL=ON \
  58. -DPACKAGE:BOOL=ON
  59. end_section "Pre$variant"
  60. }
  61. build()
  62. {
  63. local variant="$1"
  64. local build_dir="$2"
  65. if $build_viewer
  66. then
  67. begin_section "Viewer$variant"
  68. if python develop.py \
  69. --incredibuild \
  70. --unattended \
  71. -t $variant \
  72. -G "$cmake_generator" \
  73. build package
  74. # && \
  75. # python develop.py \
  76. # --incredibuild \
  77. # --unattended \
  78. # -t $variant \
  79. # -G "$cmake_generator" \
  80. # build package
  81. then
  82. echo true >"$build_dir"/build_ok
  83. else
  84. echo false >"$build_dir"/build_ok
  85. fi
  86. end_section "Viewer$variant"
  87. fi
  88. }
  89. # This is called from the branch independent script upon completion of all platform builds.
  90. build_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. # Check to see if we were invoked from the wrapper, if not, re-exec ourselves from there
  99. if [ "x$arch" = x ]
  100. then
  101. top=`hg root`
  102. if [ -x "$top/../buildscripts/hg/bin/build.sh" ]
  103. then
  104. exec "$top/../buildscripts/hg/bin/build.sh" "$top"
  105. else
  106. cat <<EOF
  107. This script, if called in a development environment, requires that the branch
  108. independent build script repository be checked out next to this repository.
  109. This repository is located at http://hg.lindenlab.com/parabuild/buildscripts
  110. EOF
  111. exit 1
  112. fi
  113. fi
  114. # Check to see if we're skipping the platform
  115. eval '$build_'"$arch" || pass
  116. # Run the version number update script
  117. # File no longer exists in code-sep branch, so let's make sure it exists in order to use it.
  118. if test -f scripts/update_version_files.py ; then
  119. begin_section UpdateVer
  120. scripts/update_version_files.py \
  121. --channel="$viewer_channel" \
  122. --server_channel="$server_channel" \
  123. --revision=$revision \
  124. --verbose \
  125. || fail update_version_files.py
  126. end_section UpdateVer
  127. fi
  128. # Now retrieve the version for use in the version manager
  129. # First three parts only, $revision will be appended automatically.
  130. build_viewer_update_version_manager_version=`scripts/get_version.py --viewer-version | sed 's/\.[0-9]*$//'`
  131. # Now run the build
  132. cd indra
  133. succeeded=true
  134. build_processes=
  135. last_built_variant=
  136. for variant in $variants
  137. do
  138. eval '$build_'"$variant" || continue
  139. eval '$build_'"$arch"_"$variant" || continue
  140. # Only the last built arch is available for upload
  141. last_built_variant="$variant"
  142. begin_section "Do$variant"
  143. build_dir=`build_dir_$arch $variant`
  144. build_dir_stubs="$build_dir/win_setup/$variant"
  145. rm -rf "$build_dir"
  146. mkdir -p "$build_dir"
  147. if pre_build "$variant" "$build_dir" >> "$build_log" 2>&1
  148. then
  149. if $build_link_parallel
  150. then
  151. begin_section BuildParallel
  152. ( build "$variant" "$build_dir" > "$build_dir/build.log" 2>&1 ) &
  153. build_processes="$build_processes $!"
  154. end_section BuildParallel
  155. elif $build_coverity
  156. then
  157. mkdir -p "$build_dir/cvbuild"
  158. coverity_config=`cygpath --windows "$coverity_dir/config/coverity_config.xml"`
  159. coverity_tmpdir=`cygpath --windows "$build_dir/cvbuild"`
  160. coverity_root=`cygpath --windows "$top/latest"`
  161. case "$variant" in
  162. Release)
  163. begin_section Coverity
  164. begin_section CovBuild
  165. "$coverity_dir"/bin/cov-build\
  166. --verbose 4 \
  167. --config "$coverity_config"\
  168. --dir "$coverity_tmpdir"\
  169. python develop.py -t $variant -G "$cmake_generator" build "$coverity_product"\
  170. >> "$build_log" 2>&1\
  171. &&\
  172. end_section CovBuild\
  173. &&\
  174. begin_section CovAnalyze\
  175. &&\
  176. "$coverity_dir"/bin/cov-analyze\
  177. --cxx\
  178. --security\
  179. --concurrency\
  180. --dir "$coverity_tmpdir"\
  181. >> "$build_log" 2>&1\
  182. &&\
  183. end_section CovAnalyze\
  184. &&\
  185. begin_section CovCommit\
  186. &&\
  187. "$coverity_dir"/bin/cov-commit-defects\
  188. --product "$coverity_product"\
  189. --dir "$coverity_tmpdir"\
  190. --remote "$coverity_server"\
  191. --strip-path "$coverity_root"\
  192. --target "$branch/$arch"\
  193. --version "$revision"\
  194. --description "$repo: $variant $revision"\
  195. --user admin --password admin\
  196. >> "$build_log" 2>&1\
  197. || record_failure "Coverity Build Failed"
  198. # since any step could have failed, rely on the enclosing block to close any pending sub-blocks
  199. end_section Coverity
  200. ;;
  201. esac
  202. if test -r "$build_dir"/cvbuild/build-log.txt
  203. then
  204. upload_item log "$build_dir"/cvbuild/build-log.txt text/plain
  205. fi
  206. else
  207. begin_section "Build$variant"
  208. build "$variant" "$build_dir" >> "$build_log" 2>&1
  209. if `cat "$build_dir/build_ok"`
  210. then
  211. echo so far so good.
  212. else
  213. record_failure "Build of \"$variant\" failed."
  214. fi
  215. end_section "Build$variant"
  216. fi
  217. else
  218. record_failure "Build Prep for \"$variant\" failed."
  219. fi
  220. end_section "Do$variant"
  221. done
  222. # If we are building variants in parallel, wait, then collect results.
  223. # This requires that the build dirs are variant specific
  224. if $build_link_parallel && [ x"$build_processes" != x ]
  225. then
  226. begin_section WaitParallel
  227. wait $build_processes
  228. for variant in $variants
  229. do
  230. eval '$build_'"$variant" || continue
  231. eval '$build_'"$arch"_"$variant" || continue
  232. begin_section "Build$variant"
  233. build_dir=`build_dir_$arch $variant`
  234. build_dir_stubs="$build_dir/win_setup/$variant"
  235. cat "$build_dir/build.log" >> "$build_log"
  236. if `cat "$build_dir/build_ok"`
  237. then
  238. echo so far so good.
  239. else
  240. record_failure "Parallel build of \"$variant\" failed."
  241. fi
  242. end_section "Build$variant"
  243. done
  244. end_section WaitParallel
  245. fi
  246. # check status and upload results to S3
  247. if $succeeded
  248. then
  249. if $build_viewer
  250. then
  251. begin_section Upload
  252. # Upload installer - note that ONLY THE FIRST ITEM uploaded as "installer"
  253. # will appear in the version manager.
  254. package=$(installer_$arch)
  255. if [ x"$package" = x ] || test -d "$package"
  256. then
  257. # Coverity doesn't package, so it's ok, anything else is fail
  258. succeeded=$build_coverity
  259. else
  260. upload_item installer "$package" binary/octet-stream
  261. # Upload crash reporter files.
  262. case "$last_built_variant" in
  263. Release)
  264. for symbolfile in $symbolfiles
  265. do
  266. upload_item symbolfile "$build_dir/$symbolfile" binary/octet-stream
  267. done
  268. ;;
  269. esac
  270. # Upload stub installers
  271. upload_stub_installers "$build_dir_stubs"
  272. fi
  273. end_section Upload
  274. else
  275. echo skipping viewer
  276. fi
  277. else
  278. echo skipping upload of build results due to failed build.
  279. fi
  280. # The branch independent build.sh script invoking this script will finish processing
  281. $succeeded || exit 1