@@ -8,38 +8,69 @@ import("//flutter/common/config.gni")
88declare_args () {
99 # Whether playgrounds are enabled for unit tests.
1010 impeller_enable_playground = false
11+
12+ # Whether Impeller is supported on the platform.
13+ impeller_supports_platform = is_mac || is_ios
1114}
1215
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+ #
1325template (" 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
1930 }
31+ target (target_type , target_name ) {
32+ forward_variables_from (invoker , " *" )
2033
21- if (! defined (invoker .cflags_objc )) {
22- cflags_objc = []
23- }
34+ if (! defined (invoker .public_configs )) {
35+ public_configs = []
36+ }
2437
25- if (! defined (invoker .cflags_objcc )) {
26- cflags_objcc = []
27- }
38+ public_configs += [ " //flutter/impeller:impeller_public_config" ]
2839
29- if (! defined (invoker .deps )) {
30- deps = []
31- }
40+ if (! defined (invoker .cflags_objc )) {
41+ cflags_objc = []
42+ }
3243
33- objc_warning_flags = [ " -Wno-unused-private-field" ]
44+ if (is_ios || is_mac ) {
45+ cflags_objc += flutter_cflags_objc_arc
46+ }
3447
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+ }
3751
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+ }
3960 }
4061}
4162
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+ #
4272template (" metal_library" ) {
73+ assert (is_ios || is_mac )
4374 assert (defined (invoker .name ), " Metal library name must be specified." )
4475 assert (defined (invoker .sources ), " Metal source files must be specified." )
4576
@@ -94,7 +125,17 @@ template("metal_library") {
94125 }
95126}
96127
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" ) {
98139 assert (defined (invoker .shaders ), " Impeller shaders must be specified." )
99140 assert (defined (invoker .name ), " Name of the shader library must be specified." )
100141
@@ -229,3 +270,27 @@ template("impeller_shaders") {
229270 ]
230271 }
231272}
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