@@ -8,38 +8,69 @@ import("//flutter/common/config.gni")
8
8
declare_args () {
9
9
# Whether playgrounds are enabled for unit tests.
10
10
impeller_enable_playground = false
11
+
12
+ # Whether Impeller is supported on the platform.
13
+ impeller_supports_platform = is_mac || is_ios
11
14
}
12
15
16
+ # ------------------------------------------------------------------------------
17
+ # @brief Define an Impeller component. Components are different
18
+ # Impeller subsystems part of the umbrella framework.
19
+ #
20
+ # @param[optional] target_type The type of the component. This can be any of
21
+ # the target types supported by GN. Defaults to
22
+ # source_set. If Impeller is not supported on the
23
+ # target platform, this target is a no-op.
24
+ #
13
25
template (" impeller_component" ) {
14
- source_set (target_name ) {
15
- forward_variables_from (invoker , " *" )
16
-
17
- if (! defined (invoker .public_configs )) {
18
- public_configs = []
26
+ if (impeller_supports_platform ) {
27
+ target_type = " source_set"
28
+ if (defined (invoker .target_type )) {
29
+ target_type = invoker .target_type
19
30
}
31
+ target (target_type , target_name ) {
32
+ forward_variables_from (invoker , " *" )
20
33
21
- if (! defined (invoker .cflags_objc )) {
22
- cflags_objc = []
23
- }
34
+ if (! defined (invoker .public_configs )) {
35
+ public_configs = []
36
+ }
24
37
25
- if (! defined (invoker .cflags_objcc )) {
26
- cflags_objcc = []
27
- }
38
+ public_configs += [ " //flutter/impeller:impeller_public_config" ]
28
39
29
- if (! defined (invoker .deps )) {
30
- deps = []
31
- }
40
+ if (! defined (invoker .cflags_objc )) {
41
+ cflags_objc = []
42
+ }
32
43
33
- objc_warning_flags = [ " -Wno-unused-private-field" ]
44
+ if (is_ios || is_mac ) {
45
+ cflags_objc += flutter_cflags_objc_arc
46
+ }
34
47
35
- cflags_objc += flutter_cflags_objc_arc + objc_warning_flags
36
- cflags_objcc += flutter_cflags_objcc_arc + objc_warning_flags
48
+ if (! defined (invoker .cflags_objcc )) {
49
+ cflags_objcc = []
50
+ }
37
51
38
- public_configs += [ " //flutter/impeller:impeller_public_config" ]
52
+ if (is_ios || is_mac ) {
53
+ cflags_objcc += flutter_cflags_objcc_arc
54
+ }
55
+ }
56
+ } else {
57
+ group (target_name ) {
58
+ not_needed (invoker , " *" )
59
+ }
39
60
}
40
61
}
41
62
63
+ # ------------------------------------------------------------------------------
64
+ # @brief Build a Metal Library. The output is a single file. Use
65
+ # get_target_outputs to get its location on build.
66
+ #
67
+ # @param[required] name The name of the Metal library.
68
+ #
69
+ # @param[required] sources The GLSL (4.60) sources to compiled into the Metal
70
+ # library.
71
+ #
42
72
template (" metal_library" ) {
73
+ assert (is_ios || is_mac )
43
74
assert (defined (invoker .name ), " Metal library name must be specified." )
44
75
assert (defined (invoker .sources ), " Metal source files must be specified." )
45
76
@@ -94,7 +125,17 @@ template("metal_library") {
94
125
}
95
126
}
96
127
97
- template (" impeller_shaders" ) {
128
+ # ------------------------------------------------------------------------------
129
+ # @brief Build and reflect shader information. Reflected shader
130
+ # information will be added to a generated source set along
131
+ # with the shader contents.
132
+ #
133
+ # @param[required] name The name of the shader library.
134
+ #
135
+ # @param[required] sources The GLSL (4.60) sources to compiled into the shader
136
+ # library.
137
+ #
138
+ template (" impeller_shaders_real" ) {
98
139
assert (defined (invoker .shaders ), " Impeller shaders must be specified." )
99
140
assert (defined (invoker .name ), " Name of the shader library must be specified." )
100
141
@@ -229,3 +270,27 @@ template("impeller_shaders") {
229
270
]
230
271
}
231
272
}
273
+
274
+ # ------------------------------------------------------------------------------
275
+ # @brief Builds the shader library from shader sources, generates
276
+ # reflected shader information as source set, and, generates a
277
+ # translation unit added as a source set that allows embedding
278
+ # shaders into the final binary. On platforms where Impeller is
279
+ # not supported, this is a no-op.
280
+ #
281
+ # @note For additional information about parameters, see
282
+ # `impeller_shaders_real`
283
+ #
284
+ # @see impeller_shaders_real
285
+ #
286
+ template (" impeller_shaders" ) {
287
+ if (impeller_supports_platform ) {
288
+ impeller_shaders_real (target_name ) {
289
+ forward_variables_from (invoker , " *" )
290
+ }
291
+ } else {
292
+ group (target_name ) {
293
+ not_needed (invoker , " *" )
294
+ }
295
+ }
296
+ }
0 commit comments