OLD | NEW |
| (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 # Given a framework, generates a header file declaring the classes from that | |
6 # framework using class-dump tool. | |
7 # | |
8 # Arguments: | |
9 # | |
10 # framework_name | |
11 # string, short name of the framework. | |
12 # | |
13 # framework_path | |
14 # string, location of the framework, usually a sub-directory of | |
15 # Xcode application bundle. | |
16 # | |
17 # framework_version | |
18 # (optional) string, version of the framework to dump class for, | |
19 # defaults to "Current" if omitted. | |
20 # | |
21 # class_dump_filter | |
22 # regexp, only display classes matching this regular expression. | |
23 # | |
24 # topological_sort | |
25 # (optional) boolean, sort classes, categories, and protocols by | |
26 # inheritance, defaults to false if omitted. | |
27 # | |
28 # All common target arugments ("visibility", "deps", ...) are forwarded by | |
29 # the template. | |
30 template("class_dump") { | |
31 assert(defined(invoker.framework_name), | |
32 "framework_name must be defined for $target_name") | |
33 assert(defined(invoker.framework_path), | |
34 "framework_path must be defined for $target_name") | |
35 assert(defined(invoker.class_dump_filter), | |
36 "class_dump_filter must be defined for $target_name") | |
37 | |
38 framework_version = "Current" | |
39 if (defined(invoker.framework_version)) { | |
40 framework_version = invoker.framework_version | |
41 } | |
42 | |
43 sort_args = [] | |
44 if (defined(invoker.topological_sort) && invoker.topological_sort) { | |
45 sort_args = [ "-I" ] | |
46 } | |
47 | |
48 class_dump = "//third_party/class-dump(${host_toolchain})" | |
49 class_dump_bin = get_label_info(class_dump, "root_out_dir") + "/class-dump" | |
50 framework = "${invoker.framework_path}/${invoker.framework_name}.framework" | |
51 | |
52 _config_name = target_name + "_config" | |
53 | |
54 config(_config_name) { | |
55 visibility = [ ":$target_name" ] | |
56 include_dirs = [ "$target_gen_dir" ] | |
57 } | |
58 | |
59 action(target_name) { | |
60 forward_variables_from(invoker, | |
61 "*", | |
62 [ | |
63 "args", | |
64 "class_dump_filter", | |
65 "framework_name", | |
66 "framework_path", | |
67 "framework_version", | |
68 "script", | |
69 "sources", | |
70 ]) | |
71 if (!defined(deps)) { | |
72 deps = [] | |
73 } | |
74 deps += [ class_dump ] | |
75 public_configs = [ ":$_config_name" ] | |
76 | |
77 script = "//third_party/class-dump/class-dump.py" | |
78 inputs = [ | |
79 class_dump_bin, | |
80 ] | |
81 sources = [ | |
82 "${framework}/Versions/${framework_version}/${invoker.framework_name}", | |
83 ] | |
84 outputs = [ | |
85 "$target_gen_dir/${invoker.framework_name}.h", | |
86 ] | |
87 args = [ | |
88 "-t=" + rebase_path(class_dump_bin, root_build_dir), | |
89 "-o=" + rebase_path(outputs[0], root_build_dir), | |
90 "--", | |
91 "-C${invoker.class_dump_filter}", | |
92 "${framework}", | |
93 ] | |
94 args += sort_args | |
95 } | |
96 } | |
OLD | NEW |