OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/ios/ios_sdk.gni") | 5 import("//build/config/ios/ios_sdk.gni") |
6 import("//build/config/mac/base_rules.gni") | 6 import("//build/config/mac/base_rules.gni") |
7 import("//build/config/mac/symbols.gni") | 7 import("//build/config/mac/symbols.gni") |
8 | 8 |
9 # Generates Info.plist files for Mac apps and frameworks. | 9 # Generates Info.plist files for Mac apps and frameworks. |
10 # | 10 # |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 # target has the same role as the "executable" target of a thin build. | 144 # target has the same role as the "executable" target of a thin build. |
145 # | 145 # |
146 # The rest of the build, including the codesigning step, are the same for | 146 # The rest of the build, including the codesigning step, are the same for |
147 # thin and fat builds. | 147 # thin and fat builds. |
148 | 148 |
149 _is_fat_build = additional_toolchains != [] | 149 _is_fat_build = additional_toolchains != [] |
150 if (_is_fat_build) { | 150 if (_is_fat_build) { |
151 _is_fat_build_main_target = current_toolchain == default_toolchain | 151 _is_fat_build_main_target = current_toolchain == default_toolchain |
152 } | 152 } |
153 | 153 |
| 154 _executable_extra_deps = [] |
| 155 _executable_extra_inputs = [] |
| 156 _executable_extra_ldflags = [] |
| 157 |
| 158 # Embeds the entitlements file if building for simulator. This is optional |
| 159 # with Xcode 7 or older but required with Xcode 8. This is not necessary for |
| 160 # device build as the entitlement is embedded via the codesigning step. |
| 161 # |
| 162 # As the generation of the entitlement depends on the |
| 163 if (use_ios_simulator) { |
| 164 _toolchain_suffix = "" |
| 165 if (_is_fat_build && !_is_fat_build_main_target) { |
| 166 _toolchain_suffix = "($default_toolchain)" |
| 167 } |
| 168 |
| 169 _generate_entitlements_target = _target_name + "_gen_entitlements" |
| 170 _generate_entitlements_target_with_toolchain_suffix = |
| 171 "$_generate_entitlements_target$_toolchain_suffix" |
| 172 |
| 173 # TODO: the correct way to generate _generate_entitlements_output would |
| 174 # be the following, but get_label_info() ignores the toolchain specifier |
| 175 # so use a workaround. |
| 176 # |
| 177 # _generate_entitlements_output = |
| 178 # get_label_info( |
| 179 # _generate_entitlements_target_with_toolchain_suffix, |
| 180 # "target_gen_dir") + |
| 181 # "/$_output_name.xcent" |
| 182 _generate_entitlements_output = "$root_build_dir/gen" + get_label_info( |
| 183 _generate_entitlements_target, |
| 184 "dir") + "/" + "$_output_name.xcent" |
| 185 |
| 186 _executable_extra_inputs += [ _generate_entitlements_output ] |
| 187 _executable_extra_deps += |
| 188 [ ":$_generate_entitlements_target_with_toolchain_suffix" ] |
| 189 _executable_extra_ldflags += [ |
| 190 "-Xlinker", |
| 191 "-sectcreate", |
| 192 "-Xlinker", |
| 193 "__TEXT", |
| 194 "-Xlinker", |
| 195 "__entitlements", |
| 196 "-Xlinker", |
| 197 rebase_path(_generate_entitlements_output, root_build_dir), |
| 198 ] |
| 199 } |
| 200 |
154 if (_is_fat_build && !_is_fat_build_main_target) { | 201 if (_is_fat_build && !_is_fat_build_main_target) { |
155 # For the non-default toolchain of a fat-build, the template expands to a | 202 # For the non-default toolchain of a fat-build, the template expands to a |
156 # single "executable" target that creates "$root_out_dir/$_output_name". | 203 # single "executable" target that creates "$root_out_dir/$_output_name". |
157 executable(_target_name) { | 204 executable(_target_name) { |
158 forward_variables_from(invoker, | 205 forward_variables_from(invoker, |
159 "*", | 206 "*", |
160 [ | 207 [ |
161 "bundle_deps", | 208 "bundle_deps", |
162 "bundle_extension", | 209 "bundle_extension", |
163 "extra_system_frameworks", | 210 "extra_system_frameworks", |
164 "entitlements_path", | 211 "entitlements_path", |
165 "extra_substitutions", | 212 "extra_substitutions", |
166 "info_plist", | 213 "info_plist", |
167 "info_plist_target", | 214 "info_plist_target", |
168 "output_name", | 215 "output_name", |
169 "product_type", | 216 "product_type", |
170 ]) | 217 ]) |
171 | 218 |
172 if (defined(visibility)) { | 219 if (defined(visibility)) { |
173 visibility += [ ":*($default_toolchain)" ] | 220 visibility += [ ":*($default_toolchain)" ] |
174 } | 221 } |
175 | 222 |
| 223 if (!defined(deps)) { |
| 224 deps = [] |
| 225 } |
| 226 deps += _executable_extra_deps |
| 227 |
| 228 if (!defined(ldflags)) { |
| 229 ldflags = [] |
| 230 } |
| 231 ldflags += _executable_extra_ldflags |
| 232 |
| 233 if (!defined(inputs)) { |
| 234 inputs = [] |
| 235 } |
| 236 inputs += _executable_extra_inputs |
| 237 |
176 output_name = _output_name | 238 output_name = _output_name |
177 if (!defined(libs)) { | 239 if (!defined(libs)) { |
178 libs = [] | 240 libs = [] |
179 } | 241 } |
180 libs += [ "UIKit.framework" ] | 242 libs += [ "UIKit.framework" ] |
181 } | 243 } |
182 } else { | 244 } else { |
183 # This is either a thin build or the default toolchain of a fat-build. | 245 # This is either a thin build or the default toolchain of a fat-build. |
184 # The template will expand in many different target ($target_name is the | 246 # The template will expand in many different target ($target_name is the |
185 # create_bundle target) used as input to the create_bundle target. | 247 # create_bundle target) used as input to the create_bundle target. |
186 _generate_info_plist = target_name + "_generate_info_plist" | 248 _generate_info_plist = target_name + "_generate_info_plist" |
187 _bundle_data_info_plist = target_name + "_bundle_data_info_plist" | 249 _bundle_data_info_plist = target_name + "_bundle_data_info_plist" |
188 | 250 |
| 251 if (use_ios_simulator || ios_enable_code_signing) { |
| 252 if (defined(invoker.entitlements_path)) { |
| 253 _entitlements_path = invoker.entitlements_path |
| 254 } else { |
| 255 if (use_ios_simulator) { |
| 256 _entitlements_path = "//build/config/ios/entitlements.plist" |
| 257 } else { |
| 258 _entitlements_path = "$ios_sdk_path/Entitlements.plist" |
| 259 } |
| 260 } |
| 261 } |
| 262 |
189 ios_info_plist(_generate_info_plist) { | 263 ios_info_plist(_generate_info_plist) { |
190 visibility = [ ":$_bundle_data_info_plist" ] | 264 visibility = [ ":$_bundle_data_info_plist" ] |
| 265 if (use_ios_simulator) { |
| 266 visibility += [ ":$_generate_entitlements_target" ] |
| 267 } |
191 executable_name = _output_name | 268 executable_name = _output_name |
192 forward_variables_from(invoker, | 269 forward_variables_from(invoker, |
193 [ | 270 [ |
194 "extra_substitutions", | 271 "extra_substitutions", |
195 "info_plist", | 272 "info_plist", |
196 "info_plist_target", | 273 "info_plist_target", |
197 ]) | 274 ]) |
198 } | 275 } |
199 | 276 |
200 bundle_data(_bundle_data_info_plist) { | 277 bundle_data(_bundle_data_info_plist) { |
201 visibility = [ ":$_target_name" ] | 278 visibility = [ ":$_target_name" ] |
202 forward_variables_from(invoker, [ "testonly" ]) | 279 forward_variables_from(invoker, [ "testonly" ]) |
203 sources = get_target_outputs(":$_generate_info_plist") | 280 sources = get_target_outputs(":$_generate_info_plist") |
204 outputs = [ | 281 outputs = [ |
205 "{{bundle_root_dir}}/Info.plist", | 282 "{{bundle_root_dir}}/Info.plist", |
206 ] | 283 ] |
207 public_deps = [ | 284 public_deps = [ |
208 ":$_generate_info_plist", | 285 ":$_generate_info_plist", |
209 ] | 286 ] |
210 } | 287 } |
211 | 288 |
| 289 if (use_ios_simulator) { |
| 290 action(_generate_entitlements_target) { |
| 291 _gen_info_plist_target = ":$_generate_info_plist" |
| 292 _gen_info_plist_outputs = get_target_outputs(_gen_info_plist_target) |
| 293 _info_plist_path = _gen_info_plist_outputs[0] |
| 294 |
| 295 script = "//build/config/ios/codesign.py" |
| 296 deps = [ |
| 297 _gen_info_plist_target, |
| 298 ] |
| 299 sources = [ |
| 300 _entitlements_path, |
| 301 _info_plist_path, |
| 302 ] |
| 303 outputs = [ |
| 304 _generate_entitlements_output, |
| 305 ] |
| 306 args = [ |
| 307 "-e=" + rebase_path(_entitlements_path, root_build_dir), |
| 308 "generate-entitlements", |
| 309 "-p=" + rebase_path(_info_plist_path, root_build_dir), |
| 310 ] + rebase_path(outputs, root_build_dir) |
| 311 } |
| 312 } |
| 313 |
212 _link_executable = _target_name + "_executable" | 314 _link_executable = _target_name + "_executable" |
213 | 315 |
214 if (ios_enable_code_signing) { | 316 if (ios_enable_code_signing) { |
215 _link_executable_visibility = [ ":$_target_name" ] | 317 _link_executable_visibility = [ ":$_target_name" ] |
216 } else { | 318 } else { |
217 _bundle_data_executable = target_name + "_bundle_data_executable" | 319 _bundle_data_executable = target_name + "_bundle_data_executable" |
218 _link_executable_visibility = [ ":$_bundle_data_executable" ] | 320 _link_executable_visibility = [ ":$_bundle_data_executable" ] |
219 } | 321 } |
220 | 322 |
221 # For a fat-build, the different "executable" outputs will be used to | 323 # For a fat-build, the different "executable" outputs will be used to |
(...skipping 29 matching lines...) Expand all Loading... |
251 visibility = _link_executable_visibility | 353 visibility = _link_executable_visibility |
252 | 354 |
253 output_name = _output_name | 355 output_name = _output_name |
254 output_prefix_override = true | 356 output_prefix_override = true |
255 if (_is_fat_build) { | 357 if (_is_fat_build) { |
256 output_dir = "$target_out_dir/$current_cpu" | 358 output_dir = "$target_out_dir/$current_cpu" |
257 } else { | 359 } else { |
258 output_dir = target_out_dir | 360 output_dir = target_out_dir |
259 } | 361 } |
260 | 362 |
| 363 if (!defined(deps)) { |
| 364 deps = [] |
| 365 } |
| 366 deps += _executable_extra_deps |
| 367 |
| 368 if (!defined(ldflags)) { |
| 369 ldflags = [] |
| 370 } |
| 371 ldflags += _executable_extra_ldflags |
| 372 |
| 373 if (!defined(inputs)) { |
| 374 inputs = [] |
| 375 } |
| 376 inputs += _executable_extra_inputs |
| 377 |
261 if (!defined(libs)) { | 378 if (!defined(libs)) { |
262 libs = [] | 379 libs = [] |
263 } | 380 } |
264 libs += [ "UIKit.framework" ] | 381 libs += [ "UIKit.framework" ] |
265 } | 382 } |
266 | 383 |
267 if (_is_fat_build) { | 384 if (_is_fat_build) { |
268 # Create the multi-architecture binary from all the single architecture | 385 # Create the multi-architecture binary from all the single architecture |
269 # binaries using "lipo". This target exists for the default toolchain | 386 # binaries using "lipo". This target exists for the default toolchain |
270 # of a fat-build only and depends on the expansion of "ios_app_bundle" | 387 # of a fat-build only and depends on the expansion of "ios_app_bundle" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 } else { | 533 } else { |
417 _bundle_extension = ".app" | 534 _bundle_extension = ".app" |
418 } | 535 } |
419 | 536 |
420 bundle_root_dir = "$root_out_dir/$_output_name$_bundle_extension" | 537 bundle_root_dir = "$root_out_dir/$_output_name$_bundle_extension" |
421 bundle_resources_dir = bundle_root_dir | 538 bundle_resources_dir = bundle_root_dir |
422 bundle_executable_dir = bundle_root_dir | 539 bundle_executable_dir = bundle_root_dir |
423 bundle_plugins_dir = "$bundle_root_dir/PlugIns" | 540 bundle_plugins_dir = "$bundle_root_dir/PlugIns" |
424 | 541 |
425 if (ios_enable_code_signing) { | 542 if (ios_enable_code_signing) { |
426 _entitlements_path = "$ios_sdk_path/Entitlements.plist" | |
427 if (defined(invoker.entitlements_path)) { | |
428 _entitlements_path = invoker.entitlements_path | |
429 } | |
430 | |
431 code_signing_script = "//build/config/ios/codesign.py" | 543 code_signing_script = "//build/config/ios/codesign.py" |
432 code_signing_sources = [ | 544 code_signing_sources = [ |
433 _entitlements_path, | 545 _entitlements_path, |
434 "$target_out_dir/$_output_name", | 546 "$target_out_dir/$_output_name", |
435 ] | 547 ] |
436 code_signing_outputs = [ | 548 code_signing_outputs = [ |
437 "$bundle_root_dir/$_output_name", | 549 "$bundle_root_dir/$_output_name", |
438 "$bundle_root_dir/_CodeSignature/CodeResources", | 550 "$bundle_root_dir/_CodeSignature/CodeResources", |
439 "$bundle_root_dir/embedded.mobileprovision", | 551 "$bundle_root_dir/embedded.mobileprovision", |
440 ] | 552 ] |
441 if (defined(invoker.extra_system_frameworks)) { | 553 if (defined(invoker.extra_system_frameworks)) { |
442 foreach(_framework, invoker.extra_system_frameworks) { | 554 foreach(_framework, invoker.extra_system_frameworks) { |
443 code_signing_outputs += [ "$bundle_root_dir/Frameworks/" + | 555 code_signing_outputs += [ "$bundle_root_dir/Frameworks/" + |
444 get_path_info(_framework, "name") ] | 556 get_path_info(_framework, "name") ] |
445 } | 557 } |
446 } | 558 } |
447 code_signing_args = [ | 559 code_signing_args = [ |
| 560 "-e=" + rebase_path(_entitlements_path, root_build_dir), |
| 561 "code-sign-bundle", |
448 "-i=" + ios_code_signing_identity, | 562 "-i=" + ios_code_signing_identity, |
449 "-b=" + rebase_path("$target_out_dir/$_output_name", root_build_dir), | 563 "-b=" + rebase_path("$target_out_dir/$_output_name", root_build_dir), |
450 "-e=" + rebase_path(_entitlements_path, root_build_dir), | |
451 rebase_path(bundle_root_dir, root_build_dir), | 564 rebase_path(bundle_root_dir, root_build_dir), |
452 ] | 565 ] |
453 if (defined(invoker.extra_system_frameworks)) { | 566 if (defined(invoker.extra_system_frameworks)) { |
454 # All framework in extra_system_frameworks are expected to be | 567 # All framework in extra_system_frameworks are expected to be |
455 # system framework and the path to be already system absolute | 568 # system framework and the path to be already system absolute |
456 # so do not use rebase_path here. | 569 # so do not use rebase_path here. |
457 foreach(_framework, invoker.extra_system_frameworks) { | 570 foreach(_framework, invoker.extra_system_frameworks) { |
458 code_signing_args += [ "-F=" + _framework ] | 571 code_signing_args += [ "-F=" + _framework ] |
459 } | 572 } |
460 } | 573 } |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 code_signing_sources = [ | 1252 code_signing_sources = [ |
1140 _entitlements_path, | 1253 _entitlements_path, |
1141 "$target_out_dir/$_xctest_output", | 1254 "$target_out_dir/$_xctest_output", |
1142 ] | 1255 ] |
1143 code_signing_outputs = [ | 1256 code_signing_outputs = [ |
1144 "$bundle_root_dir/$_xctest_output", | 1257 "$bundle_root_dir/$_xctest_output", |
1145 "$bundle_root_dir/_CodeSignature/CodeResources", | 1258 "$bundle_root_dir/_CodeSignature/CodeResources", |
1146 "$bundle_root_dir/embedded.mobileprovision", | 1259 "$bundle_root_dir/embedded.mobileprovision", |
1147 ] | 1260 ] |
1148 code_signing_args = [ | 1261 code_signing_args = [ |
| 1262 "-e=" + rebase_path(_entitlements_path, root_build_dir), |
| 1263 "code-sign-bundle", |
1149 "-i=" + ios_code_signing_identity, | 1264 "-i=" + ios_code_signing_identity, |
1150 "-b=" + | 1265 "-b=" + |
1151 rebase_path("$target_out_dir/$_xctest_output", root_build_dir), | 1266 rebase_path("$target_out_dir/$_xctest_output", root_build_dir), |
1152 "-e=" + rebase_path(_entitlements_path, root_build_dir), | |
1153 rebase_path(bundle_root_dir, root_build_dir), | 1267 rebase_path(bundle_root_dir, root_build_dir), |
1154 ] | 1268 ] |
1155 } | 1269 } |
1156 } | 1270 } |
1157 | 1271 |
1158 bundle_data(_xctest_bundle) { | 1272 bundle_data(_xctest_bundle) { |
1159 visibility = [ ":$_host_target" ] | 1273 visibility = [ ":$_host_target" ] |
1160 public_deps = [ | 1274 public_deps = [ |
1161 ":$_xctest_target", | 1275 ":$_xctest_target", |
1162 ] | 1276 ] |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 "-rpath", | 1321 "-rpath", |
1208 "-Xlinker", | 1322 "-Xlinker", |
1209 "@loader_path/Frameworks", | 1323 "@loader_path/Frameworks", |
1210 ] | 1324 ] |
1211 } | 1325 } |
1212 } | 1326 } |
1213 | 1327 |
1214 set_defaults("ios_xctest_test") { | 1328 set_defaults("ios_xctest_test") { |
1215 configs = default_executable_configs | 1329 configs = default_executable_configs |
1216 } | 1330 } |
OLD | NEW |