4 # Copyright (C) 2011 Google Inc. All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are
10 # * Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following disclaimer
14 # in the documentation and/or other materials provided with the
16 # * Neither the name of Google Inc. nor the names of its
17 # contributors may be used to endorse or promote products derived from
18 # this software without specific prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 # This script checks a WebCore static library for potential Objective-C
34 # class name collisions with the system's copy of the WebCore framework.
35 # See the postbuild action that calls it from ../WebCore.gyp for details.
40 if [[ $# -ne 2 ]]; then
41 echo "usage: ${0} class_whitelist_pattern category_whitelist_pattern" >& 2
45 lib
="${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}"
46 nm_pattern
='[atsATS] ([+-]\[|\.objc_class_name_)'
48 class_whitelist_pattern
="${1}"
49 category_whitelist_pattern
="${2}"
51 # Send nm's stderr in the pipeline to /dev/null to avoid spewing
52 # "nm: no name list" messages. This means that if the pipelined nm fails, there
53 # won't be any output, so if the entire assignment fails, run nm again to get
55 violators
=$
(nm
-p "${lib}" 2> /dev
/null | \
56 (grep -E "${nm_pattern}" || true
) | \
57 (grep -Ev "${nm_pattern}(${class_whitelist_pattern})" || true
) | \
58 (grep -Ev "\((${category_whitelist_pattern})\)" || true
)) || nm
-p "${lib}"
60 if [[ -z "${violators}" ]]; then
61 # An empty list means that everything's clean.
66 These Objective-C symbols may clash with those provided by the system's own
70 These symbols were found in:
73 This should be corrected by adding the appropriate definitions to
74 $(dirname ${0})/../WebCore.gyp
75 or by updating the whitelist in