OLD | NEW |
(Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import("//build/config/ios/rules.gni") |
| 6 |
| 7 # For Chrome on iOS we want to run EarlGrey tests (that are XCTests) for all |
| 8 # our build configurations (Debug, Release, ...). In addition, the symbols |
| 9 # visibility is configured to private by default. To simplify testing with |
| 10 # those constraints, our tests are compiled in the TEST_HOST target instead |
| 11 # of the .xctest bundle. |
| 12 template("ios_eg_test") { |
| 13 _target_name = target_name |
| 14 _output_name = target_name |
| 15 if (defined(invoker.output_name)) { |
| 16 _output_name = invoker.output_name |
| 17 } |
| 18 |
| 19 _xctest_target = _target_name |
| 20 _xctest_output = _output_name |
| 21 _xctest_bundle = _xctest_target + "_bundle" |
| 22 _xctest_config = _xctest_target + "_config" |
| 23 |
| 24 config(_xctest_config) { |
| 25 common_flags = [ |
| 26 "-F", |
| 27 "$ios_sdk_platform_path/Developer/Library/Frameworks", |
| 28 ] |
| 29 |
| 30 cflags = common_flags |
| 31 ldflags = common_flags |
| 32 |
| 33 libs = [ |
| 34 "Foundation.framework", |
| 35 "XCTest.framework", |
| 36 ] |
| 37 } |
| 38 |
| 39 _xctest_info_plist_target = _xctest_target + "_info_plist" |
| 40 _xctest_info_plist_bundle = _xctest_target + "_info_plist_bundle" |
| 41 ios_info_plist(_xctest_info_plist_target) { |
| 42 visibility = [ ":$_xctest_info_plist_bundle" ] |
| 43 info_plist = "//ios/third_party/earl_grey/Module-Info.plist" |
| 44 executable_name = _output_name |
| 45 } |
| 46 |
| 47 bundle_data(_xctest_info_plist_bundle) { |
| 48 visibility = [ ":$_xctest_target" ] |
| 49 public_deps = [ |
| 50 ":$_xctest_info_plist_target", |
| 51 ] |
| 52 sources = get_target_outputs(":$_xctest_info_plist_target") |
| 53 outputs = [ |
| 54 "{{bundle_root_dir}}/Info.plist", |
| 55 ] |
| 56 } |
| 57 |
| 58 _xctest_loadable_module_target = _xctest_target + "_loadable_module" |
| 59 _xctest_loadable_module_bundle = _xctest_target + "_loadable_module_bundle" |
| 60 loadable_module(_xctest_loadable_module_target) { |
| 61 visibility = [ ":$_xctest_loadable_module_bundle" ] |
| 62 sources = [ |
| 63 "//ios/third_party/earl_grey/xctest_shell.mm", |
| 64 ] |
| 65 configs += [ ":$_xctest_config" ] |
| 66 |
| 67 output_name = rebase_path("$target_out_dir/$_xctest_output", root_out_dir) |
| 68 output_prefix_override = true |
| 69 output_extension = "" |
| 70 } |
| 71 |
| 72 bundle_data(_xctest_loadable_module_bundle) { |
| 73 visibility = [ ":$_xctest_target" ] |
| 74 public_deps = [ |
| 75 ":$_xctest_loadable_module_target", |
| 76 ] |
| 77 sources = [ |
| 78 "$target_out_dir/$_xctest_output", |
| 79 ] |
| 80 outputs = [ |
| 81 "{{bundle_root_dir}}/$_xctest_output", |
| 82 ] |
| 83 } |
| 84 |
| 85 create_bundle(_xctest_target) { |
| 86 visibility = [ ":$_xctest_bundle" ] |
| 87 product_type = "com.apple.product-type.bundle.unit-test" |
| 88 deps = [ |
| 89 ":$_xctest_info_plist_bundle", |
| 90 ":$_xctest_loadable_module_bundle", |
| 91 ] |
| 92 bundle_root_dir = "$root_out_dir/$_xctest_output.xctest" |
| 93 } |
| 94 |
| 95 _host_target = _target_name + "_host" |
| 96 _host_output = _output_name + "_host" |
| 97 |
| 98 bundle_data(_xctest_bundle) { |
| 99 visibility = [ ":$_host_target" ] |
| 100 public_deps = [ |
| 101 ":$_xctest_target", |
| 102 ] |
| 103 sources = [ |
| 104 "$root_out_dir/$_xctest_output.xctest", |
| 105 ] |
| 106 outputs = [ |
| 107 "{{bundle_plugins_dir}}/$_xctest_output.xctest", |
| 108 ] |
| 109 } |
| 110 |
| 111 ios_app_bundle(_host_target) { |
| 112 forward_variables_from(invoker, "*", [ "testonly" ]) |
| 113 |
| 114 testonly = true |
| 115 output_name = _host_output |
| 116 info_plist = "//ios/third_party/earl_grey/Host-Info.plist" |
| 117 configs += [ ":$_xctest_config" ] |
| 118 |
| 119 if (!defined(bundle_deps)) { |
| 120 bundle_deps = [] |
| 121 } |
| 122 bundle_deps += [ |
| 123 ":$_xctest_bundle", |
| 124 "//ios/third_party/earl_grey:xctest_bundle", |
| 125 "//ios/third_party/earl_grey:earl_grey+bundle", |
| 126 "//ios/third_party/ochamcrest:ochamcrest+bundle", |
| 127 ] |
| 128 |
| 129 if (!defined(ldflags)) { |
| 130 ldflags = [] |
| 131 } |
| 132 ldflags += [ |
| 133 "-Xlinker", |
| 134 "-rpath", |
| 135 "-Xlinker", |
| 136 "@executable_path/Frameworks", |
| 137 "-Xlinker", |
| 138 "-rpath", |
| 139 "-Xlinker", |
| 140 "@loader_path/Frameworks", |
| 141 ] |
| 142 } |
| 143 } |
| 144 |
| 145 set_defaults("ios_eg_test") { |
| 146 configs = default_executable_configs |
| 147 } |
OLD | NEW |