| # 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") |
| |
| # Using a locally-built WebKit is only supported for Debug simulator builds. |
| _build_custom_webkit = checkout_ios_webkit && is_debug && use_ios_simulator |
| |
| group("webkit") { |
| if (_build_custom_webkit) { |
| deps = [ ":bundle_webkit_ios_frameworks" ] |
| } |
| |
| public_configs = [ ":_webkit_ios_config" ] |
| } |
| |
| if (_build_custom_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 "Debug-iphonesimulator" for debug iOS builds and |
| # "Release" for release 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 = "Debug-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 ChangeLog files 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/Tools/ChangeLog", |
| "src/ChangeLog", |
| "src/Source/WebKit/ChangeLog", |
| "src/Source/JavaScriptCore/ChangeLog", |
| "src/Source/WebKitLegacy/ChangeLog", |
| "src/Source/WebKitLegacy/ios/ChangeLog", |
| "src/Source/WebKitLegacy/mac/ChangeLog", |
| "src/Source/bmalloc/ChangeLog", |
| "src/Source/WebCore/ChangeLog", |
| "src/Source/WTF/ChangeLog", |
| "src/Source/ThirdParty/ChangeLog", |
| "src/WebKitLibraries/ChangeLog", |
| ] |
| |
| 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", |
| ] |
| } |
| } |
| |
| 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/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.Plugin.64.xpc", |
| "$_webkit_ios_out_product_dir/com.apple.WebKit.Plugin.64.xpc/com.apple.WebKit.Plugin.64.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", |
| "--debug", |
| "--output_dir", |
| rebase_path("$_webkit_ios_out_base_dir"), |
| ] |
| } |
| |
| compile_webkit("compile_webkit_mac_minibrowser") { |
| outputs = [ "$_webkit_mac_out_product_dir" ] |
| args = [ |
| "--asan", |
| "--output_dir", |
| rebase_path("$_webkit_mac_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/com.apple.WebKit.Networking.xpc", |
| "$_webkit_ios_out_product_dir/com.apple.WebKit.Plugin.64.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}}" ] |
| } |
| |
| 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" ] |
| |
| 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), |
| ] |
| |
| public_deps = [ ":compile_webkit_mac_minibrowser" ] |
| } |
| } |
| |
| config("_webkit_ios_config") { |
| if (_build_custom_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 = [ "$target_out_dir/$_webkit_ios_xcodebuild_out_dir_name" ] |
| } |
| |
| frameworks = [ "WebKit.framework" ] |
| } |