Roll src/third_party/WebKit 605a979:06cb9e9 (svn 202556:202558)
[chromium-blink-merge.git] / build / config / ios / rules.gni
blob994e7760de3adb90969de06817f949c437c2f41b
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.
5 ios_app_script = "//build/config/ios/ios_app.py"
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))
14   action(target_name) {
15     sources = [
16       invoker.entitlements_path,
17     ]
19     _application_path = invoker.application_path
21     script = ios_app_script
23     outputs = [
24       "$_application_path/_CodeSignature/CodeResources",
25     ]
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     ]
37     forward_variables_from(invoker,
38                            [
39                              "deps",
40                              "public_deps",
41                              "testonly",
42                            ])
43   }
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")
54   _bundle_directory = invoker.bundle_directory
55   _app_name = invoker.app_name
56   _resources = invoker.resources
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   }
67 template("ios_app") {
68   assert(defined(invoker.deps),
69          "Dependencies must be specified for $target_name")
70   assert(defined(invoker.info_plist),
71          "The application plist file must be specified for $target_name")
72   assert(defined(invoker.entitlements_path),
73          "The entitlements path must be specified for $target_name")
74   assert(defined(invoker.code_signing_identity),
75          "The code_signing_identity must be specified for $target_name")
77   # We just create a variable so we can use the same in interpolation
78   if (defined(invoker.app_name)) {
79     _app_name = invoker.app_name
80   } else {
81     _app_name = target_name
82   }
84   forward_variables_from(invoker, [ "testonly" ])
86   plist_gen_target_name = target_name + "_plist"
87   bin_gen_target_name = target_name + "_bin"
88   group_target_name = target_name
90   # Generate the executable
91   executable(bin_gen_target_name) {
92     visibility = [ ":$group_target_name" ]
94     output_name = "${_app_name}.app/${_app_name}"
96     forward_variables_from(invoker,
97                            [
98                              "all_dependent_configs",
99                              "allow_circular_includes_from",
100                              "cflags",
101                              "cflags_c",
102                              "cflags_cc",
103                              "cflags_objc",
104                              "cflags_objcc",
105                              "configs",
106                              "check_includes",
107                              "data",
108                              "data_deps",
109                              "defines",
110                              "forward_dependent_configs_from",
111                              "include_dirs",
112                              "ldflags",
113                              "public",
114                              "public_configs",
115                              "public_deps",
116                              "sources",
117                            ])
119     if (defined(invoker.libs)) {
120       libs = invoker.libs
121     } else {
122       libs = []
123     }
124     libs += [
125       "UIKit.framework",
126       "QuartzCore.framework",
127       "OpenGLES.framework",
128     ]
130     if (defined(invoker.deps)) {
131       deps = invoker.deps
132     } else {
133       deps = []
134     }
135     deps += [ ":$plist_gen_target_name" ]
136   }
138   # Process the Info.plist
139   action(plist_gen_target_name) {
140     visibility = [
141       ":$group_target_name",
142       ":$bin_gen_target_name",
143     ]
145     script = ios_app_script
147     sources = [
148       invoker.info_plist,
149     ]
150     outputs = [
151       "$root_build_dir/${_app_name}.app/Info.plist",
152     ]
154     args = [
155       "plist",
156       "-i",
157       rebase_path(invoker.info_plist, root_build_dir),
158       "-o",
159       rebase_path("$root_build_dir/${_app_name}.app"),
160     ]
161   }
163   # Perform Code Signing
164   entitlements_path = invoker.entitlements_path
165   if (invoker.code_signing_identity != "") {
166     code_sign_gen_target_name = target_name + "_codesign"
167     code_sign_ios(code_sign_gen_target_name) {
168       visibility = [ ":$target_name" ]
170       identity = invoker.code_signing_identity
171       application_path = "$root_build_dir/$app_name.app"
172       deps = [
173         ":$plist_gen_target_name",
174         ":$bin_gen_target_name",
175       ]
176     }
177   } else {
178     # This avoids a potential unused variable warning in the caller.
179     entitlements_path = entitlements_path
180   }
182   # Top level group
183   group(target_name) {
184     deps = [
185       ":$plist_gen_target_name",
186       ":$bin_gen_target_name",
187     ]
188     if (invoker.code_signing_identity != "") {
189       deps += [ ":$code_sign_gen_target_name" ]
190     }
191   }