Deprecate _WKWebsiteDataStore in favor of WKWebsiteDataStore
[WebKit-https.git] / Source / WebKit2 / mac / postprocess-framework-headers.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2014 Apple Inc. All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 #    notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 #    notice, this list of conditions and the following disclaimer in the
12 #    documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 # THE POSSIBILITY OF SUCH DAMAGE.
25 #
26
27 if [[ "${WK_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED}" == "YES" ]]; then
28     exit 0;
29 fi
30
31 TIMESTAMP_PATH=${TARGET_TEMP_DIR}/${0##*/}
32
33 if [[ -e $TIMESTAMP_PATH && $0 -nt $TIMESTAMP_PATH ]]; then
34     rm "${TIMESTAMP_PATH}";
35 fi
36
37 function rewrite_headers () {
38     if [[ "${PLATFORM_NAME}" == "macosx" ]]; then
39         OSX_VERSION=${MACOSX_DEPLOYMENT_TARGET/\./_}
40         IOS_VERSION="NA"
41     elif [[ "${PLATFORM_NAME}" =~ "iphone" ]]; then
42         IOS_VERSION=${IPHONEOS_DEPLOYMENT_TARGET/\./_}
43         OSX_VERSION="NA"
44     fi
45
46     for HEADER_PATH in $1/*.h; do
47         if [[ $HEADER_PATH -nt $TIMESTAMP_PATH ]]; then
48             ditto ${HEADER_PATH} ${TARGET_TEMP_DIR}/${HEADER_PATH##*/}
49
50             if [[ -n "$OSX_VERSION" ]] && [[ -n "$IOS_VERSION" ]]; then
51                 sed -i .tmp -e s/WK_MAC_TBA/${OSX_VERSION}/g -e s/WK_IOS_TBA/${IOS_VERSION}/g ${TARGET_TEMP_DIR}/${HEADER_PATH##*/} || exit $_
52             else
53                 sed -i .tmp -E -e 's/WK_(CLASS_|ENUM_)?AVAILABLE(_IOS|_MAC)?\(.+\)//g' -e 's/WK_(CLASS_?)DEPRECATED\(.+\)//g' ${TARGET_TEMP_DIR}/${HEADER_PATH##*/} || exit $_
54             fi
55
56             sed -i .tmp -e s/^WK_CLASS_AVAILABLE/NS_CLASS_AVAILABLE/ -e s/WK_AVAILABLE/NS_AVAILABLE/ -e s/^WK_CLASS_DEPRECATED/NS_CLASS_DEPRECATED/ -e s/WK_DEPRECATED/NS_DEPRECATED/ -e s/WK_DESIGNATED_INITIALIZER/NS_DESIGNATED_INITIALIZER/ -e s/WK_ENUM_AVAILABLE/NS_ENUM_AVAILABLE/ -e s/WK_UNAVAILABLE/NS_UNAVAILABLE/ -e s/WK_ASSUME_NONNULL_BEGIN/NS_ASSUME_NONNULL_BEGIN/ -e s/WK_ASSUME_NONNULL_END/NS_ASSUME_NONNULL_END/ -e s/WK_NULLABLE_PROPERTY/nullable,/ -e s/WK_NULLABLE_SPECIFIER/__nullable/g -e s/WK_NULLABLE/nullable/g -e s/WK_NULL_UNSPECIFIED/null_unspecified/ ${TARGET_TEMP_DIR}/${HEADER_PATH##*/} || exit $_
57             mv ${TARGET_TEMP_DIR}/${HEADER_PATH##*/} $HEADER_PATH
58         fi
59     done
60 }
61
62 rewrite_headers ${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}
63 rewrite_headers ${TARGET_BUILD_DIR}/${PRIVATE_HEADERS_FOLDER_PATH}
64
65 touch ${TIMESTAMP_PATH}