diff options
author | John Field <jfield@google.com> | 2015-09-21 18:59:19 +0000 |
---|---|---|
committer | Laszlo Csomor <laszlocsomor@google.com> | 2015-09-22 17:05:23 +0000 |
commit | 925dc5ce1c6916b43a94fa12017aa4a6390de891 (patch) | |
tree | 17da1c801a23290c563bcf4347dd90930f094c12 /src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupValue.java | |
parent | d256a821f4051273e3be1617c793c6dc5e77d964 (diff) |
Use Labels, rather than PathFragments, to represent Skylark loads internally. 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=103567562
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupValue.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupValue.java | 42 |
1 files changed, 3 insertions, 39 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupValue.java index 0ac9fd4402..e9d050d300 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupValue.java @@ -13,14 +13,9 @@ // limitations under the License. package com.google.devtools.build.lib.skyframe; -import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; -import com.google.devtools.build.lib.cmdline.PackageIdentifier; -import com.google.devtools.build.lib.cmdline.PackageIdentifier.RepositoryName; -import com.google.devtools.build.lib.skyframe.ASTFileLookupValue.ASTLookupInputException; +import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.syntax.Environment.Extension; -import com.google.devtools.build.lib.syntax.LoadStatement; -import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; @@ -58,38 +53,7 @@ public class SkylarkImportLookupValue implements SkyValue { return dependency; } - private static void checkInputArgument(PathFragment astFilePathFragment) - throws ASTLookupInputException { - if (astFilePathFragment.isAbsolute()) { - throw new ASTLookupInputException(String.format( - "Input file '%s' cannot be an absolute path.", astFilePathFragment)); - } - } - - @VisibleForTesting - static SkyKey key(PackageIdentifier pkgIdentifier) throws ASTLookupInputException { - return key(pkgIdentifier.getRepository(), pkgIdentifier.getPackageFragment()); - } - - static SkyKey key(RepositoryName repo, PathFragment fromFile, PathFragment fileToImport) - throws ASTLookupInputException { - PathFragment computedPath; - if (fileToImport.isAbsolute()) { - computedPath = fileToImport.toRelative(); - } else if (fileToImport.segmentCount() == 1) { - computedPath = fromFile.getParentDirectory().getRelative(fileToImport); - } else { - throw new ASTLookupInputException(String.format(LoadStatement.PATH_ERROR_MSG, fileToImport)); - } - return key(repo, computedPath); - } - - private static SkyKey key(RepositoryName repo, PathFragment fileToImport) - throws ASTLookupInputException { - // Skylark import lookup keys need to be valid AST file lookup keys. - checkInputArgument(fileToImport); - return new SkyKey( - SkyFunctions.SKYLARK_IMPORTS_LOOKUP, - new PackageIdentifier(repo, fileToImport)); + static SkyKey key(Label importLabel) { + return new SkyKey(SkyFunctions.SKYLARK_IMPORTS_LOOKUP, importLabel); } } |