Use Labels, rather than PathFragments, to represent Skylark loads internally. The load location for a Skylark Aspect is specified via a PathFragment, for consistency with current non-Aspect Skylark loads.

This should be a semantics-preserving change for users. In a subsequent CL, I'll change the Skylark syntax to allow load statements to use labels as well as paths, with the goal of eventually deprecating the latter.

Also:

- Removed the hack for handling relative loads in the prelude file.

- Refactored some redundant functionality in PackageFunction and SkylarkImportLookupFunction for handling loads.

- Removed the ability to put the BUILD file for the package containing a Skylark file under a different package root than the Skylark file itself. This functionality isn't currently used and is inconsistent with Blaze's handling of the package path elsewhere.

- Added BUILD files to a number of tests that load Skylark files; this is consistent with the requirement that all Skylark files need to be part of some package.

- Changed the constants used to set the location of the prelude file from paths to labels.

--
MOS_MIGRATED_REVID=107741568
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java
index 9d0cd4c..616c60c 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java
@@ -18,7 +18,6 @@
 import static com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType.ABSTRACT;
 import static com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType.TEST;
 
-import com.google.common.base.Preconditions;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
@@ -81,7 +80,7 @@
    */
   public static class Builder implements RuleDefinitionEnvironment {
     private final StringBuilder defaultWorkspaceFile = new StringBuilder();
-    private PathFragment preludePath;
+    private Label preludeLabel;
     private String runfilesPrefix;
     private final List<ConfigurationFragmentFactory> configurationFragments = new ArrayList<>();
     private final List<BuildInfoFactory> buildInfoFactories = new ArrayList<>();
@@ -105,11 +104,14 @@
       defaultWorkspaceFile.append(contents);
     }
 
-    public Builder setPrelude(String workspaceRelativePath) {
-      PathFragment preludePathFragment = new PathFragment(workspaceRelativePath);
-      Preconditions.checkArgument(!preludePathFragment.isAbsolute());
-      Preconditions.checkArgument(preludePathFragment.isNormalized());
-      this.preludePath = preludePathFragment;
+    public Builder setPrelude(String preludeLabelString) {
+      try {
+        this.preludeLabel = Label.parseAbsolute(preludeLabelString);
+      } catch (LabelSyntaxException e) {
+        String errorMsg =
+            String.format("Prelude label '%s' is invalid: %s", preludeLabelString, e.getMessage());
+        throw new IllegalArgumentException(errorMsg);
+      }
       return this;
     }
 
@@ -226,7 +228,7 @@
       }
 
       return new ConfiguredRuleClassProvider(
-          preludePath,
+          preludeLabel,
           runfilesPrefix,
           ImmutableMap.copyOf(ruleClassMap),
           ImmutableMap.copyOf(ruleDefinitionMap),
@@ -269,9 +271,9 @@
   String defaultWorkspaceFile;
 
   /**
-   * Workspace-relative path to the prelude.
+   * Label for the prelude file.
    */
-  private final PathFragment preludePath;
+  private final Label preludeLabel;
 
   /**
    * The default runfiles prefix.
@@ -315,7 +317,7 @@
   private final Environment.Frame globals;
 
   public ConfiguredRuleClassProvider(
-      PathFragment preludePath,
+      Label preludeLabel,
       String runfilesPrefix,
       ImmutableMap<String, RuleClass> ruleClassMap,
       ImmutableMap<String, Class<? extends RuleDefinition>> ruleDefinitionMap,
@@ -327,7 +329,7 @@
       ConfigurationCollectionFactory configurationCollectionFactory,
       PrerequisiteValidator prerequisiteValidator,
       ImmutableMap<String, SkylarkType> skylarkAccessibleJavaClasses) {
-    this.preludePath = preludePath;
+    this.preludeLabel = preludeLabel;
     this.runfilesPrefix = runfilesPrefix;
     this.ruleClassMap = ruleClassMap;
     this.ruleDefinitionMap = ruleDefinitionMap;
@@ -346,8 +348,8 @@
   }
 
   @Override
-  public PathFragment getPreludePath() {
-    return preludePath;
+  public Label getPreludeLabel() {
+    return preludeLabel;
   }
 
   @Override