51b8bf454b420526e19656e1a650b57332045312
[platform/upstream/gst-common.git] / check-exports
1 #!/bin/sh
2 # check-exports
3 #
4 # quick'n'dirty script that retrieves the list of exported symbols of a given
5 # library using 'nm', and compares that against the list of symbols-to-export
6 # of our win32/common/libfoo.def files.
7
8 if [ $# -ne 2 ]; then
9         echo "Usage: $0 library.def library.so"
10         exit 1
11 fi
12
13 export LC_ALL=C
14
15 def_path=$1
16 def_name=$(basename $def_path)
17 lib_path=$2
18
19 lib_result=$(mktemp /tmp/defname.XXXXXX)
20
21 # FIXME 0.11: in 0.11, we should change the export filter to only export
22 # _gst_foo, but not __gst_foo (we can't change this now, since we added
23 # __gst_debug_min and __gst_debug_enabled at some point and need to keep
24 # ABI compatibility).  So below we special-case some symbols that shouldn't
25 # really be exported, either because we're too lazy to rename them to something
26 # that's not exported (like the _gst_parse_* stuff) or because we had them in
27 # public headers at some point although they shouldn't be and so we need to
28 # keep them exported now (like _gst_debug_init, 
29 # __gst_element_factory_add_interface or
30 # __gst_element_factory_add_static_pad_template).  We suppress them here to
31 # make sure they're at least not exported in the windows msvc build (they
32 # were never in the .def file, so they never got exported).
33 nm $lib_path | awk \
34         '{
35                 if ($3 !~ /^_gst_parse_yy/ &&
36                     $3 !~ /^_gst_[a-z]*_init/ &&
37                     $3 !~ /^_gst_parse_launch/ &&
38                     $3 !~ /^__gst_element_details_/ &&
39                     $3 !~ /^__gst_element_factory_add_/ &&
40                     $3 !~ /^gst_interfaces_marshal/)
41                 {
42                         if ($2 == "B" || $2 == "S")
43                                 print "\t" $3 " DATA"
44                         else if ($2 == "T")
45                                 print "\t" $3
46                 }
47          }' | sort | awk '{ if (NR == 1) print "EXPORTS"; print $0; }' \
48         > $lib_result
49
50 diffoutput=`diff -u $def_path $lib_result`
51
52 rm $lib_result
53
54 if test "x$diffoutput" = "x"; then
55   exit 0;
56 else
57   echo -n "$diffoutput" >&2
58   echo >&2
59   exit 1;
60 fi
61