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 # This is used as the base template for both iOS and Mac frameworks.. |
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 # If the framework is unversionned, the final _target_name will be the |
| 31 # create_bundle(_framework_target), otherwise an action with the name |
| 32 # _target_name will depends on the the create_bundle() in order to prepare |
| 33 # the versioned directory structure. |
| 34 _framework_target = _target_name |
34 _framework_name = _output_name + ".framework" | 35 _framework_name = _output_name + ".framework" |
35 _framework_version = "" | 36 _framework_root_dir = "$root_out_dir/$_framework_name" |
36 if (defined(invoker.framework_version)) { | 37 if (defined(invoker.framework_version) && invoker.framework_version != "") { |
37 _framework_version = invoker.framework_version | 38 _framework_version = invoker.framework_version |
| 39 _framework_root_dir += "/Versions/$_framework_version" |
| 40 _framework_target = _target_name + "_create_bundle" |
38 } | 41 } |
39 _framework_target = _output_name + "_framework" | |
40 | 42 |
41 _shared_library_target = target_name + "_shared_library" | 43 _shared_library_target = target_name + "_shared_library" |
42 _shared_library_bundle_data = _shared_library_target + "_bundle_data" | 44 _shared_library_bundle_data = _shared_library_target + "_bundle_data" |
43 | 45 |
44 shared_library(_shared_library_target) { | 46 shared_library(_shared_library_target) { |
45 visibility = [ ":$_shared_library_bundle_data" ] | 47 visibility = [ ":$_shared_library_bundle_data" ] |
46 forward_variables_from(invoker, | 48 forward_variables_from(invoker, |
47 "*", | 49 "*", |
48 [ | 50 [ |
49 "assert_no_deps", | 51 "assert_no_deps", |
(...skipping 11 matching lines...) Expand all Loading... |
61 "$root_out_dir/${shlib_prefix}${_shared_library_target}${shlib_extension}"
, | 63 "$root_out_dir/${shlib_prefix}${_shared_library_target}${shlib_extension}"
, |
62 ] | 64 ] |
63 outputs = [ | 65 outputs = [ |
64 "{{bundle_executable_dir}}/$_output_name", | 66 "{{bundle_executable_dir}}/$_output_name", |
65 ] | 67 ] |
66 public_deps = [ | 68 public_deps = [ |
67 ":$_shared_library_target", | 69 ":$_shared_library_target", |
68 ] | 70 ] |
69 } | 71 } |
70 | 72 |
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) { | 73 create_bundle(_framework_target) { |
89 visibility = [ ":$_target_name" ] | |
90 forward_variables_from(invoker, | 74 forward_variables_from(invoker, |
91 [ | 75 [ |
92 "data_deps", | 76 "data_deps", |
93 "deps", | 77 "deps", |
94 "public_deps", | 78 "public_deps", |
95 "testonly", | 79 "testonly", |
96 "visibility", | |
97 ]) | 80 ]) |
98 | 81 |
| 82 if (defined(_framework_version)) { |
| 83 visibility = [ ":$_target_name" ] |
| 84 } else { |
| 85 forward_variables_from(invoker, [ "visibility" ]) |
| 86 } |
| 87 |
99 if (!defined(deps)) { | 88 if (!defined(deps)) { |
100 deps = [] | 89 deps = [] |
101 } | 90 } |
102 deps += [ | 91 deps += [ ":$_shared_library_bundle_data" ] |
103 ":$_info_plist_bundle_data", | |
104 ":$_shared_library_bundle_data", | |
105 ] | |
106 | 92 |
107 bundle_root_dir = "$root_out_dir/$_framework_name" | 93 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" | 94 bundle_resources_dir = "$bundle_root_dir/Resources" |
112 bundle_executable_dir = "$bundle_root_dir" | 95 bundle_executable_dir = "$bundle_root_dir" |
113 } | 96 } |
114 | 97 |
115 if (_framework_version != "") { | 98 if (defined(_framework_version)) { |
116 action(_target_name) { | 99 action(_target_name) { |
117 forward_variables_from(invoker, | 100 forward_variables_from(invoker, |
118 [ | 101 [ |
119 "visibility", | 102 "visibility", |
120 "testonly", | 103 "testonly", |
121 ]) | 104 ]) |
122 script = "$root_out_dir/gyp-mac-tool" | 105 script = "$root_out_dir/gyp-mac-tool" |
123 outputs = [ | 106 outputs = [ |
124 "$root_out_dir/$_framework_name/Versions/Current", | 107 "$root_out_dir/$_framework_name/Versions/Current", |
125 ] | 108 ] |
126 args = [ | 109 args = [ |
127 "package-framework", | 110 "package-framework", |
128 "$_framework_name", | 111 "$_framework_name", |
129 "$_framework_version", | 112 "$_framework_version", |
130 ] | 113 ] |
131 deps = [ | 114 deps = [ |
132 ":$_framework_target", | 115 ":$_framework_target", |
133 ] | 116 ] |
134 } | 117 } |
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 } | 118 } |
147 } | 119 } |
| 120 |
| 121 # Template to package a shared library into a Mac framework bundle. |
| 122 # |
| 123 # Arguments |
| 124 # |
| 125 # info_plist: |
| 126 # string, path to the Info.plist file that will be used for the bundle. |
| 127 # |
| 128 # output_name: |
| 129 # (optional) string, name of the generated framework without the |
| 130 # .framework suffix. If omitted, defaults to target_name. |
| 131 # |
| 132 # framework_version: |
| 133 # (optional) string, version of the framework. Typically this is a |
| 134 # single letter, like "A". If omitted, the Versions/ subdirectory |
| 135 # structure will not be created, and build output will go directly |
| 136 # into the framework subdirectory. |
| 137 # |
| 138 # See "gn help shared_library" for more information on arguments supported |
| 139 # by shared library target. |
| 140 template("mac_framework_bundle") { |
| 141 assert(defined(invoker.deps), |
| 142 "Dependencies must be specified for $target_name") |
| 143 assert(defined(invoker.info_plist), |
| 144 "The Info.plist file must be specified for $target_name") |
| 145 |
| 146 _info_plist_target = target_name + "_info_plist" |
| 147 |
| 148 # TODO(rsesek): Process Info.plist variables. |
| 149 |
| 150 _info_plist_bundle_data = _info_plist_target + "_bundle_data" |
| 151 |
| 152 bundle_data(_info_plist_bundle_data) { |
| 153 forward_variables_from(invoker, [ "testonly" ]) |
| 154 sources = [ |
| 155 invoker.info_plist, |
| 156 ] |
| 157 outputs = [ |
| 158 "{{bundle_root_dir}}/Info.plist", |
| 159 ] |
| 160 } |
| 161 |
| 162 framework_bundle(target_name) { |
| 163 forward_variables_from(invoker, "*", [ "info_plist" ]) |
| 164 |
| 165 if (!defined(deps)) { |
| 166 deps = [] |
| 167 } |
| 168 deps += [ ":$_info_plist_bundle_data" ] |
| 169 } |
| 170 } |
OLD | NEW |