|
29 | 29 | import net.starlark.java.annot.StarlarkBuiltin;
|
30 | 30 | import net.starlark.java.annot.StarlarkMethod;
|
31 | 31 | import net.starlark.java.eval.EvalException;
|
| 32 | +import net.starlark.java.eval.NoneType; |
| 33 | +import net.starlark.java.eval.Sequence; |
32 | 34 | import net.starlark.java.eval.StarlarkList;
|
33 | 35 | import net.starlark.java.eval.StarlarkSemantics;
|
34 | 36 |
|
@@ -117,4 +119,68 @@ public StarlarkList<StarlarkBazelModule> getModules() {
|
117 | 119 | public boolean isDevDependency(TypeCheckedTag tag) {
|
118 | 120 | return tag.isDevDependency();
|
119 | 121 | }
|
| 122 | + |
| 123 | + @StarlarkMethod( |
| 124 | + name = "extension_metadata", |
| 125 | + doc = |
| 126 | + "Constructs an opaque object that can be returned from the module extension's" |
| 127 | + + " implementation function to provide metadata about the repositories generated by" |
| 128 | + + " the extension to Bazel.", |
| 129 | + parameters = { |
| 130 | + @Param( |
| 131 | + name = "root_module_direct_deps", |
| 132 | + doc = |
| 133 | + "The names of the repositories that the extension considers to be direct" |
| 134 | + + " dependencies of the root module. If the root module imports additional" |
| 135 | + + " repositories or does not import all of these repositories via <a" |
| 136 | + + " href=\"../globals/module.html#use_repo\"><code>use_repo</code></a>, Bazel" |
| 137 | + + " will print a warning and a fixup command when the extension is" |
| 138 | + + " evaluated.<p>If one of <code>root_module_direct_deps</code> and" |
| 139 | + + " <code>root_module_direct_dev_deps</code> is specified, the other has to be" |
| 140 | + + " as well. The lists specified by these two parameters must be" |
| 141 | + + " disjoint.<p>Exactly one of <code>root_module_direct_deps</code> and" |
| 142 | + + " <code>root_module_direct_dev_deps</code> can be set to the special value" |
| 143 | + + " <code>\"all\"</code>, which is treated as if a list with the names of" |
| 144 | + + " allrepositories generated by the extension was specified as the value.", |
| 145 | + positional = false, |
| 146 | + named = true, |
| 147 | + defaultValue = "None", |
| 148 | + allowedTypes = { |
| 149 | + @ParamType(type = Sequence.class, generic1 = String.class), |
| 150 | + @ParamType(type = String.class), |
| 151 | + @ParamType(type = NoneType.class) |
| 152 | + }), |
| 153 | + @Param( |
| 154 | + name = "root_module_direct_dev_deps", |
| 155 | + doc = |
| 156 | + "The names of the repositories that the extension considers to be direct dev" |
| 157 | + + " dependencies of the root module. If the root module imports additional" |
| 158 | + + " repositories or does not import all of these repositories via <a" |
| 159 | + + " href=\"../globals/module.html#use_repo\"><code>use_repo</code></a> on an" |
| 160 | + + " extension proxy created with <code><a" |
| 161 | + + " href=\"../globals/module.html#use_extension>use_extension</a>(...," |
| 162 | + + " dev_dependency = True)</code>, Bazel will print a warning and a fixup" |
| 163 | + + " command when the extension is evaluated.<p>If one of" |
| 164 | + + " <code>root_module_direct_deps</code> and" |
| 165 | + + " <code>root_module_direct_dev_deps</code> is specified, the other has to be" |
| 166 | + + " as well. The lists specified by these two parameters must be" |
| 167 | + + " disjoint.<p>Exactly one of <code>root_module_direct_deps</code> and" |
| 168 | + + " <code>root_module_direct_dev_deps</code> can be set to the special value" |
| 169 | + + " <code>\"all\"</code>, which is treated as if a list with the names of" |
| 170 | + + " allrepositories generated by the extension was specified as the value.", |
| 171 | + positional = false, |
| 172 | + named = true, |
| 173 | + defaultValue = "None", |
| 174 | + allowedTypes = { |
| 175 | + @ParamType(type = Sequence.class, generic1 = String.class), |
| 176 | + @ParamType(type = String.class), |
| 177 | + @ParamType(type = NoneType.class) |
| 178 | + }), |
| 179 | + }) |
| 180 | + public ModuleExtensionMetadata extensionMetadata( |
| 181 | + Object rootModuleDirectDepsUnchecked, Object rootModuleDirectDevDepsUnchecked) |
| 182 | + throws EvalException { |
| 183 | + return ModuleExtensionMetadata.create( |
| 184 | + rootModuleDirectDepsUnchecked, rootModuleDirectDevDepsUnchecked); |
| 185 | + } |
120 | 186 | }
|
0 commit comments