blob: 4defcc2e7c7e5f25339c5a23ac9a57b4c7aec36f [file] [log] [blame]
John Koleszar0ea50ce2010-05-18 11:58:33 -04001#!/bin/bash
2##
John Koleszarc2140b82010-09-09 08:16:39 -04003## Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar0ea50ce2010-05-18 11:58:33 -04004##
John Koleszar94c52e42010-06-18 12:39:21 -04005## Use of this source code is governed by a BSD-style license
John Koleszar09202d82010-06-04 16:19:40 -04006## 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
John Koleszar94c52e42010-06-18 12:39:21 -04008## in the file PATENTS. All contributing project authors may
John Koleszar09202d82010-06-04 16:19:40 -04009## be found in the AUTHORS file in the root of the source tree.
John Koleszar0ea50ce2010-05-18 11:58:33 -040010##
11
12
13self=$0
14self_basename=${self##*/}
15EOL=$'\n'
16
17show_help() {
18 cat <<EOF
19Usage: ${self_basename} [options] file1 [file2 ...]
20
21This script generates a MSVC module definition file containing a list of symbols
22to export from a DLL. Source files are technically bash scripts (and thus may
23use #comment syntax) but in general, take the form of a list of symbols:
24
25 <kind> symbol1 [symbol2, symbol3, ...]
26
27where <kind> is either 'text' or 'data'
28
29
30Options:
31 --help Print this message
32 --out=filename Write output to a file [stdout]
33 --name=project_name Name of the library (required)
34EOF
35 exit 1
36}
37
38die() {
39 echo "${self_basename}: $@"
40 exit 1
41}
42
43die_unknown(){
44 echo "Unknown option \"$1\"."
45 echo "See ${self_basename} --help for available options."
46 exit 1
47}
48
49text() {
50 for sym in "$@"; do
51 echo " $sym" >> ${outfile}
52 done
53}
54
55data() {
56 for sym in "$@"; do
57 printf " %-40s DATA\n" "$sym" >> ${outfile}
58 done
59}
60
61# Process command line
62for opt in "$@"; do
63 optval="${opt#*=}"
64 case "$opt" in
65 --help|-h) show_help
66 ;;
67 --out=*) outfile="$optval"
68 ;;
69 --name=*) name="${optval}"
70 ;;
71 -*) die_unknown $opt
72 ;;
73 *) file_list[${#file_list[@]}]="$opt"
74 esac
75done
76outfile=${outfile:-/dev/stdout}
77[ -n "$name" ] || die "Library name (--name) must be specified!"
78
79echo "LIBRARY ${name}" > ${outfile}
80echo "EXPORTS" >> ${outfile}
81for f in "${file_list[@]}"; do
82 . $f
83done