]> git.saurik.com Git - apple/xnu.git/blame - config/generate_symbolset_plist.sh
xnu-7195.101.1.tar.gz
[apple/xnu.git] / config / generate_symbolset_plist.sh
CommitLineData
f427ee49
A
1#!/bin/sh
2
3set -e
4
5if [ $# -lt 3 ]; then
6 echo "Usage: $0 output.plist Info.plist input1.exports [input2.exports ... ]" 1>&2
7 exit 1
8fi
9
10OUTPUT="$1"
11PLIST="$2"
12if [ "${OUTPUT##*.}" != "plist" -o "${PLIST##*.}" != "plist" ]; then
13 echo "Usage: $0 output.plist Info.plist input1.exports [input2.exports ... ]" 1>&2
14 exit 1
15fi
16shift 2
17
c3c9b80d
A
18if [ $(egrep -c 'CFBundleIdentifier|OSBundleCompatibleVersion|CFBundleVersion' $PLIST) -lt 3 ]; then
19 echo "error: Invalid input Info.plist $PLIST" 1>&2
20 exit 1
21fi
22
f427ee49
A
23printf \
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
30awk '
31 /CFBundleIdentifier|OSBundleCompatibleVersion|CFBundleVersion/ {
32 print; getline; print
33 }
34' $PLIST >> "$OUTPUT"
35
36sort -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
69printf \
70'</dict>
71</plist>
72' >> "$OUTPUT"
73
74exit 0