Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: build/config/mac/base_rules.gni

Issue 2023703002: Beginning work on GN build (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Really add //build. Add dart_bootstrap rule. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/config/mac/OWNERS ('k') | build/config/mac/compile_xib.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 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 # This file contains rules that are shared between Mac and iOS.
6
7 import("//build/toolchain/toolchain.gni")
8
9 if (is_mac) {
10 import("//build/config/mac/mac_sdk.gni")
11 } else if (is_ios) {
12 import("//build/config/ios/ios_sdk.gni")
13 }
14
15 # Convert plist file to given format.
16 #
17 # Arguments
18 #
19 # source:
20 # string, path to the plist file to convert
21 #
22 # output:
23 # string, path to the converted plist, must be under $root_build_dir
24 #
25 # format:
26 # string, the format to `plutil -convert` the plist to.
27 template("convert_plist") {
28 assert(defined(invoker.source), "source must be defined for $target_name")
29 assert(defined(invoker.output), "output must be defined for $target_name")
30 assert(defined(invoker.format), "format must be defined for $target_name")
31
32 action(target_name) {
33 forward_variables_from(invoker,
34 [
35 "visibility",
36 "testonly",
37 "deps",
38 ])
39
40 script = "//build/config/mac/xcrun.py"
41 sources = [
42 invoker.source,
43 ]
44 outputs = [
45 invoker.output,
46 ]
47 args = [
48 "plutil",
49 "-convert",
50 invoker.format,
51 "-o",
52 rebase_path(invoker.output, root_out_dir),
53 rebase_path(invoker.source, root_out_dir),
54 ]
55 }
56 }
57
58 # The base template used to generate Info.plist files for iOS and Mac apps and
59 # frameworks.
60 #
61 # Arguments
62 #
63 # plist_templates:
64 # string array, paths to plist files which will be used for the bundle.
65 #
66 # executable_name:
67 # string, name of the generated target used for the product
68 # and executable name as specified in the output Info.plist.
69 #
70 # format:
71 # string, the format to `plutil -convert` the plist to when
72 # generating the output.
73 #
74 # extra_substitutions:
75 # (optional) string array, 'key=value' pairs for extra fields which are
76 # specified in a source Info.plist template.
77 #
78 # output_name:
79 # (optional) string, name of the generated plist file, default to
80 # "$target_gen_dir/$target_name.plist".
81 template("info_plist") {
82 assert(defined(invoker.plist_templates),
83 "A list of template plist files must be specified for $target_name")
84 assert(defined(invoker.executable_name),
85 "The executable_name must be specified for $target_name")
86 assert(defined(invoker.format),
87 "The plist format must be specified for $target_name")
88 executable_name = invoker.executable_name
89
90 _output_name = "$target_gen_dir/$target_name.plist"
91 if (defined(invoker.output_name)) {
92 _output_name = invoker.output_name
93 }
94
95 action(target_name) {
96 script = "//build/config/mac/gen_plist.py"
97 sources = invoker.plist_templates
98 outputs = [
99 _output_name,
100 ]
101 extra_args = []
102 if (defined(invoker.extra_substitutions)) {
103 foreach(substitution, invoker.extra_substitutions) {
104 extra_args += [ "-s=$substitution" ]
105 }
106 }
107 response_file_contents =
108 extra_args + [
109 "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build",
110 "-s=EXECUTABLE_NAME=$executable_name",
111 "-s=GCC_VERSION=com.apple.compilers.llvm.clang.1_0",
112 "-s=PRODUCT_NAME=$executable_name",
113 "-s=XCODE_BUILD=$xcode_build",
114 "-s=XCODE_VERSION=$xcode_version",
115 "-o=" + rebase_path(_output_name, root_build_dir),
116 "-f=" + invoker.format,
117 ] + rebase_path(sources, root_build_dir)
118 args = [ "@{{response_file_name}}" ]
119 forward_variables_from(invoker,
120 [
121 "deps",
122 "testonly",
123 "visibility",
124 ])
125 }
126 }
127
128 # This is used as the base template for both iOS and Mac frameworks.
129 #
130 # By default, the bundle target this template generates does not link the
131 # resulting framework into anything that depends on it. If a dependency wants
132 # a link-time (as well as build-time) dependency on the framework bundle,
133 # depend against "$target_name+link". If only the build-time dependency is
134 # required (e.g., for copying into another bundle), then use "$target_name".
135 #
136 # Arguments
137 #
138 # output_name:
139 # (optional) string, name of the generated framework without the
140 # .framework suffix. If omitted, defaults to target_name.
141 #
142 # framework_version:
143 # (optional) string, version of the framework. Typically this is a
144 # single letter, like "A". If omitted, the Versions/ subdirectory
145 # structure will not be created, and build output will go directly
146 # into the framework subdirectory.
147 #
148 # This template provides two targets for the resulting framework bundle. The
149 # link-time behavior varies depending on which of the two targets below is
150 # added as a dependency:
151 # - $target_name only adds a build-time dependency. Targets that depend on
152 # it will not link against the framework.
153 # - $target_name+link adds a build-time and link-time dependency. Targets
154 # that depend on it will link against the framework.
155 #
156 # The build-time-only dependency is used for when a target needs to use the
157 # framework either only for resources, or because the target loads it at run-
158 # time, via dlopen() or NSBundle. The link-time dependency will cause the
159 # dependee to have the framework loaded by dyld at launch.
160 #
161 # Example of build-time only dependency:
162 #
163 # framework_bundle("CoreTeleportation") {
164 # sources = [ ... ]
165 # }
166 #
167 # bundle_data("core_teleportation_bundle_data") {
168 # deps = [ ":CoreTeleportation" ]
169 # sources = [ "$root_out_dir/CoreTeleportation.framework" ]
170 # outputs = [ "{{bundle_root_dir}}/Frameworks/{{source_file_part}}" ]
171 # }
172 #
173 # app_bundle("GoatTeleporter") {
174 # sources = [ ... ]
175 # deps = [
176 # ":core_teleportation_bundle_data",
177 # ]
178 # }
179 #
180 # The GoatTeleporter.app will not directly link against
181 # CoreTeleportation.framework, but it will be included in the bundle's
182 # Frameworks directory.
183 #
184 # Example of link-time dependency:
185 #
186 # framework_bundle("CoreTeleportation") {
187 # sources = [ ... ]
188 # ldflags = [
189 # "-install_name",
190 # "@executable_path/../Frameworks/$target_name.framework"
191 # ]
192 # }
193 #
194 # bundle_data("core_teleportation_bundle_data") {
195 # deps = [ ":CoreTeleportation+link" ]
196 # sources = [ "$root_out_dir/CoreTeleportation.framework" ]
197 # outputs = [ "{{bundle_root_dir}}/Frameworks/{{source_file_part}}" ]
198 # }
199 #
200 # app_bundle("GoatTeleporter") {
201 # sources = [ ... ]
202 # deps = [
203 # ":core_teleportation_bundle_data",
204 # ]
205 # }
206 #
207 # Note that the framework is still copied to the app's bundle, but dyld will
208 # load this library when the app is launched because it uses the "+link"
209 # target as a dependency. This also requires that the framework set its
210 # install_name so that dyld can locate it.
211 #
212 # See "gn help shared_library" for more information on arguments supported
213 # by shared library target.
214 template("framework_bundle") {
215 _target_name = target_name
216 _output_name = target_name
217 if (defined(invoker.output_name)) {
218 _output_name = invoker.output_name
219 }
220
221 # If the framework is unversioned, the final _target_name will be the
222 # create_bundle(_framework_target), otherwise an action with the name
223 # _target_name will depends on the the create_bundle() in order to prepare
224 # the versioned directory structure.
225 _framework_target = _target_name
226 _framework_name = _output_name + ".framework"
227 _framework_root_dir = "$root_out_dir/$_framework_name"
228 if (defined(invoker.framework_version) && invoker.framework_version != "") {
229 _framework_version = invoker.framework_version
230 _framework_root_dir += "/Versions/$_framework_version"
231 _framework_target = _target_name + "_create_bundle"
232 }
233
234 _shared_library_target = target_name + "_shared_library"
235 _shared_library_bundle_data = _shared_library_target + "_bundle_data"
236
237 shared_library(_shared_library_target) {
238 visibility = [ ":$_shared_library_bundle_data" ]
239 forward_variables_from(invoker,
240 "*",
241 [
242 "assert_no_deps",
243 "data_deps",
244 "info_plist",
245 "output_name",
246 "visibility",
247 ])
248 output_name = _output_name
249 output_prefix_override = true
250 output_extension = ""
251 output_dir = "$target_out_dir/$_shared_library_target"
252 }
253
254 bundle_data(_shared_library_bundle_data) {
255 visibility = [ ":$_framework_target" ]
256 forward_variables_from(invoker, [ "testonly" ])
257 sources = [
258 "$target_out_dir/$_shared_library_target/$_output_name",
259 ]
260 outputs = [
261 "{{bundle_executable_dir}}/$_output_name",
262 ]
263 public_deps = [
264 ":$_shared_library_target",
265 ]
266 }
267
268 _framework_public_config = _target_name + "_public_config"
269 config(_framework_public_config) {
270 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs
271 # and include_dirs to avoid duplicate values on the command-line.
272 visibility = [ ":$_framework_target" ]
273 ldflags = [ "-F" + rebase_path("$root_out_dir/.", root_out_dir) ]
274 lib_dirs = [ root_out_dir ]
275 libs = [ _framework_name ]
276 }
277
278 create_bundle(_framework_target) {
279 forward_variables_from(invoker,
280 [
281 "data_deps",
282 "deps",
283 "public_deps",
284 "testonly",
285 ])
286
287 if (defined(_framework_version)) {
288 visibility = [ ":$_target_name" ]
289 } else {
290 if (defined(invoker.visibility)) {
291 visibility = invoker.visibility
292 visibility += [ ":$_target_name+link" ]
293 }
294 }
295
296 if (!defined(public_deps)) {
297 public_deps = []
298 }
299 public_deps += [ ":$_shared_library_bundle_data" ]
300
301 bundle_root_dir = _framework_root_dir
302 bundle_resources_dir = "$bundle_root_dir/Resources"
303 bundle_executable_dir = "$bundle_root_dir"
304 }
305
306 if (defined(_framework_version)) {
307 action(_target_name) {
308 forward_variables_from(invoker, [ "testonly" ])
309
310 if (defined(invoker.visibility)) {
311 visibility = invoker.visibility
312 visibility += [ ":$_target_name+link" ]
313 }
314
315 script = "$root_out_dir/gyp-mac-tool"
316 outputs = [
317 "$root_out_dir/$_framework_name/Versions/Current",
318 ]
319 args = [
320 "package-framework",
321 "$_framework_name",
322 "$_framework_version",
323 ]
324 public_deps = [
325 ":$_framework_target",
326 ]
327 }
328 }
329
330 group(_target_name + "+link") {
331 forward_variables_from(invoker,
332 [
333 "visibility",
334 "testonly",
335 ])
336 public_deps = [
337 ":$_target_name",
338 ]
339 public_configs = [ ":$_framework_public_config" ]
340 }
341 }
342
343 # Template to combile .xib or .storyboard files.
344 #
345 # Arguments
346 #
347 # sources:
348 # list of string, sources to compile
349 #
350 # ibtool_flags:
351 # (optional) list of string, additional flags to pass to the ibtool
352 template("compile_xibs") {
353 action_foreach(target_name) {
354 forward_variables_from(invoker,
355 [
356 "testonly",
357 "visibility",
358 ])
359 assert(defined(invoker.sources),
360 "Sources must be specified for $target_name")
361
362 ibtool_flags = []
363 if (defined(invoker.ibtool_flags)) {
364 ibtool_flags = invoker.ibtool_flags
365 }
366
367 script = "//build/config/mac/compile_xib.py"
368 sources = invoker.sources
369 outputs = [
370 "$target_gen_dir/{{source_name_part}}.nib",
371 ]
372 args = [
373 "--input",
374 "{{source}}",
375 "--output",
376 rebase_path("$target_gen_dir/{{source_name_part}}.nib"),
377 ] + ibtool_flags
378 }
379 }
OLDNEW
« no previous file with comments | « build/config/mac/OWNERS ('k') | build/config/mac/compile_xib.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698