190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#!/bin/bash 290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber## 3f71323e297a928af368937089d3ed71239786f86Andreas Huber## Copyright (c) 2010 The WebM project authors. All Rights Reserved. 490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber## 5f71323e297a928af368937089d3ed71239786f86Andreas Huber## Use of this source code is governed by a BSD-style license 6f71323e297a928af368937089d3ed71239786f86Andreas Huber## that can be found in the LICENSE file in the root of the source 7f71323e297a928af368937089d3ed71239786f86Andreas Huber## tree. An additional intellectual property rights grant can be found 8f71323e297a928af368937089d3ed71239786f86Andreas Huber## in the file PATENTS. All contributing project authors may 9f71323e297a928af368937089d3ed71239786f86Andreas Huber## be found in the AUTHORS file in the root of the source tree. 1090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber## 1190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 1290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 1390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberself=$0 1490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberself_basename=${self##*/} 1590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas HuberEOL=$'\n' 1690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 1790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Hubershow_help() { 1890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber cat <<EOF 1990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas HuberUsage: ${self_basename} [options] file1 [file2 ...] 2090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 2190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas HuberThis script generates a MSVC module definition file containing a list of symbols 2290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberto export from a DLL. Source files are technically bash scripts (and thus may 2390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberuse #comment syntax) but in general, take the form of a list of symbols: 2490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 2590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber <kind> symbol1 [symbol2, symbol3, ...] 2690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 2790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberwhere <kind> is either 'text' or 'data' 2890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 2990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 3090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas HuberOptions: 3190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber --help Print this message 3290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber --out=filename Write output to a file [stdout] 3390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber --name=project_name Name of the library (required) 3490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas HuberEOF 3590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber exit 1 3690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber} 3790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 3890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberdie() { 3990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber echo "${self_basename}: $@" 4090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber exit 1 4190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber} 4290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 4390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberdie_unknown(){ 4490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber echo "Unknown option \"$1\"." 4590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber echo "See ${self_basename} --help for available options." 4690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber exit 1 4790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber} 4890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 4990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Hubertext() { 5090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber for sym in "$@"; do 5190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber echo " $sym" >> ${outfile} 5290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber done 5390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber} 5490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 5590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberdata() { 5690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber for sym in "$@"; do 5790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber printf " %-40s DATA\n" "$sym" >> ${outfile} 5890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber done 5990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber} 6090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 6190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber# Process command line 6290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberfor opt in "$@"; do 6390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber optval="${opt#*=}" 6490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber case "$opt" in 6590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber --help|-h) show_help 6690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber ;; 6790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber --out=*) outfile="$optval" 6890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber ;; 6990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber --name=*) name="${optval}" 7090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber ;; 7190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber -*) die_unknown $opt 7290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber ;; 7390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber *) file_list[${#file_list[@]}]="$opt" 7490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber esac 7590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberdone 7690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberoutfile=${outfile:-/dev/stdout} 7790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber[ -n "$name" ] || die "Library name (--name) must be specified!" 7890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 7990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberecho "LIBRARY ${name}" > ${outfile} 8090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberecho "EXPORTS" >> ${outfile} 8190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberfor f in "${file_list[@]}"; do 8290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber . $f 8390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberdone 84