| 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 ios_app_script = "//build/config/ios/ios_app.py" | 5 import("//build/config/ios/ios_sdk.gni") |
| 6 | 6 |
| 7 template("code_sign_ios") { | 7 # Use this template to create application bundle for iOS. |
| 8 assert(defined(invoker.entitlements_path), | 8 # |
| 9 "The path to the entitlements .xcent file") | 9 # Arguments: |
| 10 assert(defined(invoker.identity), "The code signing identity") | 10 # |
| 11 assert(defined(invoker.application_path), "The application to code sign") | 11 # info_plist |
| 12 assert(defined(invoker.deps)) | 12 # Path to the application Info.plist template (variable substitution |
| 13 | 13 # will be performed). |
| 14 action(target_name) { | 14 # |
| 15 sources = [ | 15 # entitlements_path |
| 16 invoker.entitlements_path, | 16 # Path to the application entitlements .xcent. |
| 17 ] | 17 # |
| 18 | 18 # code_signing_identity |
| 19 _application_path = invoker.application_path | 19 # Identity to use for signing the application, if signing is enabled. |
| 20 | 20 # |
| 21 script = ios_app_script | 21 # app_name (optional) |
| 22 | 22 # Name of the application, defaults to ${target_name}. |
| 23 outputs = [ | 23 # |
| 24 "$_application_path/_CodeSignature/CodeResources", | 24 # extra_substitutions (optional) |
| 25 ] | 25 # List of string in "key=value" format. Each correspond to variable |
| 26 | 26 # substitution to perform when compiling the Info.plist template. |
| 27 args = [ | 27 # |
| 28 "codesign", | 28 # The template uses an "executable" target under the hood and forwards to it |
| 29 "-p", | 29 # all the arguments it supports. Look at "executable" documentation for more |
| 30 rebase_path(invoker.application_path, root_build_dir), | 30 # information. |
| 31 "-i", | |
| 32 invoker.identity, | |
| 33 "-e", | |
| 34 rebase_path(invoker.entitlements_path, root_build_dir), | |
| 35 ] | |
| 36 | |
| 37 forward_variables_from(invoker, | |
| 38 [ | |
| 39 "deps", | |
| 40 "public_deps", | |
| 41 "testonly", | |
| 42 ]) | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 # TODO(GYP), TODO(dpranke): Should this be part of ios_app? | |
| 47 template("resource_copy_ios") { | |
| 48 assert(defined(invoker.resources), | |
| 49 "The source list of resources to copy over") | |
| 50 assert(defined(invoker.bundle_directory), | |
| 51 "The directory within the bundle to place the sources in") | |
| 52 assert(defined(invoker.app_name), "The name of the application") | |
| 53 | |
| 54 _bundle_directory = invoker.bundle_directory | |
| 55 _app_name = invoker.app_name | |
| 56 _resources = invoker.resources | |
| 57 | |
| 58 copy(target_name) { | |
| 59 set_sources_assignment_filter([]) | |
| 60 sources = _resources | |
| 61 outputs = [ | |
| 62 "$root_build_dir/$_app_name.app/$_bundle_directory/{{source_file_part}}", | |
| 63 ] | |
| 64 } | |
| 65 } | |
| 66 | |
| 67 template("ios_app") { | 31 template("ios_app") { |
| 68 assert(defined(invoker.deps), | |
| 69 "Dependencies must be specified for $target_name") | |
| 70 assert(defined(invoker.info_plist), | 32 assert(defined(invoker.info_plist), |
| 71 "The application plist file must be specified for $target_name") | 33 "The application plist file must be specified for $target_name") |
| 72 assert(defined(invoker.entitlements_path), | 34 assert(defined(invoker.entitlements_path), |
| 73 "The entitlements path must be specified for $target_name") | 35 "The entitlements path must be specified for $target_name") |
| 74 assert(defined(invoker.code_signing_identity), | 36 assert(defined(invoker.code_signing_identity), |
| 75 "The code_signing_identity must be specified for $target_name") | 37 "The code_signing_identity must be specified for $target_name") |
| 76 | 38 |
| 77 # We just create a variable so we can use the same in interpolation | 39 # We just create a variable so we can use the same in interpolation |
| 78 if (defined(invoker.app_name)) { | 40 if (defined(invoker.app_name)) { |
| 79 _app_name = invoker.app_name | 41 _app_name = invoker.app_name |
| 80 } else { | 42 } else { |
| 81 _app_name = target_name | 43 _app_name = target_name |
| 82 } | 44 } |
| 83 | 45 |
| 84 forward_variables_from(invoker, [ "testonly" ]) | 46 forward_variables_from(invoker, [ "testonly" ]) |
| 85 | 47 |
| 86 plist_gen_target_name = target_name + "_plist" | 48 plist_gen_target_name = target_name + "__plist" |
| 87 bin_gen_target_name = target_name + "_bin" | 49 bin_gen_target_name = target_name + "__bin" |
| 88 group_target_name = target_name | 50 res_gen_target_name = target_name + "__res" |
| 51 _target_name = target_name |
| 89 | 52 |
| 90 # Generate the executable | 53 # Generate the executable |
| 91 executable(bin_gen_target_name) { | 54 executable(bin_gen_target_name) { |
| 92 visibility = [ ":$group_target_name" ] | |
| 93 | |
| 94 output_name = "${_app_name}.app/${_app_name}" | |
| 95 | |
| 96 forward_variables_from(invoker, | 55 forward_variables_from(invoker, |
| 97 [ | 56 [ |
| 98 "all_dependent_configs", | 57 "all_dependent_configs", |
| 99 "allow_circular_includes_from", | 58 "allow_circular_includes_from", |
| 59 "asmflags", |
| 100 "cflags", | 60 "cflags", |
| 101 "cflags_c", | 61 "cflags_c", |
| 102 "cflags_cc", | 62 "cflags_cc", |
| 103 "cflags_objc", | |
| 104 "cflags_objcc", | 63 "cflags_objcc", |
| 64 "check_includes", |
| 105 "configs", | 65 "configs", |
| 106 "check_includes", | |
| 107 "data", | 66 "data", |
| 108 "data_deps", | 67 "data_deps", |
| 109 "defines", | 68 "defines", |
| 69 "deps", |
| 110 "include_dirs", | 70 "include_dirs", |
| 71 "inputs", |
| 111 "ldflags", | 72 "ldflags", |
| 73 "lib_dirs", |
| 74 "libs", |
| 75 "output_extension", |
| 76 "output_name", |
| 77 "precompiled_header", |
| 78 "precompiled_source", |
| 112 "public", | 79 "public", |
| 113 "public_configs", | 80 "public_configs", |
| 114 "public_deps", | 81 "public_deps", |
| 115 "sources", | 82 "sources", |
| 116 ]) | 83 ]) |
| 117 | 84 |
| 118 if (defined(invoker.libs)) { | 85 visibility = [ ":$plist_gen_target_name" ] |
| 119 libs = invoker.libs | 86 output_name = "${_app_name}.app/${_app_name}" |
| 120 } else { | 87 |
| 88 if (!defined(invoker.libs)) { |
| 121 libs = [] | 89 libs = [] |
| 122 } | 90 } |
| 123 libs += [ | 91 libs += [ "UIKit.framework" ] |
| 124 "UIKit.framework", | 92 } |
| 125 "QuartzCore.framework", | 93 |
| 126 "OpenGLES.framework", | 94 # Copy resources. |
| 127 ] | 95 copy_bundle_data(res_gen_target_name) { |
| 128 | 96 forward_variables_from(invoker, |
| 129 if (defined(invoker.deps)) { | 97 [ |
| 130 deps = invoker.deps | 98 "bundle_data", |
| 131 } else { | 99 "deps", |
| 132 deps = [] | 100 "public_deps", |
| 133 } | 101 ]) |
| 134 deps += [ ":$plist_gen_target_name" ] | 102 visibility = [ ":$plist_gen_target_name" ] |
| 103 outputs = [ |
| 104 "$root_build_dir/$_app_name.app/{{source_file_part}}", |
| 105 ] |
| 135 } | 106 } |
| 136 | 107 |
| 137 # Process the Info.plist | 108 # Process the Info.plist |
| 138 action(plist_gen_target_name) { | 109 action(plist_gen_target_name) { |
| 139 visibility = [ | 110 visibility = [ ":$_target_name" ] |
| 140 ":$group_target_name", | 111 |
| 112 generated_info_plist = "$root_build_dir/$_app_name.app/Info.plist" |
| 113 |
| 114 script = "//build/config/ios/ios_gen_plist.py" |
| 115 outputs = [ |
| 116 generated_info_plist, |
| 117 ] |
| 118 sources = [ |
| 119 "//build/config/ios/BuildInfo.plist", |
| 120 invoker.info_plist, |
| 121 ] |
| 122 |
| 123 extra_args = [] |
| 124 if (defined(invoker.extra_substitutions)) { |
| 125 foreach(substitution, invoker.extra_substitutions) { |
| 126 extra_args += [ "-s=$substitution" ] |
| 127 } |
| 128 } |
| 129 |
| 130 args = extra_args + [ |
| 131 "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build", |
| 132 "-s=IOS_SUPPORTED_PLATFORM=$ios_sdk_platform", |
| 133 "-s=IOS_SDK_NAME=$ios_sdk_name", |
| 134 "-s=IOS_SDK_BUILD=$ios_sdk_version", |
| 135 "-s=XCODE_VERSION=$xcode_version", |
| 136 "-s=XCODE_BUILD=$xcode_build", |
| 137 "-s=PRODUCT_NAME=$_app_name", |
| 138 "-s=EXECUTABLE_NAME=$_app_name", |
| 139 "-o=" + rebase_path(generated_info_plist), |
| 140 ] + rebase_path(sources) |
| 141 |
| 142 deps = [ |
| 141 ":$bin_gen_target_name", | 143 ":$bin_gen_target_name", |
| 142 ] | 144 ":$res_gen_target_name", |
| 143 | 145 ] |
| 144 script = ios_app_script | 146 |
| 145 | 147 if (defined(invoker.extra_deps)) { |
| 146 sources = [ | 148 deps += invoker.extra_deps |
| 147 invoker.info_plist, | 149 } |
| 148 ] | 150 } |
| 149 outputs = [ | 151 |
| 150 "$root_build_dir/${_app_name}.app/Info.plist", | 152 # Perform code signature if needed. Since this require the application |
| 151 ] | 153 # bundle to be complete, this targets depends on the action generating |
| 152 | 154 # the Info.plist file, since this introduces a hard dependency (and as |
| 153 args = [ | 155 # it depends on the other targets, this ensure the bundle is complete). |
| 154 "plist", | |
| 155 "-i", | |
| 156 rebase_path(invoker.info_plist, root_build_dir), | |
| 157 "-o", | |
| 158 rebase_path("$root_build_dir/${_app_name}.app"), | |
| 159 ] | |
| 160 } | |
| 161 | |
| 162 # Perform Code Signing | |
| 163 entitlements_path = invoker.entitlements_path | |
| 164 if (invoker.code_signing_identity != "") { | 156 if (invoker.code_signing_identity != "") { |
| 165 code_sign_gen_target_name = target_name + "_codesign" | 157 action(target_name) { |
| 166 code_sign_ios(code_sign_gen_target_name) { | 158 forward_variables_from(invoker, [ "visibility" ]) |
| 167 visibility = [ ":$target_name" ] | 159 script = "//build/config/ios/ios_code_sign.py" |
| 168 | 160 |
| 169 identity = invoker.code_signing_identity | 161 sources = [ |
| 170 application_path = "$root_build_dir/$app_name.app" | 162 entitlements_path, |
| 163 ] |
| 164 outputs = [ |
| 165 "$root_build_dir/$app_name.app/_CodeSignature/CodeResources", |
| 166 ] |
| 167 |
| 168 args = [ |
| 169 "-i=" + invoker.code_signing_identity, |
| 170 "-p=" + rebase_path("$root_build_dir/$app_name.app", root_build_dir), |
| 171 "-e=" + rebase_path(invoker.entitlements_path, root_build_dir), |
| 172 ] |
| 173 |
| 171 deps = [ | 174 deps = [ |
| 172 ":$bin_gen_target_name", | |
| 173 ":$plist_gen_target_name", | 175 ":$plist_gen_target_name", |
| 174 ] | 176 ] |
| 175 } | 177 } |
| 176 } else { | 178 } else { |
| 177 # This avoids a potential unused variable warning in the caller. | 179 # This avoids a potential unused variable warning in the caller. |
| 180 entitlements_path = invoker.entitlements_path |
| 178 entitlements_path = entitlements_path | 181 entitlements_path = entitlements_path |
| 179 } | 182 |
| 180 | 183 group(target_name) { |
| 181 # Top level group | 184 forward_variables_from(invoker, [ "visibility" ]) |
| 182 group(target_name) { | 185 deps = [ |
| 183 deps = [ | 186 ":$plist_gen_target_name", |
| 184 ":$bin_gen_target_name", | 187 ] |
| 185 ":$plist_gen_target_name", | |
| 186 ] | |
| 187 if (invoker.code_signing_identity != "") { | |
| 188 deps += [ ":$code_sign_gen_target_name" ] | |
| 189 } | 188 } |
| 190 } | 189 } |
| 191 } | 190 } |
| 191 |
| 192 # Use this template to create test application bundle for iOS. |
| 193 # |
| 194 # Arguments: |
| 195 # |
| 196 # bundle_test_name (optional) |
| 197 # String to use as bundle identifier in the Info.plist. Default to |
| 198 # ${app_name}. |
| 199 # |
| 200 # test_data_files (optional) |
| 201 # List of file to copy in the application bundle. The path in the |
| 202 # bundle will be the same as the path from the source root, unless |
| 203 # test_data_prefix is defined. |
| 204 # |
| 205 # test_data_prefix (optional) |
| 206 # If defined, ${test_data_files} will be copied to this directory |
| 207 # relative to the application bundle instead of a path relative to |
| 208 # source root. |
| 209 # |
| 210 # info_plist (optional) |
| 211 # Path to the application Info.plist template (variable substitution |
| 212 # will be performed). |
| 213 # |
| 214 # entitlements_path (optional) |
| 215 # Path to the application entitlements .xcent. |
| 216 # |
| 217 # code_signing_identity (optional) |
| 218 # Identity to use for signing the application, if signing is enabled. |
| 219 # |
| 220 # app_name (optional) |
| 221 # Name of the application, defaults to ${target_name}. |
| 222 # |
| 223 # extra_substitutions (optional) |
| 224 # List of string in "key=value" format. Each correspond to variable |
| 225 # substitution to perform when compiling the Info.plist template. |
| 226 # |
| 227 # The template uses an "ios_app" target under the hood and forwards to it |
| 228 # all the arguments it supports. Look at "executable" documentation for more |
| 229 # information. |
| 230 template("ios_test_app") { |
| 231 _app_name = target_name |
| 232 if (defined(invoker.app_name)) { |
| 233 _app_name = invoker.app_name |
| 234 } |
| 235 |
| 236 if (defined(invoker.test_data_files)) { |
| 237 _copy_test_data_target_name = target_name + "__test_data" |
| 238 copy(_copy_test_data_target_name) { |
| 239 sources = invoker.test_data_files |
| 240 outputs = [ |
| 241 "$root_build_dir/$_app_name.app/{{source_root_relative_dir}}/{{source_fi
le_part}}", |
| 242 ] |
| 243 } |
| 244 } |
| 245 |
| 246 ios_app(target_name) { |
| 247 forward_variables_from(invoker, "*") |
| 248 |
| 249 app_name = _app_name |
| 250 if (defined(invoker.test_data_files)) { |
| 251 extra_deps = [ ":$_copy_test_data_target_name" ] |
| 252 } |
| 253 } |
| 254 } |
| OLD | NEW |