gen_msvs_def.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/bash
  2. ##
  3. ## Copyright (c) 2010 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. self=$0
  12. self_basename=${self##*/}
  13. EOL=$'\n'
  14. show_help() {
  15. cat <<EOF
  16. Usage: ${self_basename} [options] file1 [file2 ...]
  17. This script generates a MSVC module definition file containing a list of symbols
  18. to export from a DLL. Source files are technically bash scripts (and thus may
  19. use #comment syntax) but in general, take the form of a list of symbols:
  20. <kind> symbol1 [symbol2, symbol3, ...]
  21. where <kind> is either 'text' or 'data'
  22. Options:
  23. --help Print this message
  24. --out=filename Write output to a file [stdout]
  25. --name=project_name Name of the library (required)
  26. EOF
  27. exit 1
  28. }
  29. die() {
  30. echo "${self_basename}: $@"
  31. exit 1
  32. }
  33. die_unknown(){
  34. echo "Unknown option \"$1\"."
  35. echo "See ${self_basename} --help for available options."
  36. exit 1
  37. }
  38. text() {
  39. for sym in "$@"; do
  40. echo " $sym" >> ${outfile}
  41. done
  42. }
  43. data() {
  44. for sym in "$@"; do
  45. printf " %-40s DATA\n" "$sym" >> ${outfile}
  46. done
  47. }
  48. # Process command line
  49. for opt in "$@"; do
  50. optval="${opt#*=}"
  51. case "$opt" in
  52. --help|-h) show_help
  53. ;;
  54. --out=*) outfile="$optval"
  55. ;;
  56. --name=*) name="${optval}"
  57. ;;
  58. -*) die_unknown $opt
  59. ;;
  60. *) file_list[${#file_list[@]}]="$opt"
  61. esac
  62. done
  63. outfile=${outfile:-/dev/stdout}
  64. [ -n "$name" ] || die "Library name (--name) must be specified!"
  65. echo "LIBRARY ${name}" > ${outfile}
  66. echo "EXPORTS" >> ${outfile}
  67. for f in "${file_list[@]}"; do
  68. . $f
  69. done