]>
Commit | Line | Data |
---|---|---|
f427ee49 A |
1 | #!/bin/sh |
2 | ||
3 | set -e | |
4 | ||
5 | if [ $# -lt 3 ]; then | |
6 | echo "Usage: $0 output.plist Info.plist input1.exports [input2.exports ... ]" 1>&2 | |
7 | exit 1 | |
8 | fi | |
9 | ||
10 | OUTPUT="$1" | |
11 | PLIST="$2" | |
12 | if [ "${OUTPUT##*.}" != "plist" -o "${PLIST##*.}" != "plist" ]; then | |
13 | echo "Usage: $0 output.plist Info.plist input1.exports [input2.exports ... ]" 1>&2 | |
14 | exit 1 | |
15 | fi | |
16 | shift 2 | |
17 | ||
c3c9b80d A |
18 | if [ $(egrep -c 'CFBundleIdentifier|OSBundleCompatibleVersion|CFBundleVersion' $PLIST) -lt 3 ]; then |
19 | echo "error: Invalid input Info.plist $PLIST" 1>&2 | |
20 | exit 1 | |
21 | fi | |
22 | ||
f427ee49 A |
23 | printf \ |
24 | '<?xml version="1.0" encoding="UTF-8"?> | |
25 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
26 | <plist version="1.0"> | |
27 | <dict> | |
28 | ' > "$OUTPUT" | |
29 | ||
30 | awk ' | |
31 | /CFBundleIdentifier|OSBundleCompatibleVersion|CFBundleVersion/ { | |
32 | print; getline; print | |
33 | } | |
34 | ' $PLIST >> "$OUTPUT" | |
35 | ||
36 | sort -u "$@" | awk -F: ' | |
37 | BEGIN { | |
38 | print " <key>Symbols</key>" | |
39 | print " <array>" | |
40 | } | |
41 | $2 ~ /^_/ { | |
42 | print " <dict>" | |
43 | print " <key>SymbolName</key>" | |
44 | print " <string>"$1"</string>" | |
45 | print " <key>AliasTarget</key>" | |
46 | print " <string>"$2"</string>" | |
47 | print " </dict>" | |
48 | next | |
49 | } | |
50 | $1 ~ /^_.*\*$/ { | |
51 | print " <dict>" | |
52 | print " <key>SymbolPrefix</key>" | |
53 | print " <string>"substr($1, 1, length($1) - 1)"</string>" | |
54 | print " </dict>" | |
55 | next | |
56 | } | |
57 | $1 ~ /^_/ { | |
58 | print " <dict>" | |
59 | print " <key>SymbolName</key>" | |
60 | print " <string>"$1"</string>" | |
61 | print " </dict>" | |
62 | next | |
63 | } | |
64 | END { | |
65 | print " </array>" | |
66 | } | |
67 | ' >> "$OUTPUT" | |
68 | ||
69 | printf \ | |
70 | '</dict> | |
71 | </plist> | |
72 | ' >> "$OUTPUT" | |
73 | ||
74 | exit 0 |