blob: 4a650bf71103ccdf687c620d0b8c3c918dc08e6a [file] [log] [blame]
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/gclient_args.gni")
import("//build/config/ios/ios_sdk.gni")
import("//build/config/zip.gni")
declare_args() {
build_mac_webkit = false
}
# Using a locally-built iOS WebKit is only supported for simulator builds, and
# only if not building WebKit for macOS.
_build_ios_webkit = checkout_ios_webkit && target_environment == "simulator" &&
!build_mac_webkit
_build_mac_webkit = checkout_ios_webkit && build_mac_webkit
group("webkit") {
if (_build_ios_webkit) {
deps = [ ":bundle_webkit_ios_frameworks" ]
}
public_configs = [ ":_webkit_ios_config" ]
}
if (_build_ios_webkit || _build_mac_webkit) {
# WebKit is built from source using xcodebuild (invoked via the
# build_webkit.py wrapper script). The WebKit build places its output in a
# sub-directory named "Release-iphonesimulator" for iOS builds and
# "Release" for macOS builds.
_webkit_ios_out_base_dir = "$target_out_dir/iOS"
_webkit_mac_out_base_dir = "$target_out_dir/macOS"
_webkit_ios_xcodebuild_out_dir_name = "Release-iphonesimulator"
_webkit_mac_xcodebuild_out_dir_name = "Release"
_webkit_ios_out_product_dir =
"$_webkit_ios_out_base_dir/$_webkit_ios_xcodebuild_out_dir_name"
_webkit_mac_out_product_dir =
"$_webkit_mac_out_base_dir/$_webkit_mac_xcodebuild_out_dir_name"
template("compile_webkit") {
action(target_name) {
visibility = [
":bundle_webkit_ios_frameworks",
":copy_webkit_mac_minibrowser",
":webkit",
]
script = "build_webkit.py"
inputs = [
# Because it's difficult to list every webkit source file as an input
# here, use the top-50 most frequently-changed files (excluding
# ChangeLogs, which are now deprecated) as a proxy to determine whether or
# not source files have changed.
# TODO(crbug.com/934252): This will not pick up local edits to source
# files, so find a way to properly rebuild when those change.
"src/LayoutTests/TestExpectations",
"src/Source/WebCore/WebCore.xcodeproj/project.pbxproj",
"src/LayoutTests/platform/ios-wk2/TestExpectations",
"src/LayoutTests/platform/mac-wk2/TestExpectations",
"src/Source/WebKit/WebKit.xcodeproj/project.pbxproj",
"src/LayoutTests/platform/mac-wk1/TestExpectations",
"src/LayoutTests/platform/mac/TestExpectations",
"src/Source/WebKit/UIProcess/WebPageProxy.cpp",
"src/Source/WebCore/Sources.txt",
"src/LayoutTests/platform/ios/TestExpectations",
"src/LayoutTests/platform/glib/TestExpectations",
"src/Source/WebKit/WebProcess/WebPage/WebPage.cpp",
"src/Source/WebCore/Headers.cmake",
"src/Source/WebKit/UIProcess/WebPageProxy.h",
"src/LayoutTests/platform/win/TestExpectations",
"src/Source/WebCore/dom/Document.cpp",
"src/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml",
"src/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm",
"src/Source/WebCore/testing/Internals.cpp",
"src/LayoutTests/platform/gtk/TestExpectations",
"src/Source/WebKit/WebProcess/WebPage/WebPage.h",
"src/Tools/CISupport/ews-build/steps.py",
"src/Source/WTF/wtf/PlatformHave.h",
"src/metadata/contributors.json",
"src/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py",
"src/Tools/Scripts/libraries/webkitscmpy/setup.py",
"src/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj",
"src/Source/WebCore/html/HTMLMediaElement.cpp",
"src/Source/WebCore/css/CSSComputedStyleDeclaration.cpp",
"src/Source/WebCore/CMakeLists.txt",
"src/Source/WebCore/dom/Element.cpp",
"src/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp",
"src/Source/WebKit/NetworkProcess/NetworkProcess.cpp",
"src/Tools/CISupport/ews-build/steps_unittest.py",
"src/Source/WebCore/DerivedSources.make",
"src/Source/WebCore/animation/CSSPropertyAnimation.cpp",
"src/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in",
"src/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm",
"src/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj",
"src/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp",
"src/Source/WebCore/rendering/RenderLayer.cpp",
"src/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb.in",
"src/Source/WebCore/rendering/style/RenderStyle.h",
"src/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp",
"src/Source/WebCore/dom/Document.h",
"src/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm",
"src/Source/WebCore/css/parser/CSSPropertyParser.cpp",
"src/Source/WebKit/SourcesCocoa.txt",
"src/Source/WebCore/testing/Internals.h",
"src/Source/WebCore/rendering/RenderBlockFlow.cpp",
]
outputs = invoker.outputs
args = invoker.args
# TODO(crbug.com/934252): "-j 4" restricts xcodebuild to four simultaneous
# jobs. This is intended to prevent overloading the machine, because ninja
# will already be spawning a large number of jobs in parallel with
# xcodebuild, but it causes the webkit build to run very slowly. Find a way
# to increase the parallelism here.
args += [
"-j",
"4",
"-quiet",
]
}
}
}
if (_build_ios_webkit) {
compile_webkit("compile_webkit_ios_frameworks") {
outputs = [
# The frameworks themselves include many resource files, but as a first
# step, use just the binaries.
"$_webkit_ios_out_product_dir/JavaScriptCore.framework",
"$_webkit_ios_out_product_dir/JavaScriptCore.framework/JavaScriptCore",
"$_webkit_ios_out_product_dir/WebCore.framework",
"$_webkit_ios_out_product_dir/WebCore.framework/WebCore",
"$_webkit_ios_out_product_dir/WebKit.framework",
"$_webkit_ios_out_product_dir/WebKit.framework/WebKit",
"$_webkit_ios_out_product_dir/WebKitLegacy.framework",
"$_webkit_ios_out_product_dir/WebKitLegacy.framework/WebKitLegacy",
"$_webkit_ios_out_product_dir/WebKitTestRunnerApp.app/Frameworks/libclang_rt.asan_iossim_dynamic.dylib",
"$_webkit_ios_out_product_dir/com.apple.WebKit.Networking.xpc",
"$_webkit_ios_out_product_dir/com.apple.WebKit.Networking.xpc/com.apple.WebKit.Networking.Development",
"$_webkit_ios_out_product_dir/com.apple.WebKit.WebContent.Development.xpc",
"$_webkit_ios_out_product_dir/com.apple.WebKit.WebContent.Development.xpc/com.apple.WebKit.WebContent.Development.Development",
"$_webkit_ios_out_product_dir/com.apple.WebKit.WebContent.xpc",
"$_webkit_ios_out_product_dir/com.apple.WebKit.WebContent.xpc/com.apple.WebKit.WebContent.Development",
]
args = [
"--ios_simulator",
"--asan",
"--output_dir",
rebase_path("$_webkit_ios_out_base_dir"),
]
}
bundle_data("bundle_webkit_ios_frameworks") {
public_deps = [ ":compile_webkit_ios_frameworks" ]
sources = [
"$_webkit_ios_out_product_dir/JavaScriptCore.framework",
"$_webkit_ios_out_product_dir/WebCore.framework",
"$_webkit_ios_out_product_dir/WebKit.framework",
"$_webkit_ios_out_product_dir/WebKitLegacy.framework",
"$_webkit_ios_out_product_dir/WebKitTestRunnerApp.app/Frameworks/libclang_rt.asan_iossim_dynamic.dylib",
"$_webkit_ios_out_product_dir/com.apple.WebKit.Networking.xpc",
"$_webkit_ios_out_product_dir/com.apple.WebKit.WebContent.Development.xpc",
"$_webkit_ios_out_product_dir/com.apple.WebKit.WebContent.xpc",
]
outputs =
[ "{{bundle_contents_dir}}/WebKitFrameworks/{{source_file_part}}" ]
}
}
if (_build_mac_webkit) {
compile_webkit("compile_webkit_mac_minibrowser") {
outputs = [ "$_webkit_mac_out_product_dir" ]
args = [
"--asan",
"--clean",
"--output_dir",
rebase_path("$_webkit_mac_out_base_dir"),
# The arguments below allow building with Xcode 12.5 (with the macOS 11.3
# SDK).
"MACOSX_DEPLOYMENT_TARGET=11.3",
"TARGET_MAC_OS_X_VERSION_MAJOR=110000",
"MAC_OS_X_VERSION_ACTUAL=110300",
"MAC_OS_X_VERSION_MAJOR=110000",
"MAC_OS_X_VERSION_MINOR=110300",
"MAC_OS_X_PRODUCT_BUILD_VERSION=20E232",
]
}
action("copy_webkit_mac_minibrowser") {
script = "copy_webkit_for_clusterfuzz.py"
sources = [
"$_webkit_mac_out_product_dir",
"run-clusterfuzz.sh",
]
outputs = [ "$root_out_dir/WebKitMacOS" ]
_clang_asan_lib = rebase_path(sources[0], root_build_dir) + "/WebKitTestRunnerApp.app/Contents/Frameworks/libclang_rt.asan_osx_dynamic.dylib"
args = [
"--output",
rebase_path(outputs[0], root_build_dir),
"--webkit_build",
rebase_path(sources[0], root_build_dir),
"--clusterfuzz_script",
rebase_path(sources[1], root_build_dir),
"--clang_asan_library",
"$_clang_asan_lib",
]
public_deps = [ ":compile_webkit_mac_minibrowser" ]
}
}
config("_webkit_ios_config") {
if (_build_ios_webkit) {
# From the ld documentation: "Directories specified with -F are searched in
# the order they appear on the command line and before the default search
# path."
framework_dirs =
[ "$_webkit_ios_out_base_dir/$_webkit_ios_xcodebuild_out_dir_name" ]
}
frameworks = [ "WebKit.framework" ]
}