20
20
import com .google .common .base .Predicates ;
21
21
import com .google .common .collect .ImmutableList ;
22
22
import com .google .common .collect .Iterables ;
23
+ import com .google .devtools .build .lib .bazel .bzlmod .BazelDepGraphValue ;
24
+ import com .google .devtools .build .lib .bazel .bzlmod .BazelModuleResolutionValue ;
23
25
import com .google .devtools .build .lib .bazel .bzlmod .BzlmodRepoRuleValue ;
24
26
import com .google .devtools .build .lib .bazel .bzlmod .ModuleExtensionId ;
27
+ import com .google .devtools .build .lib .bazel .bzlmod .ModuleFileValue ;
25
28
import com .google .devtools .build .lib .cmdline .Label ;
26
29
import com .google .devtools .build .lib .cmdline .PackageIdentifier ;
27
30
import com .google .devtools .build .lib .events .Event ;
@@ -72,6 +75,15 @@ public class BzlmodRepoCycleReporter implements CyclesReporter.SingleCycleReport
72
75
private static final Predicate <SkyKey > IS_WORKSPACE_FILE =
73
76
SkyFunctions .isSkyFunction (WorkspaceFileValue .WORKSPACE_FILE );
74
77
78
+ private static final Predicate <SkyKey > IS_MODULE_RESOLUTION =
79
+ SkyFunctions .isSkyFunction (SkyFunctions .BAZEL_MODULE_RESOLUTION );
80
+
81
+ private static final Predicate <SkyKey > IS_DEP_GRAPH =
82
+ SkyFunctions .isSkyFunction (SkyFunctions .BAZEL_DEP_GRAPH );
83
+
84
+ private static final Predicate <SkyKey > IS_MODULE_FILE =
85
+ SkyFunctions .isSkyFunction (SkyFunctions .MODULE_FILE );
86
+
75
87
private static void requestRepoDefinitions (
76
88
ExtendedEventHandler eventHandler , Iterable <SkyKey > repos ) {
77
89
for (SkyKey repo : repos ) {
@@ -117,7 +129,10 @@ public boolean maybeReportCycle(
117
129
IS_MODULE_EXTENSION_REPO_MAPPING_ENTRIES ,
118
130
IS_PACKAGE ,
119
131
IS_EXTERNAL_PACKAGE ,
120
- IS_WORKSPACE_FILE ))
132
+ IS_WORKSPACE_FILE ,
133
+ IS_MODULE_RESOLUTION ,
134
+ IS_DEP_GRAPH ,
135
+ IS_MODULE_FILE ))
121
136
&& Iterables .any (cycle , Predicates .or (IS_REPO_RULE , IS_EXTENSION_IMPL ))) {
122
137
StringBuilder cycleMessage =
123
138
new StringBuilder (
@@ -131,7 +146,10 @@ public boolean maybeReportCycle(
131
146
IS_EXTENSION_IMPL ,
132
147
IS_BZL_LOAD ,
133
148
IS_REPO_MAPPING ,
134
- IS_WORKSPACE_FILE ));
149
+ IS_WORKSPACE_FILE ,
150
+ IS_MODULE_RESOLUTION ,
151
+ IS_DEP_GRAPH ,
152
+ IS_MODULE_FILE ));
135
153
Function <Object , String > printer =
136
154
rawInput -> {
137
155
SkyKey input = (SkyKey ) rawInput ;
@@ -148,6 +166,12 @@ public boolean maybeReportCycle(
148
166
return String .format ("repository mapping of %s" , key .repoName ());
149
167
} else if (input .argument () instanceof WorkspaceFileValue .WorkspaceFileKey ) {
150
168
return "WORKSPACE file" ;
169
+ } else if (input .argument () == BazelModuleResolutionValue .KEY ) {
170
+ return "module resolution" ;
171
+ } else if (input .argument () == BazelDepGraphValue .KEY ) {
172
+ return "module dependency graph" ;
173
+ } else if (input .argument () instanceof ModuleFileValue .Key ) {
174
+ return "module file of " + input .argument ();
151
175
} else {
152
176
Preconditions .checkArgument (input .argument () instanceof BzlLoadValue .Key );
153
177
return ((BzlLoadValue .Key ) input .argument ()).getLabel ().toString ();
0 commit comments