msvs_common.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/bin/bash
  2. ##
  3. ## Copyright (c) 2014 The WebM project authors. All Rights Reserved.
  4. ##
  5. ## Use of this source code is governed by a BSD-style license
  6. ## that can be found in the LICENSE file in the root of the source
  7. ## tree. An additional intellectual property rights grant can be found
  8. ## in the file PATENTS. All contributing project authors may
  9. ## be found in the AUTHORS file in the root of the source tree.
  10. ##
  11. if [ "$(uname -o 2>/dev/null)" = "Cygwin" ] \
  12. && cygpath --help >/dev/null 2>&1; then
  13. FIXPATH='cygpath -m'
  14. else
  15. FIXPATH='echo_path'
  16. fi
  17. die() {
  18. echo "${self_basename}: $@" >&2
  19. exit 1
  20. }
  21. die_unknown(){
  22. echo "Unknown option \"$1\"." >&2
  23. echo "See ${self_basename} --help for available options." >&2
  24. exit 1
  25. }
  26. echo_path() {
  27. for path; do
  28. echo "$path"
  29. done
  30. }
  31. # Output one, possibly changed based on the system, path per line.
  32. fix_path() {
  33. $FIXPATH "$@"
  34. }
  35. # Corrects the paths in file_list in one pass for efficiency.
  36. # $1 is the name of the array to be modified.
  37. fix_file_list() {
  38. declare -n array_ref=$1
  39. files=$(fix_path "${array_ref[@]}")
  40. local IFS=$'\n'
  41. array_ref=($files)
  42. }
  43. generate_uuid() {
  44. local hex="0123456789ABCDEF"
  45. local i
  46. local uuid=""
  47. local j
  48. #93995380-89BD-4b04-88EB-625FBE52EBFB
  49. for ((i=0; i<32; i++)); do
  50. (( j = $RANDOM % 16 ))
  51. uuid="${uuid}${hex:$j:1}"
  52. done
  53. echo "${uuid:0:8}-${uuid:8:4}-${uuid:12:4}-${uuid:16:4}-${uuid:20:12}"
  54. }
  55. indent1=" "
  56. indent=""
  57. indent_push() {
  58. indent="${indent}${indent1}"
  59. }
  60. indent_pop() {
  61. indent="${indent%${indent1}}"
  62. }
  63. tag_attributes() {
  64. for opt in "$@"; do
  65. optval="${opt#*=}"
  66. [ -n "${optval}" ] ||
  67. die "Missing attribute value in '$opt' while generating $tag tag"
  68. echo "${indent}${opt%%=*}=\"${optval}\""
  69. done
  70. }
  71. open_tag() {
  72. local tag=$1
  73. shift
  74. if [ $# -ne 0 ]; then
  75. echo "${indent}<${tag}"
  76. indent_push
  77. tag_attributes "$@"
  78. echo "${indent}>"
  79. else
  80. echo "${indent}<${tag}>"
  81. indent_push
  82. fi
  83. }
  84. close_tag() {
  85. local tag=$1
  86. indent_pop
  87. echo "${indent}</${tag}>"
  88. }
  89. tag() {
  90. local tag=$1
  91. shift
  92. if [ $# -ne 0 ]; then
  93. echo "${indent}<${tag}"
  94. indent_push
  95. tag_attributes "$@"
  96. indent_pop
  97. echo "${indent}/>"
  98. else
  99. echo "${indent}<${tag}/>"
  100. fi
  101. }