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 import("//build/toolchain/toolchain.gni") | 5 import("//build/toolchain/toolchain.gni") |
6 | 6 |
7 # Template to package a shared library into a Mac framework bundle. | 7 # Template to package a shared library into a framework bundle. |
Robert Sesek
2016/04/11 15:35:26
"This is used as the base template for both iOS an
sdefresne
2016/04/12 11:51:19
Done.
| |
8 # | 8 # |
9 # Arguments | 9 # Arguments |
10 # | 10 # |
11 # info_plist: | |
12 # string, path to the Info.plist file that will be used for the bundle. | |
13 # | |
14 # output_name: | 11 # output_name: |
15 # (optional) string, name of the generated framework without the | 12 # (optional) string, name of the generated framework without the |
16 # .framework suffix. If omitted, defaults to target_name. | 13 # .framework suffix. If omitted, defaults to target_name. |
17 # | 14 # |
18 # framework_version: | 15 # framework_version: |
19 # (optional) string, version of the framework. Typically this is a | 16 # (optional) string, version of the framework. Typically this is a |
20 # single letter, like "A". If omitted, the Versions/ subdirectory | 17 # single letter, like "A". If omitted, the Versions/ subdirectory |
21 # structure will not be created, and build output will go directly | 18 # structure will not be created, and build output will go directly |
22 # into the framework subdirectory. | 19 # into the framework subdirectory. |
23 template("mac_framework") { | 20 # |
24 assert(defined(invoker.deps), | 21 # See "gn help shared_library" for more information on arguments supported |
25 "Dependencies must be specified for $target_name") | 22 # by shared library target. |
26 assert(defined(invoker.info_plist), | 23 template("framework_bundle") { |
27 "The Info.plist file must be specified for $target_name") | |
28 | |
29 _target_name = target_name | 24 _target_name = target_name |
30 _output_name = target_name | 25 _output_name = target_name |
31 if (defined(invoker.output_name)) { | 26 if (defined(invoker.output_name)) { |
32 _output_name = invoker.output_name | 27 _output_name = invoker.output_name |
33 } | 28 } |
29 | |
30 _framework_target = _target_name | |
Robert Sesek
2016/04/11 15:35:26
Leave a comment here along the lines of:
"If the
sdefresne
2016/04/12 11:51:19
Done.
| |
34 _framework_name = _output_name + ".framework" | 31 _framework_name = _output_name + ".framework" |
35 _framework_version = "" | 32 _framework_root_dir = "$root_out_dir/$_framework_name" |
36 if (defined(invoker.framework_version)) { | 33 if (defined(invoker.framework_version) && invoker.framework_version != "") { |
37 _framework_version = invoker.framework_version | 34 _framework_version = invoker.framework_version |
35 _framework_root_dir += "/Versions/$_framework_version" | |
36 _framework_target = _target_name + "_create_bundle" | |
38 } | 37 } |
39 _framework_target = _output_name + "_framework" | |
40 | 38 |
41 _shared_library_target = target_name + "_shared_library" | 39 _shared_library_target = target_name + "_shared_library" |
42 _shared_library_bundle_data = _shared_library_target + "_bundle_data" | 40 _shared_library_bundle_data = _shared_library_target + "_bundle_data" |
43 | 41 |
44 shared_library(_shared_library_target) { | 42 shared_library(_shared_library_target) { |
45 visibility = [ ":$_shared_library_bundle_data" ] | 43 visibility = [ ":$_shared_library_bundle_data" ] |
46 forward_variables_from(invoker, | 44 forward_variables_from(invoker, |
47 "*", | 45 "*", |
48 [ | 46 [ |
49 "assert_no_deps", | 47 "assert_no_deps", |
50 "data_deps", | 48 "data_deps", |
51 "info_plist", | |
52 "output_name", | 49 "output_name", |
53 "visibility", | |
Robert Sesek
2016/04/11 15:35:26
Does the local visibility definition override here
sdefresne
2016/04/12 11:51:19
I incorrectly removed "visibility" and "info_plist
| |
54 ]) | 50 ]) |
55 } | 51 } |
56 | 52 |
57 bundle_data(_shared_library_bundle_data) { | 53 bundle_data(_shared_library_bundle_data) { |
58 visibility = [ ":$_framework_target" ] | 54 visibility = [ ":$_framework_target" ] |
59 forward_variables_from(invoker, [ "testonly" ]) | 55 forward_variables_from(invoker, [ "testonly" ]) |
60 sources = [ | 56 sources = [ |
61 "$root_out_dir/${shlib_prefix}${_shared_library_target}${shlib_extension}" , | 57 "$root_out_dir/${shlib_prefix}${_shared_library_target}${shlib_extension}" , |
62 ] | 58 ] |
63 outputs = [ | 59 outputs = [ |
64 "{{bundle_executable_dir}}/$_output_name", | 60 "{{bundle_executable_dir}}/$_output_name", |
65 ] | 61 ] |
66 public_deps = [ | 62 public_deps = [ |
67 ":$_shared_library_target", | 63 ":$_shared_library_target", |
68 ] | 64 ] |
69 } | 65 } |
70 | 66 |
71 _info_plist_target = target_name + "_info_plist" | |
72 | |
73 # TODO(rsesek): Process Info.plist variables. | |
74 | |
75 _info_plist_bundle_data = _info_plist_target + "_bundle_data" | |
76 | |
77 bundle_data(_info_plist_bundle_data) { | |
78 visibility = [ ":$_framework_target" ] | |
79 forward_variables_from(invoker, [ "testonly" ]) | |
80 sources = [ | |
81 invoker.info_plist, | |
82 ] | |
83 outputs = [ | |
84 "{{bundle_root_dir}}/Info.plist", | |
85 ] | |
86 } | |
87 | |
88 create_bundle(_framework_target) { | 67 create_bundle(_framework_target) { |
89 visibility = [ ":$_target_name" ] | |
90 forward_variables_from(invoker, | 68 forward_variables_from(invoker, |
91 [ | 69 [ |
92 "data_deps", | 70 "data_deps", |
93 "deps", | 71 "deps", |
94 "public_deps", | 72 "public_deps", |
95 "testonly", | 73 "testonly", |
96 "visibility", | |
97 ]) | 74 ]) |
98 | 75 |
76 if (defined(_framework_version)) { | |
77 visibility = [ ":$_target_name" ] | |
78 } else { | |
79 forward_variables_from(invoker, [ "visibility" ]) | |
80 } | |
81 | |
99 if (!defined(deps)) { | 82 if (!defined(deps)) { |
100 deps = [] | 83 deps = [] |
101 } | 84 } |
102 deps += [ | 85 deps += [ ":$_shared_library_bundle_data" ] |
103 ":$_info_plist_bundle_data", | |
104 ":$_shared_library_bundle_data", | |
105 ] | |
106 | 86 |
107 bundle_root_dir = "$root_out_dir/$_framework_name" | 87 bundle_root_dir = _framework_root_dir |
108 if (_framework_version != "") { | |
109 bundle_root_dir += "/Versions/$_framework_version" | |
110 } | |
111 bundle_resources_dir = "$bundle_root_dir/Resources" | 88 bundle_resources_dir = "$bundle_root_dir/Resources" |
112 bundle_executable_dir = "$bundle_root_dir" | 89 bundle_executable_dir = "$bundle_root_dir" |
113 } | 90 } |
114 | 91 |
115 if (_framework_version != "") { | 92 if (defined(_framework_version)) { |
116 action(_target_name) { | 93 action(_target_name) { |
117 forward_variables_from(invoker, | 94 forward_variables_from(invoker, |
118 [ | 95 [ |
119 "visibility", | 96 "visibility", |
120 "testonly", | 97 "testonly", |
121 ]) | 98 ]) |
122 script = "$root_out_dir/gyp-mac-tool" | 99 script = "$root_out_dir/gyp-mac-tool" |
123 outputs = [ | 100 outputs = [ |
124 "$root_out_dir/$_framework_name/Versions/Current", | 101 "$root_out_dir/$_framework_name/Versions/Current", |
125 ] | 102 ] |
126 args = [ | 103 args = [ |
127 "package-framework", | 104 "package-framework", |
128 "$_framework_name", | 105 "$_framework_name", |
129 "$_framework_version", | 106 "$_framework_version", |
130 ] | 107 ] |
131 deps = [ | 108 deps = [ |
132 ":$_framework_target", | 109 ":$_framework_target", |
133 ] | 110 ] |
134 } | 111 } |
135 } else { | |
136 group(_target_name) { | |
137 forward_variables_from(invoker, | |
138 [ | |
139 "visibility", | |
140 "testonly", | |
141 ]) | |
142 deps = [ | |
143 ":$_framework_target", | |
144 ] | |
145 } | |
146 } | 112 } |
147 } | 113 } |
114 | |
115 # Template to package a shared library into a Mac framework bundle. | |
116 # | |
117 # Arguments | |
118 # | |
119 # info_plist: | |
120 # string, path to the Info.plist file that will be used for the bundle. | |
121 # | |
122 # output_name: | |
123 # (optional) string, name of the generated framework without the | |
124 # .framework suffix. If omitted, defaults to target_name. | |
125 # | |
126 # framework_version: | |
127 # (optional) string, version of the framework. Typically this is a | |
128 # single letter, like "A". If omitted, the Versions/ subdirectory | |
129 # structure will not be created, and build output will go directly | |
130 # into the framework subdirectory. | |
131 # | |
132 # See "gn help shared_library" for more information on arguments supported | |
133 # by shared library target. | |
134 template("mac_framework_bundle") { | |
135 assert(defined(invoker.deps), | |
136 "Dependencies must be specified for $target_name") | |
137 assert(defined(invoker.info_plist), | |
138 "The Info.plist file must be specified for $target_name") | |
139 | |
140 _info_plist_target = target_name + "_info_plist" | |
141 | |
142 # TODO(rsesek): Process Info.plist variables. | |
143 | |
144 _info_plist_bundle_data = _info_plist_target + "_bundle_data" | |
145 | |
146 bundle_data(_info_plist_bundle_data) { | |
147 forward_variables_from(invoker, [ "testonly" ]) | |
148 sources = [ | |
149 invoker.info_plist, | |
150 ] | |
151 outputs = [ | |
152 "{{bundle_root_dir}}/Info.plist", | |
153 ] | |
154 } | |
155 | |
156 framework_bundle(target_name) { | |
157 forward_variables_from(invoker, "*", [ "info_plist" ]) | |
158 | |
159 if (!defined(deps)) { | |
160 deps = [] | |
161 } | |
162 deps += [ ":$_info_plist_bundle_data" ] | |
163 } | |
164 } | |
OLD | NEW |