opensrc-build.sh
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:13k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. #!/bin/sh
  2. # This is the build script used by Linden Lab's autmated build system.
  3. #
  4. set -x
  5. export INSTALL_USE_HTTP_FOR_SCP=true
  6. export PATH=/bin:/usr/bin:$PATH
  7. arch=`uname | cut -b-6`
  8. here=`echo $0 | sed 's:[^/]*$:.:'`
  9. year=`date +%Y`
  10. branch=`svn info | grep '^URL:' | sed 's:.*/::'`
  11. revision=`svn info | grep '^Revision:' | sed 's/.*: //'`
  12. top=`cd "$here/../../.." && pwd`
  13. [ x"$WGET_CACHE" = x ] && export WGET_CACHE=/var/tmp/parabuild/wget
  14. [ x"$S3GET_URL" = x ]  && export S3GET_URL=http://viewer-source-downloads.s3.amazonaws.com/$year
  15. [ x"$S3PUT_URL" = x ]  && export S3PUT_URL=https://s3.amazonaws.com/viewer-source-downloads/$year
  16. [ x"$S3SYMBOL_URL" = x ]  && export S3SYMBOL_URL=https://s3.amazonaws.com/automated-builds-secondlife-com/binaries
  17. [ x"$PUBLIC_URL" = x ] && export PUBLIC_URL=http://secondlife.com/developers/opensource/downloads/$year
  18. [ x"$PUBLIC_EMAIL" = x ] && export PUBLIC_EMAIL=sldev-commits@lists.secondlife.com
  19. # Make sure command worked and bail out if not, reporting failure to parabuild
  20. fail()
  21. {
  22.   release_lock
  23.   echo "BUILD FAILED" $@
  24.   exit 1
  25. }
  26.   
  27. pass() 
  28.   release_lock
  29.   echo "BUILD SUCCESSFUL"
  30.   exit 0
  31. }
  32. # Locking to avoid contention with u-s-c
  33. LOCK_CREATE=/usr/bin/lockfile-create
  34. LOCK_TOUCH=/usr/bin/lockfile-touch
  35. LOCK_REMOVE=/usr/bin/lockfile-remove
  36. LOCK_PROCESS=
  37. locking_available()
  38. {
  39.   test -x "$LOCK_CREATE"
  40.     -a -x "$LOCK_TOUCH"
  41.     -a -x "$LOCK_REMOVE"
  42. }
  43. acquire_lock()
  44. {
  45.   if locking_available 
  46.   then
  47.     if "$LOCK_CREATE" /var/lock/update-system-config --retry 99
  48.     then
  49.       "$LOCK_TOUCH" /var/lock/update-system-config &
  50.       LOCK_PROCESS="$!"
  51.     else
  52.       fail acquire lock
  53.     fi
  54.   else
  55.     true
  56.   fi
  57. }
  58. release_lock()
  59. {
  60.   if locking_available
  61.   then
  62.     if test x"$LOCK_PROCESS" != x
  63.     then
  64.       kill "$LOCK_PROCESS"
  65.       "$LOCK_REMOVE" /var/lock/update-system-config
  66.     else
  67.       echo No Lock Acquired >&2
  68.     fi
  69.   else
  70.     true
  71.   fi
  72. }
  73. get_asset()
  74. {
  75.   mkdir -p "$WGET_CACHE" || fail creating WGET_CACHE
  76.   local tarball=`basename "$1"`
  77.   test -r "$WGET_CACHE/$tarball" || ( cd "$WGET_CACHE" && curl --location --remote-name "$1" || fail getting $1 )
  78.   case "$tarball" in
  79.   *.zip) unzip -qq -d "$top" -o "$WGET_CACHE/$tarball" || fail unzip $tarball ;;
  80.   *.tar.gz|*.tgz) tar -C "$top" -xzf  "$WGET_CACHE/$tarball" || fail untar $tarball ;;
  81.   *) fail unrecognized filetype: $tarball ;;
  82.   esac
  83. }
  84. s3_available()
  85. {
  86.   test -x "$helpers/s3get.sh" -a -x "$helpers/s3put.sh" -a -r "$helpers/s3curl.pl"
  87. }
  88. build_dir_Darwin()
  89. {
  90.   echo build-darwin-universal
  91. }
  92. build_dir_Linux()
  93. {
  94.   echo viewer-linux-i686-`echo $1 | tr A-Z a-z`
  95. }
  96. build_dir_CYGWIN()
  97. {
  98.   echo build-vc80
  99. }
  100. installer_Darwin()
  101. {
  102.   ls -1td "`build_dir_Darwin Release`/newview/"*.dmg 2>/dev/null | sed 1q
  103. }
  104. installer_Linux()
  105. {
  106.   ls -1td "`build_dir_Linux Release`/newview/"*.tar.bz2 2>/dev/null | sed 1q
  107. }
  108. installer_CYGWIN()
  109. {
  110.   d=`build_dir_CYGWIN Release`
  111.   p=`sed 's:.*=::' "$d/newview/Release/touched.bat"`
  112.   echo "$d/newview/Release/$p"
  113. }
  114. # deal with aborts etc..
  115. trap fail 1 2 3 14 15
  116. # Check location
  117. cd "$here/../.."
  118. test -x ../linden/scripts/automated_build_scripts/opensrc-build.sh
  119.  || fail 'The parent dir of your checkout needs to be named "linden"' 
  120. . doc/asset_urls.txt
  121. get_asset "$SLASSET_ART"
  122. update_version_files=
  123. # Set up platform specific stuff
  124. case "$arch" in
  125. # Note that we can only build the "Release" variant for Darwin, because of a compiler bug:
  126. # ld: bl out of range (-16777272 max is +/-16M)
  127. #  from __static_initialization_and_destruction_0(int, int)at 0x033D319C
  128. #  in __StaticInit of
  129. #  indra/build-darwin-universal/newview/SecondLife.build/Debug/Second Life.build/Objects-normal/ppc/llvoicevisualizer.o
  130. #  to ___cxa_atexit$island_2 at 0x023D50F8
  131. #  in __text of
  132. #  indra/build-darwin-universal/newview/SecondLife.build/Debug/Second Life.build/Objects-normal/ppc/Second Life
  133. #  in __static_initialization_and_destruction_0(int, int)
  134. #  from indra/build-darwin-universal/newview/SecondLife.build/Debug/Second Life.build/Objects-normal/ppc/llvoicevisualizer.o
  135. Darwin)
  136.   helpers=/usr/local/buildscripts/shared/latest
  137.   variants="Release"
  138.   cmake_generator="Xcode"
  139.   fmod=fmodapi375mac
  140.   fmod_tar="$fmod.zip"
  141.   fmod_so=libfmod.a
  142.   fmod_lib=lib
  143.   target_dirs="libraries/universal-darwin/lib_debug
  144.                libraries/universal-darwin/lib_release
  145.                libraries/universal-darwin/lib_release_client"
  146.   other_archs="$S3GET_URL/$branch/$revision/CYGWIN $S3GET_URL/$branch/$revision/Linux"
  147.   symbolfiles=
  148.   mail="$helpers"/mail.py
  149.   all_done="$helpers"/all_done.py
  150.   test -r "$helpers/update_version_files.py" && update_version_files="$helpers/update_version_files.py"
  151.   libs_asset="$SLASSET_LIBS_DARWIN"
  152.   ;;
  153. CYGWIN)
  154.   helpers=/cygdrive/c/buildscripts/shared/latest
  155.   variants="Debug RelWithDebInfo Release"
  156.   #variants="Release"
  157.   cmake_generator="vc80"
  158.   fmod=fmodapi375win
  159.   fmod_tar=fmodapi375win.zip
  160.   fmod_so=fmodvc.lib
  161.   fmod_lib=lib
  162.   target_dirs="libraries/i686-win32/lib/debug
  163.                libraries/i686-win32/lib/release"
  164.   other_archs="$S3GET_URL/$branch/$revision/Darwin $S3GET_URL/$branch/$revision/Linux"
  165.   symbolfiles="newview/Release/secondlife-bin.pdb newview/Release/secondlife-bin.map newview/Release/secondlife-bin.exe"
  166.   export PATH="/cygdrive/c/Python25:/cygdrive/c/Program Files/Cmake 2.6/bin":$PATH
  167.   export PERL="/cygdrive/c/Perl/bin/perl.exe"
  168.   export S3CURL="C:\buildscripts\shared\latest\hg\bin\s3curl.py"
  169.   export SIGN_PY="C:\buildscripts\shared\latest\code-signing\sign.py"
  170.   export CURL="C:\cygwin\bin\curl.exe"
  171.   mail="C:\buildscripts\shared\latest\mail.py"
  172.   all_done="C:\buildscripts\shared\latest\all_done.py"
  173.   test -r "$helpers/update_version_files.py" && update_version_files="C:\buildscripts\shared\latest\update_version_files.py"
  174.   libs_asset="$SLASSET_LIBS_WIN32"
  175.   ;;
  176. Linux)
  177.   helpers=/var/opt/parabuild/buildscripts/shared/latest
  178.   if [ x"$CXX" = x ]
  179.   then
  180.     if test -x /usr/bin/g++-4.1
  181. then
  182.   if test -x /usr/bin/distcc
  183.   then
  184.     export CXX="/usr/bin/distcc /usr/bin/g++-4.1"
  185.   else
  186.     export CXX=/usr/bin/g++-4.1
  187.   fi
  188. fi
  189.   fi
  190.   acquire_lock
  191.   variants="Debug RelWithDebInfo Release"
  192.   #variants="Release"
  193.   cmake_generator="Unix Makefiles"
  194.   fmod=fmodapi375linux
  195.   fmod_tar="$fmod".tar.gz
  196.   fmod_so=libfmod-3.75.so
  197.   fmod_lib=.
  198.   target_dirs="libraries/i686-linux/lib_debug
  199.                libraries/i686-linux/lib_release
  200.                libraries/i686-linux/lib_release_client"
  201.   other_archs="$S3GET_URL/$branch/$revision/Darwin $S3GET_URL/$branch/$revision/CYGWIN"
  202.   symbolfiles=
  203.   mail="$helpers"/mail.py
  204.   all_done="$helpers"/all_done.py
  205.   test -r "$helpers/update_version_files.py" && update_version_files="$helpers/update_version_files.py"
  206.   # Change the DISTCC_DIR to be somewhere that the parabuild process can write to
  207.   if test -r /etc/debian_version
  208.   then
  209.     [ x"$DISTCC_DIR" = x ] && export DISTCC_DIR=/var/tmp/parabuild
  210.     case `cat /etc/debian_version` in
  211.     3.*) [ x"$DISTCC_HOSTS" = x ]
  212.          && export DISTCC_HOSTS="build-linux-1/3
  213.                                   station30/2,lzo" ;;
  214.     4.*) [ x"$DISTCC_HOSTS" = x ]
  215.          && export DISTCC_HOSTS="build-linux-6/2,lzo
  216.                                  build-linux-2/2,lzo
  217.                                  build-linux-3/2,lzo
  218.                                  build-linux-4/2,lzo
  219.                                  build-linux-5/2,lzo
  220.                                  build-linux-7/2,lzo
  221.                                  build-linux-8/2,lzo
  222.                                  build-linux-9/2,lzo" ;;
  223.     esac
  224.   fi
  225.   libs_asset="$SLASSET_LIBS_LINUXI386"
  226.   ;;
  227. *) fail undefined $arch ;;
  228. esac
  229. get_asset "http://www.fmod.org/index.php/release/version/$fmod_tar"
  230. case "$arch" in
  231. Darwin)
  232.   # Create fat binary on Mac...
  233.   if lipo -create -output "../$fmod"/api/$fmod_lib/libfmod-universal.a
  234.      "../$fmod"/api/$fmod_lib/libfmod.a
  235.      "../$fmod"/api/$fmod_lib/libfmodx86.a
  236.   then
  237.     mv "../$fmod"/api/$fmod_lib/libfmod.a "../$fmod"/api/$fmod_lib/libfmodppc.a
  238.     mv "../$fmod"/api/$fmod_lib/libfmod-universal.a "../$fmod"/api/$fmod_lib/libfmod.a
  239.     echo Created fat binary
  240.   else
  241.     fail running lipo
  242.   fi
  243.   ;;
  244. CYGWIN)
  245.   # install Quicktime.  This will fail outside of Linden's network
  246.   scripts/install.py quicktime
  247.   ;;
  248. esac
  249. # Only run this if the script exists
  250. if test x"$update_version_files" = x 
  251. then
  252.   echo "Private Build..." > indra/build.log
  253.   [ x"$VIEWER_CHANNEL" = x ] && export VIEWER_CHANNEL="CommunityDeveloper"
  254. else
  255.   # By right, this should be in the branched source tree, but for now it will be a helper
  256.   python "$update_version_files" --verbose --src-root=. --viewer > indra/build.log
  257.   [ x"$VIEWER_CHANNEL" = x ] && export VIEWER_CHANNEL="Snowglobe Test Build"
  258. fi
  259. # First, go into the directory where the code was checked out by Parabuild
  260. cd indra
  261. # This is the way it works now, but it will soon work on a variant dependent way
  262. for target_dir in $target_dirs
  263. do
  264.   mkdir -p "../$target_dir"
  265.   cp -f "../../$fmod/api/$fmod_lib/$fmod_so"  "../$target_dir"
  266. done
  267. mkdir -p "../libraries/include"
  268. cp -f "../../$fmod/api/inc/"*  "../libraries/include"
  269. # Special Windows case
  270. test -r "../../$fmod/api/fmod.dll" && cp -f "../../$fmod/api/fmod.dll" newview
  271. # Now run the build command over all variants
  272. succeeded=true
  273. ### TEST CODE - remove when done
  274. ### variants=
  275. ### echo "Artificial build failure to test notifications" > build.log
  276. ### succeeded=false
  277. ### END TEST CODE
  278. for variant in $variants
  279. do
  280.   build_dir=`build_dir_$arch $variant`
  281.   rm -rf "$build_dir"
  282.   get_asset "$libs_asset" # Thus plunks stuff into the build dir, so have to restore it now.
  283.   # This is the way it will work in future
  284.   #for target_dir in $target_dirs
  285.   #do
  286.   #  mkdir -p "$build_dir/$target_dir"
  287.   #  cp "../../$fmod/api/$fmod_lib/$fmod_so"  "$build_dir/$target_dir"
  288.   #done
  289.   #mkdir -p "$build_dir/libraries/include"
  290.   #cp "../../$fmod/api/inc/"*  "$build_dir/libraries/include"
  291.   echo "==== $variant ====" >> build.log
  292.   if ./develop.py 
  293.     --unattended 
  294.     --incredibuild 
  295.     -t $variant 
  296.     -G "$cmake_generator" 
  297.    configure 
  298.     -DVIEWER_CHANNEL:STRING="$VIEWER_CHANNEL"
  299.     -DVIEWER_LOGIN_CHANNEL:STRING="$VIEWER_CHANNEL"
  300.     -DPACKAGE:BOOL=ON >>build.log 2>&1
  301.   then
  302.     if ./develop.py
  303.          --unattended
  304.          --incredibuild 
  305.          -t $variant
  306.          -G "$cmake_generator" 
  307.        build prepare >>build.log 2>&1
  308.     then
  309.       if ./develop.py
  310.            --unattended
  311.            --incredibuild 
  312.            -t $variant
  313.            -G "$cmake_generator" 
  314.          build package >>build.log 2>&1
  315.   then
  316.         # run tests if needed
  317.         true
  318.   else
  319.     succeeded=false
  320.   fi
  321.     else
  322.       succeeded=false
  323.     fi
  324.   else
  325.     succeeded=false
  326.   fi
  327. done
  328. # check statuis and upload results to S3
  329. subject=
  330. if $succeeded
  331. then
  332.   package=`installer_$arch`
  333.   test -r "$package" || fail not found: $package
  334.   package_file=`echo $package | sed 's:.*/::'`
  335.   if s3_available
  336.   then
  337.     echo "$PUBLIC_URL/$branch/$revision/$package_file" > "$arch"
  338.     echo "$PUBLIC_URL/$branch/$revision/good-build.$arch" >> "$arch"
  339.     "$helpers/s3put.sh" "$package" "$S3PUT_URL/$branch/$revision/$package_file"    binary/octet-stream
  340.        || fail Uploading "$package"
  341.     "$helpers/s3put.sh" build.log  "$S3PUT_URL/$branch/$revision/good-build.$arch" text/plain
  342.        || fail Uploading build.log
  343.     "$helpers/s3put.sh" "$arch"    "$S3PUT_URL/$branch/$revision/$arch"            text/plain
  344.        || fail Uploading token file
  345.     for symbolfile in $symbolfiles
  346.     do
  347.       targetfile="`echo $symbolfile | sed 's:.*/::'`"
  348.       "$helpers/s3put.sh" "$build_dir/$symbolfile" "$S3SYMBOL_URL/$revision/$targetfile" binary/octet-stream
  349.         || fail Uploading "$symbolfile"
  350.     done
  351.     if python "$all_done"
  352.           curl
  353.          "$S3GET_URL/$branch/$revision/$arch"
  354.           $other_archs > message
  355.     then
  356.       subject="Successful Build for $branch ($revision)"
  357.     fi
  358.   else
  359.     true s3 is not available
  360.   fi
  361. else
  362.   if s3_available
  363.   then
  364.     "$helpers/s3put.sh" build.log "$S3PUT_URL/$branch/$revision/failed-build.$arch" text/plain
  365.        || fail Uploading build.log
  366.     subject="Failed Build for $branch ($revision) on $arch"
  367.     cat >message <<EOF
  368. Build for $branch ($revision) failed for $arch.
  369. Please see the build log for details:
  370. $PUBLIC_URL/$branch/$revision/failed-build.$arch
  371. EOF
  372.   else
  373.     true s3 is not available
  374.   fi
  375. fi
  376. # We have something to say...
  377. if [ x"$subject" != x ]
  378. then
  379.   # Extract change list since last build
  380.   if [ x"$PARABUILD_CHANGE_LIST_NUMBER" = x ]
  381.   then
  382.     echo "No change information available" >> message
  383.   elif [ x"$PARABUILD_PREVIOUS_CHANGE_LIST_NUMBER" = x ]
  384.   then
  385.     ( cd .. && svn log --verbose --stop-on-copy --limit 50 ) >>message
  386.   else
  387.     if [ "$PARABUILD_PREVIOUS_CHANGE_LIST_NUMBER" -lt "$PARABUILD_CHANGE_LIST_NUMBER" ]
  388. then
  389.   range=`expr 1 + "$PARABUILD_PREVIOUS_CHANGE_LIST_NUMBER"`:"$PARABUILD_CHANGE_LIST_NUMBER"
  390. else
  391.   range="$PARABUILD_CHANGE_LIST_NUMBER"
  392. fi
  393.     ( cd .. && svn log --verbose -r"$range" ) >>message
  394.   fi
  395.   # $PUBLIC_EMAIL can be a list, so no quotes
  396.   python "$mail" "$subject" $PUBLIC_EMAIL <message
  397. fi
  398. if $succeeded
  399. then
  400.   pass
  401. else
  402.   fail
  403. fi