diff options
author | sdefresne <sdefresne@chromium.org> | 2015-10-21 17:41:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-22 00:42:04 +0000 |
commit | aa7c1cf96274a0a531629f934bd9091a55439270 (patch) | |
tree | f3e5ee07adc85ceaa0ad217c92e0489b1989af6e | |
parent | 945f0b0bb8395df906781961116065caec94e22f (diff) | |
download | chromium_src-aa7c1cf96274a0a531629f934bd9091a55439270.zip chromium_src-aa7c1cf96274a0a531629f934bd9091a55439270.tar.gz chromium_src-aa7c1cf96274a0a531629f934bd9091a55439270.tar.bz2 |
[iOS][GN] Port ios_web_unittests to build with gn
Add template to run a java command as an "script", i.e. templates
java_action/java_action_foreach similar to action/action_foreach.
Add template to compile a bunch of JavaScript to a bundle and to
compile JavaScript files with closure compile (only enable checks
that are known to work).
Fix gcdwebserver public configuration to add the dependency on libz
to libs instead of using ldflags.
Add files missing from //ui/base:test_support when building for iOS
with gn (they are present in the gyp build).
BUG=459705
Review URL: https://codereview.chromium.org/1393303003
Cr-Commit-Position: refs/heads/master@{#355460}
-rw-r--r-- | BUILD.gn | 3 | ||||
-rw-r--r-- | build/util/java_action.gni | 101 | ||||
-rwxr-xr-x | build/util/java_action.py | 82 | ||||
-rw-r--r-- | ios/third_party/gcdwebserver/BUILD.gn | 3 | ||||
-rw-r--r-- | ios/web/BUILD.gn | 506 | ||||
-rw-r--r-- | ios/web/ios_web.gyp | 11 | ||||
-rw-r--r-- | ios/web/ios_web_unittests.gyp | 1 | ||||
-rw-r--r-- | ios/web/js_compile.gni | 171 | ||||
-rw-r--r-- | ui/base/BUILD.gn | 7 |
9 files changed, 880 insertions, 5 deletions
@@ -187,8 +187,7 @@ group("both_gn_and_gyp") { deps += [ "//ios/net:ios_net_unittests", "//ios/testing:ocmock_support_unittest", - "//ios/third_party/gcdwebserver", - "//ios/third_party/blink:html_tokenizer", + "//ios/web:ios_web_unittests", ] } diff --git a/build/util/java_action.gni b/build/util/java_action.gni new file mode 100644 index 0000000..d9ca472 --- /dev/null +++ b/build/util/java_action.gni @@ -0,0 +1,101 @@ +# Copyright 2015 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. + +jarrunner = "//build/util/java_action.py" + +# Declare a target that runs a java command a single time. +# +# This target type allows you to run a java command a single time to produce +# one or more output files. If you want to run a java command for each of a +# set of input files, see "java_action_foreach". +# +# See "gn help action" for more information on how to use this target. This +# template is based on the "action" and supports the same variables. +template("java_action") { + assert(defined(invoker.script), + "Need script in $target_name listing the .jar file to run.") + assert(defined(invoker.outputs), + "Need outputs in $target_name listing the generated outputs.") + + jarscript = invoker.script + action(target_name) { + script = jarrunner + + inputs = [ + jarscript, + ] + if (defined(invoker.inputs)) { + inputs += invoker.inputs + } + + args = [ + "-jar", + rebase_path(jarscript, root_build_dir), + ] + if (defined(invoker.args)) { + args += invoker.args + } + + forward_variables_from(invoker, + [ + "console", + "data", + "data_deps", + "depfile", + "deps", + "outputs", + "sources", + "visibility", + ]) + } +} + +# Declare a target that runs a java command over a set of files. +# +# This target type allows you to run a java command once-per-file over a set of +# sources. If you want to run a java command once that takes many files as +# input, see "java_action". +# +# See "gn help action_foreach" for more information on how to use this target. +# This template is based on the "action_foreach" supports the same variables. +template("java_action_foreach") { + assert(defined(invoker.script), + "Need script in $target_name listing the .jar file to run.") + assert(defined(invoker.outputs), + "Need outputs in $target_name listing the generated outputs.") + assert(defined(invoker.sources), + "Need sources in $target_name listing the target inputs.") + + jarscript = invoker.script + action_foreach(target_name) { + script = jarrunner + + inputs = [ + jarscript, + ] + if (defined(invoker.inputs)) { + inputs += invoker.inputs + } + + args = [ + "-jar", + rebase_path(jarscript, root_build_dir), + ] + if (defined(invoker.args)) { + args += invoker.args + } + + forward_variables_from(invoker, + [ + "console", + "data", + "data_deps", + "depfile", + "deps", + "outputs", + "sources", + "visibility", + ]) + } +} diff --git a/build/util/java_action.py b/build/util/java_action.py new file mode 100755 index 0000000..abf084c --- /dev/null +++ b/build/util/java_action.py @@ -0,0 +1,82 @@ +#!/usr/bin/python +# Copyright 2015 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. + +"""Wrapper script to run java command as action with gn.""" + +import os +import subprocess +import sys + +EXIT_SUCCESS = 0 +EXIT_FAILURE = 1 + + +def IsExecutable(path): + """Returns whether file at |path| exists and is executable. + + Args: + path: absolute or relative path to test. + + Returns: + True if the file at |path| exists, False otherwise. + """ + return os.path.isfile(path) and os.access(path, os.X_OK) + + +def FindCommand(command): + """Looks up for |command| in PATH. + + Args: + command: name of the command to lookup, if command is a relative or + absolute path (i.e. contains some path separator) then only that + path will be tested. + + Returns: + Full path to command or None if the command was not found. + + On Windows, this respects the PATHEXT environment variable when the + command name does not have an extension. + """ + fpath, _ = os.path.split(command) + if fpath: + if IsExecutable(command): + return command + + if sys.platform == 'win32': + # On Windows, if the command does not have an extension, cmd.exe will + # try all extensions from PATHEXT when resolving the full path. + command, ext = os.path.splitext(command) + if not ext: + exts = os.environ['PATHEXT'].split(os.path.pathsep) + else: + exts = [ext] + else: + exts = [''] + + for path in os.environ['PATH'].split(os.path.pathsep): + for ext in exts: + path = os.path.join(path, command) + ext + if IsExecutable(path): + return path + + return None + + +def main(): + java_path = FindCommand('java') + if not java_path: + sys.stderr.write('java: command not found\n') + sys.exit(EXIT_FAILURE) + + args = sys.argv[1:] + if len(args) < 2 or args[0] != '-jar': + sys.stderr.write('usage: %s -jar JARPATH [java_args]...\n' % sys.argv[0]) + sys.exit(EXIT_FAILURE) + + return subprocess.check_call([java_path] + args) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/ios/third_party/gcdwebserver/BUILD.gn b/ios/third_party/gcdwebserver/BUILD.gn index da07148..65d0d66 100644 --- a/ios/third_party/gcdwebserver/BUILD.gn +++ b/ios/third_party/gcdwebserver/BUILD.gn @@ -3,11 +3,12 @@ # found in the LICENSE file. config("public_config") { - ldflags = [ "-lz" ] libs = [ "CFNetwork.framework", "MobileCoreServices.framework", + "z", ] + include_dirs = [ "src/GCDWebServer/Core", "src/GCDWebServer/Requests", diff --git a/ios/web/BUILD.gn b/ios/web/BUILD.gn new file mode 100644 index 0000000..9eb1a11 --- /dev/null +++ b/ios/web/BUILD.gn @@ -0,0 +1,506 @@ +# Copyright 2015 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. + +# GN build of //ios/web only supports building with the web implementation of +# WebThread as opposed to GYP build that allow using a shim implementation based +# on top of BrowserThread. +# +# See ios/web/ios_web.gyp for more information on how gyp supports this. The +# gn targets will fold the target selection in the gyp "incomplete" targets. + +import("//testing/test.gni") +import("//ios/web/js_compile.gni") + +config("config") { + visibility = [ ":web" ] + + # The WebKit framework is only available since iOS 8.0 but Chrome on iOS do + # supports iOS 7.0 so need to use weak linking. + # TODO(crbug.com/541549): change to regular linking once support for iOS 7 is + # dropped. + ldflags = [ + "-weak_framework", + "WebKit", + ] +} + +source_set("web") { + deps = [ + ":core", + ":js_resources", + ":user_agent", + "//base", + "//components/url_formatter", + "//ios/net", + "//ios/third_party/blink:html_tokenizer", + "//net", + "//ui/base", + "//ui/gfx", + "//ui/gfx/geometry:geometry", + "//ui/resources", + "//url", + ] + + sources = [ + "active_state_manager_impl.h", + "active_state_manager_impl.mm", + "alloc_with_zone_interceptor.h", + "alloc_with_zone_interceptor.mm", + "browser_state.mm", + "browser_url_rewriter_impl.cc", + "browser_url_rewriter_impl.h", + "browsing_data_managers/crw_browsing_data_manager.h", + "browsing_data_managers/crw_cookie_browsing_data_manager.h", + "browsing_data_managers/crw_cookie_browsing_data_manager.mm", + "browsing_data_partition_impl.h", + "browsing_data_partition_impl.mm", + "crw_browsing_data_store.mm", + "interstitials/html_web_interstitial_impl.h", + "interstitials/html_web_interstitial_impl.mm", + "interstitials/native_web_interstitial_impl.h", + "interstitials/native_web_interstitial_impl.mm", + "interstitials/web_interstitial_facade_delegate.h", + "interstitials/web_interstitial_impl.h", + "interstitials/web_interstitial_impl.mm", + "load_committed_details.cc", + "navigation/crw_session_certificate_policy_manager.h", + "navigation/crw_session_certificate_policy_manager.mm", + "navigation/crw_session_controller+private_constructors.h", + "navigation/crw_session_controller.h", + "navigation/crw_session_controller.mm", + "navigation/crw_session_entry.h", + "navigation/crw_session_entry.mm", + "navigation/navigation_item_facade_delegate.h", + "navigation/navigation_item_impl.h", + "navigation/navigation_item_impl.mm", + "navigation/navigation_manager_delegate.h", + "navigation/navigation_manager_facade_delegate.h", + "navigation/navigation_manager_impl.h", + "navigation/navigation_manager_impl.mm", + "navigation/nscoder_util.h", + "navigation/nscoder_util.mm", + "navigation/time_smoother.cc", + "navigation/time_smoother.h", + "navigation/web_load_params.h", + "navigation/web_load_params.mm", + "net/cert_policy.cc", + "net/cert_store_impl.cc", + "net/cert_store_impl.h", + "net/cert_verifier_block_adapter.cc", + "net/cert_verifier_block_adapter.h", + "net/certificate_policy_cache.cc", + "net/clients/crw_csp_network_client.h", + "net/clients/crw_csp_network_client.mm", + "net/clients/crw_js_injection_network_client.h", + "net/clients/crw_js_injection_network_client.mm", + "net/clients/crw_js_injection_network_client_factory.h", + "net/clients/crw_js_injection_network_client_factory.mm", + "net/clients/crw_passkit_delegate.h", + "net/clients/crw_passkit_network_client.h", + "net/clients/crw_passkit_network_client.mm", + "net/clients/crw_passkit_network_client_factory.h", + "net/clients/crw_passkit_network_client_factory.mm", + "net/clients/crw_redirect_network_client.h", + "net/clients/crw_redirect_network_client.mm", + "net/clients/crw_redirect_network_client_factory.h", + "net/clients/crw_redirect_network_client_factory.mm", + "net/cookie_notification_bridge.h", + "net/cookie_notification_bridge.mm", + "net/crw_cert_policy_cache.h", + "net/crw_cert_policy_cache.mm", + "net/crw_cert_verification_controller.h", + "net/crw_cert_verification_controller.mm", + "net/crw_request_tracker_delegate.h", + "net/crw_url_verifying_protocol_handler.h", + "net/crw_url_verifying_protocol_handler.mm", + "net/request_group_util.h", + "net/request_group_util.mm", + "net/request_tracker_data_memoizing_store.h", + "net/request_tracker_factory_impl.h", + "net/request_tracker_factory_impl.mm", + "net/request_tracker_impl.h", + "net/request_tracker_impl.mm", + "net/web_http_protocol_handler_delegate.h", + "net/web_http_protocol_handler_delegate.mm", + "public/active_state_manager.h", + "public/block_types.h", + "public/browser_state.h", + "public/browser_url_rewriter.h", + "public/browsing_data_partition.h", + "public/browsing_data_partition_client.cc", + "public/browsing_data_partition_client.h", + "public/cert_policy.h", + "public/cert_store.h", + "public/certificate_policy_cache.h", + "public/crw_browsing_data_store.h", + "public/crw_browsing_data_store_delegate.h", + "public/favicon_status.cc", + "public/favicon_status.h", + "public/favicon_url.cc", + "public/favicon_url.h", + "public/interstitials/web_interstitial.h", + "public/interstitials/web_interstitial_delegate.h", + "public/load_committed_details.h", + "public/navigation_item.h", + "public/navigation_manager.h", + "public/referrer.h", + "public/referrer_util.cc", + "public/referrer_util.h", + "public/security_style.h", + "public/ssl_status.cc", + "public/ssl_status.h", + "public/string_util.h", + "public/url_scheme_util.h", + "public/url_util.h", + "public/user_metrics.h", + "public/web/url_data_source_ios.h", + "public/web_client.h", + "public/web_client.mm", + "public/web_controller_factory.h", + "public/web_controller_factory.mm", + "public/web_kit_constants.h", + "public/web_state/credential.h", + "public/web_state/crw_web_controller_observer.h", + "public/web_state/crw_web_user_interface_delegate.h", + "public/web_state/crw_web_view_proxy.h", + "public/web_state/crw_web_view_scroll_view_proxy.h", + "public/web_state/global_web_state_observer.h", + "public/web_state/js/crw_js_injection_evaluator.h", + "public/web_state/js/crw_js_injection_manager.h", + "public/web_state/js/crw_js_injection_receiver.h", + "public/web_state/page_display_state.h", + "public/web_state/page_display_state.mm", + "public/web_state/ui/crw_content_view.h", + "public/web_state/ui/crw_generic_content_view.h", + "public/web_state/ui/crw_native_content.h", + "public/web_state/ui/crw_native_content_provider.h", + "public/web_state/ui/crw_web_delegate.h", + "public/web_state/ui/crw_web_view_content_view.h", + "public/web_state/url_verification_constants.h", + "public/web_state/web_state.h", + "public/web_state/web_state_observer.h", + "public/web_state/web_state_observer_bridge.h", + "public/web_state/web_state_policy_decider.h", + "public/web_state/web_state_user_data.h", + "public/web_thread.h", + "public/web_thread_delegate.h", + "public/web_ui_ios_data_source.h", + "public/web_view_counter.h", + "public/web_view_creation_util.h", + "public/web_view_type.h", + "string_util.cc", + "ui_web_view_util.h", + "ui_web_view_util.mm", + "url_scheme_util.mm", + "url_util.cc", + "user_metrics.cc", + "weak_nsobject_counter.h", + "weak_nsobject_counter.mm", + "web_kit_constants.cc", + "web_state/blocked_popup_info.h", + "web_state/blocked_popup_info.mm", + "web_state/credential.cc", + "web_state/crw_recurring_task_delegate.h", + "web_state/crw_web_view_proxy_impl.h", + "web_state/crw_web_view_proxy_impl.mm", + "web_state/crw_web_view_scroll_view_proxy.mm", + "web_state/error_translation_util.h", + "web_state/error_translation_util.mm", + "web_state/frame_info.h", + "web_state/global_web_state_event_tracker.cc", + "web_state/global_web_state_event_tracker.h", + "web_state/global_web_state_observer.cc", + "web_state/js/credential_util.h", + "web_state/js/credential_util.mm", + "web_state/js/crw_js_early_script_manager.h", + "web_state/js/crw_js_early_script_manager.mm", + "web_state/js/crw_js_injection_manager.mm", + "web_state/js/crw_js_injection_receiver.mm", + "web_state/js/crw_js_invoke_parameter_queue.h", + "web_state/js/crw_js_invoke_parameter_queue.mm", + "web_state/js/crw_js_plugin_placeholder_manager.h", + "web_state/js/crw_js_plugin_placeholder_manager.mm", + "web_state/js/crw_js_window_id_manager.h", + "web_state/js/crw_js_window_id_manager.mm", + "web_state/js/page_script_util.h", + "web_state/js/page_script_util.mm", + "web_state/ui/crw_context_menu_provider.h", + "web_state/ui/crw_context_menu_provider.mm", + "web_state/ui/crw_debug_web_view.h", + "web_state/ui/crw_debug_web_view.mm", + "web_state/ui/crw_generic_content_view.mm", + "web_state/ui/crw_simple_web_view_controller.h", + "web_state/ui/crw_static_file_web_view.h", + "web_state/ui/crw_static_file_web_view.mm", + "web_state/ui/crw_swipe_recognizer_provider.h", + "web_state/ui/crw_touch_tracking_recognizer.h", + "web_state/ui/crw_touch_tracking_recognizer.mm", + "web_state/ui/crw_ui_simple_web_view_controller.h", + "web_state/ui/crw_ui_simple_web_view_controller.mm", + "web_state/ui/crw_ui_web_view_web_controller.h", + "web_state/ui/crw_ui_web_view_web_controller.mm", + "web_state/ui/crw_web_controller+protected.h", + "web_state/ui/crw_web_controller.h", + "web_state/ui/crw_web_controller.mm", + "web_state/ui/crw_web_controller_container_view.h", + "web_state/ui/crw_web_controller_container_view.mm", + "web_state/ui/crw_web_view_content_view.mm", + "web_state/ui/crw_wk_script_message_router.h", + "web_state/ui/crw_wk_script_message_router.mm", + "web_state/ui/crw_wk_simple_web_view_controller.h", + "web_state/ui/crw_wk_simple_web_view_controller.mm", + "web_state/ui/crw_wk_web_view_crash_detector.h", + "web_state/ui/crw_wk_web_view_crash_detector.mm", + "web_state/ui/crw_wk_web_view_web_controller.h", + "web_state/ui/crw_wk_web_view_web_controller.mm", + "web_state/ui/web_view_js_utils.h", + "web_state/ui/web_view_js_utils.mm", + "web_state/ui/wk_back_forward_list_item_holder.h", + "web_state/ui/wk_back_forward_list_item_holder.mm", + "web_state/ui/wk_web_view_configuration_provider.h", + "web_state/ui/wk_web_view_configuration_provider.mm", + "web_state/web_controller_observer_bridge.h", + "web_state/web_controller_observer_bridge.mm", + "web_state/web_state.cc", + "web_state/web_state_facade_delegate.h", + "web_state/web_state_impl.h", + "web_state/web_state_impl.mm", + "web_state/web_state_observer.cc", + "web_state/web_state_observer_bridge.mm", + "web_state/web_state_policy_decider.mm", + "web_state/web_view_internal_creation_util.h", + "web_state/web_view_internal_creation_util.mm", + "web_state/wk_web_view_security_util.h", + "web_state/wk_web_view_security_util.mm", + "web_thread_impl.cc", + "web_thread_impl.h", + "web_view_counter_impl.h", + "web_view_counter_impl.mm", + "web_view_creation_util.mm", + "webui/crw_web_ui_manager.h", + "webui/crw_web_ui_manager.mm", + "webui/crw_web_ui_page_builder.h", + "webui/crw_web_ui_page_builder.mm", + "webui/shared_resources_data_source_ios.cc", + "webui/shared_resources_data_source_ios.h", + "webui/url_data_manager_ios.cc", + "webui/url_data_manager_ios.h", + "webui/url_data_manager_ios_backend.cc", + "webui/url_data_manager_ios_backend.h", + "webui/url_data_source_ios.cc", + "webui/url_data_source_ios_impl.cc", + "webui/url_data_source_ios_impl.h", + "webui/url_fetcher_block_adapter.h", + "webui/url_fetcher_block_adapter.mm", + "webui/web_ui_ios_controller_factory_registry.cc", + "webui/web_ui_ios_controller_factory_registry.h", + "webui/web_ui_ios_data_source_impl.cc", + "webui/web_ui_ios_data_source_impl.h", + "webui/web_ui_ios_impl.h", + "webui/web_ui_ios_impl.mm", + ] + + public_configs = [ ":config" ] +} + +source_set("core") { + deps = [ + "//base", + ] + + sources = [ + "crw_network_activity_indicator_manager.h", + "crw_network_activity_indicator_manager.mm", + "history_state_util.h", + "history_state_util.mm", + ] +} + +source_set("user_agent") { + deps = [ + "//base", + ] + + sources = [ + "public/user_agent.h", + "public/user_agent.mm", + ] +} + +source_set("test_support") { + testonly = true + + deps = [ + "//ios/testing:ocmock_support", + "//ios/third_party/gcdwebserver", + "//testing/gmock", + "//testing/gtest", + "//third_party/ocmock", + ":web", + ] + + sources = [ + "public/test/crw_test_js_injection_receiver.h", + "public/test/crw_test_js_injection_receiver.mm", + "public/test/http_server.h", + "public/test/http_server.mm", + "public/test/js_test_util.h", + "public/test/js_test_util.mm", + "public/test/response_providers/data_response_provider.h", + "public/test/response_providers/data_response_provider.mm", + "public/test/response_providers/file_based_response_provider.h", + "public/test/response_providers/file_based_response_provider.mm", + "public/test/response_providers/file_based_response_provider_impl.cc", + "public/test/response_providers/file_based_response_provider_impl.h", + "public/test/response_providers/response_provider.cc", + "public/test/response_providers/response_provider.h", + "public/test/test_browser_state.cc", + "public/test/test_browser_state.h", + "public/test/test_web_client.h", + "public/test/test_web_client.mm", + "public/test/test_web_state.cc", + "public/test/test_web_state.h", + "public/test/test_web_thread.h", + "public/test/test_web_thread_bundle.h", + "public/test/test_web_view_content_view.h", + "public/test/test_web_view_content_view.mm", + "public/test/web_test_util.h", + "test/crw_fake_web_controller_observer.h", + "test/crw_fake_web_controller_observer.mm", + "test/test_web_thread.cc", + "test/test_web_thread_bundle.cc", + "test/web_test.h", + "test/web_test.mm", + "test/web_test_suite.cc", + "test/web_test_suite.h", + "test/wk_web_view_crash_utils.h", + "test/wk_web_view_crash_utils.mm", + ] +} + +test("ios_web_unittests") { + deps = [ + "//base", + "//base/test:test_support", + "//net:test_support", + "//testing/gmock", + "//testing/gtest", + "//third_party/ocmock", + "//ui/base:test_support", + "//ios/testing:ocmock_support", + ":web", + ":test_support", + ] + + sources = [ + "active_state_manager_impl_unittest.mm", + "alloc_with_zone_interceptor_unittest.mm", + "browser_state_unittest.cc", + "browsing_data_partition_impl_unittest.mm", + "crw_browsing_data_store_unittest.mm", + "crw_network_activity_indicator_manager_unittest.mm", + "history_state_util_unittest.mm", + "navigation/crw_session_controller_unittest.mm", + "navigation/crw_session_entry_unittest.mm", + "navigation/navigation_item_impl_unittest.mm", + "navigation/navigation_manager_impl_unittest.mm", + "navigation/nscoder_util_unittest.mm", + "net/cert_policy_unittest.cc", + "net/cert_verifier_block_adapter_unittest.cc", + "net/clients/crw_csp_network_client_unittest.mm", + "net/clients/crw_js_injection_network_client_unittest.mm", + "net/clients/crw_passkit_network_client_unittest.mm", + "net/crw_cert_policy_cache_unittest.mm", + "net/crw_cert_verification_controller_unittest.mm", + "net/crw_url_verifying_protocol_handler_unittest.mm", + "net/request_group_util_unittest.mm", + "net/request_tracker_impl_unittest.mm", + "net/web_http_protocol_handler_delegate_unittest.mm", + "public/referrer_util_unittest.cc", + "public/test/http_server_unittest.mm", + "string_util_unittest.cc", + "test/crw_fake_web_controller_observer_unittest.mm", + "test/run_all_unittests.cc", + "ui_web_view_util_unittest.mm", + "url_scheme_util_unittest.mm", + "url_util_unittest.cc", + "weak_nsobject_counter_unittest.mm", + "web_state/crw_web_view_scroll_view_proxy_unittest.mm", + "web_state/js/common_js_unittest.mm", + "web_state/js/core_js_unittest.mm", + "web_state/js/credential_util_unittest.mm", + "web_state/js/crw_js_early_script_manager_unittest.mm", + "web_state/js/crw_js_injection_manager_unittest.mm", + "web_state/js/crw_js_invoke_parameter_queue_unittest.mm", + "web_state/js/crw_js_window_id_manager_unittest.mm", + "web_state/js/page_script_util_unittest.mm", + "web_state/ui/crw_static_file_web_view_unittest.mm", + "web_state/ui/crw_ui_simple_web_view_controller_unittest.mm", + "web_state/ui/crw_web_controller_container_view_unittest.mm", + "web_state/ui/crw_web_controller_observer_unittest.mm", + "web_state/ui/crw_web_controller_unittest.mm", + "web_state/ui/crw_wk_script_message_router_unittest.mm", + "web_state/ui/crw_wk_simple_web_view_controller_unittest.mm", + "web_state/ui/crw_wk_web_view_crash_detector_unittest.mm", + "web_state/ui/web_view_js_utils_unittest.mm", + "web_state/ui/wk_back_forward_list_item_holder_unittest.mm", + "web_state/ui/wk_web_view_configuration_provider_unittest.mm", + "web_state/web_state_impl_unittest.mm", + "web_state/web_view_internal_creation_util_unittest.mm", + "web_state/wk_web_view_security_util_unittest.mm", + "web_view_counter_impl_unittest.mm", + "webui/crw_web_ui_manager_unittest.mm", + "webui/crw_web_ui_page_builder_unittest.mm", + "webui/url_fetcher_block_adapter_unittest.mm", + ] +} + +js_compile_bundle("web_bundle_ui") { + visibility = [ ":js_resources" ] + closure_entry_point = "__crWeb.webBundle" + + sources = [ + "web_state/js/resources/base.js", + "web_state/js/resources/common.js", + "web_state/js/resources/console.js", + "web_state/js/resources/core.js", + "web_state/js/resources/core_dynamic_ui.js", + "web_state/js/resources/dialog_overrides.js", + "web_state/js/resources/message.js", + "web_state/js/resources/message_dynamic_ui.js", + "web_state/js/resources/web_bundle_ui.js", + "web_state/js/resources/window_open_ui.js", + ] +} + +js_compile_bundle("web_bundle_wk") { + visibility = [ ":js_resources" ] + closure_entry_point = "__crWeb.webBundle" + + sources = [ + "web_state/js/resources/base.js", + "web_state/js/resources/common.js", + "web_state/js/resources/console.js", + "web_state/js/resources/core.js", + "web_state/js/resources/core_dynamic_wk.js", + "web_state/js/resources/dialog_overrides.js", + "web_state/js/resources/message.js", + "web_state/js/resources/message_dynamic_wk.js", + "web_state/js/resources/web_bundle_wk.js", + "web_state/js/resources/window_open_wk.js", + ] +} + +js_compile_checked("js_resources") { + deps = [ + ":web_bundle_ui", + ":web_bundle_wk", + ] + + sources = [ + "web_state/js/resources/plugin_placeholder.js", + "web_state/js/resources/window_id.js", + "webui/resources/web_ui.js", + ] +} diff --git a/ios/web/ios_web.gyp b/ios/web/ios_web.gyp index 891985a..98628a1 100644 --- a/ios/web/ios_web.gyp +++ b/ios/web/ios_web.gyp @@ -41,6 +41,7 @@ # This will become unnecessary once Chrome switches to using ios_web_thread, # at which point that will be folded into this target. { + # GN version: //ios/web 'target_name': 'ios_web', 'type': 'static_library', 'include_dirs': [ @@ -174,8 +175,6 @@ 'public/string_util.h', 'public/url_scheme_util.h', 'public/url_util.h', - 'public/user_agent.h', - 'public/user_agent.mm', 'public/user_metrics.h', 'public/web/url_data_source_ios.h', 'public/web_client.h', @@ -322,6 +321,8 @@ 'webui/web_ui_ios_impl.mm', ], 'link_settings': { + # TODO(crbug.com/541549): change to regular linking once support for + # iOS 7 is dropped. 'xcode_settings': { 'OTHER_LDFLAGS': [ '-weak_framework WebKit', @@ -367,6 +368,7 @@ }, # Target shared by ios_web and CrNet. { + # GN version: //ios/web:core 'target_name': 'ios_web_core', 'type': 'static_library', 'dependencies': [ @@ -383,6 +385,7 @@ ], }, { + # GN version: //ios/web:web_bundle_ui 'target_name': 'ios_web_js_bundle_ui', 'type': 'none', 'variables': { @@ -413,6 +416,7 @@ ], }, { + # GN version: //ios/web:web_bundle_wk 'target_name': 'ios_web_js_bundle_wk', 'type': 'none', 'variables': { @@ -443,6 +447,7 @@ ], }, { + # GN version: //ios/web:js_resources 'target_name': 'js_resources', 'type': 'none', 'dependencies': [ @@ -466,6 +471,7 @@ ], }, { + # GN version: //ios/web:test_support 'target_name': 'test_support_ios_web', 'type': 'static_library', 'dependencies': [ @@ -552,6 +558,7 @@ ], }, { + # GN version: //ios/web:user_agent 'target_name': 'user_agent', 'type': 'static_library', 'include_dirs': [ diff --git a/ios/web/ios_web_unittests.gyp b/ios/web/ios_web_unittests.gyp index 8c7c517..3f1b88a 100644 --- a/ios/web/ios_web_unittests.gyp +++ b/ios/web/ios_web_unittests.gyp @@ -7,6 +7,7 @@ }, 'targets': [ { + # GN version: //ios/web:ios_web_unittests 'target_name': 'ios_web_unittests', 'type': '<(gtest_target_type)', 'dependencies': [ diff --git a/ios/web/js_compile.gni b/ios/web/js_compile.gni new file mode 100644 index 0000000..6c9590a --- /dev/null +++ b/ios/web/js_compile.gni @@ -0,0 +1,171 @@ +# Copyright 2015 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/util/java_action.gni") + +declare_args() { + # Control whether the JavaScript files shipped with Chrome on iOS are + # compiled with closure_compiler or not. Useful for debugging. + compile_javascript = true +} + +closure_compiler_path = "//third_party/closure_compiler/compiler/compiler.jar" + +# Defines a target that create a JavaScript bundle using the closure compiler. +# +# Variables +# sources: +# List of JavaScript files to compile into the bundle. +# +# closure_entry_point: +# Name of the entry point closure module. +# +# deps (optional) +# List of targets required by this target. +# +# visibility (optional) +# Visibility restrictions. +# +# Generates a single JavaScript bundle file that can be put in the application +# bundle. +# +# TODO(eugenebut): this should uses the same error flags as js_compile_checked. +template("js_compile_bundle") { + assert(defined(invoker.sources), + "Need sources in $target_name listing the js files.") + + assert(defined(invoker.closure_entry_point), + "Need closure_entry_point in $target_name for generated js file.") + + java_action(target_name) { + forward_variables_from(invoker, + [ + "deps", + "visibility", + ]) + + script = closure_compiler_path + sources = invoker.sources + outputs = [ + "$target_gen_dir/$target_name.js", + ] + + args = [ + "--compilation_level", + "SIMPLE_OPTIMIZATIONS", + "--js_output_file", + rebase_path("$target_gen_dir/$target_name.js", root_build_dir), + "--only_closure_dependencies", + "--closure_entry_point", + invoker.closure_entry_point, + "--js", + ] + rebase_path(sources, root_build_dir) + + # TODO(crbug.com/546283): add the generated bundle to the list of files to + # move in the application bundle, equivalent to the following gyp code: + # + # "link_settings": { + # "mac_bundle_resources": [ + # "<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_NAME).js", + # ], + # }, + } +} + +# Defines a target that compile JavaScript files with error checking using the +# closure compiler. +# +# Variables +# sources: +# List of JavaScript files to compile. +# +# deps (optional) +# List of targets required by this target. +# +# visibility (optional) +# Visibility restrictions. +# +# TODO(eugenebut): use flags from third_party/closure_compiler/closure_args.gni +# once they are the same. +template("js_compile_checked") { + assert(defined(invoker.sources), + "Need sources in $target_name listing the js files.") + + if (compile_javascript) { + java_action_foreach(target_name) { + forward_variables_from(invoker, + [ + "deps", + "visibility", + ]) + + script = closure_compiler_path + sources = invoker.sources + outputs = [ + "$target_gen_dir/{{source_file_part}}", + ] + + # TODO(eugenebut): need to enable the following compilation checks once + # the corresponding errors have been fixed: + # --jscomp_error=checkTypes + # --jscomp_error=checkVars + # --jscomp_error=missingProperties + # --jscomp_error=missingReturn + # --jscomp_error=undefinedVars + + args = [ + "--compilation_level", + "SIMPLE_OPTIMIZATIONS", + "--jscomp_error=accessControls", + "--jscomp_error=ambiguousFunctionDecl", + "--jscomp_error=constantProperty", + "--jscomp_error=deprecated", + "--jscomp_error=externsValidation", + "--jscomp_error=globalThis", + "--jscomp_error=invalidCasts", + "--jscomp_error=nonStandardJsDocs", + "--jscomp_error=suspiciousCode", + "--jscomp_error=undefinedNames", + "--jscomp_error=unknownDefines", + "--jscomp_error=uselessCode", + "--jscomp_error=visibility", + "--js", + "{{source}}", + "--js_output_file", + rebase_path("$target_gen_dir/{{source_file_part}}", root_build_dir), + ] + + # TODO(crbug.com/546283): add the generated bundle to the list of files + # to move in the application bundle, equivalent to the following gyp code: + # + # "link_settings": { + # "mac_bundle_resources": [ + # "<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_NAME).js", + # ], + # }, + } + } else { + copy(target_name) { + forward_variables_from(invoker, + [ + "deps", + "visibility", + ]) + + sources = invoker.sources + outputs = [ + "$target_gen_dir/{{source_file_part}}", + ] + + # TODO(crbug.com/546283): add the generated bundle to the list of files + # to move in the application bundle, equivalent to the following gyp code: + # + # "link_settings": { + # "mac_bundle_resources": [ + # "<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_NAME).js", + # ], + # }, + } + } +} diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn index b42879a..31979ab 100644 --- a/ui/base/BUILD.gn +++ b/ui/base/BUILD.gn @@ -604,6 +604,13 @@ source_set("test_support") { "test/windowed_nsnotification_observer.h", "test/windowed_nsnotification_observer.mm", ] + } else { + sources += [ + "test/ios/keyboard_appearance_listener.h", + "test/ios/keyboard_appearance_listener.mm", + "test/ios/ui_view_test_utils.h", + "test/ios/ui_view_test_utils.mm", + ] } public_deps = [ |