android-sync.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. # Copyright 2012 the V8 project authors. All rights reserved.
  3. # Redistribution and use in source and binary forms, with or without
  4. # modification, are permitted provided that the following conditions are
  5. # met:
  6. #
  7. # * Redistributions of source code must retain the above copyright
  8. # notice, this list of conditions and the following disclaimer.
  9. # * Redistributions in binary form must reproduce the above
  10. # copyright notice, this list of conditions and the following
  11. # disclaimer in the documentation and/or other materials provided
  12. # with the distribution.
  13. # * Neither the name of Google Inc. nor the names of its
  14. # contributors may be used to endorse or promote products derived
  15. # from this software without specific prior written permission.
  16. #
  17. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  20. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  21. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. # This script pushes android binaries and test data to the device.
  29. # The first argument can be either "android.release" or "android.debug".
  30. # The second argument is a relative path to the output directory with binaries.
  31. # The third argument is the absolute path to the V8 directory on the host.
  32. # The fourth argument is the absolute path to the V8 directory on the device.
  33. if [ ${#@} -lt 4 ] ; then
  34. echo "$0: Error: need 4 arguments"
  35. exit 1
  36. fi
  37. ARCH_MODE=$1
  38. OUTDIR=$2
  39. HOST_V8=$3
  40. ANDROID_V8=$4
  41. function LINUX_MD5 {
  42. local HASH=$(md5sum $1)
  43. echo ${HASH%% *}
  44. }
  45. function DARWIN_MD5 {
  46. local HASH=$(md5 $1)
  47. echo ${HASH} | cut -f2 -d "=" | cut -f2 -d " "
  48. }
  49. host_os=$(uname -s)
  50. case "${host_os}" in
  51. "Linux")
  52. MD5=LINUX_MD5
  53. ;;
  54. "Darwin")
  55. MD5=DARWIN_MD5
  56. ;;
  57. *)
  58. echo "$0: Host platform ${host_os} is not supported" >& 2
  59. exit 1
  60. esac
  61. function sync_file {
  62. local FILE=$1
  63. local ANDROID_HASH=$(adb shell "md5 \"$ANDROID_V8/$FILE\"")
  64. local HOST_HASH=$($MD5 "$HOST_V8/$FILE")
  65. if [ "${ANDROID_HASH%% *}" != "${HOST_HASH}" ]; then
  66. adb push "$HOST_V8/$FILE" "$ANDROID_V8/$FILE" &> /dev/null
  67. fi
  68. echo -n "."
  69. }
  70. function sync_dir {
  71. local DIR=$1
  72. echo -n "sync to $ANDROID_V8/$DIR"
  73. for FILE in $(find "$HOST_V8/$DIR" -not -path "*.svn*" -type f); do
  74. local RELATIVE_FILE=${FILE:${#HOST_V8}}
  75. sync_file "$RELATIVE_FILE"
  76. done
  77. echo ""
  78. }
  79. echo -n "sync to $ANDROID_V8/$OUTDIR/$ARCH_MODE"
  80. sync_file "$OUTDIR/$ARCH_MODE/cctest"
  81. sync_file "$OUTDIR/$ARCH_MODE/d8"
  82. sync_file "$OUTDIR/$ARCH_MODE/snapshot_blob.bin"
  83. sync_file "$OUTDIR/$ARCH_MODE/unittests"
  84. echo ""
  85. echo -n "sync to $ANDROID_V8/tools"
  86. sync_file tools/arguments.mjs
  87. sync_file tools/codemap.mjs
  88. sync_file tools/consarray.mjs
  89. sync_file tools/csvparser.mjs
  90. sync_file tools/dumpcpp.mjs
  91. sync_file tools/logreader.mjs
  92. sync_file tools/profile.mjs
  93. sync_file tools/profile_view.mjs
  94. sync_file tools/splaytree.mjs
  95. sync_file tools/tickprocessor.mjs
  96. echo ""
  97. sync_dir test/intl
  98. sync_dir test/message
  99. sync_dir test/mjsunit