Add postprocess-header-rule scripts
authorkrollin@apple.com <krollin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Apr 2019 21:07:30 +0000 (21:07 +0000)
committerkrollin@apple.com <krollin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Apr 2019 21:07:30 +0000 (21:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197072
<rdar://problem/50027299>

Reviewed by Brent Fulgham.

Several projects have post-processing build phases where exported
headers are tweaked after they've been copied. This post-processing is
performed via scripts called postprocess-headers.sh. For reasons
related to XCBuild, we are now transitioning to a build process where
the post-processing is performed at the same time as the
exporting/copying. To support this process, add similar scripts named
postprocess-header-rule, which are geared towards processing a single
file at a time rather than all exported files at once. Also add a
build rule that makes use of these scripts. These scripts and build
rules are not used at the moment; they will come into use in an
imminent patch.

Note that I've named these postprocess-header-rule rather than
postprocess-header-rule.sh. Scripts in Tools/Scripts do not have
suffixes indicating how the tool is implemented. Scripts in
per-project Scripts folders appear to be mixed regarding the use of
suffixes. I'm opting here to follow the Tools/Scripts convention, with
the expectation that over time we completely standardize on that.

Source/JavaScriptCore:

* JavaScriptCore.xcodeproj/project.pbxproj:
* Scripts/postprocess-header-rule: Added.

Source/WebKit:

* Scripts/postprocess-header-rule: Added.
* WebKit.xcodeproj/project.pbxproj:

Source/WebKitLegacy:

* WebKitLegacy.xcodeproj/project.pbxproj:
* scripts/postprocess-header-rule: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244466 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/Scripts/postprocess-header-rule [new file with mode: 0755]
Source/WebKit/ChangeLog
Source/WebKit/Scripts/postprocess-header-rule [new file with mode: 0755]
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKitLegacy/ChangeLog
Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj
Source/WebKitLegacy/scripts/postprocess-header-rule [new file with mode: 0755]

index 02169b7..a30b284 100644 (file)
@@ -1,3 +1,33 @@
+2019-04-19  Keith Rollin  <krollin@apple.com>
+
+        Add postprocess-header-rule scripts
+        https://bugs.webkit.org/show_bug.cgi?id=197072
+        <rdar://problem/50027299>
+
+        Reviewed by Brent Fulgham.
+
+        Several projects have post-processing build phases where exported
+        headers are tweaked after they've been copied. This post-processing is
+        performed via scripts called postprocess-headers.sh. For reasons
+        related to XCBuild, we are now transitioning to a build process where
+        the post-processing is performed at the same time as the
+        exporting/copying. To support this process, add similar scripts named
+        postprocess-header-rule, which are geared towards processing a single
+        file at a time rather than all exported files at once. Also add a
+        build rule that makes use of these scripts. These scripts and build
+        rules are not used at the moment; they will come into use in an
+        imminent patch.
+
+        Note that I've named these postprocess-header-rule rather than
+        postprocess-header-rule.sh. Scripts in Tools/Scripts do not have
+        suffixes indicating how the tool is implemented. Scripts in
+        per-project Scripts folders appear to be mixed regarding the use of
+        suffixes. I'm opting here to follow the Tools/Scripts convention, with
+        the expectation that over time we completely standardize on that.
+
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * Scripts/postprocess-header-rule: Added.
+
 2019-04-18  Saam barati  <sbarati@apple.com>
 
         Remove useConcurrentBarriers option
index 88bc97e..e0ef301 100644 (file)
                FEFD6FC61D5E7992008F2F0B /* JSStringInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildRule section */
+               535E08C222545AC800DF00CA /* PBXBuildRule */ = {
+                       isa = PBXBuildRule;
+                       compilerSpec = com.apple.compilers.proxy.script;
+                       filePatterns = "*.h";
+                       fileType = pattern.proxy;
+                       isEditable = 1;
+                       outputFiles = (
+                               "$(HEADER_OUTPUT_DIR)/$(INPUT_FILE_NAME)",
+                       );
+                       script = "exec \"${SRCROOT}/Scripts/postprocess-header-rule\"\n";
+               };
+/* End PBXBuildRule section */
+
 /* Begin PBXContainerItemProxy section */
                0F6183461C45F67A0072450B /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                535557131D9D9EA5006D583B /* WasmMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmMemory.h; sourceTree = "<group>"; };
                535557151D9DFA32006D583B /* WasmMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmMemory.cpp; sourceTree = "<group>"; };
                535C246B1F7A1777006EC40E /* UnifiedSource136.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnifiedSource136.cpp; path = "DerivedSources/JavaScriptCore/unified-sources/UnifiedSource136.cpp"; sourceTree = BUILT_PRODUCTS_DIR; };
+               535E08C9225460AB00DF00CA /* postprocess-header-rule */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "postprocess-header-rule"; sourceTree = "<group>"; };
                53696E5720A3A70200D7E01E /* BytecodeStructs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BytecodeStructs.h; sourceTree = "<group>"; };
                536B30871F71C5380037FC33 /* UnifiedSource119.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnifiedSource119.cpp; path = "DerivedSources/JavaScriptCore/unified-sources/UnifiedSource119.cpp"; sourceTree = BUILT_PRODUCTS_DIR; };
                536B30881F71C5380037FC33 /* UnifiedSource125.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnifiedSource125.cpp; path = "DerivedSources/JavaScriptCore/unified-sources/UnifiedSource125.cpp"; sourceTree = BUILT_PRODUCTS_DIR; };
                9959E9251BD17F1E001AA413 /* Scripts */ = {
                        isa = PBXGroup;
                        children = (
+                               535E08C9225460AB00DF00CA /* postprocess-header-rule */,
                                99DA00971BD598E000F4575C /* wkbuiltins */,
                                9959E9271BD17FA0001AA413 /* cssmin.py */,
                                9959E92F1BD181F6001AA413 /* generate-combined-inspector-json.py */,
                                53609F9021DFFA9C008FA60A /* Check .xcfilelists */,
                        );
                        buildRules = (
+                               535E08C222545AC800DF00CA /* PBXBuildRule */,
                        );
                        dependencies = (
                                65788AAD18B40A7B00C189FF /* PBXTargetDependency */,
diff --git a/Source/JavaScriptCore/Scripts/postprocess-header-rule b/Source/JavaScriptCore/Scripts/postprocess-header-rule
new file mode 100755 (executable)
index 0000000..ab048d3
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/bash
+#
+# Copyright (C) 2014-2019 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+if [[ -z "${SCRIPT_HEADER_VISIBILITY}" ]]; then
+    exit 0
+fi
+
+if [[ "${JSC_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED}" == "YES" ]]; then
+    ditto "${SCRIPT_INPUT_FILE}" "${SCRIPT_OUTPUT_FILE_0}"
+    exit 0
+fi
+
+function process_definitions () {
+    local DEFINITIONS_FILE=$1
+
+    if [[ ! -f "${DEFINITIONS_FILE}" ]]; then
+        return 1
+    fi
+
+    source "${DEFINITIONS_FILE}"
+}
+
+function rewrite_headers () {
+    if [[ "${PLATFORM_NAME}" == "macosx" ]]; then
+        [[ -n ${OSX_VERSION} ]] || OSX_VERSION=${MACOSX_DEPLOYMENT_TARGET}
+        [[ -n ${IOS_VERSION} ]] || IOS_VERSION="NA"
+        [[ -n ${OSX_VERSION_NUMBER} ]] || OSX_VERSION_NUMBER=${TARGET_MAC_OS_X_VERSION_MAJOR}
+        [[ -n ${IOS_VERSION_NUMBER} ]] || IOS_VERSION_NUMBER="0"
+    elif [[ "${PLATFORM_NAME}" =~ "iphone" ]]; then
+        [[ -n ${IOS_VERSION} ]] || IOS_VERSION=${IPHONEOS_DEPLOYMENT_TARGET}
+        [[ -n ${OSX_VERSION} ]] || OSX_VERSION="NA"
+        [[ -n ${OSX_VERSION_NUMBER} ]] || OSX_VERSION_NUMBER="0"
+        [[ -n ${IOS_VERSION_NUMBER} ]] || IOS_VERSION_NUMBER=${SDK_VERSION_MAJOR}
+    fi
+
+    SED_OPTIONS=(
+    )
+
+    if [[ -n "$OSX_VERSION" && -n "$IOS_VERSION" ]]; then
+        SED_OPTIONS+=(
+            -e s/JSC_MAC_TBA/${OSX_VERSION}/g
+            -e s/JSC_IOS_TBA/${IOS_VERSION}/g
+            -e s/JSC_MAC_VERSION_TBA/${OSX_VERSION_NUMBER}/g
+            -e s/JSC_IOS_VERSION_TBA/${IOS_VERSION_NUMBER}/g
+            -e s/JSC_API_AVAILABLE/API_AVAILABLE/
+            -e s/JSC_API_DEPRECATED/API_DEPRECATED/
+            -e "s/^JSC_CLASS_AVAILABLE/JS_EXPORT API_AVAILABLE/"
+            -e "s/^JSC_CLASS_DEPRECATED/JS_EXPORT API_DEPRECATED/"
+        )
+    else
+        SED_OPTIONS+=(
+            -e 's/JSC_(API_|CLASS_)AVAILABLE\(.*\)\s*\)//g'
+            -e 's/JSC_(API_|CLASS_)DEPRECATED(_WITH_REPLACEMENT)?\(.*\)\s*\)//g'
+            -e 's/JSC_(MAC|IOS)_VERSION_TBA/0/g'
+        )
+    fi
+
+    SED_OPTIONS+=(${OTHER_SED_OPTIONS[*]})
+
+    ditto "${1}" "${2}"
+    sed -i .tmp -E "${SED_OPTIONS[@]}" "${2}" || exit $?
+}
+
+DEFINITIONS_PATH=usr/local/include/WebKitAdditions/Scripts/postprocess-framework-headers-definitions
+
+process_definitions "${BUILT_PRODUCTS_DIR}/${DEFINITIONS_PATH}" || process_definitions "${SDKROOT}/${DEFINITIONS_PATH}"
+
+rewrite_headers "${SCRIPT_INPUT_FILE}" "${SCRIPT_OUTPUT_FILE_0}"
index 9f86838..9eac676 100644 (file)
@@ -1,3 +1,33 @@
+2019-04-19  Keith Rollin  <krollin@apple.com>
+
+        Add postprocess-header-rule scripts
+        https://bugs.webkit.org/show_bug.cgi?id=197072
+        <rdar://problem/50027299>
+
+        Reviewed by Brent Fulgham.
+
+        Several projects have post-processing build phases where exported
+        headers are tweaked after they've been copied. This post-processing is
+        performed via scripts called postprocess-headers.sh. For reasons
+        related to XCBuild, we are now transitioning to a build process where
+        the post-processing is performed at the same time as the
+        exporting/copying. To support this process, add similar scripts named
+        postprocess-header-rule, which are geared towards processing a single
+        file at a time rather than all exported files at once. Also add a
+        build rule that makes use of these scripts. These scripts and build
+        rules are not used at the moment; they will come into use in an
+        imminent patch.
+
+        Note that I've named these postprocess-header-rule rather than
+        postprocess-header-rule.sh. Scripts in Tools/Scripts do not have
+        suffixes indicating how the tool is implemented. Scripts in
+        per-project Scripts folders appear to be mixed regarding the use of
+        suffixes. I'm opting here to follow the Tools/Scripts convention, with
+        the expectation that over time we completely standardize on that.
+
+        * Scripts/postprocess-header-rule: Added.
+        * WebKit.xcodeproj/project.pbxproj:
+
 2019-04-19  Brady Eidson  <beidson@apple.com>
 
         Deprecate WebKit2 plug-in support.
diff --git a/Source/WebKit/Scripts/postprocess-header-rule b/Source/WebKit/Scripts/postprocess-header-rule
new file mode 100755 (executable)
index 0000000..ddca918
--- /dev/null
@@ -0,0 +1,113 @@
+#!/bin/bash
+#
+# Copyright (C) 2014-2019 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+if [[ -z "${SCRIPT_HEADER_VISIBILITY}" ]]; then
+    exit 0
+fi
+
+function process_definitions () {
+    local DEFINITIONS_FILE=$1
+
+    if [[ ! -f "${DEFINITIONS_FILE}" ]]; then
+        return 1
+    fi
+
+    source "${DEFINITIONS_FILE}"
+}
+
+function rewrite_headers () {
+    ditto "${1}" "${2}"
+
+    if [[ ! -z `grep '#import <WebKitAdditions/.*\.h>' "${2}"` ]]; then
+        python "${SRCROOT}/mac/replace-webkit-additions-includes.py" "${2}" "${BUILT_PRODUCTS_DIR}" "${SDKROOT}" || exit $?
+    fi
+
+    if [[ "${WK_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED}" != "YES" ]]; then
+        if [[ "${WK_PLATFORM_NAME}" == "macosx" ]]; then
+            [[ -n ${OSX_VERSION} ]] || OSX_VERSION=${MACOSX_DEPLOYMENT_TARGET}
+            [[ -n ${IOS_VERSION} ]] || IOS_VERSION="NA"
+        elif [[ "${WK_PLATFORM_NAME}" =~ "iphone" ]]; then
+            [[ -n ${IOS_VERSION} ]] || IOS_VERSION=${IPHONEOS_DEPLOYMENT_TARGET}
+            [[ -n ${OSX_VERSION} ]] || OSX_VERSION="NA"
+        fi
+
+        SED_OPTIONS=(
+        )
+
+        if [[ -n "$OSX_VERSION" && -n "$IOS_VERSION" ]]; then
+            SED_OPTIONS+=(
+                -e s/WK_MAC_TBA/${OSX_VERSION}/g
+                -e s/WK_IOS_TBA/${IOS_VERSION}/g
+                -e s/WK_API_AVAILABLE/API_AVAILABLE/
+                -e s/WK_API_DEPRECATED/API_DEPRECATED/
+                -e "s/^WK_CLASS_AVAILABLE/WK_EXTERN API_AVAILABLE/"
+                -e "s/^WK_CLASS_DEPRECATED/WK_EXTERN API_DEPRECATED/"
+            )
+        else
+            SED_OPTIONS+=(
+                -e 's/WK_(API_|CLASS_)AVAILABLE\(.*\)\s*\)//g'
+                -e 's/WK_(API_|CLASS_)DEPRECATED(_WITH_REPLACEMENT)?\(.*\)\s*\)//g'
+            )
+        fi
+
+        SED_OPTIONS+=(${OTHER_SED_OPTIONS[*]})
+
+        sed -i .tmp -E "${SED_OPTIONS[@]}" "${2}" || exit $?
+    fi
+
+    HEADER_NAME=$(basename "${2}")
+    if [[ "${HEADER_NAME}" == "WKBase.h" ]]; then
+        unifdef -B -D__APPLE__ -UBUILDING_GTK__ -UBUILDING_WPE__ -UUSE_SOUP -o "${2}".unifdef "${2}"
+
+        case $? in
+            0) rm "${2}".unifdef ;;
+            1) mv "${2}"{.unifdef,} ;;
+            *) exit 1
+        esac
+    fi
+
+    if [[ "${HEADER_NAME}" == "WKFoundation.h" ]]; then
+        if [[ "${WK_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED}" == "YES" ]]; then
+            UNIFDEF_OPTIONS="-UWK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED"
+        else
+            UNIFDEF_OPTIONS="-DWK_FRAMEWORK_HEADER_POSTPROCESSING_ENABLED"
+        fi
+
+        unifdef -B ${UNIFDEF_OPTIONS} -o "${2}".unifdef "${2}"
+
+        case $? in
+            0) rm "${2}".unifdef ;;
+            1) mv "${2}"{.unifdef,} ;;
+            *) exit 1
+        esac
+    fi
+}
+
+DEFINITIONS_PATH=usr/local/include/WebKitAdditions/Scripts/postprocess-framework-headers-definitions
+
+process_definitions "${BUILT_PRODUCTS_DIR}/${DEFINITIONS_PATH}" || process_definitions "${SDKROOT}/${DEFINITIONS_PATH}"
+
+rewrite_headers "${SCRIPT_INPUT_FILE}" "${SCRIPT_OUTPUT_FILE_0}"
index 6f0a01c..d4c7b54 100644 (file)
                FEE43FD31E67B0180077D6D1 /* WebInspectorInterruptDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = FEE43FD11E67AFC60077D6D1 /* WebInspectorInterruptDispatcher.h */; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildRule section */
