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 mac_app_script = "//build/config/mac/mac_app.py" |
| 6 |
| 7 template("code_sign_mac") { |
| 8 assert(defined(invoker.entitlements_path), |
| 9 "The path to the entitlements .xcent file") |
| 10 assert(defined(invoker.identity), |
| 11 "The code signing identity") |
| 12 assert(defined(invoker.application_path), |
| 13 "The application to code sign") |
| 14 assert(defined(invoker.deps)) |
| 15 |
| 16 action(target_name) { |
| 17 sources = [ |
| 18 invoker.entitlements_path, |
| 19 ] |
| 20 |
| 21 _application_path = invoker.application_path |
| 22 |
| 23 script = mac_app_script |
| 24 |
| 25 outputs = [ |
| 26 "$_application_path/_CodeSignature/CodeResources" |
| 27 ] |
| 28 |
| 29 args = [ |
| 30 "codesign", |
| 31 "-p", |
| 32 rebase_path(invoker.application_path, root_build_dir), |
| 33 "-i", |
| 34 invoker.identity, |
| 35 "-e", |
| 36 rebase_path(invoker.entitlements_path, root_build_dir), |
| 37 ] |
| 38 |
| 39 deps = invoker.deps |
| 40 } |
| 41 } |
| 42 |
| 43 template("process_nibs_mac") { |
| 44 assert(defined(invoker.sources), |
| 45 "The nib sources must be specified") |
| 46 assert(defined(invoker.module), |
| 47 "The nib module must be specified") |
| 48 assert(defined(invoker.output_dir), |
| 49 "The output directory must be specified") |
| 50 |
| 51 action_foreach(target_name) { |
| 52 sources = invoker.sources |
| 53 |
| 54 script = mac_app_script |
| 55 |
| 56 invoker_out_dir = invoker.output_dir |
| 57 |
| 58 outputs = [ |
| 59 "$root_build_dir/$invoker_out_dir/{{source_name_part}}.nib" |
| 60 ] |
| 61 |
| 62 args = [ |
| 63 "nib", |
| 64 "-i", |
| 65 "{{source}}", |
| 66 "-o", |
| 67 invoker_out_dir, |
| 68 "-m", |
| 69 invoker.module, |
| 70 ] |
| 71 } |
| 72 } |
| 73 |
| 74 template("resource_copy_mac") { |
| 75 assert(defined(invoker.resources), |
| 76 "The source list of resources to copy over") |
| 77 assert(defined(invoker.bundle_directory), |
| 78 "The directory within the bundle to place the sources in") |
| 79 assert(defined(invoker.app_name), |
| 80 "The name of the application") |
| 81 |
| 82 _bundle_directory = invoker.bundle_directory |
| 83 _app_name = invoker.app_name |
| 84 _resources = invoker.resources |
| 85 |
| 86 copy(target_name) { |
| 87 set_sources_assignment_filter([]) |
| 88 sources = _resources |
| 89 outputs = [ "$root_build_dir/$_app_name.app/$_bundle_directory/Contents/Reso
urces/{{source_file_part}}" ] |
| 90 |
| 91 if (defined(invoker.deps)) { |
| 92 deps = invoker.deps |
| 93 } |
| 94 } |
| 95 } |
| 96 |
| 97 template("mac_app") { |
| 98 |
| 99 assert(defined(invoker.deps), |
| 100 "Dependencies must be specified for $target_name") |
| 101 assert(defined(invoker.info_plist), |
| 102 "The application plist file must be specified for $target_name") |
| 103 assert(defined(invoker.app_name), |
| 104 "The name of Mac application for $target_name") |
| 105 assert(defined(invoker.xibs), |
| 106 "The list of XIB files must be specified for $target_name") |
| 107 # assert(defined(invoker.entitlements_path), |
| 108 # "The entitlements path must be specified for $target_name") |
| 109 # assert(defined(invoker.code_signing_identity), |
| 110 # "The entitlements path must be specified for $target_name") |
| 111 |
| 112 # We just create a variable so we can use the same in interpolation |
| 113 app_name = invoker.app_name |
| 114 |
| 115 # Generate the project structure |
| 116 |
| 117 struct_gen_target_name = target_name + "_struct" |
| 118 |
| 119 action(struct_gen_target_name) { |
| 120 |
| 121 script = mac_app_script |
| 122 |
| 123 sources = [] |
| 124 outputs = [ "$root_build_dir/$app_name.app" ] |
| 125 |
| 126 args = [ |
| 127 "structure", |
| 128 "-d", |
| 129 rebase_path(root_build_dir), |
| 130 "-n", |
| 131 app_name |
| 132 ] |
| 133 |
| 134 } |
| 135 |
| 136 # Generate the executable |
| 137 |
| 138 bin_gen_target_name = target_name + "_bin" |
| 139 |
| 140 executable(bin_gen_target_name) { |
| 141 deps = invoker.deps |
| 142 output_name = app_name |
| 143 } |
| 144 |
| 145 # Process the Info.plist |
| 146 |
| 147 plist_gen_target_name = target_name + "_plist" |
| 148 |
| 149 action(plist_gen_target_name) { |
| 150 |
| 151 script = mac_app_script |
| 152 |
| 153 sources = [ invoker.info_plist ] |
| 154 outputs = [ "$root_build_dir/plist/$app_name/Info.plist" ] |
| 155 |
| 156 args = [ |
| 157 "plist", |
| 158 "-i", |
| 159 rebase_path(invoker.info_plist, root_build_dir), |
| 160 "-o", |
| 161 rebase_path("$root_build_dir/plist/$app_name"), |
| 162 ] |
| 163 } |
| 164 |
| 165 # Copy the generated binaries and assets to their appropriate locations |
| 166 |
| 167 copy_plist_gen_target_name = target_name + "_plist_copy" |
| 168 copy(copy_plist_gen_target_name) { |
| 169 sources = [ |
| 170 "$root_build_dir/plist/$app_name/Info.plist", |
| 171 ] |
| 172 |
| 173 outputs = [ |
| 174 "$root_build_dir/$app_name.app/Contents/{{source_file_part}}" |
| 175 ] |
| 176 |
| 177 deps = [ |
| 178 ":$plist_gen_target_name", |
| 179 ] |
| 180 } |
| 181 |
| 182 copy_bin_target_name = target_name + "_bin_copy" |
| 183 copy(copy_bin_target_name) { |
| 184 sources = [ |
| 185 "$root_build_dir/$app_name", |
| 186 ] |
| 187 |
| 188 outputs = [ |
| 189 "$root_build_dir/$app_name.app/Contents/MacOS/{{source_file_part}}" |
| 190 ] |
| 191 |
| 192 deps = [ |
| 193 ":$bin_gen_target_name", |
| 194 ] |
| 195 } |
| 196 |
| 197 copy_xib_target_name = target_name + "_xib_copy" |
| 198 process_nibs_mac(copy_xib_target_name) { |
| 199 sources = invoker.xibs |
| 200 module = app_name |
| 201 output_dir = "$app_name.app/Contents/Resources" |
| 202 } |
| 203 |
| 204 copy_all_target_name = target_name + "_all_copy" |
| 205 group(copy_all_target_name) { |
| 206 deps = [ |
| 207 ":$struct_gen_target_name", |
| 208 ":$copy_plist_gen_target_name", |
| 209 ":$copy_bin_target_name", |
| 210 ":$copy_xib_target_name", |
| 211 ] |
| 212 } |
| 213 |
| 214 # Top level group |
| 215 |
| 216 group(target_name) { |
| 217 deps = [ ":$copy_all_target_name" ] |
| 218 } |
| 219 |
| 220 } |
OLD | NEW |