Skip to content

Commit e64f666

Browse files
authored
devops: fork webkit into a separate browser (#5834)
Official WebKit no longer supports Mac 10.14. However, since this system is still very much in use, we want to be able to keep it running for a while. This patch adds a new browser that we would compile and maintain specifically for Mac 10.14: `deprecated-webkit-mac-10.14`. This browser is a clone of Webkit r1443 that is the last known revision to compile on Mac 10.14. As we move on, we're free to modify this browser however we want, backporting important patches. References #5833
1 parent 5cf1361 commit e64f666

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+25488
-5
lines changed

browser_patches/checkout_build_archive_upload.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,6 @@ elif [[ "$BUILD_FLAVOR" == "webkit-win64" ]]; then
201201
BROWSER_NAME="webkit"
202202
EXPECTED_HOST_OS="MINGW"
203203
BUILD_BLOB_NAME="webkit-win64.zip"
204-
elif [[ "$BUILD_FLAVOR" == "webkit-mac-10.14" ]]; then
205-
BROWSER_NAME="webkit"
206-
EXPECTED_HOST_OS="Darwin"
207-
EXPECTED_HOST_OS_VERSION="10.14"
208-
BUILD_BLOB_NAME="webkit-mac-10.14.zip"
209204
elif [[ "$BUILD_FLAVOR" == "webkit-mac-10.15" ]]; then
210205
BROWSER_NAME="webkit"
211206
EXPECTED_HOST_OS="Darwin"
@@ -222,6 +217,16 @@ elif [[ "$BUILD_FLAVOR" == "webkit-mac-11.0-arm64" ]]; then
222217
EXPECTED_HOST_OS_VERSION="11.0"
223218
EXPECTED_ARCH="arm64"
224219
BUILD_BLOB_NAME="webkit-mac-11.0-arm64.zip"
220+
221+
222+
# ===================================
223+
# DEPRECATED WEBKIT COMPILATION
224+
# ===================================
225+
elif [[ "$BUILD_FLAVOR" == "deprecated-webkit-mac-10.14" ]]; then
226+
BROWSER_NAME="deprecated-webkit-mac-10.14"
227+
EXPECTED_HOST_OS="Darwin"
228+
EXPECTED_HOST_OS_VERSION="10.14"
229+
BUILD_BLOB_NAME="deprecated-webkit-mac-10.14.zip"
225230
else
226231
echo ERROR: unknown build flavor - "$BUILD_FLAVOR"
227232
exit 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/checkout
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1443
2+
Changed: [email protected] Mon 01 Mar 2021 09:57:46 AM PST
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
REMOTE_URL="https://git.webkit.org/git/WebKit.git"
2+
BASE_BRANCH="master"
3+
BASE_REVISION="b3de1a5d49442523744d6326dbc852cea829a145"
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#!/bin/bash
2+
set -e
3+
set +x
4+
5+
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
6+
echo "usage: $(basename $0) [output-absolute-path]"
7+
echo
8+
echo "Generate distributable .zip archive from ./checkout folder that was previously built."
9+
echo
10+
exit 0
11+
fi
12+
13+
ZIP_PATH=$1
14+
if [[ $ZIP_PATH != /* ]]; then
15+
echo "ERROR: path $ZIP_PATH is not absolute"
16+
exit 1
17+
fi
18+
if [[ $ZIP_PATH != *.zip ]]; then
19+
echo "ERROR: path $ZIP_PATH must have .zip extension"
20+
exit 1
21+
fi
22+
if [[ -f $ZIP_PATH ]]; then
23+
echo "ERROR: path $ZIP_PATH exists; can't do anything."
24+
exit 1
25+
fi
26+
if ! [[ -d $(dirname $ZIP_PATH) ]]; then
27+
echo "ERROR: folder for path $($ZIP_PATH) does not exist."
28+
exit 1
29+
fi
30+
31+
main() {
32+
if [[ ! -z "${WK_CHECKOUT_PATH}" ]]; then
33+
cd "${WK_CHECKOUT_PATH}"
34+
echo "WARNING: checkout path from WK_CHECKOUT_PATH env: ${WK_CHECKOUT_PATH}"
35+
else
36+
cd "checkout"
37+
fi
38+
39+
set -x
40+
if [[ "$(uname)" == "Darwin" ]]; then
41+
createZipForMac
42+
elif [[ "$(uname)" == "Linux" ]]; then
43+
createZipForLinux
44+
elif [[ "$(uname)" == MINGW* ]]; then
45+
createZipForWindows
46+
else
47+
echo "ERROR: cannot upload on this platform!" 1>&2
48+
exit 1;
49+
fi
50+
}
51+
52+
53+
createZipForLinux() {
54+
# create a TMP directory to copy all necessary files
55+
local tmpdir=$(mktemp -d -t webkit-deploy-XXXXXXXXXX)
56+
mkdir -p $tmpdir
57+
58+
# copy runner
59+
cp -t $tmpdir $SCRIPTS_DIR/pw_run.sh
60+
# copy protocol
61+
node $SCRIPTS_DIR/concat_protocol.js > $tmpdir/protocol.json
62+
63+
# Generate and unpack MiniBrowser bundles for each port
64+
for port in gtk wpe; do
65+
WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/${port^^} Tools/Scripts/generate-bundle \
66+
--bundle=MiniBrowser --release \
67+
--platform=${port} --destination=${tmpdir}
68+
unzip ${tmpdir}/MiniBrowser_${port}_release.zip -d ${tmpdir}/minibrowser-${port}
69+
rm -f ${tmpdir}/MiniBrowser_${port}_release.zip
70+
done
71+
72+
# tar resulting directory and cleanup TMP.
73+
cd $tmpdir
74+
zip --symlinks -r $ZIP_PATH ./
75+
cd -
76+
rm -rf $tmpdir
77+
}
78+
79+
# see https://docs.microsoft.com/en-us/visualstudio/install/tools-for-managing-visual-studio-instances?view=vs-2019
80+
printMSVCRedistDir() {
81+
local dll_file=$("C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -find '**\Redist\MSVC\*\x64\**\vcruntime140.dll')
82+
local redist_dir=$(dirname "$dll_file")
83+
if ! [[ -d $redist_dir ]]; then
84+
echo "ERROR: cannot find MS VS C++ redistributable $redist_dir"
85+
exit 1;
86+
fi
87+
echo "$redist_dir"
88+
}
89+
90+
createZipForWindows() {
91+
# create a TMP directory to copy all necessary files
92+
local tmpdir="/tmp/webkit-deploy-$(date +%s)"
93+
mkdir -p $tmpdir
94+
95+
cp -t $tmpdir ./WebKitLibraries/win/bin64/*.dll
96+
cd WebKitBuild/Release/bin64
97+
cp -r -t $tmpdir WebKit.resources
98+
cp -t $tmpdir JavaScriptCore.dll PlaywrightLib.dll WTF.dll WebKit2.dll libEGL.dll libGLESv2.dll
99+
cp -t $tmpdir Playwright.exe WebKitNetworkProcess.exe WebKitWebProcess.exe
100+
cd -
101+
cd "$(printMSVCRedistDir)"
102+
cp -t $tmpdir msvcp140.dll vcruntime140.dll vcruntime140_1.dll msvcp140_2.dll
103+
cd -
104+
105+
# copy protocol
106+
node $SCRIPTS_DIR/concat_protocol.js > $tmpdir/protocol.json
107+
# tar resulting directory and cleanup TMP.
108+
cd $tmpdir
109+
zip -r $ZIP_PATH ./
110+
cd -
111+
rm -rf $tmpdir
112+
}
113+
114+
createZipForMac() {
115+
# create a TMP directory to copy all necessary files
116+
local tmpdir=$(mktemp -d)
117+
118+
# copy all relevant files
119+
ditto {./WebKitBuild/Release,$tmpdir}/com.apple.WebKit.Networking.xpc
120+
ditto {./WebKitBuild/Release,$tmpdir}/com.apple.WebKit.Plugin.64.xpc
121+
ditto {./WebKitBuild/Release,$tmpdir}/com.apple.WebKit.WebContent.xpc
122+
ditto {./WebKitBuild/Release,$tmpdir}/JavaScriptCore.framework
123+
ditto {./WebKitBuild/Release,$tmpdir}/libwebrtc.dylib
124+
ditto {./WebKitBuild/Release,$tmpdir}/Playwright.app
125+
ditto {./WebKitBuild/Release,$tmpdir}/PluginProcessShim.dylib
126+
ditto {./WebKitBuild/Release,$tmpdir}/WebCore.framework
127+
ditto {./WebKitBuild/Release,$tmpdir}/WebInspectorUI.framework
128+
ditto {./WebKitBuild/Release,$tmpdir}/WebKit.framework
129+
ditto {./WebKitBuild/Release,$tmpdir}/WebKitLegacy.framework
130+
ditto {$SCRIPTS_DIR,$tmpdir}/pw_run.sh
131+
# copy protocol
132+
node $SCRIPTS_DIR/concat_protocol.js > $tmpdir/protocol.json
133+
134+
# Remove all broken symlinks. @see https://github.com/microsoft/playwright/issues/5472
135+
find "${tmpdir}" -type l ! -exec test -e {} \; -print | xargs rm
136+
137+
# zip resulting directory and cleanup TMP.
138+
ditto -c -k $tmpdir $ZIP_PATH
139+
rm -rf $tmpdir
140+
}
141+
142+
trap "cd $(pwd -P)" EXIT
143+
cd "$(dirname "$0")"
144+
SCRIPTS_DIR="$(pwd -P)"
145+
146+
main "$@"
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
set -e
3+
set +x
4+
5+
trap "cd $(pwd -P)" EXIT
6+
cd "$(dirname $0)"
7+
SCRIPT_FOLDER="$(pwd -P)"
8+
9+
build_gtk() {
10+
if ! [[ -d ./WebKitBuild/GTK/DependenciesGTK ]]; then
11+
yes | WEBKIT_JHBUILD=1 WEBKIT_JHBUILD_MODULESET=minimal WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/GTK DEBIAN_FRONTEND=noninteractive ./Tools/Scripts/update-webkitgtk-libs
12+
fi
13+
local CMAKE_ARGS=""
14+
if [[ -n "${EXPORT_COMPILE_COMMANDS}" ]]; then
15+
CMAKE_ARGS="--cmakeargs=\"-DCMAKE_EXPORT_COMPILE_COMMANDS=1\""
16+
fi
17+
WEBKIT_JHBUILD=1 WEBKIT_JHBUILD_MODULESET=minimal WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/GTK ./Tools/Scripts/build-webkit --gtk --release "${CMAKE_ARGS}" --touch-events --orientation-events --no-bubblewrap-sandbox --no-webxr MiniBrowser
18+
}
19+
20+
build_wpe() {
21+
if ! [[ -d ./WebKitBuild/WPE/DependenciesWPE ]]; then
22+
yes | WEBKIT_JHBUILD=1 WEBKIT_JHBUILD_MODULESET=minimal WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/WPE DEBIAN_FRONTEND=noninteractive ./Tools/Scripts/update-webkitwpe-libs
23+
fi
24+
local CMAKE_ARGS=""
25+
if [[ -n "${EXPORT_COMPILE_COMMANDS}" ]]; then
26+
CMAKE_ARGS="--cmakeargs=\"-DCMAKE_EXPORT_COMPILE_COMMANDS=1\""
27+
fi
28+
WEBKIT_JHBUILD=1 WEBKIT_JHBUILD_MODULESET=minimal WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/WPE ./Tools/Scripts/build-webkit --wpe --release "${CMAKE_ARGS}" --touch-events --orientation-events --no-bubblewrap-sandbox --no-webxr MiniBrowser
29+
}
30+
31+
ensure_linux_deps() {
32+
yes | DEBIAN_FRONTEND=noninteractive ./Tools/gtk/install-dependencies
33+
yes | DEBIAN_FRONTEND=noninteractive ./Tools/wpe/install-dependencies
34+
yes | DEBIAN_FRONTEND=noninteractive WEBKIT_JHBUILD=1 WEBKIT_JHBUILD_MODULESET=minimal WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/WPE ./Tools/Scripts/update-webkitwpe-libs
35+
yes | DEBIAN_FRONTEND=noninteractive WEBKIT_JHBUILD=1 WEBKIT_JHBUILD_MODULESET=minimal WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/GTK ./Tools/Scripts/update-webkitgtk-libs
36+
}
37+
38+
if [[ ! -z "${WK_CHECKOUT_PATH}" ]]; then
39+
cd "${WK_CHECKOUT_PATH}"
40+
echo "WARNING: checkout path from WK_CHECKOUT_PATH env: ${WK_CHECKOUT_PATH}"
41+
else
42+
cd "checkout"
43+
fi
44+
45+
if [[ "$(uname)" == "Darwin" ]]; then
46+
./Tools/Scripts/build-webkit --release --touch-events --orientation-events
47+
elif [[ "$(uname)" == "Linux" ]]; then
48+
if [[ $# == 0 || (-z "$1") ]]; then
49+
echo
50+
echo BUILDING: GTK and WPE
51+
echo
52+
build_wpe
53+
build_gtk
54+
elif [[ "$1" == "--full" ]]; then
55+
echo
56+
echo BUILDING: GTK and WPE
57+
echo
58+
ensure_linux_deps
59+
build_wpe
60+
build_gtk
61+
elif [[ "$1" == "--gtk" ]]; then
62+
echo
63+
echo BUILDING: GTK
64+
echo
65+
build_gtk
66+
elif [[ "$1" == "--wpe" ]]; then
67+
echo
68+
echo BUILDING: WPE
69+
echo
70+
build_wpe
71+
fi
72+
elif [[ "$(uname)" == MINGW* ]]; then
73+
/c/Windows/System32/cmd.exe "/c $(cygpath -w ${SCRIPT_FOLDER}/buildwin.bat)"
74+
else
75+
echo "ERROR: cannot upload on this platform!" 1>&2
76+
exit 1;
77+
fi
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set PATH=%WEBKIT_BUILD_PATH%
2+
set WEBKIT_LIBRARIES=%CD%\WebKitLibraries\win
3+
set WEBKIT_OUTPUTDIR=%CD%\WebKitBuild
4+
perl %CD%\Tools\Scripts\build-webkit --wincairo --release --no-ninja --touch-events --orientation-events --dark-mode-css --generate-project-only --cmakeargs="-DLIBVPX_PACKAGE_PATH=C:\vcpkg\packages\libvpx_x64-windows"
5+
%DEVENV% %CD%\WebKitBuild\Release\WebKit.sln /build "Release|x64"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -e
3+
set +x
4+
5+
trap "cd $(pwd -P)" EXIT
6+
cd "$(dirname $0)"
7+
8+
if [[ ! -z "${WK_CHECKOUT_PATH}" ]]; then
9+
cd "${WK_CHECKOUT_PATH}"
10+
echo "WARNING: checkout path from WK_CHECKOUT_PATH env: ${WK_CHECKOUT_PATH}"
11+
else
12+
cd "checkout"
13+
fi
14+
15+
if [[ -d ./WebKitBuild ]]; then
16+
rm -rf ./WebKitBuild/Release
17+
fi
18+
if [[ -d ./WebKitBuild/GTK ]]; then
19+
rm -rf ./WebKitBuild/GTK/Release
20+
fi
21+
if [[ -d ./WebKitBuild/WPE ]]; then
22+
rm -rf ./WebKitBuild/WPE/Release
23+
fi
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const checkoutPath = process.env.WK_CHECKOUT_PATH || path.join(__dirname, 'checkout');
4+
const protocolDir = path.join(checkoutPath, './Source/JavaScriptCore/inspector/protocol');
5+
const files = fs.readdirSync(protocolDir).filter(f => f.endsWith('.json')).map(f => path.join(protocolDir, f));
6+
const json = files.map(file => JSON.parse(fs.readFileSync(file)));
7+
console.log(JSON.stringify(json));
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Copyright (C) 2010-2017 Apple Inc. All rights reserved.
2+
//
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions
5+
// are met:
6+
// 1. Redistributions of source code must retain the above copyright
7+
// notice, this list of conditions and the following disclaimer.
8+
// 2. Redistributions in binary form must reproduce the above copyright
9+
// notice, this list of conditions and the following disclaimer in the
10+
// documentation and/or other materials provided with the distribution.
11+
//
12+
// THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
13+
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15+
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
16+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17+
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18+
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19+
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20+
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23+
24+
#include? "../../../../Internal/Configurations/HaveInternalSDK.xcconfig"
25+
#include "SDKVariant.xcconfig"
26+
27+
USE_INTERNAL_SDK = $(USE_INTERNAL_SDK_$(CONFIGURATION));
28+
USE_INTERNAL_SDK_Production = YES;
29+
USE_INTERNAL_SDK_Debug = $(HAVE_INTERNAL_SDK);
30+
USE_INTERNAL_SDK_Release = $(HAVE_INTERNAL_SDK);
31+
32+
GCC_PREPROCESSOR_DEFINITIONS = DISABLE_LEGACY_WEBKIT_DEPRECATIONS $(inherited);
33+
34+
CLANG_CXX_LANGUAGE_STANDARD = gnu++1z;
35+
CLANG_CXX_LIBRARY = libc++;
36+
CLANG_ENABLE_OBJC_WEAK = YES;
37+
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym;
38+
PREBINDING = NO
39+
GCC_C_LANGUAGE_STANDARD = gnu99
40+
GCC_ENABLE_CPP_EXCEPTIONS = NO;
41+
GCC_PRECOMPILE_PREFIX_HEADER = YES
42+
ENABLE_STRICT_OBJC_MSGSEND = YES;
43+
GCC_TREAT_WARNINGS_AS_ERRORS = YES
44+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
45+
CLANG_WARN_BOOL_CONVERSION = YES;
46+
CLANG_WARN_COMMA = YES;
47+
CLANG_WARN_CONSTANT_CONVERSION = YES;
48+
CLANG_WARN_EMPTY_BODY = YES;
49+
CLANG_WARN_ENUM_CONVERSION = YES;
50+
CLANG_WARN_INFINITE_RECURSION = YES;
51+
CLANG_WARN_INT_CONVERSION = YES;
52+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
53+
CLANG_WARN_STRICT_PROTOTYPES = YES;
54+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
55+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
56+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
57+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
58+
CLANG_WARN_UNREACHABLE_CODE = YES;
59+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
60+
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
61+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
62+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
63+
GCC_WARN_UNUSED_FUNCTION = YES
64+
GCC_WARN_UNUSED_VARIABLE = YES
65+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
66+
GCC_WARN_UNDECLARED_SELECTOR = YES;
67+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
68+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
69+
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
70+
WARNING_CFLAGS = -Wall -W -Wno-unused-parameter
71+
GCC_NO_COMMON_BLOCKS = YES;
72+
73+
SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx tvos tvsimulator watchos watchsimulator;
74+
75+
TARGET_MAC_OS_X_VERSION_MAJOR = $(TARGET_MAC_OS_X_VERSION_MAJOR$(MACOSX_DEPLOYMENT_TARGET:suffix:identifier));
76+
TARGET_MAC_OS_X_VERSION_MAJOR_13 = 101300;
77+
TARGET_MAC_OS_X_VERSION_MAJOR_14 = 101400;
78+
TARGET_MAC_OS_X_VERSION_MAJOR_15 = 101500;
79+
TARGET_MAC_OS_X_VERSION_MAJOR_16 = 101600;
80+
81+
SDKROOT = macosx.internal;
82+
83+
OTHER_CFLAGS = $(ASAN_OTHER_CFLAGS);
84+
OTHER_CPLUSPLUSFLAGS = $(ASAN_OTHER_CPLUSPLUSFLAGS);
85+
OTHER_LDFLAGS = $(ASAN_OTHER_LDFLAGS);
86+
87+
CODE_SIGN_IDENTITY = -;

0 commit comments

Comments
 (0)