Title: [290805] trunk/Source
Revision
290805
Author
msab...@apple.com
Date
2022-03-03 17:26:55 -0800 (Thu, 03 Mar 2022)

Log Message

Copy WebKit frameworks and XPC processes to Secondary Path
https://bugs.webkit.org/show_bug.cgi?id=237394

Reviewed by Saam Barati.

Source/_javascript_Core:

Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
when it is set.

* Configurations/Base.xcconfig:
* _javascript_Core.xcodeproj/project.pbxproj:
* Scripts/copy-frameworks-to-secondary-path.sh: Added.

Source/ThirdParty/ANGLE:

Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
when it is set.

* ANGLE.xcodeproj/project.pbxproj:
* Configurations/ANGLE-dynamic.xcconfig:
* scripts/copy-frameworks-to-secondary-path.sh: Added.

Source/ThirdParty/libwebrtc:

Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
when it is set.

* Configurations/libwebrtc.xcconfig:
* Scripts/copy-frameworks-to-secondary-path.sh: Added.
* libwebrtc.xcodeproj/project.pbxproj:

Source/WebCore:

Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
when it is set.

* Configurations/WebCore.xcconfig:
* Scripts/copy-frameworks-to-secondary-path.sh: Added.
* WebCore.xcodeproj/project.pbxproj:

Source/WebGPU:

Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
when it is set.

* Configurations/WebGPU.xcconfig:
* Scripts/copy-frameworks-to-secondary-path.sh: Added.
* WebGPU.xcodeproj/project.pbxproj:

Source/WebInspectorUI:

Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
when it is set.

* Configurations/WebInspectorUIFramework.xcconfig:
* Scripts/copy-frameworks-to-secondary-path.sh: Added.
* WebInspectorUI.xcodeproj/project.pbxproj:

Source/WebKit:

Added build configuration variables and scripts to copy the built Framework as well as the XPC services 
to the SYSTEM_SECONDARY_CONTENT_PATH when it is set.  When copying the XPC services, we update the XPC
binaries to reference the frameworks from the SYSTEM_SECONDARY_CONTENT_PATH by updating
DYLD_VERSIONED_FRAMEWORK_PATH.

* Configurations/Base.xcconfig:
* Configurations/WebKitSwift.xcconfig:
* Scripts/copy-frameworks-to-secondary-path.sh: Added.
* Scripts/copy-xpc-services-to-secondary-path.sh: Added.
* Scripts/update-dyld-environment-load-command: Added.
* Scripts/webkitpy: Added.
* Scripts/webkitpy/mach_o.py: Added.
(_utf8_bytes_to_str):
(_mach_o_int_field):
(_mach_o_int_field._get_mach_o_int_field):
(_mach_o_int_field._set_mach_o_int_field):
(_mach_o_int_field._set_mach_o_int_field.func):
(_mach_o_chararray_field):
(_mach_o_chararray_field._get_mach_o_chararray_field):
(_mach_o_chararray_field._set_mach_o_chararray_field):
(_mach_o_chararray_field._set_mach_o_chararray_field.func):
(_mach_o_varchar_field):
(_mach_o_varchar_field._get_mach_o_varchar_field):
(_mach_o_varchar_field._set_mach_o_varchar_field):
(_mach_o_varchar_field._set_mach_o_varchar_field.func):
(MachOCommand):
(MachOCommand.__init__):
(MachOSourceVersionCommand):
(MachOSourceVersionCommand.version_str):
(MachOSection):
(MachOSection.__init__):
(MachOSegmentCommand):
(MachOSection32):
(MachOSegment32Command):
(MachOSegment32Command.__init__):
(MachOSection64):
(MachOSegment64Command):
(MachOSegment64Command.__init__):
(MachOLoadDylibCommand):
(MachOLoadDylibCommand._version_str):
(MachOLoadDylibCommand.compatibility_version_str):
(MachOLoadDylibCommand.current_version_str):
(MachODyldEnvironmentCommand):
(MachODyldEnvironmentCommand.variable):
(MachODyldEnvironmentCommand.value):
(MachODyldEnvironmentCommand.build):
(MachOIDDylibCommand):
(MachOHeader):
(MachOHeader.__init__):
(MachOHeader.used_header_size):
(MachOHeader.total_header_size):
(MachOHeader.available_header_size):
(MachOHeader.architecture_name):
(MachOHeader.id_command):
(MachOHeader.dyld_env_commands):
(MachOHeader.dyld_versioned_framework_paths):
(MachOHeader.filter_commands):
(MachOHeader.update_file):
(MachOHeader.parse_command):
(MachOHeader32LE):
(MachOHeader32LE.__init__):
(MachOHeader64LE):
(MachOHeader64LE.__init__):
(MachOFile):
(MachOFile.__init__):
(is_macho_bytes):
(is_macho_file):
(enumerate_macho_files):
* WebKit.xcodeproj/project.pbxproj:

Source/WebKitLegacy:

Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
when it is set.

* WebKitLegacy.xcodeproj/project.pbxproj:
* scripts/copy-frameworks-to-secondary-path.sh: Added.

Source/WebKitLegacy/mac:

Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
when it is set.

* Configurations/Base.xcconfig:

Modified Paths

Added Paths

Removed Paths

  • trunk/Source/ThirdParty/libwebrtc/Scripts/

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (290804 => 290805)


--- trunk/Source/_javascript_Core/ChangeLog	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-03-04 01:26:55 UTC (rev 290805)
@@ -1,3 +1,17 @@
+2022-03-03  Michael Saboff  <msab...@apple.com>
+
+        Copy WebKit frameworks and XPC processes to Secondary Path
+        https://bugs.webkit.org/show_bug.cgi?id=237394
+
+        Reviewed by Saam Barati.
+
+        Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
+        when it is set.
+
+        * Configurations/Base.xcconfig:
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        * Scripts/copy-frameworks-to-secondary-path.sh: Added.
+
 2022-03-03  Tom Tartarin  <t...@leaningtech.com>
 
         [JSC] Update wasm branch hinting

Modified: trunk/Source/_javascript_Core/Configurations/Base.xcconfig (290804 => 290805)


--- trunk/Source/_javascript_Core/Configurations/Base.xcconfig	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/_javascript_Core/Configurations/Base.xcconfig	2022-03-04 01:26:55 UTC (rev 290805)
@@ -33,6 +33,9 @@
 
 INSTALL_PATH_PREFIX = $(INSTALL_PATH_PREFIX_$(USE_SYSTEM_CONTENT_PATH));
 INSTALL_PATH_PREFIX_YES = $(SYSTEM_CONTENT_PATH);
+SECONDARY_STAGED_FRAMEWORK_DIRECTORY = $(SYSTEM_SECONDARY_CONTENT_PATH)$(SYSTEM_LIBRARY_DIR)/StagedFrameworks/Safari
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH = NO
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH[sdk=macos*] = $(USE_SYSTEM_CONTENT_PATH)
 
 ALWAYS_SEARCH_USER_PATHS = NO;
 

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (290804 => 290805)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2022-03-04 01:26:55 UTC (rev 290805)
@@ -11556,6 +11556,7 @@
 				1A02D9A81B34A882000D1522 /* Add Symlink in /System/Library/PrivateFrameworks */,
 				53609F9021DFFA9C008FA60A /* Check .xcfilelists */,
 				6577FFC6276AC8D20011AEC8 /* Create Symlink to Alt Root Path */,
+				6517571427C9860C00D9FE40 /* Copy Frameworks to Secondary Path */,
 			);
 			buildRules = (
 				535E08C222545AC800DF00CA /* PBXBuildRule */,
@@ -11922,6 +11923,24 @@
 			shellPath = /bin/sh;
 			shellScript = "set -e\n\n# Skip for Production builds.\nif [[ ${CONFIGURATION:=Debug} == \"Production\" ]]; then\n    exit\nfi\n\nmkdir -p \"${BUILT_PRODUCTS_DIR}/${_javascript_CORE_HELPERS_DIR}\"\nditto \"${BUILT_PRODUCTS_DIR}/jsc\" \"${BUILT_PRODUCTS_DIR}/${_javascript_CORE_HELPERS_DIR}/jsc\"\n";
 		};
+		6517571427C9860C00D9FE40 /* Copy Frameworks to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy Frameworks to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH=\"_javascript_Core\"\n\"${SRCROOT}/Scripts/copy-frameworks-to-secondary-path.sh\"\n";
+		};
 		6577FFC6276AC8D20011AEC8 /* Create Symlink to Alt Root Path */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 8;

Added: trunk/Source/_javascript_Core/Scripts/copy-frameworks-to-secondary-path.sh (0 => 290805)


