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