blob: dbb2674ac5d99f4e3bad5dd55b0201da9b7dc80e [file] [log] [blame]
John Koleszar0ea50ce2010-05-18 11:58:33 -04001#!/bin/bash
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002## Copyright (c) 2016, Alliance for Open Media. All rights reserved
John Koleszar0ea50ce2010-05-18 11:58:33 -04003##
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004## This source code is subject to the terms of the BSD 2 Clause License and
5## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6## was not distributed with this source code in the LICENSE file, you can
7## obtain it at www.aomedia.org/license/software. If the Alliance for Open
8## Media Patent License 1.0 was not distributed with this source code in the
9## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
John Koleszar0ea50ce2010-05-18 11:58:33 -040010##
John Koleszar0ea50ce2010-05-18 11:58:33 -040011
12self=$0
13self_basename=${self##*/}
14EOL=$'\n'
15
16show_help() {
17 cat <<EOF
18Usage: ${self_basename} [options] file1 [file2 ...]
19
20This script generates a MSVC module definition file containing a list of symbols
21to export from a DLL. Source files are technically bash scripts (and thus may
22use #comment syntax) but in general, take the form of a list of symbols:
23
24 <kind> symbol1 [symbol2, symbol3, ...]
25
26where <kind> is either 'text' or 'data'
27
28
29Options:
30 --help Print this message
31 --out=filename Write output to a file [stdout]
32 --name=project_name Name of the library (required)
33EOF
34 exit 1
35}
36
37die() {
38 echo "${self_basename}: $@"
39 exit 1
40}
41
42die_unknown(){
43 echo "Unknown option \"$1\"."
44 echo "See ${self_basename} --help for available options."
45 exit 1
46}
47
48text() {
49 for sym in "$@"; do
50 echo " $sym" >> ${outfile}
51 done
52}
53
54data() {
55 for sym in "$@"; do
56 printf " %-40s DATA\n" "$sym" >> ${outfile}
57 done
58}
59
60# Process command line
61for opt in "$@"; do
62 optval="${opt#*=}"
63 case "$opt" in
64 --help|-h) show_help
65 ;;
66 --out=*) outfile="$optval"
67 ;;
68 --name=*) name="${optval}"
69 ;;
70 -*) die_unknown $opt
71 ;;
72 *) file_list[${#file_list[@]}]="$opt"
73 esac
74done
75outfile=${outfile:-/dev/stdout}
76[ -n "$name" ] || die "Library name (--name) must be specified!"
77
78echo "LIBRARY ${name}" > ${outfile}
79echo "EXPORTS" >> ${outfile}
80for f in "${file_list[@]}"; do
81 . $f
82done