| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | #!/bin/bash
 | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:07 -08:00
										 |  |  | set -e | 
					
						
							|  |  |  | set +x | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   echo "usage: $(basename "$0") [output-absolute-path]" | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  |   echo | 
					
						
							|  |  |  |   echo "Generate distributable .zip archive from ./checkout folder that was previously built." | 
					
						
							|  |  |  |   echo | 
					
						
							|  |  |  |   exit 0 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:07 -08:00
										 |  |  | ZIP_PATH=$1 | 
					
						
							|  |  |  | if [[ $ZIP_PATH != /* ]]; then | 
					
						
							|  |  |  |   echo "ERROR: path $ZIP_PATH is not absolute" | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | if [[ $ZIP_PATH != *.zip ]]; then | 
					
						
							|  |  |  |   echo "ERROR: path $ZIP_PATH must have .zip extension" | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | if [[ -f $ZIP_PATH ]]; then | 
					
						
							|  |  |  |   echo "ERROR: path $ZIP_PATH exists; can't do anything." | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  | if ! [[ -d $(dirname "$ZIP_PATH") ]]; then | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:07 -08:00
										 |  |  |   echo "ERROR: folder for path $($ZIP_PATH) does not exist." | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | main() { | 
					
						
							| 
									
										
										
										
											2020-12-07 08:42:20 -08:00
										 |  |  |   if [[ ! -z "${WK_CHECKOUT_PATH}" ]]; then | 
					
						
							|  |  |  |     cd "${WK_CHECKOUT_PATH}" | 
					
						
							|  |  |  |     echo "WARNING: checkout path from WK_CHECKOUT_PATH env: ${WK_CHECKOUT_PATH}" | 
					
						
							|  |  |  |   else | 
					
						
							| 
									
										
										
										
											2021-10-14 10:20:06 -07:00
										 |  |  |     cd "$HOME/webkit" | 
					
						
							| 
									
										
										
										
											2020-12-07 08:42:20 -08:00
										 |  |  |   fi | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:07 -08:00
										 |  |  |   set -x | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  |   if [[ "$(uname)" == "Darwin" ]]; then | 
					
						
							|  |  |  |     createZipForMac | 
					
						
							|  |  |  |   elif [[ "$(uname)" == "Linux" ]]; then | 
					
						
							|  |  |  |     createZipForLinux | 
					
						
							| 
									
										
										
										
											2020-01-16 15:32:50 -08:00
										 |  |  |   elif [[ "$(uname)" == MINGW* ]]; then | 
					
						
							|  |  |  |     createZipForWindows | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  |   else | 
					
						
							|  |  |  |     echo "ERROR: cannot upload on this platform!" 1>&2 | 
					
						
							|  |  |  |     exit 1; | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-23 15:57:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | createZipForLinux() { | 
					
						
							|  |  |  |   # create a TMP directory to copy all necessary files | 
					
						
							|  |  |  |   local tmpdir=$(mktemp -d -t webkit-deploy-XXXXXXXXXX) | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   mkdir -p "$tmpdir" | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # copy runner | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   cp -t "$tmpdir" "$SCRIPTS_DIR"/pw_run.sh | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  |   # copy protocol | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   node "$SCRIPTS_DIR"/concat_protocol.js > "$tmpdir"/protocol.json | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-28 19:48:57 +02:00
										 |  |  |   # Generate and unpack MiniBrowser bundles for each port | 
					
						
							|  |  |  |   for port in gtk wpe; do | 
					
						
							|  |  |  |     WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/${port^^} Tools/Scripts/generate-bundle \
 | 
					
						
							|  |  |  |         --bundle=MiniBrowser --release \
 | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |         --platform=${port} --destination="${tmpdir}" | 
					
						
							|  |  |  |      unzip "${tmpdir}"/MiniBrowser_${port}_release.zip -d "${tmpdir}"/minibrowser-${port} | 
					
						
							|  |  |  |      rm -f "${tmpdir}"/MiniBrowser_${port}_release.zip | 
					
						
							| 
									
										
										
										
											2020-08-28 19:48:57 +02:00
										 |  |  |   done | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # tar resulting directory and cleanup TMP. | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   cd "$tmpdir" | 
					
						
							|  |  |  |   zip --symlinks -r "$ZIP_PATH" ./ | 
					
						
							| 
									
										
										
										
											2020-01-10 19:14:55 -08:00
										 |  |  |   cd - | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   rm -rf "$tmpdir" | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-16 15:32:50 -08:00
										 |  |  | createZipForWindows() { | 
					
						
							|  |  |  |   # create a TMP directory to copy all necessary files | 
					
						
							|  |  |  |   local tmpdir="/tmp/webkit-deploy-$(date +%s)" | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   mkdir -p "$tmpdir" | 
					
						
							| 
									
										
										
										
											2020-01-16 15:32:50 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   cp -t "$tmpdir" ./WebKitLibraries/win/bin64/*.dll | 
					
						
							| 
									
										
										
										
											2020-01-16 15:32:50 -08:00
										 |  |  |   cd WebKitBuild/Release/bin64 | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   cp -r -t "$tmpdir" WebKit.resources | 
					
						
							|  |  |  |   cp -t "$tmpdir" JavaScriptCore.dll PlaywrightLib.dll WTF.dll WebKit2.dll libEGL.dll libGLESv2.dll | 
					
						
							|  |  |  |   cp -t "$tmpdir" Playwright.exe WebKitNetworkProcess.exe WebKitWebProcess.exe | 
					
						
							| 
									
										
										
										
											2020-01-16 15:32:50 -08:00
										 |  |  |   cd - | 
					
						
							| 
									
										
										
										
											2020-11-05 16:51:42 -08:00
										 |  |  |   cd "$(printMSVCRedistDir)" | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   cp -t "$tmpdir" msvcp140.dll vcruntime140.dll vcruntime140_1.dll msvcp140_2.dll | 
					
						
							| 
									
										
										
										
											2020-01-17 09:24:45 -08:00
										 |  |  |   cd - | 
					
						
							| 
									
										
										
										
											2020-01-16 15:32:50 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # copy protocol | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   node "$SCRIPTS_DIR"/concat_protocol.js > "$tmpdir"/protocol.json | 
					
						
							| 
									
										
										
										
											2020-01-16 15:32:50 -08:00
										 |  |  |   # tar resulting directory and cleanup TMP. | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   cd "$tmpdir" | 
					
						
							|  |  |  |   zip -r "$ZIP_PATH" ./ | 
					
						
							| 
									
										
										
										
											2020-01-16 15:32:50 -08:00
										 |  |  |   cd - | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   rm -rf "$tmpdir" | 
					
						
							| 
									
										
										
										
											2020-01-16 15:32:50 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | createZipForMac() { | 
					
						
							|  |  |  |   # create a TMP directory to copy all necessary files | 
					
						
							|  |  |  |   local tmpdir=$(mktemp -d) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   # copy all relevant files | 
					
						
							| 
									
										
										
										
											2021-08-11 01:47:02 +02:00
										 |  |  |   ditto {./WebKitBuild/Release,"$tmpdir"}/com.apple.WebKit.GPU.xpc | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   ditto {./WebKitBuild/Release,"$tmpdir"}/com.apple.WebKit.Networking.xpc | 
					
						
							|  |  |  |   ditto {./WebKitBuild/Release,"$tmpdir"}/com.apple.WebKit.WebContent.xpc | 
					
						
							|  |  |  |   ditto {./WebKitBuild/Release,"$tmpdir"}/JavaScriptCore.framework | 
					
						
							|  |  |  |   ditto {./WebKitBuild/Release,"$tmpdir"}/libANGLE-shared.dylib | 
					
						
							|  |  |  |   ditto {./WebKitBuild/Release,"$tmpdir"}/libwebrtc.dylib | 
					
						
							|  |  |  |   ditto {./WebKitBuild/Release,"$tmpdir"}/Playwright.app | 
					
						
							|  |  |  |   ditto {./WebKitBuild/Release,"$tmpdir"}/WebCore.framework | 
					
						
							|  |  |  |   ditto {./WebKitBuild/Release,"$tmpdir"}/WebInspectorUI.framework | 
					
						
							|  |  |  |   ditto {./WebKitBuild/Release,"$tmpdir"}/WebKit.framework | 
					
						
							|  |  |  |   ditto {./WebKitBuild/Release,"$tmpdir"}/WebKitLegacy.framework | 
					
						
							|  |  |  |   ditto {"$SCRIPTS_DIR","$tmpdir"}/pw_run.sh | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  |   # copy protocol | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   node "$SCRIPTS_DIR"/concat_protocol.js > "$tmpdir"/protocol.json | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-19 21:31:33 -08:00
										 |  |  |   # Remove all broken symlinks. @see https://github.com/microsoft/playwright/issues/5472 | 
					
						
							|  |  |  |   find "${tmpdir}" -type l ! -exec test -e {} \; -print | xargs rm | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  |   # zip resulting directory and cleanup TMP. | 
					
						
							| 
									
										
										
										
											2021-08-07 15:32:18 +03:00
										 |  |  |   ditto -c -k "$tmpdir" "$ZIP_PATH" | 
					
						
							|  |  |  |   rm -rf "$tmpdir" | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-19 16:08:27 -08:00
										 |  |  | trap "cd $(pwd -P)" EXIT | 
					
						
							| 
									
										
										
										
											2020-06-03 17:47:33 -07:00
										 |  |  | cd "$(dirname "$0")" | 
					
						
							|  |  |  | SCRIPTS_DIR="$(pwd -P)" | 
					
						
							| 
									
										
										
										
											2021-11-05 15:28:44 -07:00
										 |  |  | source "${SCRIPTS_DIR}/../utils.sh" | 
					
						
							| 
									
										
										
										
											2019-11-19 16:08:27 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | main "$@" |