OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 ios_app_script = "//build/config/ios/ios_app.py" |
| 6 |
| 7 template("code_sign_ios") { |
| 8 assert(defined(invoker.entitlements_path), |
| 9 "The path to the entitlements .xcent file") |
| 10 assert(defined(invoker.identity), "The code signing identity") |
| 11 assert(defined(invoker.application_path), "The application to code sign") |
| 12 assert(defined(invoker.deps)) |
| 13 |
| 14 action(target_name) { |
| 15 sources = [ |
| 16 invoker.entitlements_path, |
| 17 ] |
| 18 |
| 19 _application_path = invoker.application_path |
| 20 |
| 21 script = ios_app_script |
| 22 |
| 23 outputs = [ |
| 24 "$_application_path/_CodeSignature/CodeResources", |
| 25 ] |
| 26 |
| 27 args = [ |
| 28 "codesign", |
| 29 "-p", |
| 30 rebase_path(invoker.application_path, root_build_dir), |
| 31 "-i", |
| 32 invoker.identity, |
| 33 "-e", |
| 34 rebase_path(invoker.entitlements_path, root_build_dir), |
| 35 ] |
| 36 |
| 37 deps = invoker.deps |
| 38 } |
| 39 } |
| 40 |
| 41 template("resource_copy_ios") { |
| 42 assert(defined(invoker.resources), |
| 43 "The source list of resources to copy over") |
| 44 assert(defined(invoker.bundle_directory), |
| 45 "The directory within the bundle to place the sources in") |
| 46 assert(defined(invoker.app_name), "The name of the application") |
| 47 |
| 48 _bundle_directory = invoker.bundle_directory |
| 49 _app_name = invoker.app_name |
| 50 _resources = invoker.resources |
| 51 |
| 52 copy(target_name) { |
| 53 set_sources_assignment_filter([]) |
| 54 sources = _resources |
| 55 outputs = [ |
| 56 "$root_build_dir/$_app_name.app/$_bundle_directory/{{source_file_part}}", |
| 57 ] |
| 58 } |
| 59 } |
| 60 |
| 61 template("ios_app") { |
| 62 assert(defined(invoker.deps), |
| 63 "Dependencies must be specified for $target_name") |
| 64 assert(defined(invoker.info_plist), |
| 65 "The application plist file must be specified for $target_name") |
| 66 assert(defined(invoker.app_name), |
| 67 "The name of iOS application for $target_name") |
| 68 assert(defined(invoker.entitlements_path), |
| 69 "The entitlements path must be specified for $target_name") |
| 70 assert(defined(invoker.code_signing_identity), |
| 71 "The entitlements path must be specified for $target_name") |
| 72 |
| 73 # We just create a variable so we can use the same in interpolation |
| 74 app_name = invoker.app_name |
| 75 |
| 76 # Generate the project structure |
| 77 |
| 78 struct_gen_target_name = target_name + "_struct" |
| 79 |
| 80 action(struct_gen_target_name) { |
| 81 script = ios_app_script |
| 82 |
| 83 sources = [] |
| 84 outputs = [ |
| 85 "$root_build_dir/$app_name.app", |
| 86 ] |
| 87 |
| 88 args = [ |
| 89 "structure", |
| 90 "-d", |
| 91 rebase_path(root_build_dir), |
| 92 "-n", |
| 93 app_name, |
| 94 ] |
| 95 } |
| 96 |
| 97 # Generate the executable |
| 98 |
| 99 bin_gen_target_name = target_name + "_bin" |
| 100 |
| 101 executable(bin_gen_target_name) { |
| 102 libs = [ |
| 103 "UIKit.framework", |
| 104 "QuartzCore.framework", |
| 105 "OpenGLES.framework", |
| 106 ] |
| 107 deps = invoker.deps |
| 108 output_name = app_name |
| 109 } |
| 110 |
| 111 # Process the Info.plist |
| 112 |
| 113 plist_gen_target_name = target_name + "_plist" |
| 114 |
| 115 action(plist_gen_target_name) { |
| 116 script = ios_app_script |
| 117 |
| 118 sources = [ |
| 119 invoker.info_plist, |
| 120 ] |
| 121 outputs = [ |
| 122 "$root_build_dir/Info.plist", |
| 123 ] |
| 124 |
| 125 args = [ |
| 126 "plist", |
| 127 "-i", |
| 128 rebase_path(invoker.info_plist, root_build_dir), |
| 129 "-o", |
| 130 rebase_path(root_build_dir), |
| 131 ] |
| 132 } |
| 133 |
| 134 # Copy the generated binaries and assets to their appropriate locations |
| 135 |
| 136 copy_gen_target_name = target_name + "_copy" |
| 137 copy(copy_gen_target_name) { |
| 138 sources = [ |
| 139 "$root_build_dir/$app_name", |
| 140 "$root_build_dir/Info.plist", |
| 141 ] |
| 142 |
| 143 outputs = [ |
| 144 "$root_build_dir/$app_name.app/{{source_file_part}}", |
| 145 ] |
| 146 |
| 147 deps = [ |
| 148 ":$struct_gen_target_name", |
| 149 ":$bin_gen_target_name", |
| 150 ":$plist_gen_target_name", |
| 151 ] |
| 152 } |
| 153 |
| 154 # Perform Code Signing |
| 155 |
| 156 code_sign_gen_target_name = target_name + "_codesign" |
| 157 code_sign_ios(code_sign_gen_target_name) { |
| 158 entitlements_path = invoker.entitlements_path |
| 159 identity = invoker.code_signing_identity |
| 160 application_path = "$root_build_dir/$app_name.app" |
| 161 deps = [ |
| 162 ":$copy_gen_target_name", |
| 163 ] |
| 164 } |
| 165 |
| 166 # Top level group |
| 167 |
| 168 group(target_name) { |
| 169 # Skip code signing if no identity is provided. This is useful for simulator |
| 170 # builds |
| 171 deps = [] |
| 172 if (invoker.code_signing_identity == "") { |
| 173 deps += [ ":$copy_gen_target_name" ] |
| 174 } else { |
| 175 deps += [ ":$code_sign_gen_target_name" ] |
| 176 } |
| 177 } |
| 178 } |
OLD | NEW |