--- trunk/Source/_javascript_Core/Scripts/copy-frameworks-to-secondary-path.sh	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/copy-frameworks-to-secondary-path.sh	2022-03-04 01:26:55 UTC (rev 290805)
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -e
+
+if [[ "${DEPLOYMENT_LOCATION}" != "YES" ]]; then
+    echo "error: $(basename $0) should only be run for deployment-style (\"production\" / \"non-engineering\") builds."
+    exit 1
+fi
+
+if [[ "${USE_SYSTEM_CONTENT_PATH}" != "YES" || "${COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH}" != "YES" ]]; then
+    echo "Skipping copying frameworks to secondary content path."
+    exit 0
+fi
+
+if [[ "${ACTION}" == "installapi" || "${ACTION}" == "installhdrs" ]]; then
+    echo "Skipping copying frameworks to secondary content path for installapi or installhdrs action."
+    exit 0
+fi
+
+if [[ -z "${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH}" && -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    echo "warning: Neither FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH or DYLIBS_TO_COPY_TO_SECONDARY_PATH are set."
+fi
+
+if [[ -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    echo "error: SECONDARY_STAGED_FRAMEWORK_DIRECTORY is not set."
+    exit 1
+fi
+
+function copy_product_to_destination_framework_directory
+{
+    PRODUCT_COMPONENT=$1
+
+    # In deployment builds, BUILT_PRODUCTS_DIR doesn't point to the actual location of any products,
+    # but to a single folder of symlinks to all built products, regardless of whether they are actually
+    # being installed. We need to copy the actual products to the secondary content path, *not* just a symlink.
+    SOURCE_PRODUCT_PATH="$(readlink "${BUILT_PRODUCTS_DIR}/${PRODUCT_COMPONENT}")"
+
+    echo "Copying ${SOURCE_PRODUCT_PATH} to ${DESTINATION_FRAMEWORK_DIRECTORY}"
+    rsync -aE "${SOURCE_PRODUCT_PATH}" "${DESTINATION_FRAMEWORK_DIRECTORY}"
+}
+
+if [[ ! -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for FRAMEWORK_NAME in $(echo ${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        FRAMEWORK_BUNDLE_NAME="${FRAMEWORK_NAME}.framework"
+
+        copy_product_to_destination_framework_directory ${FRAMEWORK_BUNDLE_NAME}
+    done
+fi
+
+if [[ ! -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}${STAGED_DYLIB_FRAMEWORK_PATH}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for DYLIB in $(echo ${DYLIBS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        copy_product_to_destination_framework_directory ${DYLIB}
+    done
+fi
Property changes on: trunk/Source/_javascript_Core/Scripts/copy-frameworks-to-secondary-path.sh
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Modified: trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj (290804 => 290805)


--- trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj	2022-03-04 01:26:55 UTC (rev 290805)
@@ -3506,6 +3506,7 @@
 				31CD00CE2491974C00486F27 /* CopyFiles */,
 				31CD00CF2491976800486F27 /* CopyFiles */,
 				31CD00D2249197FD00486F27 /* Adjust ANGLE Paths */,
+				6517572227CEED7200D9FE40 /* Copy Frameworks to Secondary Path */,
 			);
 			buildRules = (
 				31A9E9A0249AA04200C7E243 /* PBXBuildRule */,
@@ -3594,6 +3595,24 @@
 			shellPath = /bin/sh;
 			shellScript = "if [ \"${XCODE_VERSION_ACTUAL}\" -ge \"1140\" -a \"${WK_USE_NEW_BUILD_SYSTEM}\" = \"YES\" ]; then\n    # In this configuration, post-processing is performed at the same time as copying in the postprocess-header-rule script, so there's no need for this separate step.\n    exit 0\nfi\n\nexec \"$SRCROOT/adjust-angle-include-paths.py\"\n";
 		};
+		6517572227CEED7200D9FE40 /* Copy Frameworks to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy Frameworks to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export DYLIBS_TO_COPY_TO_SECONDARY_PATH=\"libANGLE-shared.dylib\"\n\"${SRCROOT}/scripts/copy-frameworks-to-secondary-path.sh\"\n";
+		};
 		FFDA50D5269F895400AE11E2 /* Bake Metal Library to NSData */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 2147483647;

Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (290804 => 290805)


--- trunk/Source/ThirdParty/ANGLE/ChangeLog	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog	2022-03-04 01:26:55 UTC (rev 290805)
@@ -1,3 +1,17 @@
+2022-03-02  Michael Saboff  <msab...@apple.com>
+
+        Copy WebKit frameworks and XPC processes to Secondary Path
+        https://bugs.webkit.org/show_bug.cgi?id=237394
+
+        Reviewed by Saam Barati.
+
+        Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
+        when it is set.
+
+        * ANGLE.xcodeproj/project.pbxproj:
+        * Configurations/ANGLE-dynamic.xcconfig:
+        * scripts/copy-frameworks-to-secondary-path.sh: Added.
+
 2022-02-24  Kyle Piddington  <kpidding...@apple.com>
         
         Roll ANGLE to Feb 18 2022 (78c64dd74ee5)

Modified: trunk/Source/ThirdParty/ANGLE/Configurations/ANGLE-dynamic.xcconfig (290804 => 290805)


--- trunk/Source/ThirdParty/ANGLE/Configurations/ANGLE-dynamic.xcconfig	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/ThirdParty/ANGLE/Configurations/ANGLE-dynamic.xcconfig	2022-03-04 01:26:55 UTC (rev 290805)
@@ -16,6 +16,10 @@
 
 INSTALL_PATH_PREFIX = $(INSTALL_PATH_PREFIX_USE_SYSTEM_CONTENT_PATH_$(USE_SYSTEM_CONTENT_PATH));
 INSTALL_PATH_PREFIX_USE_SYSTEM_CONTENT_PATH_YES = $(SYSTEM_CONTENT_PATH);
+SECONDARY_STAGED_FRAMEWORK_DIRECTORY = $(SYSTEM_SECONDARY_CONTENT_PATH)$(SYSTEM_LIBRARY_DIR)/StagedFrameworks/Safari
+STAGED_DYLIB_FRAMEWORK_PATH=/WebCore.framework/Versions/A/Frameworks
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH = NO
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH[sdk=macos*] = $(USE_SYSTEM_CONTENT_PATH)
 
 INSTALL_PATH = $(INSTALL_PATH_PREFIX)$(NORMAL_WEBCORE_FRAMEWORKS_DIR)/WebCore.framework/Frameworks;
 INSTALL_PATH[sdk=macosx*] = $(INSTALL_PATH_USE_ALTERNATE_FRAMEWORKS_DIR_$(WK_USE_ALTERNATE_FRAMEWORKS_DIR));

Added: trunk/Source/ThirdParty/ANGLE/scripts/copy-frameworks-to-secondary-path.sh (0 => 290805)


--- trunk/Source/ThirdParty/ANGLE/scripts/copy-frameworks-to-secondary-path.sh	                        (rev 0)
+++ trunk/Source/ThirdParty/ANGLE/scripts/copy-frameworks-to-secondary-path.sh	2022-03-04 01:26:55 UTC (rev 290805)
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -e
+
+if [[ "${DEPLOYMENT_LOCATION}" != "YES" ]]; then
+    echo "error: $(basename $0) should only be run for deployment-style (\"production\" / \"non-engineering\") builds."
+    exit 1
+fi
+
+if [[ "${USE_SYSTEM_CONTENT_PATH}" != "YES" || "${COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH}" != "YES" ]]; then
+    echo "Skipping copying frameworks to secondary content path."
+    exit 0
+fi
+
+if [[ "${ACTION}" == "installapi" || "${ACTION}" == "installhdrs" ]]; then
+    echo "Skipping copying frameworks to secondary content path for installapi or installhdrs action."
+    exit 0
+fi
+
+if [[ -z "${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH}" && -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    echo "warning: Neither FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH or DYLIBS_TO_COPY_TO_SECONDARY_PATH are set."
+fi
+
+if [[ -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    echo "error: SECONDARY_STAGED_FRAMEWORK_DIRECTORY is not set."
+    exit 1
+fi
+
+function copy_product_to_destination_framework_directory
+{
+    PRODUCT_COMPONENT=$1
+
+    # In deployment builds, BUILT_PRODUCTS_DIR doesn't point to the actual location of any products,
+    # but to a single folder of symlinks to all built products, regardless of whether they are actually
+    # being installed. We need to copy the actual products to the secondary content path, *not* just a symlink.
+    SOURCE_PRODUCT_PATH="$(readlink "${BUILT_PRODUCTS_DIR}/${PRODUCT_COMPONENT}")"
+
+    echo "Copying ${SOURCE_PRODUCT_PATH} to ${DESTINATION_FRAMEWORK_DIRECTORY}"
+    rsync -aE "${SOURCE_PRODUCT_PATH}" "${DESTINATION_FRAMEWORK_DIRECTORY}"
+}
+
+if [[ ! -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for FRAMEWORK_NAME in $(echo ${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        FRAMEWORK_BUNDLE_NAME="${FRAMEWORK_NAME}.framework"
+
+        copy_product_to_destination_framework_directory ${FRAMEWORK_BUNDLE_NAME}
+    done
+fi
+
+if [[ ! -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}${STAGED_DYLIB_FRAMEWORK_PATH}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for DYLIB in $(echo ${DYLIBS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        copy_product_to_destination_framework_directory ${DYLIB}
+    done
+fi
Property changes on: trunk/Source/ThirdParty/ANGLE/scripts/copy-frameworks-to-secondary-path.sh
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (290804 => 290805)


--- trunk/Source/ThirdParty/libwebrtc/ChangeLog	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog	2022-03-04 01:26:55 UTC (rev 290805)
@@ -1,3 +1,17 @@
+2022-03-02  Michael Saboff  <msab...@apple.com>
+
+        Copy WebKit frameworks and XPC processes to Secondary Path
+        https://bugs.webkit.org/show_bug.cgi?id=237394
+
+        Reviewed by Saam Barati.
+
+        Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
+        when it is set.
+
+        * Configurations/libwebrtc.xcconfig:
+        * Scripts/copy-frameworks-to-secondary-path.sh: Added.
+        * libwebrtc.xcodeproj/project.pbxproj:
+
 2022-02-18  Robert Jenner  <jen...@apple.com>
 
         Unreviewed, reverting r290149.

Modified: trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.xcconfig (290804 => 290805)


--- trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.xcconfig	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.xcconfig	2022-03-04 01:26:55 UTC (rev 290805)
@@ -33,6 +33,10 @@
 
 INSTALL_PATH_PREFIX = $(INSTALL_PATH_PREFIX_USE_SYSTEM_CONTENT_PATH_$(USE_SYSTEM_CONTENT_PATH));
 INSTALL_PATH_PREFIX_USE_SYSTEM_CONTENT_PATH_YES = $(SYSTEM_CONTENT_PATH);
+SECONDARY_STAGED_FRAMEWORK_DIRECTORY = $(SYSTEM_SECONDARY_CONTENT_PATH)$(SYSTEM_LIBRARY_DIR)/StagedFrameworks/Safari
+STAGED_DYLIB_FRAMEWORK_PATH=/WebCore.framework/Versions/A/Frameworks
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH = NO
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH[sdk=macos*] = $(USE_SYSTEM_CONTENT_PATH)
 
 INSTALL_PATH = $(INSTALL_PATH_PREFIX)$(NORMAL_WEBCORE_FRAMEWORKS_DIR)/WebCore.framework/Frameworks;
 INSTALL_PATH[sdk=macosx*] = $(INSTALL_PATH_USE_OVERRIDE_FRAMEWORKS_DIR_$(WK_USE_OVERRIDE_FRAMEWORKS_DIR));

Added: trunk/Source/ThirdParty/libwebrtc/Scripts/copy-frameworks-to-secondary-path.sh (0 => 290805)


--- trunk/Source/ThirdParty/libwebrtc/Scripts/copy-frameworks-to-secondary-path.sh	                        (rev 0)
+++ trunk/Source/ThirdParty/libwebrtc/Scripts/copy-frameworks-to-secondary-path.sh	2022-03-04 01:26:55 UTC (rev 290805)
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -e
+
+if [[ "${DEPLOYMENT_LOCATION}" != "YES" ]]; then
+    echo "error: $(basename $0) should only be run for deployment-style (\"production\" / \"non-engineering\") builds."
+    exit 1
+fi
+
+if [[ "${USE_SYSTEM_CONTENT_PATH}" != "YES" || "${COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH}" != "YES" ]]; then
+    echo "Skipping copying frameworks to secondary content path."
+    exit 0
+fi
+
+if [[ "${ACTION}" == "installapi" || "${ACTION}" == "installhdrs" ]]; then
+    echo "Skipping copying frameworks to secondary content path for installapi or installhdrs action."
+    exit 0
+fi
+
+if [[ -z "${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH}" && -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    echo "warning: Neither FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH or DYLIBS_TO_COPY_TO_SECONDARY_PATH are set."
+fi
+
+if [[ -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    echo "error: SECONDARY_STAGED_FRAMEWORK_DIRECTORY is not set."
+    exit 1
+fi
+
+function copy_product_to_destination_framework_directory
+{
+    PRODUCT_COMPONENT=$1
+
+    # In deployment builds, BUILT_PRODUCTS_DIR doesn't point to the actual location of any products,
+    # but to a single folder of symlinks to all built products, regardless of whether they are actually
+    # being installed. We need to copy the actual products to the secondary content path, *not* just a symlink.
+    SOURCE_PRODUCT_PATH="$(readlink "${BUILT_PRODUCTS_DIR}/${PRODUCT_COMPONENT}")"
+
+    echo "Copying ${SOURCE_PRODUCT_PATH} to ${DESTINATION_FRAMEWORK_DIRECTORY}"
+    rsync -aE "${SOURCE_PRODUCT_PATH}" "${DESTINATION_FRAMEWORK_DIRECTORY}"
+}
+
+if [[ ! -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for FRAMEWORK_NAME in $(echo ${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        FRAMEWORK_BUNDLE_NAME="${FRAMEWORK_NAME}.framework"
+
+        copy_product_to_destination_framework_directory ${FRAMEWORK_BUNDLE_NAME}
+    done
+fi
+
+if [[ ! -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}${STAGED_DYLIB_FRAMEWORK_PATH}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for DYLIB in $(echo ${DYLIBS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        copy_product_to_destination_framework_directory ${DYLIB}
+    done
+fi
Property changes on: trunk/Source/ThirdParty/libwebrtc/Scripts/copy-frameworks-to-secondary-path.sh
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Added: trunk/Source/ThirdParty/libwebrtc/Scripts/create-symlink-to-altroot.sh (0 => 290805)


--- trunk/Source/ThirdParty/libwebrtc/Scripts/create-symlink-to-altroot.sh	                        (rev 0)
+++ trunk/Source/ThirdParty/libwebrtc/Scripts/create-symlink-to-altroot.sh	2022-03-04 01:26:55 UTC (rev 290805)
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+set -e
+
+if [[ "${SKIP_INSTALL}" == "YES" ]]; then
+    exit 0
+fi
+
+if [[ -z "${SYSTEM_PUBLIC_HEADER_PREFIX}" || -z "${HEADER_FOLDER_LIST}" || -z "${SYSTEM_PUBLIC_LIBRARY_PREFIX}" || -z "${LIBRARY_LIST}" ]]; then
+    exit 0
+fi
+
+create_symlink_if_needed()
+{
+    INSTALL_FOLDER_PREFIX=$1
+    PUBLIC_FOLDER_PREFIX=$2
+    SYSTEM_FOLDER_PREFIX=$3
+    TARGET=$4
+
+    SYSTEM_HEADER_PATH="${SYSTEM_FOLDER_PREFIX}/${TARGET}"
+
+    # Convert eg. `/System/Library/PrivateFrameworks` to `../../..`
+    RELATIVE_PATH_FROM_SYMLINK_TO_ROOT=$(echo "${PUBLIC_FOLDER_PREFIX}" | sed -E -e "s/\/[a-zA-Z0-9_]+/..\//g" -e "s/\/$//")
+    SYMLINK_VALUE="${RELATIVE_PATH_FROM_SYMLINK_TO_ROOT}${INSTALL_FOLDER_PREFIX}/${TARGET}"
+
+    if [[ -L "${SYSTEM_HEADER_PATH}" ]]; then
+        EXISTING_SYMLINK_VALUE=$(readlink "${SYSTEM_HEADER_PATH}")
+
+        if [[ "${EXISTING_SYMLINK_VALUE}" == "${SYMLINK_VALUE}" ]]; then
+            exit 0
+        fi
+
+        echo "warning: existing symlink is incorrect; expected ${SYMLINK_VALUE}, got ${EXISTING_SYMLINK_VALUE}"
+    elif [[ -e "${SYSTEM_HEADER_PATH}" ]]; then
+        echo "error: expected a symlink at ${SYSTEM_HEADER_PATH}"
+        exit 1
+    fi
+
+    ln -sf "${SYMLINK_VALUE}" "${SYSTEM_HEADER_PATH}"
+}
+
+if [[ "${ACTION}" == "installhdrs" || "${ACTION}" == "install" ]]
+then
+    if [[ ! -d ${SYSTEM_PUBLIC_HEADER_PREFIX} ]]; then
+        mkdir -p ${SYSTEM_PUBLIC_HEADER_PREFIX}
+    fi
+
+    for HEADER_FOLDER in `echo ${HEADER_FOLDER_LIST} | cut -d' ' -f1-`
+    do
+        create_symlink_if_needed ${INSTALL_PUBLIC_HEADER_PREFIX} ${PUBLIC_HEADERS_FOLDER_PREFIX} ${SYSTEM_PUBLIC_HEADER_PREFIX} ${HEADER_FOLDER}
+    done
+fi
+
+if [[ "${ACTION}" == "install" ]]
+then
+    if [[ ! -d ${SYSTEM_PUBLIC_LIBRARY_PREFIX} ]]; then
+        mkdir -p ${SYSTEM_PUBLIC_LIBRARY_PREFIX}
+    fi
+
+    for LIBRARY in `echo ${LIBRARY_LIST} | cut -d' ' -f1-`
+    do
+        create_symlink_if_needed ${INSTALL_PUBLIC_LIBRARY_PREFIX} ${PUBLIC_LIBRARY_FOLDER_PREFIX} ${SYSTEM_PUBLIC_LIBRARY_PREFIX} ${LIBRARY}
+    done
+fi
Property changes on: trunk/Source/ThirdParty/libwebrtc/Scripts/create-symlink-to-altroot.sh
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Modified: trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj (290804 => 290805)


--- trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj	2022-03-04 01:26:55 UTC (rev 290805)
@@ -17394,6 +17394,7 @@
 				312BDB0B15FECAB00097EBC7 /* CopyFiles */,
 				312BDB0D15FECACE0097EBC7 /* CopyFiles */,
 				659A86EA279796F800AC37B6 /* Create Symlink to Alt Root Path */,
+				6517572127CEECB000D9FE40 /* Copy Frameworks to Secondary Path */,
 			);
 			buildRules = (
 			);
@@ -17513,6 +17514,24 @@
 			shellPath = /bin/sh;
 			shellScript = "if [ \"${ACTION}\" = \"installhdrs\" ] || [ \"${ACTION}\" = \"installapi\" ]; then\n    exit 0;\nfi\n\nif [ -f ../../../Tools/Scripts/check-for-weak-vtables-and-externals ]; then\n    ../../../Tools/Scripts/check-for-weak-vtables-and-externals || exit $?\nfi\n";
 		};
+		6517572127CEECB000D9FE40 /* Copy Frameworks to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy Frameworks to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export DYLIBS_TO_COPY_TO_SECONDARY_PATH=\"libwebrtc.dylib\"\n\"${SRCROOT}/Scripts/copy-frameworks-to-secondary-path.sh\"\n";
+		};
 		659A86EA279796F800AC37B6 /* Create Symlink to Alt Root Path */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 8;

Modified: trunk/Source/WebCore/ChangeLog (290804 => 290805)


--- trunk/Source/WebCore/ChangeLog	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebCore/ChangeLog	2022-03-04 01:26:55 UTC (rev 290805)
@@ -1,3 +1,17 @@
+2022-03-03  Michael Saboff  <msab...@apple.com>
+
+        Copy WebKit frameworks and XPC processes to Secondary Path
+        https://bugs.webkit.org/show_bug.cgi?id=237394
+
+        Reviewed by Saam Barati.
+
+        Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
+        when it is set.
+
+        * Configurations/WebCore.xcconfig:
+        * Scripts/copy-frameworks-to-secondary-path.sh: Added.
+        * WebCore.xcodeproj/project.pbxproj:
+
 2022-03-03  Dan Glastonbury  <d...@apple.com>
 
         Allow [SecureContext] extended attribute on namespaces.

Modified: trunk/Source/WebCore/Configurations/WebCore.xcconfig (290804 => 290805)


--- trunk/Source/WebCore/Configurations/WebCore.xcconfig	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebCore/Configurations/WebCore.xcconfig	2022-03-04 01:26:55 UTC (rev 290805)
@@ -58,6 +58,9 @@
 
 INSTALL_PATH_PREFIX = $(INSTALL_PATH_PREFIX_USE_SYSTEM_CONTENT_PATH_$(USE_SYSTEM_CONTENT_PATH));
 INSTALL_PATH_PREFIX_USE_SYSTEM_CONTENT_PATH_YES = $(SYSTEM_CONTENT_PATH);
+SECONDARY_STAGED_FRAMEWORK_DIRECTORY = $(SYSTEM_SECONDARY_CONTENT_PATH)$(SYSTEM_LIBRARY_DIR)/StagedFrameworks/Safari/
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH = NO
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH[sdk=macos*] = $(USE_SYSTEM_CONTENT_PATH)
 
 INSTALL_PATH = $(INSTALL_PATH_PREFIX)$(INSTALL_PATH_$(WK_COCOA_TOUCH));
 INSTALL_PATH_cocoatouch = $(WK_ALTERNATE_WEBKIT_SDK_PATH)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks;

Added: trunk/Source/WebCore/Scripts/copy-frameworks-to-secondary-path.sh (0 => 290805)


--- trunk/Source/WebCore/Scripts/copy-frameworks-to-secondary-path.sh	                        (rev 0)
+++ trunk/Source/WebCore/Scripts/copy-frameworks-to-secondary-path.sh	2022-03-04 01:26:55 UTC (rev 290805)
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -e
+
+if [[ "${DEPLOYMENT_LOCATION}" != "YES" ]]; then
+    echo "error: $(basename $0) should only be run for deployment-style (\"production\" / \"non-engineering\") builds."
+    exit 1
+fi
+
+if [[ "${USE_SYSTEM_CONTENT_PATH}" != "YES" || "${COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH}" != "YES" ]]; then
+    echo "Skipping copying frameworks to secondary content path."
+    exit 0
+fi
+
+if [[ "${ACTION}" == "installapi" || "${ACTION}" == "installhdrs" ]]; then
+    echo "Skipping copying frameworks to secondary content path for installapi or installhdrs action."
+    exit 0
+fi
+
+if [[ -z "${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH}" && -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    echo "warning: Neither FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH or DYLIBS_TO_COPY_TO_SECONDARY_PATH are set."
+fi
+
+if [[ -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    echo "error: SECONDARY_STAGED_FRAMEWORK_DIRECTORY is not set."
+    exit 1
+fi
+
+function copy_product_to_destination_framework_directory
+{
+    PRODUCT_COMPONENT=$1
+
+    # In deployment builds, BUILT_PRODUCTS_DIR doesn't point to the actual location of any products,
+    # but to a single folder of symlinks to all built products, regardless of whether they are actually
+    # being installed. We need to copy the actual products to the secondary content path, *not* just a symlink.
+    SOURCE_PRODUCT_PATH="$(readlink "${BUILT_PRODUCTS_DIR}/${PRODUCT_COMPONENT}")"
+
+    echo "Copying ${SOURCE_PRODUCT_PATH} to ${DESTINATION_FRAMEWORK_DIRECTORY}"
+    rsync -aE "${SOURCE_PRODUCT_PATH}" "${DESTINATION_FRAMEWORK_DIRECTORY}"
+}
+
+if [[ ! -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for FRAMEWORK_NAME in $(echo ${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        FRAMEWORK_BUNDLE_NAME="${FRAMEWORK_NAME}.framework"
+
+        copy_product_to_destination_framework_directory ${FRAMEWORK_BUNDLE_NAME}
+    done
+fi
+
+if [[ ! -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}${STAGED_DYLIB_FRAMEWORK_PATH}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for DYLIB in $(echo ${DYLIBS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        copy_product_to_destination_framework_directory ${DYLIB}
+    done
+fi
Property changes on: trunk/Source/WebCore/Scripts/copy-frameworks-to-secondary-path.sh
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (290804 => 290805)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2022-03-04 01:26:55 UTC (rev 290805)
@@ -38335,6 +38335,7 @@
 				49D6AE1B27B6984B0000EB06 /* Copy PDF.js Extras */,
 				5379C7AA21E5287100E4A8F6 /* Check .xcfilelists */,
 				6577FFC7276AC9AD0011AEC8 /* Create Symlink to Alt Root Path */,
+				6517571F27CEE87600D9FE40 /* Copy Frameworks to Secondary Path */,
 			);
 			buildRules = (
 			);
@@ -38622,6 +38623,24 @@
 			shellPath = /bin/sh;
 			shellScript = "if [ \"${ACTION}\" = \"installhdrs\" -o \"${ACTION}\" = \"installapi\" ]; then\n    exit 0;\nfi\n\nif [ -f ../../Tools/Scripts/check-for-inappropriate-files-in-framework ]; then\n    ../../Tools/Scripts/check-for-inappropriate-files-in-framework || exit $?\nfi\n\ntouch \"${TARGET_TEMP_DIR}/CheckForInappropriateFilesInFramework.txt\"\n";
 		};
+		6517571F27CEE87600D9FE40 /* Copy Frameworks to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy Frameworks to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH=\"WebCore\"\n\"${SRCROOT}/Scripts/copy-frameworks-to-secondary-path.sh\"\n";
+		};
 		6577FFC7276AC9AD0011AEC8 /* Create Symlink to Alt Root Path */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 8;

Modified: trunk/Source/WebGPU/ChangeLog (290804 => 290805)


--- trunk/Source/WebGPU/ChangeLog	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebGPU/ChangeLog	2022-03-04 01:26:55 UTC (rev 290805)
@@ -1,3 +1,17 @@
+2022-03-03  Michael Saboff  <msab...@apple.com>
+
+        Copy WebKit frameworks and XPC processes to Secondary Path
+        https://bugs.webkit.org/show_bug.cgi?id=237394
+
+        Reviewed by Saam Barati.
+
+        Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
+        when it is set.
+
+        * Configurations/WebGPU.xcconfig:
+        * Scripts/copy-frameworks-to-secondary-path.sh: Added.
+        * WebGPU.xcodeproj/project.pbxproj:
+
 2022-03-03  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         [WebGPU] Abide by the WebKit Style Guide

Modified: trunk/Source/WebGPU/Configurations/WebGPU.xcconfig (290804 => 290805)


--- trunk/Source/WebGPU/Configurations/WebGPU.xcconfig	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebGPU/Configurations/WebGPU.xcconfig	2022-03-04 01:26:55 UTC (rev 290805)
@@ -31,6 +31,9 @@
 INSTALL_PATH_USE_SYSTEM_CONTENT_PATH_YES = $(SYSTEM_CONTENT_PATH)$(WEBGPU_FRAMEWORKS_DIR);
 INSTALL_PATH_USE_SYSTEM_CONTENT_PATH_ = $(INSTALL_PATH_USE_SYSTEM_CONTENT_PATH_NO);
 INSTALL_PATH_USE_SYSTEM_CONTENT_PATH_NO = $(WEBGPU_FRAMEWORKS_DIR);
+SECONDARY_STAGED_FRAMEWORK_DIRECTORY = $(SYSTEM_SECONDARY_CONTENT_PATH)$(SYSTEM_LIBRARY_DIR)/StagedFrameworks/Safari
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH = NO
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH[sdk=macos*] = $(USE_SYSTEM_CONTENT_PATH)
 
 DYLIB_INSTALL_NAME_BASE = $(DYLIB_INSTALL_NAME_BASE_$(WK_USE_ALTERNATE_FRAMEWORKS_DIR));
 DYLIB_INSTALL_NAME_BASE_NO = $(NORMAL_WEBGPU_FRAMEWORKS_DIR);

Added: trunk/Source/WebGPU/Scripts/copy-frameworks-to-secondary-path.sh (0 => 290805)


--- trunk/Source/WebGPU/Scripts/copy-frameworks-to-secondary-path.sh	                        (rev 0)
+++ trunk/Source/WebGPU/Scripts/copy-frameworks-to-secondary-path.sh	2022-03-04 01:26:55 UTC (rev 290805)
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -e
+
+if [[ "${DEPLOYMENT_LOCATION}" != "YES" ]]; then
+    echo "error: $(basename $0) should only be run for deployment-style (\"production\" / \"non-engineering\") builds."
+    exit 1
+fi
+
+if [[ "${USE_SYSTEM_CONTENT_PATH}" != "YES" || "${COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH}" != "YES" ]]; then
+    echo "Skipping copying frameworks to secondary content path."
+    exit 0
+fi
+
+if [[ "${ACTION}" == "installapi" || "${ACTION}" == "installhdrs" ]]; then
+    echo "Skipping copying frameworks to secondary content path for installapi or installhdrs action."
+    exit 0
+fi
+
+if [[ -z "${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH}" && -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    echo "warning: Neither FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH or DYLIBS_TO_COPY_TO_SECONDARY_PATH are set."
+fi
+
+if [[ -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    echo "error: SECONDARY_STAGED_FRAMEWORK_DIRECTORY is not set."
+    exit 1
+fi
+
+function copy_product_to_destination_framework_directory
+{
+    PRODUCT_COMPONENT=$1
+
+    # In deployment builds, BUILT_PRODUCTS_DIR doesn't point to the actual location of any products,
+    # but to a single folder of symlinks to all built products, regardless of whether they are actually
+    # being installed. We need to copy the actual products to the secondary content path, *not* just a symlink.
+    SOURCE_PRODUCT_PATH="$(readlink "${BUILT_PRODUCTS_DIR}/${PRODUCT_COMPONENT}")"
+
+    echo "Copying ${SOURCE_PRODUCT_PATH} to ${DESTINATION_FRAMEWORK_DIRECTORY}"
+    rsync -aE "${SOURCE_PRODUCT_PATH}" "${DESTINATION_FRAMEWORK_DIRECTORY}"
+}
+
+if [[ ! -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for FRAMEWORK_NAME in $(echo ${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        FRAMEWORK_BUNDLE_NAME="${FRAMEWORK_NAME}.framework"
+
+        copy_product_to_destination_framework_directory ${FRAMEWORK_BUNDLE_NAME}
+    done
+fi
+
+if [[ ! -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}${STAGED_DYLIB_FRAMEWORK_PATH}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for DYLIB in $(echo ${DYLIBS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        copy_product_to_destination_framework_directory ${DYLIB}
+    done
+fi
Property changes on: trunk/Source/WebGPU/Scripts/copy-frameworks-to-secondary-path.sh
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Modified: trunk/Source/WebGPU/WebGPU.xcodeproj/project.pbxproj (290804 => 290805)


--- trunk/Source/WebGPU/WebGPU.xcodeproj/project.pbxproj	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebGPU/WebGPU.xcodeproj/project.pbxproj	2022-03-04 01:26:55 UTC (rev 290805)
@@ -3,7 +3,7 @@
 	archiveVersion = 1;
 	classes = {
 	};
-	objectVersion = 51;
+	objectVersion = 55;
 	objects = {
 
 /* Begin PBXBuildFile section */
@@ -84,7 +84,7 @@
 			files = (
 			);
 			runOnlyForDeploymentPostprocessing = 1;
-    };
+		};
 		DD05A35B27BF09B60096EFAB /* Product Dependencies */ = {
 			isa = PBXCopyFilesBuildPhase;
 			buildActionMask = 2147483647;
@@ -437,6 +437,7 @@
 				1CEBD7E02716AFBA00A5254D /* Frameworks */,
 				1CEBD7E12716AFBA00A5254D /* Resources */,
 				6577FFC8276ACA060011AEC8 /* Create Symlink to Alt Root Path */,
+				6517571627C9AC3000D9FE40 /* Copy Frameworks to Secondary Path */,
 			);
 			buildRules = (
 			);
@@ -472,7 +473,6 @@
 		1CEBD7DA2716AFBA00A5254D /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
-				BuildIndependentTargetsInParallel = NO;
 				DefaultBuildSystemTypeForWorkspace = Original;
 				LastSwiftUpdateCheck = 1400;
 				LastUpgradeCheck = 1330;
@@ -530,6 +530,24 @@
 /* End PBXResourcesBuildPhase section */
 
 /* Begin PBXShellScriptBuildPhase section */
+		6517571627C9AC3000D9FE40 /* Copy Frameworks to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy Frameworks to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH=\"WebGPU\"\n\"${SRCROOT}/Scripts/copy-frameworks-to-secondary-path.sh\"\n";
+		};
 		6577FFC8276ACA060011AEC8 /* Create Symlink to Alt Root Path */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 8;

Modified: trunk/Source/WebInspectorUI/ChangeLog (290804 => 290805)


--- trunk/Source/WebInspectorUI/ChangeLog	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebInspectorUI/ChangeLog	2022-03-04 01:26:55 UTC (rev 290805)
@@ -1,3 +1,17 @@
+2022-03-02  Michael Saboff  <msab...@apple.com>
+
+        Copy WebKit frameworks and XPC processes to Secondary Path
+        https://bugs.webkit.org/show_bug.cgi?id=237394
+
+        Reviewed by Saam Barati.
+
+        Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
+        when it is set.
+
+        * Configurations/WebInspectorUIFramework.xcconfig:
+        * Scripts/copy-frameworks-to-secondary-path.sh: Added.
+        * WebInspectorUI.xcodeproj/project.pbxproj:
+
 2022-03-01  Devin Rousso  <drou...@apple.com>
 
         Web Inspector: add a switch to control whether breakpoint evaluations (condition, ignore count, actions) are also affected by script blackboxing

Modified: trunk/Source/WebInspectorUI/Configurations/WebInspectorUIFramework.xcconfig (290804 => 290805)


--- trunk/Source/WebInspectorUI/Configurations/WebInspectorUIFramework.xcconfig	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebInspectorUI/Configurations/WebInspectorUIFramework.xcconfig	2022-03-04 01:26:55 UTC (rev 290805)
@@ -12,6 +12,10 @@
 INSTALL_PATH_USE_SYSTEM_CONTENT_PATH_YES = $(SYSTEM_CONTENT_PATH)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks;
 INSTALL_PATH_USE_OVERRIDE_FRAMEWORKS_DIR_NO = $(SYSTEM_LIBRARY_DIR)/PrivateFrameworks;
 INSTALL_PATH_USE_OVERRIDE_FRAMEWORKS_DIR_YES = $(WK_OVERRIDE_FRAMEWORKS_DIR);
+SECONDARY_STAGED_FRAMEWORK_DIRECTORY = $(SYSTEM_SECONDARY_CONTENT_PATH)$(SYSTEM_LIBRARY_DIR)/StagedFrameworks/Safari
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH = NO
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH[sdk=macos*] = $(USE_SYSTEM_CONTENT_PATH)
+
 DYLIB_INSTALL_NAME_BASE = $(SYSTEM_LIBRARY_DIR)/PrivateFrameworks;
 PRODUCT_NAME = WebInspectorUI;
 PRODUCT_BUNDLE_IDENTIFIER = com.apple.$(PRODUCT_NAME:rfc1034identifier);

Added: trunk/Source/WebInspectorUI/Scripts/copy-frameworks-to-secondary-path.sh (0 => 290805)


--- trunk/Source/WebInspectorUI/Scripts/copy-frameworks-to-secondary-path.sh	                        (rev 0)
+++ trunk/Source/WebInspectorUI/Scripts/copy-frameworks-to-secondary-path.sh	2022-03-04 01:26:55 UTC (rev 290805)
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -e
+
+if [[ "${DEPLOYMENT_LOCATION}" != "YES" ]]; then
+    echo "error: $(basename $0) should only be run for deployment-style (\"production\" / \"non-engineering\") builds."
+    exit 1
+fi
+
+if [[ "${USE_SYSTEM_CONTENT_PATH}" != "YES" || "${COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH}" != "YES" ]]; then
+    echo "Skipping copying frameworks to secondary content path."
+    exit 0
+fi
+
+if [[ "${ACTION}" == "installapi" || "${ACTION}" == "installhdrs" ]]; then
+    echo "Skipping copying frameworks to secondary content path for installapi or installhdrs action."
+    exit 0
+fi
+
+if [[ -z "${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH}" && -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    echo "warning: Neither FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH or DYLIBS_TO_COPY_TO_SECONDARY_PATH are set."
+fi
+
+if [[ -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    echo "error: SECONDARY_STAGED_FRAMEWORK_DIRECTORY is not set."
+    exit 1
+fi
+
+function copy_product_to_destination_framework_directory
+{
+    PRODUCT_COMPONENT=$1
+
+    # In deployment builds, BUILT_PRODUCTS_DIR doesn't point to the actual location of any products,
+    # but to a single folder of symlinks to all built products, regardless of whether they are actually
+    # being installed. We need to copy the actual products to the secondary content path, *not* just a symlink.
+    SOURCE_PRODUCT_PATH="$(readlink "${BUILT_PRODUCTS_DIR}/${PRODUCT_COMPONENT}")"
+
+    echo "Copying ${SOURCE_PRODUCT_PATH} to ${DESTINATION_FRAMEWORK_DIRECTORY}"
+    rsync -aE "${SOURCE_PRODUCT_PATH}" "${DESTINATION_FRAMEWORK_DIRECTORY}"
+}
+
+if [[ ! -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for FRAMEWORK_NAME in $(echo ${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        FRAMEWORK_BUNDLE_NAME="${FRAMEWORK_NAME}.framework"
+
+        copy_product_to_destination_framework_directory ${FRAMEWORK_BUNDLE_NAME}
+    done
+fi
+
+if [[ ! -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}${STAGED_DYLIB_FRAMEWORK_PATH}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for DYLIB in $(echo ${DYLIBS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        copy_product_to_destination_framework_directory ${DYLIB}
+    done
+fi
Property changes on: trunk/Source/WebInspectorUI/Scripts/copy-frameworks-to-secondary-path.sh
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Modified: trunk/Source/WebInspectorUI/WebInspectorUI.xcodeproj/project.pbxproj (290804 => 290805)


--- trunk/Source/WebInspectorUI/WebInspectorUI.xcodeproj/project.pbxproj	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebInspectorUI/WebInspectorUI.xcodeproj/project.pbxproj	2022-03-04 01:26:55 UTC (rev 290805)
@@ -120,6 +120,7 @@
 				1C60FF1214E6D9AF006CD77D /* Copy User Interface Resources */,
 				1C78EE1417611302002F6AA5 /* Sources */,
 				6577FFC9276ACA680011AEC8 /* Create Symlink to Alt Root Path */,
+				6517571727C9AD6B00D9FE40 /* Copy Frameworks to Secondary Path */,
 			);
 			buildRules = (
 			);
@@ -179,6 +180,24 @@
 			shellPath = /bin/sh;
 			shellScript = "/usr/bin/perl \"${SRCROOT}/Scripts/copy-user-interface-resources.pl\"\n";
 		};
+		6517571727C9AD6B00D9FE40 /* Copy Frameworks to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy Frameworks to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH=\"WebInspectorUI\"\n\"${SRCROOT}/Scripts/copy-frameworks-to-secondary-path.sh\"\n";
+		};
 		6577FFC9276ACA680011AEC8 /* Create Symlink to Alt Root Path */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 8;

Modified: trunk/Source/WebKit/ChangeLog (290804 => 290805)


--- trunk/Source/WebKit/ChangeLog	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebKit/ChangeLog	2022-03-04 01:26:55 UTC (rev 290805)
@@ -1,3 +1,80 @@
+2022-03-03  Michael Saboff  <msab...@apple.com>
+
+        Copy WebKit frameworks and XPC processes to Secondary Path
+        https://bugs.webkit.org/show_bug.cgi?id=237394
+
+        Reviewed by Saam Barati.
+
+        Added build configuration variables and scripts to copy the built Framework as well as the XPC services 
+        to the SYSTEM_SECONDARY_CONTENT_PATH when it is set.  When copying the XPC services, we update the XPC
+        binaries to reference the frameworks from the SYSTEM_SECONDARY_CONTENT_PATH by updating
+        DYLD_VERSIONED_FRAMEWORK_PATH.
+
+        * Configurations/Base.xcconfig:
+        * Configurations/WebKitSwift.xcconfig:
+        * Scripts/copy-frameworks-to-secondary-path.sh: Added.
+        * Scripts/copy-xpc-services-to-secondary-path.sh: Added.
+        * Scripts/update-dyld-environment-load-command: Added.
+        * Scripts/webkitpy: Added.
+        * Scripts/webkitpy/mach_o.py: Added.
+        (_utf8_bytes_to_str):
+        (_mach_o_int_field):
+        (_mach_o_int_field._get_mach_o_int_field):
+        (_mach_o_int_field._set_mach_o_int_field):
+        (_mach_o_int_field._set_mach_o_int_field.func):
+        (_mach_o_chararray_field):
+        (_mach_o_chararray_field._get_mach_o_chararray_field):
+        (_mach_o_chararray_field._set_mach_o_chararray_field):
+        (_mach_o_chararray_field._set_mach_o_chararray_field.func):
+        (_mach_o_varchar_field):
+        (_mach_o_varchar_field._get_mach_o_varchar_field):
+        (_mach_o_varchar_field._set_mach_o_varchar_field):
+        (_mach_o_varchar_field._set_mach_o_varchar_field.func):
+        (MachOCommand):
+        (MachOCommand.__init__):
+        (MachOSourceVersionCommand):
+        (MachOSourceVersionCommand.version_str):
+        (MachOSection):
+        (MachOSection.__init__):
+        (MachOSegmentCommand):
+        (MachOSection32):
+        (MachOSegment32Command):
+        (MachOSegment32Command.__init__):
+        (MachOSection64):
+        (MachOSegment64Command):
+        (MachOSegment64Command.__init__):
+        (MachOLoadDylibCommand):
+        (MachOLoadDylibCommand._version_str):
+        (MachOLoadDylibCommand.compatibility_version_str):
+        (MachOLoadDylibCommand.current_version_str):
+        (MachODyldEnvironmentCommand):
+        (MachODyldEnvironmentCommand.variable):
+        (MachODyldEnvironmentCommand.value):
+        (MachODyldEnvironmentCommand.build):
+        (MachOIDDylibCommand):
+        (MachOHeader):
+        (MachOHeader.__init__):
+        (MachOHeader.used_header_size):
+        (MachOHeader.total_header_size):
+        (MachOHeader.available_header_size):
+        (MachOHeader.architecture_name):
+        (MachOHeader.id_command):
+        (MachOHeader.dyld_env_commands):
+        (MachOHeader.dyld_versioned_framework_paths):
+        (MachOHeader.filter_commands):
+        (MachOHeader.update_file):
+        (MachOHeader.parse_command):
+        (MachOHeader32LE):
+        (MachOHeader32LE.__init__):
+        (MachOHeader64LE):
+        (MachOHeader64LE.__init__):
+        (MachOFile):
+        (MachOFile.__init__):
+        (is_macho_bytes):
+        (is_macho_file):
+        (enumerate_macho_files):
+        * WebKit.xcodeproj/project.pbxproj:
+
 2022-03-03  Robert Jenner  <jen...@apple.com>
 
         Unreviewed, reverting r290752.

Modified: trunk/Source/WebKit/Configurations/Base.xcconfig (290804 => 290805)


--- trunk/Source/WebKit/Configurations/Base.xcconfig	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebKit/Configurations/Base.xcconfig	2022-03-04 01:26:55 UTC (rev 290805)
@@ -31,6 +31,9 @@
 
 INSTALL_PATH_PREFIX = $(INSTALL_PATH_PREFIX_$(USE_SYSTEM_CONTENT_PATH));
 INSTALL_PATH_PREFIX_YES = $(SYSTEM_CONTENT_PATH);
+SECONDARY_STAGED_FRAMEWORK_DIRECTORY = $(SYSTEM_SECONDARY_CONTENT_PATH)$(SYSTEM_LIBRARY_DIR)/StagedFrameworks/Safari
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH = NO
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH[sdk=macos*] = $(USE_SYSTEM_CONTENT_PATH)
 
 ALWAYS_SEARCH_USER_PATHS = NO;
 

Modified: trunk/Source/WebKit/Configurations/WebKitSwift.xcconfig (290804 => 290805)


--- trunk/Source/WebKit/Configurations/WebKitSwift.xcconfig	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebKit/Configurations/WebKitSwift.xcconfig	2022-03-04 01:26:55 UTC (rev 290805)
@@ -28,6 +28,7 @@
 SWIFT_OBJC_INTERFACE_HEADER_NAME = WebKitSwift-Swift.h
 
 INSTALL_PATH = $(INSTALL_PATH_PREFIX)$(WEBKIT_FRAMEWORKS_DIR)/WebKit.framework/$(WK_FRAMEWORK_VERSION_PREFIX)Frameworks;
+STAGED_DYLIB_FRAMEWORK_PATH=/WebKit.framework/Versions/A/Frameworks
 
 DYLIB_INSTALL_NAME_BASE = $(WEBKIT_FRAMEWORKS_DIR);
 

Added: trunk/Source/WebKit/Scripts/copy-frameworks-to-secondary-path.sh (0 => 290805)


--- trunk/Source/WebKit/Scripts/copy-frameworks-to-secondary-path.sh	                        (rev 0)
+++ trunk/Source/WebKit/Scripts/copy-frameworks-to-secondary-path.sh	2022-03-04 01:26:55 UTC (rev 290805)
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -e
+
+if [[ "${DEPLOYMENT_LOCATION}" != "YES" ]]; then
+    echo "error: $(basename $0) should only be run for deployment-style (\"production\" / \"non-engineering\") builds."
+    exit 1
+fi
+
+if [[ "${USE_SYSTEM_CONTENT_PATH}" != "YES" || "${COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH}" != "YES" ]]; then
+    echo "Skipping copying frameworks to secondary content path."
+    exit 0
+fi
+
+if [[ "${ACTION}" == "installapi" || "${ACTION}" == "installhdrs" ]]; then
+    echo "Skipping copying frameworks to secondary content path for installapi or installhdrs action."
+    exit 0
+fi
+
+if [[ -z "${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH}" && -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    echo "warning: Neither FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH or DYLIBS_TO_COPY_TO_SECONDARY_PATH are set."
+fi
+
+if [[ -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    echo "error: SECONDARY_STAGED_FRAMEWORK_DIRECTORY is not set."
+    exit 1
+fi
+
+function copy_product_to_destination_framework_directory
+{
+    PRODUCT_COMPONENT=$1
+
+    # In deployment builds, BUILT_PRODUCTS_DIR doesn't point to the actual location of any products,
+    # but to a single folder of symlinks to all built products, regardless of whether they are actually
+    # being installed. We need to copy the actual products to the secondary content path, *not* just a symlink.
+    SOURCE_PRODUCT_PATH="$(readlink "${BUILT_PRODUCTS_DIR}/${PRODUCT_COMPONENT}")"
+
+    echo "Copying ${SOURCE_PRODUCT_PATH} to ${DESTINATION_FRAMEWORK_DIRECTORY}"
+    rsync -aE "${SOURCE_PRODUCT_PATH}" "${DESTINATION_FRAMEWORK_DIRECTORY}"
+}
+
+if [[ ! -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for FRAMEWORK_NAME in $(echo ${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        FRAMEWORK_BUNDLE_NAME="${FRAMEWORK_NAME}.framework"
+
+        copy_product_to_destination_framework_directory ${FRAMEWORK_BUNDLE_NAME}
+    done
+fi
+
+if [[ ! -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}${STAGED_DYLIB_FRAMEWORK_PATH}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for DYLIB in $(echo ${DYLIBS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        copy_product_to_destination_framework_directory ${DYLIB}
+    done
+fi
Property changes on: trunk/Source/WebKit/Scripts/copy-frameworks-to-secondary-path.sh
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Added: trunk/Source/WebKit/Scripts/copy-xpc-services-to-secondary-path.sh (0 => 290805)


--- trunk/Source/WebKit/Scripts/copy-xpc-services-to-secondary-path.sh	                        (rev 0)
+++ trunk/Source/WebKit/Scripts/copy-xpc-services-to-secondary-path.sh	2022-03-04 01:26:55 UTC (rev 290805)
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+set -e
+
+if [[ "${DEPLOYMENT_LOCATION}" != "YES" ]]; then
+    echo "error: $(basename $0) should only be run for deployment-style (\"production\" / \"non-engineering\") builds."
+    exit 1
+fi
+
+if [[ "${USE_SYSTEM_CONTENT_PATH}" != "YES" || "${COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH}" != "YES" ]]; then
+    echo "Skipping copying XPC services to secondary content path."
+    exit 0
+fi
+
+if [[ "${ACTION}" == "installapi" || "${ACTION}" == "installhdrs" ]]; then
+    echo "Skipping copying frameworks to secondary content path for installapi or installhdrs action."
+    exit 0
+fi
+
+if [[ -z "${XPC_BUNDLES_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    echo "warning: XPC_BUNDLES_TO_COPY_TO_SECONDARY_PATH is not set."
+fi
+
+if [[ -z "${XPC_BUNDLE_INSTALL_PATH_IN_SECONDARY_PATH}" ]]; then
+    echo "error: XPC_BUNDLE_INSTALL_PATH_IN_SECONDARY_PATH is not set."
+    exit 1
+fi
+
+if [[ -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    echo "error: SECONDARY_STAGED_FRAMEWORK_DIRECTORY is not set."
+    exit 1
+fi
+
+UPDATE_DYLD_LOAD_COMMAND="$(dirname $0)/update-dyld-environment-load-command"
+
+for XPC_BUNDLE_NAME in $(echo ${XPC_BUNDLES_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+do
+    # In deployment builds, BUILT_PRODUCTS_DIR doesn't point to the actual location of any products,
+    # but to a single folder of symlinks to all built products, regardless of whether they are actually
+    # being installed. We need to copy the actual products to the secondary path, *not* just a symlink.
+    SOURCE_BUNDLE_PATH="$(readlink "${BUILT_PRODUCTS_DIR}/${XPC_BUNDLE_NAME}")"
+
+    DESTINATION_XPC_BUNDLE_DIRECTORY="${DSTROOT}${XPC_BUNDLE_INSTALL_PATH_IN_SECONDARY_PATH}"
+
+    mkdir -p "${DESTINATION_XPC_BUNDLE_DIRECTORY}"
+
+    echo "Copying ${SOURCE_BUNDLE_PATH} to ${DESTINATION_XPC_BUNDLE_DIRECTORY}"
+    rsync -aE "${SOURCE_BUNDLE_PATH}" "${DESTINATION_XPC_BUNDLE_DIRECTORY}"
+
+    DESTINATION_XPC_BUNDLE_PATH="${DESTINATION_XPC_BUNDLE_DIRECTORY}/${XPC_BUNDLE_NAME}"
+    XPC_EXECUTABLE_PATH="${DESTINATION_XPC_BUNDLE_PATH}/Contents/MacOS/$(basename "${DESTINATION_XPC_BUNDLE_PATH}" | sed -E "s/\\.[^\.]+$//")"
+
+    echo "Updating DYLD environment variables in ${XPC_EXECUTABLE_PATH}"
+    "${UPDATE_DYLD_LOAD_COMMAND}" "${XPC_EXECUTABLE_PATH}" "DYLD_VERSIONED_FRAMEWORK_PATH=${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}"
+
+    echo "Re-signing ${DESTINATION_XPC_BUNDLE_PATH}"
+    codesign --sign "${CODE_SIGN_IDENTITY}" --force --preserve-metadata=entitlements,flags,identifier,requirements,runtime "${DESTINATION_XPC_BUNDLE_PATH}"
+
+done
Property changes on: trunk/Source/WebKit/Scripts/copy-xpc-services-to-secondary-path.sh
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Added: trunk/Source/WebKit/Scripts/update-dyld-environment-load-command (0 => 290805)


--- trunk/Source/WebKit/Scripts/update-dyld-environment-load-command	                        (rev 0)
+++ trunk/Source/WebKit/Scripts/update-dyld-environment-load-command	2022-03-04 01:26:55 UTC (rev 290805)
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+# encoding: utf-8
+
+import argparse
+import sys
+from typing import Any, Dict, Iterable, List, Tuple
+from webkitpy import mach_o
+
+def main(args: List[str]):
+    parser = argparse.ArgumentParser()
+    parser.add_argument("binary")
+    parser.add_argument("variables", nargs="+")
+    options = parser.parse_args(args)
+
+    with open(options.binary, "r+b") as binary_file:
+        mach_o_file = mach_o.MachOFile(binary_file)
+
+        for mach_o_header in mach_o_file.headers:
+            mach_o_header.filter_commands(lambda command: not isinstance(command, mach_o.MachODyldEnvironmentCommand))
+
+            for variable_pair in options.variables:
+                mach_o_header.commands.append(mach_o.MachODyldEnvironmentCommand.build(variable_pair))
+
+            mach_o_header.update_file(binary_file)
+
+    return 0
+
+if __name__ == '__main__':
+    sys.exit(main(sys.argv[1:]))
Property changes on: trunk/Source/WebKit/Scripts/update-dyld-environment-load-command
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Added: trunk/Source/WebKit/Scripts/webkitpy/mach_o.py (0 => 290805)


--- trunk/Source/WebKit/Scripts/webkitpy/mach_o.py	                        (rev 0)
+++ trunk/Source/WebKit/Scripts/webkitpy/mach_o.py	2022-03-04 01:26:55 UTC (rev 290805)
@@ -0,0 +1,546 @@
+#!/usr/bin/env python3
+# encoding: utf-8
+
+import os
+import re
+import struct
+
+from typing import Any, Dict, Iterable, List, Tuple, Callable
+from io import BufferedReader, BufferedRandom, BytesIO, SEEK_CUR
+
+
+MH_OBJECT = 1
+MH_EXECUTE = 2
+MH_FVMLIB = 3
+MH_CORE = 4
+MH_PRELOAD = 5
+MH_DYLIB = 6
+MH_DYLINKER = 7
+MH_BUNDLE = 8
+
+MACHO_32LE_SIGNATURE = b'\xce\xfa\xed\xfe'
+MACHO_64LE_SIGNATURE = b'\xcf\xfa\xed\xfe'
+MACHO_FAT_SIGNATURE = b'\xca\xfe\xba\xbe'
+
+LC_REQ_DYLD = 0x80000000
+
+LC_SEGMENT = 1
+LC_LOAD_DYLIB = 12
+LC_ID_DYLIB = 13
+LC_LOAD_WEAK_DYLIB = 24 | LC_REQ_DYLD
+LC_SEGMENT_64 = 25
+LC_CODE_SIGNATURE = 29
+LC_DYLD_ENVIRONMENT = 39
+LC_SOURCE_VERSION = 42
+
+S_ZEROFILL = 1
+S_GB_ZEROFILL = 12
+S_THREAD_LOCAL_ZEROFILL = 18
+
+CPU_ARCH_MASK = 0xff000000
+CPU_ARCH_ABI64 = 0x01000000
+
+CPU_TYPE_X86 = 7
+CPU_TYPE_X86_64 = CPU_TYPE_X86 | CPU_ARCH_ABI64
+CPU_TYPE_ARM = 12
+CPU_TYPE_ARM64 = CPU_TYPE_ARM | CPU_ARCH_ABI64
+
+CPU_SUBTYPE_ARM64E = 2
+
+DYLD_SEGMENT32_STRUCT_SIZE = 56
+DYLD_SECTION32_STRUCT_SIZE = 76
+
+DYLD_SEGMENT64_STRUCT_SIZE = 72
+DYLD_SECTION64_STRUCT_SIZE = 86
+
+_cpu_names: Dict[int, str] = {
+    CPU_TYPE_ARM: "arm",
+    CPU_TYPE_ARM64: "arm64",
+    CPU_TYPE_X86: "i386",
+    CPU_TYPE_X86_64: "x86_64",
+}
+
+_arch_suffix: Dict[int, str] = {
+    CPU_SUBTYPE_ARM64E: "e"
+}
+
+_command_map: Dict[int, Any] = None
+
+
+def _utf8_bytes_to_str(data: bytes):
+    return data.decode('utf-8').split("\x00")[0]
+
+
+def _mach_o_int_field(offset: int, length: int = 4):
+    def _get_mach_o_int_field(offset: int, length: int = 4):
+        return lambda self: int.from_bytes(self.data[offset:(offset + length)], byteorder="little", signed=False)
+
+    def _set_mach_o_int_field(offset: int, length: int = 4):
+        def func(self, value: int):
+            self.data[offset:(offset + length)] = value.to_bytes(length, byteorder="little", signed=False)
+        return func
+
+    return property(_get_mach_o_int_field(offset, length), _set_mach_o_int_field(offset, length))
+
+
+def _mach_o_chararray_field(offset: int, length: int):
+    def _get_mach_o_chararray_field(offset: int, length: int):
+        return lambda self: _utf8_bytes_to_str(self.data[offset:(offset + length)])
+
+    def _set_mach_o_chararray_field(offset: int, length: int):
+        def func(self, value: str):
+            encoded_string = value.encode("utf-8")
+
+            if len(encoded_string) > length:
+                encoded_string = encoded_string[:length]
+            elif len(encoded_string) < length:
+                encoded_string += bytearray(length - len(encoded_string))
+
+            self.data[offset:(offset + length)] = encoded_string
+        return func
+
+    return property(_get_mach_o_chararray_field(offset, length), _set_mach_o_chararray_field(offset, length))
+
+
+def _mach_o_varchar_field(offset_property_name: str):
+    def _get_mach_o_varchar_field(offset_property_name: str):
+        return lambda self: _utf8_bytes_to_str(self.data[getattr(self, offset_property_name):])
+
+    def _set_mach_o_varchar_field(offset_property_name: str):
+        def func(self, value: str):
+            encoded_string = value.encode("utf-8")
+            self.data[getattr(self, offset_property_name):] = encoded_string
+
+            # MACH-O commands needs to be memory-aligned.
+            if (len(self.data) % 8) != 0:
+                self.data += bytearray(8 - (len(self.data) % 8))
+
+            self.command_size = len(self.data)
+        return func
+
+    return property(_get_mach_o_varchar_field(offset_property_name), _set_mach_o_varchar_field(offset_property_name))
+
+
+class MachOCommand:
+    data: bytearray
+    command: int = _mach_o_int_field(0)
+    command_size: int = _mach_o_int_field(4)
+
+    def __init__(self, data: bytes):
+        self.data = ""
+
+
+class MachOSourceVersionCommand(MachOCommand):
+    version: int = _mach_o_int_field(8, 8)
+
+    def version_str(self) -> str:
+        return f"{(self.version >> 40) & 0xFFFFFF}.{(self.version >> 30) & 0x3FF}.{(self.version >> 20) & 0x3FF}.{(self.version >> 10) & 0x3FF}.{self.version & 0x3FF}"
+
+
+class MachOSection:
+    data: bytearray
+    sectname: str
+    segname: str
+    addr: int
+    size: int
+    offset: int
+    align: int
+    reloff: int
+    nreloc: int
+    flags: int
+    reserved1: int
+    reserved2: int
+
+    def __init__(self, data: bytes):
+        self.data = ""
+
+
+class MachOSegmentCommand(MachOCommand):
+    name: str
+    vmaddr: int
+    vmsize: int
+    fileoff: int
+    filesize: int
+    maxprot: int
+    initprot: int
+    nsects: int
+    flags: int
+    sections: List[MachOSection]
+
+
+class MachOSection32(MachOSection):
+    sectname: str = _mach_o_chararray_field(8, 16)
+    segname: str = _mach_o_chararray_field(24, 16)
+    addr: int = _mach_o_int_field(40)
+    size: int = _mach_o_int_field(44)
+    offset: int = _mach_o_int_field(48)
+    align: int = _mach_o_int_field(52)
+    reloff: int = _mach_o_int_field(56)
+    nreloc: int = _mach_o_int_field(60)
+    flags: int = _mach_o_int_field(64)
+    reserved1: int = _mach_o_int_field(68)
+    reserved2: int = _mach_o_int_field(72)
+
+
+class MachOSegment32Command(MachOSegmentCommand):
+    name: str = _mach_o_chararray_field(8, 16)
+    vmaddr: int = _mach_o_int_field(24)
+    vmsize: int = _mach_o_int_field(28)
+    fileoff: int = _mach_o_int_field(32)
+    filesize: int = _mach_o_int_field(36)
+    maxprot: int = _mach_o_int_field(40)
+    initprot: int = _mach_o_int_field(44)
+    nsects: int = _mach_o_int_field(48)
+    flags: int = _mach_o_int_field(52)
+
+    def __init__(self, data: bytes):
+        super().__init__(data)
+
+        offset = DYLD_SEGMENT32_STRUCT_SIZE
+        self.sections = []
+        for section in range(0, self.nsects):
+            self.sections.append(MachOSection32(data[offset:(offset + DYLD_SECTION32_STRUCT_SIZE)]))
+            offset += DYLD_SECTION32_STRUCT_SIZE
+
+
+class MachOSection64(MachOSection):
+    sectname: str = _mach_o_chararray_field(8, 16)
+    segname: str = _mach_o_chararray_field(24, 16)
+    addr: int = _mach_o_int_field(40, 8)
+    size: int = _mach_o_int_field(48, 8)
+    offset: int = _mach_o_int_field(56)
+    align: int = _mach_o_int_field(60)
+    reloff: int = _mach_o_int_field(64)
+    nreloc: int = _mach_o_int_field(68)
+    flags: int = _mach_o_int_field(72)
+    reserved1: int = _mach_o_int_field(76)
+    reserved2: int = _mach_o_int_field(80)
+    reserved3: int = _mach_o_int_field(84)
+
+
+class MachOSegment64Command(MachOSegmentCommand):
+    name: str = _mach_o_chararray_field(8, 16)
+    vmaddr: int = _mach_o_int_field(24, 8)
+    vmsize: int = _mach_o_int_field(32, 8)
+    fileoff: int = _mach_o_int_field(40, 8)
+    filesize: int = _mach_o_int_field(48, 8)
+    maxprot: int = _mach_o_int_field(56)
+    initprot: int = _mach_o_int_field(60)
+    nsects: int = _mach_o_int_field(64)
+    flags: int = _mach_o_int_field(68)
+
+    def __init__(self, data: bytes):
+        super().__init__(data)
+
+        offset = DYLD_SEGMENT64_STRUCT_SIZE
+        self.sections = []
+        for section in range(0, self.nsects):
+            self.sections.append(MachOSection32(data[offset:(offset + DYLD_SECTION64_STRUCT_SIZE)]))
+            offset += DYLD_SECTION64_STRUCT_SIZE
+
+
+class MachOLoadDylibCommand(MachOCommand):
+    install_name_offset: int = _mach_o_int_field(8)
+    timestamp: int = _mach_o_int_field(12)
+    current_version: int = _mach_o_int_field(16)
+    compatibility_version: int = _mach_o_int_field(20)
+    install_name: str = _mach_o_varchar_field("install_name_offset")
+
+    def _version_str(self, version: int) -> str:
+        return f"{(version >> 16) & 0xffff}.{(version >> 8) & 0xff}.{version & 0xff}"
+
+    def compatibility_version_str(self) -> str:
+        return self._version_str(self.compatibility_version)
+
+    def current_version_str(self) -> str:
+        return self._version_str(self.current_version)
+
+
+class MachODyldEnvironmentCommand(MachOCommand):
+    pair_offset: int = _mach_o_int_field(8)
+    pair: str = _mach_o_varchar_field("pair_offset")
+
+    @property
+    def variable(self):
+        return self.pair.split("=")[0]
+
+    @property
+    def value(self):
+        return self.pair.split("=")[1]
+
+    @classmethod
+    def build(self, pair: str) -> "MachODyldEnvironmentCommand":
+        command = self(struct.pack("<IIII", LC_DYLD_ENVIRONMENT, 16, 12, 0))
+        command.pair = pair
+        return command
+
+
+class MachOIDDylibCommand(MachOLoadDylibCommand):
+    pass
+
+
+_command_map = {
+    LC_SEGMENT: MachOSegment32Command,
+    LC_SEGMENT_64: MachOSegment64Command,
+    LC_LOAD_DYLIB: MachOLoadDylibCommand,
+    LC_LOAD_WEAK_DYLIB: MachOLoadDylibCommand,
+    LC_SOURCE_VERSION: MachOSourceVersionCommand,
+    LC_DYLD_ENVIRONMENT: MachODyldEnvironmentCommand,
+    LC_ID_DYLIB: MachOIDDylibCommand,
+}
+
+
+class MachOHeader:
+    data: bytearray
+    start_offset: int
+    end_offset: int
+    magic: int
+    cputype: int
+    cpusubtype: int
+    filetype: int
+    command_count: int
+    command_size: int
+    commands: List[MachOCommand]
+    flags: int
+
+    def __init__(self):
+        self.commands = []
+
+    @property
+    def used_header_size(self) -> int:
+        return self.end_offset - self.start_offset
+
+    @property
+    def total_header_size(self) -> int:
+        lowest_offset = None
+
+        for command in self.commands:
+            if not isinstance(command, MachOSegmentCommand):
+                continue
+
+            for section in command.sections:
+                if section.offset <= 0 or section.flags & S_GB_ZEROFILL or section.flags & S_THREAD_LOCAL_ZEROFILL or section.flags & S_ZEROFILL:
+                    continue
+
+                if lowest_offset is None:
+                    lowest_offset = section.offset
+                else:
+                    lowest_offset = min(lowest_offset, section.offset)
+
+        return lowest_offset
+
+    @property
+    def available_header_size(self) -> int:
+        return self.total_header_size - self.used_header_size
+
+    @property
+    def architecture_name(self) -> str:
+        if self.cputype in _cpu_names:
+            if self.cpusubtype in _arch_suffix:
+                return _cpu_names[self.cputype] + _arch_suffix[self.cpusubtype]
+
+            return _cpu_names[self.cputype]
+
+        return "%i.%i" % (self.cputype, self.subcputype)
+
+    @property
+    def id_command(self) -> MachOIDDylibCommand:
+        for command in self.commands:
+            if isinstance(command, MachOIDDylibCommand):
+                return command
+
+    @property
+    def dyld_env_commands(self) -> Iterable[MachODyldEnvironmentCommand]:
+        for command in self.commands:
+            if isinstance(command, MachODyldEnvironmentCommand):
+                yield command
+
+    @property
+    def dyld_versioned_framework_paths(self) -> Iterable[str]:
+        for command in self.dyld_env_commands:
+            if command.variable == "DYLD_VERSIONED_FRAMEWORK_PATH":
+                for entry in command.value.split(":"):
+                    yield entry
+
+    def filter_commands(self, func: Callable[[MachOCommand], bool]) -> None:
+        self.commands = list(filter(func, self.commands))
+
+    def update_file(self, binary_file: BufferedRandom) -> None:
+        command_size = 0
+
+        for command in self.commands:
+            command_size += len(command.data)
+
+        updated_header_size = len(self.data) + command_size
+        total_header_size = self.total_header_size
+
+        if updated_header_size > total_header_size:
+            raise RuntimeError(f"Updated header ({updated_header_size} bytes) doesn't fit the available space ({total_header_size} bytes)")
+
+        self.command_count = len(self.commands)
+        self.command_size = command_size
+
+        binary_file.seek(self.start_offset)
+        binary_file.write(self.data)
+
+        for command in self.commands:
+            binary_file.write(command.data)
+
+        if self.end_offset > binary_file.tell():
+            binary_file.write(bytearray(self.end_offset - binary_file.tell()))
+        else:
+            self.end_offset = binary_file.tell()
+
+    @classmethod
+    def parse_command(self, data: bytes) -> MachOCommand:
+        command = int.from_bytes(data[0:4], byteorder="little")
+        if command in _command_map:
+            return _command_map[command](data)
+
+        return MachOCommand(data)
+
+
+class MachOHeader32LE(MachOHeader):
+    magic: int = _mach_o_int_field(0)
+    cputype: int = _mach_o_int_field(4)
+    cpusubtype: int = _mach_o_int_field(8)
+    filetype: int = _mach_o_int_field(12)
+    command_count: int = _mach_o_int_field(16)
+    command_size: int = _mach_o_int_field(20)
+    flags: int = _mach_o_int_field(24)
+
+    def __init__(self, file: BufferedReader):
+        super().__init__()
+        self.start_offset = file.tell()
+        self.data = ""
+
+        for _ in range(0, self.command_count):
+            (_, command_size) = struct.unpack("<II", file.peek(8)[:8])
+            self.commands.append(MachOHeader.parse_command(file.read(command_size)))
+
+        self.end_offset = file.tell()
+
+
+class MachOHeader64LE(MachOHeader):
+    magic: int = _mach_o_int_field(0)
+    cputype: int = _mach_o_int_field(4)
+    cpusubtype: int = _mach_o_int_field(8)
+    filetype: int = _mach_o_int_field(12)
+    command_count: int = _mach_o_int_field(16)
+    command_size: int = _mach_o_int_field(20)
+    flags: int = _mach_o_int_field(24)
+    reserved: int = _mach_o_int_field(28)
+
+    def __init__(self, file: BufferedReader):
+        super().__init__()
+        self.start_offset = file.tell()
+        self.data = ""
+
+        for _ in range(0, self.command_count):
+            (_, command_size) = struct.unpack("<II", file.peek(8)[:8])
+            self.commands.append(MachOHeader.parse_command(file.read(command_size)))
+
+        self.end_offset = file.tell()
+
+
+class MachOFile:
+    headers: List[MachOHeader]
+
+    def __init__(self, file: BufferedReader):
+        self.headers = []
+        magic = file.peek(4)[:4]
+
+        if magic == MACHO_32LE_SIGNATURE:
+            # 32-bits Mach-O
+            self.headers.append(MachOHeader32LE(file))
+            return
+
+        if magic == MACHO_64LE_SIGNATURE:
+            # 64-bits Mach-O
+            self.headers.append(MachOHeader64LE(file))
+            return
+
+        if magic == MACHO_FAT_SIGNATURE:
+            # Universal Mach-O
+            (magic, architecture_count) = struct.unpack('>II', file.read(8))
+            architectures = []
+
+            for _ in range(0, architecture_count):
+                architectures.append(file.read(20))
+
+            for architecture in architectures:
+                (cpu_type, cpu_sub_type, file_offset, size, align) = struct.unpack('>IIIII', architecture)
+                file.seek(file_offset)
+                magic = file.peek(4)[:4]
+
+                if magic == MACHO_32LE_SIGNATURE:
+                    self.headers.append(MachOHeader32LE(file))
+                elif magic == MACHO_64LE_SIGNATURE:
+                    self.headers.append(MachOHeader64LE(file))
+                else:
+                    raise RuntimeError("Invalid Mach-O header found")
+
+            return
+
+        raise RuntimeError("Not a supported Mach-O file")
+
+
+def is_macho_bytes(data: bytes) -> bool:
+    if len(data) < 4:
+        return False
+
+    magic = data[:4]
+    return magic in [MACHO_64LE_SIGNATURE, MACHO_32LE_SIGNATURE, MACHO_FAT_SIGNATURE]
+
+
+def is_macho_file(filename: str) -> bool:
+    with open(filename, "rb") as file:
+        magic = file.peek(4)[:4]
+        return is_macho_bytes(magic)
+
+
+def enumerate_macho_files(start_point: str) -> Iterable[Tuple[str, MachOFile]]:
+    import tarfile
+
+    if os.path.isdir(start_point):
+        for root, _, files in os.walk(start_point, topdown=False, followlinks=False):
+            for name in files:
+                if name.endswith(".a"):
+                    continue
+
+                path = os.path.join(root, name)
+
+                if os.path.islink(path):
+                    continue
+
+                try:
+                    if not is_macho_file(path):
+                        continue
+
+                    with open(path, "rb") as file:
+                        macho_file = MachOFile(file)
+                except:
+                    continue
+
+                yield (os.path.relpath(path, start_point), macho_file)
+    elif tarfile.is_tarfile(start_point):
+        archive = tarfile.open(start_point)
+
+        while True:
+            member = archive.next()
+            if not member:
+                break
+
+            if not member.isfile():
+                continue
+
+            if member.name.endswith(".a"):
+                continue
+
+            data = ""
+
+            if is_macho_bytes(data):
+                yield (os.path.normpath(member.name), MachOFile(BufferedReader(BytesIO(data))))
+    else:
+        with open(start_point, "rb") as file:
+            yield (start_point, MachOFile(file))

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (290804 => 290805)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2022-03-04 01:26:55 UTC (rev 290805)
@@ -14422,6 +14422,7 @@
 				2D9FB222237523830049F936 /* Unlock keychain */,
 				2D9FB223237523830049F936 /* Process GPU entitlements */,
 				6577FFBF2769C7550011AEC8 /* Create Symlink to Alt Root Path */,
+				6517571E27CEE6BD00D9FE40 /* Copy XPC Service to Secondary Path */,
 			);
 			buildRules = (
 			);
@@ -14445,6 +14446,7 @@
 				A1EF36BF2581F73B0090B02A /* Copy Plug-ins */,
 				7AFCBD5520B8917D00F55C9C /* Process WebContent entitlements */,
 				6577FFBD2769C70F0011AEC8 /* Create Symlink to Alt Root Path */,
+				6517571C27CEE64B00D9FE40 /* Copy XPC Service to Secondary Path */,
 			);
 			buildRules = (
 			);
@@ -14485,6 +14487,7 @@
 				5742A2F02535613F00B7BA14 /* Resources */,
 				5742A2F12535613F00B7BA14 /* Unlock keychain */,
 				5742A2F22535613F00B7BA14 /* Process WebAuthentication entitlements */,
+				6517572327CFC24A00D9FE40 /* Copy XPC Service to Secondary Path */,
 			);
 			buildRules = (
 			);
@@ -14547,6 +14550,7 @@
 				7A7E8DF02748392500DCC97A /* Copy Plug-ins */,
 				7A7E8DF22748392500DCC97A /* Process WebContent entitlements */,
 				6577FFBC2769C6D90011AEC8 /* Create Symlink to Alt Root Path */,
+				6517571B27CEE61200D9FE40 /* Copy XPC Service to Secondary Path */,
 			);
 			buildRules = (
 			);
@@ -14594,6 +14598,7 @@
 				0FB94836239F31B700926A8F /* Copy Testing Headers */,
 				DFD03A29270D5F57001A996E /* Copy Daemon Plists */,
 				6577FFB92769C1460011AEC8 /* Create Symlink to Alt Root Path */,
+				6517571927C9B43A00D9FE40 /* Copy Frameworks to Secondary Path */,
 			);
 			buildRules = (
 				535E08C422545B7200DF00CA /* PBXBuildRule */,
@@ -14637,6 +14642,7 @@
 				7AFCBD5420B8911D00F55C9C /* Process WebContent entitlements */,
 				4157853721279CC600DD3800 /* Copy Custom WebContent Resources to Framework Private Headers */,
 				6577FFBB2769C6AA0011AEC8 /* Create Symlink to Alt Root Path */,
+				6517571827C9B38B00D9FE40 /* Copy XPC Service to Secondary Path */,
 			);
 			buildRules = (
 			);
@@ -14660,6 +14666,7 @@
 				41D0FC8020E43B4500076AE8 /* Unlock keychain */,
 				41D0FC8120E43B7000076AE8 /* Process Network entitlements */,
 				6577FFBE2769C7370011AEC8 /* Create Symlink to Alt Root Path */,
+				6517571D27CEE66D00D9FE40 /* Copy XPC Service to Secondary Path */,
 			);
 			buildRules = (
 			);
@@ -14680,6 +14687,7 @@
 				CD95493226159004008372D9 /* Sources */,
 				CD95493326159004008372D9 /* Frameworks */,
 				6577FFBA2769C64A0011AEC8 /* Create Symlink to Alt Root Path */,
+				6517571527C9AB4C00D9FE40 /* Copy Frameworks to Secondary Path */,
 			);
 			buildRules = (
 			);
@@ -15272,6 +15280,150 @@
 			shellPath = /bin/sh;
 			shellScript = "if [ \"${ACTION}\" = \"installhdrs\" ] || [ \"${ACTION}\" = \"installapi\" ]; then\n    exit 0;\nfi\n\nif [ -f ../../Tools/Scripts/check-for-inappropriate-files-in-framework ]; then\n    ../../Tools/Scripts/check-for-inappropriate-files-in-framework || exit $?\nfi\n";
 		};
+		6517571527C9AB4C00D9FE40 /* Copy Frameworks to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy Frameworks to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export DYLIBS_TO_COPY_TO_SECONDARY_PATH=\"libWebKitSwift.dylib\"\n\"${SRCROOT}/Scripts/copy-frameworks-to-secondary-path.sh\"\n";
+		};
+		6517571827C9B38B00D9FE40 /* Copy XPC Service to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy XPC Service to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export XPC_BUNDLES_TO_COPY_TO_SECONDARY_PATH=\"com.apple.WebKit.WebContent.xpc\"\nexport XPC_BUNDLE_INSTALL_PATH_IN_SECONDARY_PATH=\"${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}/WebKit.framework/Versions/A/XPCServices\"\n\"${SRCROOT}/Scripts/copy-xpc-services-to-secondary-path.sh\"\n";
+		};
+		6517571927C9B43A00D9FE40 /* Copy Frameworks to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy Frameworks to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH=\"WebKit\"\n\"${SRCROOT}/Scripts/copy-frameworks-to-secondary-path.sh\"\n";
+		};
+		6517571B27CEE61200D9FE40 /* Copy XPC Service to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy XPC Service to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export XPC_BUNDLES_TO_COPY_TO_SECONDARY_PATH=\"com.apple.WebKit.WebContent.CaptivePortal.xpc\"\nexport XPC_BUNDLE_INSTALL_PATH_IN_SECONDARY_PATH=\"${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}/WebKit.framework/Versions/A/XPCServices\"\n\"${SRCROOT}/Scripts/copy-xpc-services-to-secondary-path.sh\"\n";
+		};
+		6517571C27CEE64B00D9FE40 /* Copy XPC Service to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy XPC Service to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export XPC_BUNDLES_TO_COPY_TO_SECONDARY_PATH=\"com.apple.WebKit.WebContent.Development.xpc\"\nexport XPC_BUNDLE_INSTALL_PATH_IN_SECONDARY_PATH=\"${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}/WebKit.framework/Versions/A/XPCServices\"\n\"${SRCROOT}/Scripts/copy-xpc-services-to-secondary-path.sh\"\n";
+		};
+		6517571D27CEE66D00D9FE40 /* Copy XPC Service to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy XPC Service to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export XPC_BUNDLES_TO_COPY_TO_SECONDARY_PATH=\"com.apple.WebKit.Networking.xpc\"\nexport XPC_BUNDLE_INSTALL_PATH_IN_SECONDARY_PATH=\"${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}/WebKit.framework/Versions/A/XPCServices\"\n\"${SRCROOT}/Scripts/copy-xpc-services-to-secondary-path.sh\"\n";
+		};
+		6517571E27CEE6BD00D9FE40 /* Copy XPC Service to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy XPC Service to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export XPC_BUNDLES_TO_COPY_TO_SECONDARY_PATH=\"com.apple.WebKit.GPU.xpc\"\nexport XPC_BUNDLE_INSTALL_PATH_IN_SECONDARY_PATH=\"${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}/WebKit.framework/Versions/A/XPCServices\"\n\"${SRCROOT}/Scripts/copy-xpc-services-to-secondary-path.sh\"\n";
+		};
+		6517572327CFC24A00D9FE40 /* Copy XPC Service to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy XPC Service to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export XPC_BUNDLES_TO_COPY_TO_SECONDARY_PATH=\"com.apple.WebKit.WebAuthn.xpc\"\nexport XPC_BUNDLE_INSTALL_PATH_IN_SECONDARY_PATH=\"${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}/WebKit.framework/Versions/A/XPCServices\"\n\"${SRCROOT}/Scripts/copy-xpc-services-to-secondary-path.sh\"\n";
+		};
 		6577FFB92769C1460011AEC8 /* Create Symlink to Alt Root Path */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 8;

Modified: trunk/Source/WebKitLegacy/ChangeLog (290804 => 290805)


--- trunk/Source/WebKitLegacy/ChangeLog	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebKitLegacy/ChangeLog	2022-03-04 01:26:55 UTC (rev 290805)
@@ -1,3 +1,16 @@
+2022-03-02  Michael Saboff  <msab...@apple.com>
+
+        Copy WebKit frameworks and XPC processes to Secondary Path
+        https://bugs.webkit.org/show_bug.cgi?id=237394
+
+        Reviewed by Saam Barati.
+
+        Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
+        when it is set.
+
+        * WebKitLegacy.xcodeproj/project.pbxproj:
+        * scripts/copy-frameworks-to-secondary-path.sh: Added.
+
 2022-03-01  Alex Christensen  <achristen...@webkit.org>
 
         [AppleWin] Start using Visual Studio 2022

Modified: trunk/Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj (290804 => 290805)


--- trunk/Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj	2022-03-04 01:26:55 UTC (rev 290805)
@@ -3081,6 +3081,7 @@
 				1A3193D5191856E500E1CF89 /* Symlink WebKitPluginHost */,
 				537CF83A22EFBFB100C6EBB3 /* Check .xcfilelists */,
 				650473452789431C00AF78A2 /* Create Symlink to Alt Root Path */,
+				6517572027CEE91400D9FE40 /* Copy Frameworks to Secondary Path */,
 			);
 			buildRules = (
 				535E08C322545B4C00DF00CA /* PBXBuildRule */,
@@ -3346,6 +3347,24 @@
 			shellPath = /bin/sh;
 			shellScript = "\"${SRCROOT}/scripts/create-symlink-to-altroot.sh\"\n";
 		};
+		6517572027CEE91400D9FE40 /* Copy Frameworks to Secondary Path */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 8;
+			files = (
+			);
+			inputFileListPaths = (
+			);
+			inputPaths = (
+			);
+			name = "Copy Frameworks to Secondary Path";
+			outputFileListPaths = (
+			);
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+			shellPath = /bin/sh;
+			shellScript = "export FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH=\"WebKitLegacy\"\n\"${SRCROOT}/scripts/copy-frameworks-to-secondary-path.sh\"\n";
+		};
 		7C02321B251B9A8A00BA7BB6 /* Generate Preferences */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 2147483647;

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (290804 => 290805)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2022-03-04 01:26:55 UTC (rev 290805)
@@ -1,3 +1,15 @@
+2022-03-02  Michael Saboff  <msab...@apple.com>
+
+        Copy WebKit frameworks and XPC processes to Secondary Path
+        https://bugs.webkit.org/show_bug.cgi?id=237394
+
+        Reviewed by Saam Barati.
+
+        Added build configuration variables and scripts to copy the built Framework to the SYSTEM_SECONDARY_CONTENT_PATH
+        when it is set.
+
+        * Configurations/Base.xcconfig:
+
 2022-03-01  Wenson Hsieh  <wenson_hs...@apple.com>
 
         focus({preventScroll: true}) does not prevent scrolling on iOS

Modified: trunk/Source/WebKitLegacy/mac/Configurations/Base.xcconfig (290804 => 290805)


--- trunk/Source/WebKitLegacy/mac/Configurations/Base.xcconfig	2022-03-04 01:21:23 UTC (rev 290804)
+++ trunk/Source/WebKitLegacy/mac/Configurations/Base.xcconfig	2022-03-04 01:26:55 UTC (rev 290805)
@@ -33,6 +33,9 @@
 
 INSTALL_PATH_PREFIX = $(INSTALL_PATH_PREFIX_$(USE_SYSTEM_CONTENT_PATH));
 INSTALL_PATH_PREFIX_YES = $(SYSTEM_CONTENT_PATH);
+SECONDARY_STAGED_FRAMEWORK_DIRECTORY = $(SYSTEM_SECONDARY_CONTENT_PATH)$(SYSTEM_LIBRARY_DIR)/StagedFrameworks/Safari/
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH = NO
+COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH[sdk=macos*] = $(USE_SYSTEM_CONTENT_PATH)
 
 ALWAYS_SEARCH_USER_PATHS = NO;
 

Added: trunk/Source/WebKitLegacy/scripts/copy-frameworks-to-secondary-path.sh (0 => 290805)


--- trunk/Source/WebKitLegacy/scripts/copy-frameworks-to-secondary-path.sh	                        (rev 0)
+++ trunk/Source/WebKitLegacy/scripts/copy-frameworks-to-secondary-path.sh	2022-03-04 01:26:55 UTC (rev 290805)
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -e
+
+if [[ "${DEPLOYMENT_LOCATION}" != "YES" ]]; then
+    echo "error: $(basename $0) should only be run for deployment-style (\"production\" / \"non-engineering\") builds."
+    exit 1
+fi
+
+if [[ "${USE_SYSTEM_CONTENT_PATH}" != "YES" || "${COPY_STAGED_FRAMEWORKS_TO_SECONDARY_PATH}" != "YES" ]]; then
+    echo "Skipping copying frameworks to secondary content path."
+    exit 0
+fi
+
+if [[ "${ACTION}" == "installapi" || "${ACTION}" == "installhdrs" ]]; then
+    echo "Skipping copying frameworks to secondary content path for installapi or installhdrs action."
+    exit 0
+fi
+
+if [[ -z "${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH}" && -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    echo "warning: Neither FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH or DYLIBS_TO_COPY_TO_SECONDARY_PATH are set."
+fi
+
+if [[ -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    echo "error: SECONDARY_STAGED_FRAMEWORK_DIRECTORY is not set."
+    exit 1
+fi
+
+function copy_product_to_destination_framework_directory
+{
+    PRODUCT_COMPONENT=$1
+
+    # In deployment builds, BUILT_PRODUCTS_DIR doesn't point to the actual location of any products,
+    # but to a single folder of symlinks to all built products, regardless of whether they are actually
+    # being installed. We need to copy the actual products to the secondary content path, *not* just a symlink.
+    SOURCE_PRODUCT_PATH="$(readlink "${BUILT_PRODUCTS_DIR}/${PRODUCT_COMPONENT}")"
+
+    echo "Copying ${SOURCE_PRODUCT_PATH} to ${DESTINATION_FRAMEWORK_DIRECTORY}"
+    rsync -aE "${SOURCE_PRODUCT_PATH}" "${DESTINATION_FRAMEWORK_DIRECTORY}"
+}
+
+if [[ ! -z "${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for FRAMEWORK_NAME in $(echo ${FRAMEWORKS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        FRAMEWORK_BUNDLE_NAME="${FRAMEWORK_NAME}.framework"
+
+        copy_product_to_destination_framework_directory ${FRAMEWORK_BUNDLE_NAME}
+    done
+fi
+
+if [[ ! -z "${DYLIBS_TO_COPY_TO_SECONDARY_PATH}" ]]; then
+    DESTINATION_FRAMEWORK_DIRECTORY="${DSTROOT}${SECONDARY_STAGED_FRAMEWORK_DIRECTORY}${STAGED_DYLIB_FRAMEWORK_PATH}"
+    mkdir -p "${DESTINATION_FRAMEWORK_DIRECTORY}"
+
+    for DYLIB in $(echo ${DYLIBS_TO_COPY_TO_SECONDARY_PATH} | tr ' ' '\n')
+    do
+        copy_product_to_destination_framework_directory ${DYLIB}
+    done
+fi
Property changes on: trunk/Source/WebKitLegacy/scripts/copy-frameworks-to-secondary-path.sh
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to