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 ;
@@ -69,6 +72,15 @@ public class BzlmodRepoCycleReporter implements CyclesReporter.SingleCycleReport
69
72
private static final Predicate <SkyKey > IS_WORKSPACE_FILE =
70
73
SkyFunctions .isSkyFunction (WorkspaceFileValue .WORKSPACE_FILE );
71
74
75
+ private static final Predicate <SkyKey > IS_MODULE_RESOLUTION =
76
+ SkyFunctions .isSkyFunction (SkyFunctions .BAZEL_MODULE_RESOLUTION );
77
+
78
+ private static final Predicate <SkyKey > IS_DEP_GRAPH =
79
+ SkyFunctions .isSkyFunction (SkyFunctions .BAZEL_DEP_GRAPH );
80
+
81
+ private static final Predicate <SkyKey > IS_MODULE_FILE =
82
+ SkyFunctions .isSkyFunction (SkyFunctions .MODULE_FILE );
83
+
72
84
private static void requestRepoDefinitions (
73
85
ExtendedEventHandler eventHandler , Iterable <SkyKey > repos ) {
74
86
for (SkyKey repo : repos ) {
@@ -113,7 +125,10 @@ public boolean maybeReportCycle(
113
125
IS_MODULE_EXTENSION_REPO_MAPPING_ENTRIES ,
114
126
IS_PACKAGE ,
115
127
IS_EXTERNAL_PACKAGE ,
116
- IS_WORKSPACE_FILE ))
128
+ IS_WORKSPACE_FILE ,
129
+ IS_MODULE_RESOLUTION ,
130
+ IS_DEP_GRAPH ,
131
+ IS_MODULE_FILE ))
117
132
&& Iterables .any (cycle , Predicates .or (IS_REPO_RULE , IS_EXTENSION_IMPL ))) {
118
133
StringBuilder cycleMessage =
119
134
new StringBuilder (
@@ -127,7 +142,10 @@ public boolean maybeReportCycle(
127
142
IS_EXTENSION_IMPL ,
128
143
IS_BZL_LOAD ,
129
144
IS_REPO_MAPPING ,
130
- IS_WORKSPACE_FILE ));
145
+ IS_WORKSPACE_FILE ,
146
+ IS_MODULE_RESOLUTION ,
147
+ IS_DEP_GRAPH ,
148
+ IS_MODULE_FILE ));
131
149
Function <Object , String > printer =
132
150
rawInput -> {
133
151
SkyKey input = (SkyKey ) rawInput ;
@@ -144,6 +162,12 @@ public boolean maybeReportCycle(
144
162
return String .format ("repository mapping of %s" , key .repoName ());
145
163
} else if (input .argument () instanceof WorkspaceFileValue .WorkspaceFileKey ) {
146
164
return "WORKSPACE file" ;
165
+ } else if (input .argument () == BazelModuleResolutionValue .KEY ) {
166
+ return "module resolution" ;
167
+ } else if (input .argument () == BazelDepGraphValue .KEY ) {
168
+ return "module dependency graph" ;
169
+ } else if (input .argument () instanceof ModuleFileValue .Key ) {
170
+ return "module file of " + input .argument ();
147
171
} else {
148
172
Preconditions .checkArgument (input .argument () instanceof BzlLoadValue .Key );
149
173
return ((BzlLoadValue .Key ) input .argument ()).getLabel ().toString ();
0 commit comments