+               535E08C422545B7200DF00CA /* PBXBuildRule */ = {
+                       isa = PBXBuildRule;
+                       compilerSpec = com.apple.compilers.proxy.script;
+                       filePatterns = "*.h";
+                       fileType = pattern.proxy;
+                       isEditable = 1;
+                       outputFiles = (
+                               "$(HEADER_OUTPUT_DIR)/$(INPUT_FILE_NAME)",
+                       );
+                       script = "exec \"${SRCROOT}/Scripts/postprocess-header-rule\"\n";
+               };
+/* End PBXBuildRule section */
+
 /* Begin PBXContainerItemProxy section */
                2D11BA042126A5AE006F8878 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                532159511DBAE6FC0054AA3C /* NetworkDataTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkDataTask.cpp; sourceTree = "<group>"; };
                532159521DBAE6FC0054AA3C /* NetworkSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkSession.cpp; sourceTree = "<group>"; };
                535BCB902069C49C00CCCE02 /* NetworkActivityTracker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NetworkActivityTracker.h; sourceTree = "<group>"; };
+               535E08CA225460FC00DF00CA /* postprocess-header-rule */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "postprocess-header-rule"; sourceTree = "<group>"; };
                536F46D3220D385100126322 /* PluginService.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = PluginService.entitlements; sourceTree = "<group>"; };
                539EB5461DC2EE40009D48CF /* NetworkDataTaskBlob.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkDataTaskBlob.cpp; sourceTree = "<group>"; };
                539EB5471DC2EE40009D48CF /* NetworkDataTaskBlob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkDataTaskBlob.h; sourceTree = "<group>"; };
                C0CE73351247F70E00BC0EC4 /* Scripts */ = {
                        isa = PBXGroup;
                        children = (
+                               535E08CA225460FC00DF00CA /* postprocess-header-rule */,
                                7CDE73A21F9DA59700390312 /* PreferencesTemplates */,
                                0FC0856E187CE0A900780D86 /* __init__.py */,
                                4157853021276B6F00DD3800 /* copy-webcontent-resources-to-private-headers.sh */,
                                933170072234674500B32554 /* Create symlinks to XPC services for engineering builds */,
                        );
                        buildRules = (
+                               535E08C422545B7200DF00CA /* PBXBuildRule */,
                        );
                        dependencies = (
                                E1AC2E3E20F7B9C000B0897D /* PBXTargetDependency */,
index 10dbebb..1a349f4 100644 (file)
@@ -1,3 +1,33 @@
+2019-04-19  Keith Rollin  <krollin@apple.com>
+
+        Add postprocess-header-rule scripts
+        https://bugs.webkit.org/show_bug.cgi?id=197072
+        <rdar://problem/50027299>
+
+        Reviewed by Brent Fulgham.
+
+        Several projects have post-processing build phases where exported
+        headers are tweaked after they've been copied. This post-processing is
+        performed via scripts called postprocess-headers.sh. For reasons
+        related to XCBuild, we are now transitioning to a build process where
+        the post-processing is performed at the same time as the
+        exporting/copying. To support this process, add similar scripts named
+        postprocess-header-rule, which are geared towards processing a single
+        file at a time rather than all exported files at once. Also add a
+        build rule that makes use of these scripts. These scripts and build
+        rules are not used at the moment; they will come into use in an
+        imminent patch.
+
+        Note that I've named these postprocess-header-rule rather than
+        postprocess-header-rule.sh. Scripts in Tools/Scripts do not have
+        suffixes indicating how the tool is implemented. Scripts in
+        per-project Scripts folders appear to be mixed regarding the use of
+        suffixes. I'm opting here to follow the Tools/Scripts convention, with
+        the expectation that over time we completely standardize on that.
+
+        * WebKitLegacy.xcodeproj/project.pbxproj:
+        * scripts/postprocess-header-rule: Added.
+
 2019-04-18  Don Olmstead  <don.olmstead@sony.com>
 
         [CMake] Make WebCore headers copies
index 874d43c..025a02e 100644 (file)
                F834AAD80E64B1C700E2737C /* WebTextIterator.mm in Sources */ = {isa = PBXBuildFile; fileRef = F834AAD60E64B1C700E2737C /* WebTextIterator.mm */; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildRule section */
+               535E08C322545B4C00DF00CA /* PBXBuildRule */ = {
+                       isa = PBXBuildRule;
+                       compilerSpec = com.apple.compilers.proxy.script;
+                       filePatterns = "*.h";
+                       fileType = pattern.proxy;
+                       isEditable = 1;
+                       outputFiles = (
+                               "$(HEADER_OUTPUT_DIR)/$(INPUT_FILE_NAME)",
+                       );
+                       script = "exec \"${SRCROOT}/scripts/postprocess-header-rule\"\n";
+               };
+/* End PBXBuildRule section */
+
 /* Begin PBXCopyFilesBuildPhase section */
                535E08CB2254637200DF00CA /* Copy Mig Files into Private Framework Headers */ = {
                        isa = PBXCopyFilesBuildPhase;
                51FDC4D20B0AF5C100F84EB3 /* WebHistoryItemPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebHistoryItemPrivate.h; sourceTree = "<group>"; };
                5241ADF30B1BC48A004012BD /* WebCache.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCache.h; sourceTree = "<group>"; };
                5241ADF40B1BC48A004012BD /* WebCache.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCache.mm; sourceTree = "<group>"; };
+               535E08C52254604E00DF00CA /* postprocess-header-rule */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "postprocess-header-rule"; path = "scripts/postprocess-header-rule"; sourceTree = "<group>"; };
                598AD9191201CEC900ABAE4E /* WebDeviceOrientationClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDeviceOrientationClient.h; sourceTree = "<group>"; };
                598AD91D1201CECF00ABAE4E /* WebDeviceOrientationClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebDeviceOrientationClient.mm; sourceTree = "<group>"; };
                598AD91F1201CF0700ABAE4E /* WebDeviceOrientation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDeviceOrientation.h; sourceTree = "<group>"; };
                                A10C1D8F1820307D0036883A /* WebKit.iOS.exp */,
                                F5C283730284676D018635CA /* WebKitPrefix.h */,
                                A182B74E199E7B8F001FD95A /* migrate-headers.sh */,
+                               535E08C52254604E00DF00CA /* postprocess-header-rule */,
                                A182B74F199E7B8F001FD95A /* postprocess-headers.sh */,
                                6508A4A7099B375F00BCBF45 /* Default Delegates */,
                                F57D194A034E732C01A80180 /* DOM */,
                                1A3193D5191856E500E1CF89 /* Symlink WebKitPluginHost */,
                        );
                        buildRules = (
+                               535E08C322545B4C00DF00CA /* PBXBuildRule */,
                        );
                        dependencies = (
                        );
diff --git a/Source/WebKitLegacy/scripts/postprocess-header-rule b/Source/WebKitLegacy/scripts/postprocess-header-rule
new file mode 100755 (executable)
index 0000000..da8e82b
--- /dev/null
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# Copyright (C) 2019 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+if [[ -z "${SCRIPT_HEADER_VISIBILITY}" ]]; then
+    exit 0
+fi
+
+ditto "${SCRIPT_INPUT_FILE}" "${SCRIPT_OUTPUT_FILE_0}"
+header="${SCRIPT_OUTPUT_FILE_0}"
+
+if [[ ${USE_INTERNAL_SDK} == "YES" ]]; then
+    USE_APPLE_INTERNAL_SDK=1
+else
+    USE_APPLE_INTERNAL_SDK=0
+fi
+
+if [[ ${WK_PLATFORM_NAME} == macosx ]]; then
+    unifdefOptions="-DTARGET_OS_IPHONE=0 -DTARGET_OS_SIMULATOR=0"
+elif [[ ${WK_PLATFORM_NAME} == *simulator* ]]; then
+    unifdefOptions="-DTARGET_OS_IPHONE=1 -DTARGET_OS_SIMULATOR=1 -DUSE_APPLE_INTERNAL_SDK=${USE_APPLE_INTERNAL_SDK}"
+else
+    unifdefOptions="-DTARGET_OS_IPHONE=1 -DTARGET_OS_SIMULATOR=0 -DUSE_APPLE_INTERNAL_SDK=${USE_APPLE_INTERNAL_SDK}"
+fi
+
+# FIXME: We should consider making this logic general purpose so as to support keeping or removing
+# code guarded by an arbitrary feature define. For now it's sufficient to process touch- and gesture-
+# guarded code.
+for featureDefine in "ENABLE_TOUCH_EVENTS" "ENABLE_IOS_GESTURE_EVENTS"
+do
+    # We assume a disabled feature is either undefined or has the empty string as its value.
+    eval "isFeatureEnabled=\$$featureDefine"
+    if [[ -z $isFeatureEnabled ]]; then
+        unifdefOptions="$unifdefOptions -D$featureDefine=0"
+    else
+        unifdefOptions="$unifdefOptions -D$featureDefine=1"
+    fi
+done
+
+unifdef -B ${unifdefOptions} -o ${header}.unifdef ${header}
+case $? in
+    0) rm ${header}.unifdef ;;
+    1) mv ${header}{.unifdef,} ;;
+    *) exit 1 ;;
+esac
+
+if [[ ${header} == "./WebKitAvailability.h" ]]; then
+    exit 0
+fi
+
+if [[ ${WK_PLATFORM_NAME} != macosx ]]; then
+    sed -E -e "s/ *WEBKIT_((CLASS_|ENUM_)?(AVAILABLE|DEPRECATED))_MAC\([^)]+\)//g" < ${header} > ${header}.sed
+    if cmp -s ${header} ${header}.sed; then
+        rm ${header}.sed
+    else
+        mv ${header}.sed ${header}
+    fi
+fi