- Revision
- 270315
- Author
- [email protected]
- Date
- 2020-12-01 10:39:50 -0800 (Tue, 01 Dec 2020)
Log Message
Consolidate header postprocessing scripts
https://bugs.webkit.org/show_bug.cgi?id=219388
<rdar://problem/71840357>
Reviewed by David Kilzer.
Our build system contains the following scripts to perform some
postprocessing of headers that we export to the SDK:
_javascript_Core/postprocess-headers.sh
WebKit/mac/postprocess-framework-headers.sh
WebKitLegacy/mac/postprocess-headers.sh
The preceding scripts are used when using the non-XCBuild -- or
"legacy" -- Xcode build system. They are invoked in a custom Run
Script build phase after the headers have been exported with the
standard Xcode facility for creating frameworks.
Alternatively, we also have the following postprocessing scripts:
WebKit/Scripts/postprocess-header-rule
_javascript_Core/Scripts/postprocess-header-rule
WebKitLegacy/scripts/postprocess-header-rule
These scripts are used when using the XCBuild build system. They are
invoked *during* the header export process to copy and postprocess the
headers in one blow. They are part of a Custom Build Rule for
exporting files ending in ".h".
The reason why we have two sets of scripts is because of the different
capabilities of the two Xcode build systems. The legacy system does
not support a custom "export header" step that would allow us to copy
and postprocess each header in a single step. Therefore, when using
the legacy build system, we export in one build step and postprocess
in a subsequent build step. And XCBuild doesn't like the approach
taken by the old build system where files are exported first and then
munged in a separate step, since that confuses its notion of the state
of the build ("Hey! That file I exported in the previous build? I see
now that it's been changed, so I'm going to export it again. And
change its modification date. And then rebuild everything downstream
that uses it."). Therefore, XCBuild added a facility for copying and
postprocessing in one step.
The scripts supporting each of these approaches are very similar to
each other, such that there is a lot of code duplication between them.
At the same time, by having two sets of scripts that are very similar
to each other, we run the risk of "drift", where files in one set may
get updated while their counterparts in the other set are not.
Address this duplication by making the scripts in the "legacy" set be
mere stubs that invoke the scripts in the new "XCBuild" set. In doing
this, we also fix a case of drift: the legacy-based scripts made use
of a timestamp file to determine if headers needed to be reprocessed
and exported, while the XCBuild-based scripts used a "process the
files and export them if any actual changes now exist between this new
version and any previously-exported version" approach.
Along the way, fix a bug in WebKitLegacy's postprocess-header-rule
that resulted in WebKitAvailability.h not being processed. The
practical effect of this bug is that the file ended up with both macOS
and iOS code, along with the #if that controlled which chunk of code
was compiled, instead of just the chunk of code specific to the
targeted SDK. Normally, the unused chunk of code would get removed
through the invocation of `unifdef`. But, because of the bug, the
results of running `unifdef` were being discarded.
Source/_javascript_Core:
* postprocess-headers.sh:
Source/WebKit:
* mac/postprocess-framework-headers.sh:
Source/WebKitLegacy:
* scripts/postprocess-header-rule:
Source/WebKitLegacy/mac:
* postprocess-headers.sh:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (270314 => 270315)
--- trunk/Source/_javascript_Core/ChangeLog 2020-12-01 18:25:47 UTC (rev 270314)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-12-01 18:39:50 UTC (rev 270315)
@@ -1,3 +1,73 @@
+2020-12-01 Keith Rollin <[email protected]>
+
+ Consolidate header postprocessing scripts
+ https://bugs.webkit.org/show_bug.cgi?id=219388
+ <rdar://problem/71840357>
+
+ Reviewed by David Kilzer.
+
+ Our build system contains the following scripts to perform some
+ postprocessing of headers that we export to the SDK:
+
+ _javascript_Core/postprocess-headers.sh
+ WebKit/mac/postprocess-framework-headers.sh
+ WebKitLegacy/mac/postprocess-headers.sh
+
+ The preceding scripts are used when using the non-XCBuild -- or
+ "legacy" -- Xcode build system. They are invoked in a custom Run
+ Script build phase after the headers have been exported with the
+ standard Xcode facility for creating frameworks.
+
+ Alternatively, we also have the following postprocessing scripts:
+
+ WebKit/Scripts/postprocess-header-rule
+ _javascript_Core/Scripts/postprocess-header-rule
+ WebKitLegacy/scripts/postprocess-header-rule
+
+ These scripts are used when using the XCBuild build system. They are
+ invoked *during* the header export process to copy and postprocess the
+ headers in one blow. They are part of a Custom Build Rule for
+ exporting files ending in ".h".
+
+ The reason why we have two sets of scripts is because of the different
+ capabilities of the two Xcode build systems. The legacy system does
+ not support a custom "export header" step that would allow us to copy
+ and postprocess each header in a single step. Therefore, when using
+ the legacy build system, we export in one build step and postprocess
+ in a subsequent build step. And XCBuild doesn't like the approach
+ taken by the old build system where files are exported first and then
+ munged in a separate step, since that confuses its notion of the state
+ of the build ("Hey! That file I exported in the previous build? I see
+ now that it's been changed, so I'm going to export it again. And
+ change its modification date. And then rebuild everything downstream
+ that uses it."). Therefore, XCBuild added a facility for copying and
+ postprocessing in one step.
+
+ The scripts supporting each of these approaches are very similar to
+ each other, such that there is a lot of code duplication between them.
+ At the same time, by having two sets of scripts that are very similar
+ to each other, we run the risk of "drift", where files in one set may
+ get updated while their counterparts in the other set are not.
+
+ Address this duplication by making the scripts in the "legacy" set be
+ mere stubs that invoke the scripts in the new "XCBuild" set. In doing
+ this, we also fix a case of drift: the legacy-based scripts made use
+ of a timestamp file to determine if headers needed to be reprocessed
+ and exported, while the XCBuild-based scripts used a "process the
+ files and export them if any actual changes now exist between this new
+ version and any previously-exported version" approach.
+
+ Along the way, fix a bug in WebKitLegacy's postprocess-header-rule
+ that resulted in WebKitAvailability.h not being processed. The
+ practical effect of this bug is that the file ended up with both macOS
+ and iOS code, along with the #if that controlled which chunk of code
+ was compiled, instead of just the chunk of code specific to the
+ targeted SDK. Normally, the unused chunk of code would get removed
+ through the invocation of `unifdef`. But, because of the bug, the
+ results of running `unifdef` were being discarded.
+
+ * postprocess-headers.sh:
+
2020-12-01 Alexey Shvayka <[email protected]>
Remove unused getPrimitiveNumber() methods
Modified: trunk/Source/_javascript_Core/postprocess-headers.sh (270314 => 270315)
--- trunk/Source/_javascript_Core/postprocess-headers.sh 2020-12-01 18:25:47 UTC (rev 270314)
+++ trunk/Source/_javascript_Core/postprocess-headers.sh 2020-12-01 18:39:50 UTC (rev 270315)
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright (C) 2014-2018 Apple Inc. All rights reserved.
+# Copyright (C) 2014-2020 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -24,81 +24,18 @@
# THE POSSIBILITY OF SUCH DAMAGE.
#
-if [[ "${JSC_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED}" == "YES" ]]; then
- exit 0;
-fi
+POSTPROCESS_HEADER_RULE="${SRCROOT}/Scripts/postprocess-header-rule"
+[[ -x "${POSTPROCESS_HEADER_RULE}" ]] || { echo "### Unable to find ${POSTPROCESS_HEADER_RULE}"; exit 1; }
-TIMESTAMP_PATH=${TARGET_TEMP_DIR}/${0##*/}
-
-if [[ -e $TIMESTAMP_PATH && $0 -nt $TIMESTAMP_PATH ]]; then
- rm "${TIMESTAMP_PATH}";
-fi
-
-function process_definitions () {
- local DEFINITIONS_FILE=$1
-
- if [[ ! -f "${DEFINITIONS_FILE}" ]]; then
- return 1
- fi
-
- if [[ -e $TIMESTAMP_PATH && "${DEFINITIONS_FILE}" -nt $TIMESTAMP_PATH ]]; then
- rm "${TIMESTAMP_PATH}";
- 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[*]})
-
+function rewrite_headers ()
+{
for HEADER_PATH in "${1}/"*.h; do
- if [[ "$HEADER_PATH" -nt $TIMESTAMP_PATH ]]; then
- ditto "${HEADER_PATH}" "${TARGET_TEMP_DIR}/${HEADER_PATH##*/}"
- sed -i .tmp -E "${SED_OPTIONS[@]}" "${TARGET_TEMP_DIR}/${HEADER_PATH##*/}" || exit $?
- mv "${TARGET_TEMP_DIR}/${HEADER_PATH##*/}" "$HEADER_PATH"
- fi
+ SCRIPT_HEADER_VISIBILITY="${2}" \
+ SCRIPT_INPUT_FILE="${HEADER_PATH}" \
+ SCRIPT_OUTPUT_FILE_0="${HEADER_PATH}" \
+ "${POSTPROCESS_HEADER_RULE}"
done
}
-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 "${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}"
-rewrite_headers "${TARGET_BUILD_DIR}/${PRIVATE_HEADERS_FOLDER_PATH}"
-
-touch ${TIMESTAMP_PATH}
+rewrite_headers "${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}" Public
+rewrite_headers "${TARGET_BUILD_DIR}/${PRIVATE_HEADERS_FOLDER_PATH}" Private
Modified: trunk/Source/WebKit/ChangeLog (270314 => 270315)
--- trunk/Source/WebKit/ChangeLog 2020-12-01 18:25:47 UTC (rev 270314)
+++ trunk/Source/WebKit/ChangeLog 2020-12-01 18:39:50 UTC (rev 270315)
@@ -1,3 +1,73 @@
+2020-12-01 Keith Rollin <[email protected]>
+
+ Consolidate header postprocessing scripts
+ https://bugs.webkit.org/show_bug.cgi?id=219388
+ <rdar://problem/71840357>
+
+ Reviewed by David Kilzer.
+
+ Our build system contains the following scripts to perform some
+ postprocessing of headers that we export to the SDK:
+
+ _javascript_Core/postprocess-headers.sh
+ WebKit/mac/postprocess-framework-headers.sh
+ WebKitLegacy/mac/postprocess-headers.sh
+
+ The preceding scripts are used when using the non-XCBuild -- or
+ "legacy" -- Xcode build system. They are invoked in a custom Run
+ Script build phase after the headers have been exported with the
+ standard Xcode facility for creating frameworks.
+
+ Alternatively, we also have the following postprocessing scripts:
+
+ WebKit/Scripts/postprocess-header-rule
+ _javascript_Core/Scripts/postprocess-header-rule
+ WebKitLegacy/scripts/postprocess-header-rule
+
+ These scripts are used when using the XCBuild build system. They are
+ invoked *during* the header export process to copy and postprocess the
+ headers in one blow. They are part of a Custom Build Rule for
+ exporting files ending in ".h".
+
+ The reason why we have two sets of scripts is because of the different
+ capabilities of the two Xcode build systems. The legacy system does
+ not support a custom "export header" step that would allow us to copy
+ and postprocess each header in a single step. Therefore, when using
+ the legacy build system, we export in one build step and postprocess
+ in a subsequent build step. And XCBuild doesn't like the approach
+ taken by the old build system where files are exported first and then
+ munged in a separate step, since that confuses its notion of the state
+ of the build ("Hey! That file I exported in the previous build? I see
+ now that it's been changed, so I'm going to export it again. And
+ change its modification date. And then rebuild everything downstream
+ that uses it."). Therefore, XCBuild added a facility for copying and
+ postprocessing in one step.
+
+ The scripts supporting each of these approaches are very similar to
+ each other, such that there is a lot of code duplication between them.
+ At the same time, by having two sets of scripts that are very similar
+ to each other, we run the risk of "drift", where files in one set may
+ get updated while their counterparts in the other set are not.
+
+ Address this duplication by making the scripts in the "legacy" set be
+ mere stubs that invoke the scripts in the new "XCBuild" set. In doing
+ this, we also fix a case of drift: the legacy-based scripts made use
+ of a timestamp file to determine if headers needed to be reprocessed
+ and exported, while the XCBuild-based scripts used a "process the
+ files and export them if any actual changes now exist between this new
+ version and any previously-exported version" approach.
+
+ Along the way, fix a bug in WebKitLegacy's postprocess-header-rule
+ that resulted in WebKitAvailability.h not being processed. The
+ practical effect of this bug is that the file ended up with both macOS
+ and iOS code, along with the #if that controlled which chunk of code
+ was compiled, instead of just the chunk of code specific to the
+ targeted SDK. Normally, the unused chunk of code would get removed
+ through the invocation of `unifdef`. But, because of the bug, the
+ results of running `unifdef` were being discarded.
+
+ * mac/postprocess-framework-headers.sh:
+
2020-12-01 Kate Cheney <[email protected]>
ITP logging mixes up the UI process ITP state with the Settings ITP state
Modified: trunk/Source/WebKit/mac/postprocess-framework-headers.sh (270314 => 270315)
--- trunk/Source/WebKit/mac/postprocess-framework-headers.sh 2020-12-01 18:25:47 UTC (rev 270314)
+++ trunk/Source/WebKit/mac/postprocess-framework-headers.sh 2020-12-01 18:39:50 UTC (rev 270315)
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright (C) 2014 Apple Inc. All rights reserved.
+# Copyright (C) 2014-2020 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -24,74 +24,18 @@
# THE POSSIBILITY OF SUCH DAMAGE.
#
-if [[ "${WK_FRAMEWORK_HEADER_POSTPROCESSING_DISABLED}" == "YES" ]]; then
- exit 0;
-fi
+POSTPROCESS_HEADER_RULE="${SRCROOT}/Scripts/postprocess-header-rule"
+[[ -x "${POSTPROCESS_HEADER_RULE}" ]] || { echo "### Unable to find ${POSTPROCESS_HEADER_RULE}"; exit 1; }
-TIMESTAMP_PATH=${TARGET_TEMP_DIR}/${0##*/}
-
-if [[ -e $TIMESTAMP_PATH && $0 -nt $TIMESTAMP_PATH ]]; then
- rm "${TIMESTAMP_PATH}";
-fi
-
-function process_definitions () {
- local DEFINITIONS_FILE=$1
-
- if [[ ! -f "${DEFINITIONS_FILE}" ]]; then
- return 1
- fi
-
- if [[ -e $TIMESTAMP_PATH && "${DEFINITIONS_FILE}" -nt $TIMESTAMP_PATH ]]; then
- rm "${TIMESTAMP_PATH}";
- fi
-
- source "${DEFINITIONS_FILE}"
-}
-
-function rewrite_headers () {
- 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[*]})
-
+function rewrite_headers ()
+{
for HEADER_PATH in "${1}/"*.h; do
- if [[ "$HEADER_PATH" -nt $TIMESTAMP_PATH ]]; then
- ditto "${HEADER_PATH}" "${TARGET_TEMP_DIR}/${HEADER_PATH##*/}"
- sed -i .tmp -E "${SED_OPTIONS[@]}" "${TARGET_TEMP_DIR}/${HEADER_PATH##*/}" || exit $?
- mv "${TARGET_TEMP_DIR}/${HEADER_PATH##*/}" "$HEADER_PATH"
- fi
+ SCRIPT_HEADER_VISIBILITY="${2}" \
+ SCRIPT_INPUT_FILE="${HEADER_PATH}" \
+ SCRIPT_OUTPUT_FILE_0="${HEADER_PATH}" \
+ "${POSTPROCESS_HEADER_RULE}"
done
}
-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 "${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}"
-rewrite_headers "${TARGET_BUILD_DIR}/${PRIVATE_HEADERS_FOLDER_PATH}"
-
-touch ${TIMESTAMP_PATH}
+rewrite_headers "${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}" Public
+rewrite_headers "${TARGET_BUILD_DIR}/${PRIVATE_HEADERS_FOLDER_PATH}" Private
Modified: trunk/Source/WebKitLegacy/ChangeLog (270314 => 270315)
--- trunk/Source/WebKitLegacy/ChangeLog 2020-12-01 18:25:47 UTC (rev 270314)
+++ trunk/Source/WebKitLegacy/ChangeLog 2020-12-01 18:39:50 UTC (rev 270315)
@@ -1,3 +1,73 @@
+2020-12-01 Keith Rollin <[email protected]>
+
+ Consolidate header postprocessing scripts
+ https://bugs.webkit.org/show_bug.cgi?id=219388
+ <rdar://problem/71840357>
+
+ Reviewed by David Kilzer.
+
+ Our build system contains the following scripts to perform some
+ postprocessing of headers that we export to the SDK:
+
+ _javascript_Core/postprocess-headers.sh
+ WebKit/mac/postprocess-framework-headers.sh
+ WebKitLegacy/mac/postprocess-headers.sh
+
+ The preceding scripts are used when using the non-XCBuild -- or
+ "legacy" -- Xcode build system. They are invoked in a custom Run
+ Script build phase after the headers have been exported with the
+ standard Xcode facility for creating frameworks.
+
+ Alternatively, we also have the following postprocessing scripts:
+
+ WebKit/Scripts/postprocess-header-rule
+ _javascript_Core/Scripts/postprocess-header-rule
+ WebKitLegacy/scripts/postprocess-header-rule
+
+ These scripts are used when using the XCBuild build system. They are
+ invoked *during* the header export process to copy and postprocess the
+ headers in one blow. They are part of a Custom Build Rule for
+ exporting files ending in ".h".
+
+ The reason why we have two sets of scripts is because of the different
+ capabilities of the two Xcode build systems. The legacy system does
+ not support a custom "export header" step that would allow us to copy
+ and postprocess each header in a single step. Therefore, when using
+ the legacy build system, we export in one build step and postprocess
+ in a subsequent build step. And XCBuild doesn't like the approach
+ taken by the old build system where files are exported first and then
+ munged in a separate step, since that confuses its notion of the state
+ of the build ("Hey! That file I exported in the previous build? I see
+ now that it's been changed, so I'm going to export it again. And
+ change its modification date. And then rebuild everything downstream
+ that uses it."). Therefore, XCBuild added a facility for copying and
+ postprocessing in one step.
+
+ The scripts supporting each of these approaches are very similar to
+ each other, such that there is a lot of code duplication between them.
+ At the same time, by having two sets of scripts that are very similar
+ to each other, we run the risk of "drift", where files in one set may
+ get updated while their counterparts in the other set are not.
+
+ Address this duplication by making the scripts in the "legacy" set be
+ mere stubs that invoke the scripts in the new "XCBuild" set. In doing
+ this, we also fix a case of drift: the legacy-based scripts made use
+ of a timestamp file to determine if headers needed to be reprocessed
+ and exported, while the XCBuild-based scripts used a "process the
+ files and export them if any actual changes now exist between this new
+ version and any previously-exported version" approach.
+
+ Along the way, fix a bug in WebKitLegacy's postprocess-header-rule
+ that resulted in WebKitAvailability.h not being processed. The
+ practical effect of this bug is that the file ended up with both macOS
+ and iOS code, along with the #if that controlled which chunk of code
+ was compiled, instead of just the chunk of code specific to the
+ targeted SDK. Normally, the unused chunk of code would get removed
+ through the invocation of `unifdef`. But, because of the bug, the
+ results of running `unifdef` were being discarded.
+
+ * scripts/postprocess-header-rule:
+
2020-11-04 David Kilzer <[email protected]>
WebKit should remove unused debug variant support
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (270314 => 270315)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2020-12-01 18:25:47 UTC (rev 270314)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2020-12-01 18:39:50 UTC (rev 270315)
@@ -1,3 +1,73 @@
+2020-12-01 Keith Rollin <[email protected]>
+
+ Consolidate header postprocessing scripts
+ https://bugs.webkit.org/show_bug.cgi?id=219388
+ <rdar://problem/71840357>
+
+ Reviewed by David Kilzer.
+
+ Our build system contains the following scripts to perform some
+ postprocessing of headers that we export to the SDK:
+
+ _javascript_Core/postprocess-headers.sh
+ WebKit/mac/postprocess-framework-headers.sh
+ WebKitLegacy/mac/postprocess-headers.sh
+
+ The preceding scripts are used when using the non-XCBuild -- or
+ "legacy" -- Xcode build system. They are invoked in a custom Run
+ Script build phase after the headers have been exported with the
+ standard Xcode facility for creating frameworks.
+
+ Alternatively, we also have the following postprocessing scripts:
+
+ WebKit/Scripts/postprocess-header-rule
+ _javascript_Core/Scripts/postprocess-header-rule
+ WebKitLegacy/scripts/postprocess-header-rule
+
+ These scripts are used when using the XCBuild build system. They are
+ invoked *during* the header export process to copy and postprocess the
+ headers in one blow. They are part of a Custom Build Rule for
+ exporting files ending in ".h".
+
+ The reason why we have two sets of scripts is because of the different
+ capabilities of the two Xcode build systems. The legacy system does
+ not support a custom "export header" step that would allow us to copy
+ and postprocess each header in a single step. Therefore, when using
+ the legacy build system, we export in one build step and postprocess
+ in a subsequent build step. And XCBuild doesn't like the approach
+ taken by the old build system where files are exported first and then
+ munged in a separate step, since that confuses its notion of the state
+ of the build ("Hey! That file I exported in the previous build? I see
+ now that it's been changed, so I'm going to export it again. And
+ change its modification date. And then rebuild everything downstream
+ that uses it."). Therefore, XCBuild added a facility for copying and
+ postprocessing in one step.
+
+ The scripts supporting each of these approaches are very similar to
+ each other, such that there is a lot of code duplication between them.
+ At the same time, by having two sets of scripts that are very similar
+ to each other, we run the risk of "drift", where files in one set may
+ get updated while their counterparts in the other set are not.
+
+ Address this duplication by making the scripts in the "legacy" set be
+ mere stubs that invoke the scripts in the new "XCBuild" set. In doing
+ this, we also fix a case of drift: the legacy-based scripts made use
+ of a timestamp file to determine if headers needed to be reprocessed
+ and exported, while the XCBuild-based scripts used a "process the
+ files and export them if any actual changes now exist between this new
+ version and any previously-exported version" approach.
+
+ Along the way, fix a bug in WebKitLegacy's postprocess-header-rule
+ that resulted in WebKitAvailability.h not being processed. The
+ practical effect of this bug is that the file ended up with both macOS
+ and iOS code, along with the #if that controlled which chunk of code
+ was compiled, instead of just the chunk of code specific to the
+ targeted SDK. Normally, the unused chunk of code would get removed
+ through the invocation of `unifdef`. But, because of the bug, the
+ results of running `unifdef` were being discarded.
+
+ * postprocess-headers.sh:
+
2020-11-30 Chris Dumez <[email protected]>
sessionStorage should not be cloned when a window is opened with rel=noopener
Modified: trunk/Source/WebKitLegacy/mac/postprocess-headers.sh (270314 => 270315)
--- trunk/Source/WebKitLegacy/mac/postprocess-headers.sh 2020-12-01 18:25:47 UTC (rev 270314)
+++ trunk/Source/WebKitLegacy/mac/postprocess-headers.sh 2020-12-01 18:39:50 UTC (rev 270315)
@@ -1,73 +1,41 @@
#!/bin/sh
+#
+# Copyright (C) 2014-2020 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.
+#
-postProcessInDirectory()
+POSTPROCESS_HEADER_RULE="${SRCROOT}/scripts/postprocess-header-rule"
+[[ -x "${POSTPROCESS_HEADER_RULE}" ]] || { echo "### Unable to find ${POSTPROCESS_HEADER_RULE}"; exit 1; }
+
+function rewrite_headers ()
{
- touch -r "$1" "${TARGET_TEMP_DIR}/postprocess-headers-saved.timestamp"
-
- cd "$1"
-
- local unifdefOptions
-
- 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
+ for HEADER_PATH in "${1}/"*.h; do
+ SCRIPT_HEADER_VISIBILITY="${2}" \
+ SCRIPT_INPUT_FILE="${HEADER_PATH}" \
+ SCRIPT_OUTPUT_FILE_0="${HEADER_PATH}" \
+ "${POSTPROCESS_HEADER_RULE}"
done
-
- for header in $(find . -name '*.h' -type f); do
- 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
- continue
- 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
- done
-
- touch -r "${TARGET_TEMP_DIR}/postprocess-headers-saved.timestamp" "$1"
}
-postProcessInDirectory "${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}"
-postProcessInDirectory "${TARGET_BUILD_DIR}/${PRIVATE_HEADERS_FOLDER_PATH}"
-
-touch "${DERIVED_FILE_DIR}/postprocess-headers.timestamp"
+rewrite_headers "${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}" Public
+rewrite_headers "${TARGET_BUILD_DIR}/${PRIVATE_HEADERS_FOLDER_PATH}" Private
Modified: trunk/Source/WebKitLegacy/scripts/postprocess-header-rule (270314 => 270315)
--- trunk/Source/WebKitLegacy/scripts/postprocess-header-rule 2020-12-01 18:25:47 UTC (rev 270314)
+++ trunk/Source/WebKitLegacy/scripts/postprocess-header-rule 2020-12-01 18:39:50 UTC (rev 270315)
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (C) 2019 Apple Inc. All rights reserved.
+# Copyright (C) 2019-2020 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -70,13 +70,11 @@
esac
HEADER_NAME=$(basename "${WORK_FILE}" '.tmp')
-if [[ "${HEADER_NAME}" == "WebKitAvailability.h" ]]; then
- exit 0
+if [[ "${HEADER_NAME}" != "WebKitAvailability.h" ]]; then
+ if [[ ${WK_PLATFORM_NAME} != macosx ]]; then
+ sed -i '' -E -e "s/ *WEBKIT_((CLASS_|ENUM_)?(AVAILABLE|DEPRECATED))_MAC\([^)]+\)//g" "${WORK_FILE}"
+ fi
fi
-if [[ ${WK_PLATFORM_NAME} != macosx ]]; then
- sed -i '' -E -e "s/ *WEBKIT_((CLASS_|ENUM_)?(AVAILABLE|DEPRECATED))_MAC\([^)]+\)//g" "${WORK_FILE}"
-fi
-
cmp -s "${WORK_FILE}" "${DEST_FILE}" && rm -f "${WORK_FILE}" || mv "${WORK_FILE}" "${DEST_FILE}"
[[ "${SOURCE_FILE}" -nt "${DEST_FILE}" ]] && touch "${DEST_FILE}" || true