Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Dec 5, 2022
1 parent 263aec4 commit 5100f17
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/com/google/devtools/build/skydoc/SkydocMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.Label.PackageContext;
import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
import com.google.devtools.build.lib.cmdline.RepositoryMapping;
import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.collect.nestedset.Depset;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
Expand Down Expand Up @@ -282,7 +285,10 @@ public Module eval(

List<AspectInfoWrapper> aspectInfoList = new ArrayList<>();

Module module = recursiveEval(semantics, label, label.getRepository().getName(), ruleInfoList,
// Resolve the label provided on the command line with the main repository's repository mapping.
// The stardoc rules always pass in a canonical label, so in this case the repository mapping
// is not used.
Module module = recursiveEval(semantics, label, RepositoryName.MAIN.getName(), ruleInfoList,
providerInfoList, aspectInfoList);

Map<StarlarkCallable, RuleInfoWrapper> ruleFunctions =
Expand Down Expand Up @@ -433,7 +439,8 @@ private Module recursiveEval(
// process loads
Map<String, Module> imports = new HashMap<>();
for (String load : prog.getLoads()) {
Label apparentLabel = label.getRelativeWithRemapping(load, ImmutableMap.of());
Label apparentLabel = Label.parseWithPackageContext(load,
PackageContext.of(label.getPackageIdentifier(), RepositoryMapping.ALWAYS_FALLBACK));
try {
Module loadedModule =
recursiveEval(semantics, apparentLabel, sourceRepository, ruleInfoList,
Expand Down Expand Up @@ -473,7 +480,7 @@ path, load, pathOfLabel(apparentLabel, sourceRepository)),
return module;
}

private Path pathOfLabel(Label label, String sourceRepository) throws IOException {
private Path pathOfLabel(Label label, String sourceRepository) {
String targetRepositoryApparentName =
label.getRepository().isMain() ? workspaceName : label.getRepository().getName();
String rlocationPath = targetRepositoryApparentName + "/" + label.toPathFragment().toString();
Expand Down

0 comments on commit 5100f17

Please sign in to comment.