13
13
# limitations under the License.
14
14
# ==============================================================================
15
15
16
+ load ("@bazel_skylib//lib:selects.bzl" , "selects" )
17
+ load (
18
+ "@bazel_skylib//rules:common_settings.bzl" ,
19
+ "bool_flag" ,
20
+ )
16
21
load ("//tensorflow/lite:build_def.bzl" , "tflite_copts" , "tflite_linkopts" )
17
22
18
23
package (
@@ -23,6 +28,35 @@ package(
23
28
licenses = ["notice" ],
24
29
)
25
30
31
+ # If --define EXPLICIT_DISABLE_HEXAGON=1 is passed, the Hexagon delegate will be disabled.
32
+ config_setting (
33
+ name = "explicit_disable_hexagon_define" ,
34
+ define_values = {
35
+ "EXPLICIT_DISABLE_HEXAGON" : "1" ,
36
+ },
37
+ )
38
+
39
+ bool_flag (
40
+ name = "explicit_disable_hexagon" ,
41
+ build_setting_default = False ,
42
+ )
43
+
44
+ config_setting (
45
+ name = "explicit_disable_hexagon_flag" ,
46
+ flag_values = {
47
+ ":explicit_disable_hexagon" : "True" ,
48
+ },
49
+ )
50
+
51
+ # Set if either the explicit_disable_hexagon define or the flag is set.
52
+ selects .config_setting_group (
53
+ name = "explicit_disable_hexagon_setting" ,
54
+ match_any = [
55
+ ":explicit_disable_hexagon_define" ,
56
+ ":explicit_disable_hexagon_flag" ,
57
+ ],
58
+ )
59
+
26
60
cc_library (
27
61
name = "hexagon_implementation" ,
28
62
srcs = ["hexagon_implementation.cc" ],
@@ -77,21 +111,31 @@ cc_library(
77
111
78
112
cc_library (
79
113
name = "hexagon_delegate" ,
80
- srcs = ["hexagon_delegate.cc" ],
81
- hdrs = ["hexagon_delegate.h" ],
114
+ srcs = select ({
115
+ ":explicit_disable_hexagon_setting" : [],
116
+ "//conditions:default" : ["hexagon_delegate.cc" ],
117
+ }),
118
+ hdrs = select ({
119
+ ":explicit_disable_hexagon_setting" : [],
120
+ "//conditions:default" : ["hexagon_delegate.h" ],
121
+ }),
82
122
tags = [
83
123
"manual" ,
84
124
"nobuilder" ,
85
125
],
86
- deps = [
87
- ":hexagon_delegate_kernel" ,
88
- ":hexagon_implementation" ,
89
- ":utils" ,
90
- "//tensorflow/lite:kernel_api" ,
91
- "//tensorflow/lite:minimal_logging" ,
92
- "//tensorflow/lite/core/c:common" ,
93
- "//tensorflow/lite/delegates/utils:simple_delegate" ,
94
- ] + select ({
126
+ deps = select ({
127
+ ":explicit_disable_hexagon_setting" : [],
128
+ "//conditions:default" : [
129
+ ":hexagon_delegate_kernel" ,
130
+ ":hexagon_implementation" ,
131
+ ":utils" ,
132
+ "//tensorflow/lite:kernel_api" ,
133
+ "//tensorflow/lite:minimal_logging" ,
134
+ "//tensorflow/lite/core/c:common" ,
135
+ "//tensorflow/lite/delegates/utils:simple_delegate" ,
136
+ ],
137
+ }) + select ({
138
+ ":explicit_disable_hexagon_setting" : [],
95
139
"//tensorflow:ios" : [],
96
140
"//tensorflow:ios_x86_64" : [],
97
141
"//tensorflow:macos" : [],
0 commit comments