From 145b701977726094f8ae44f6532b9fb3e2057e5e Mon Sep 17 00:00:00 2001 From: Lukacs Berki Date: Thu, 27 Aug 2015 14:20:57 +0000 Subject: Make load() work in remote repositories too. Previously, load() always looked up .bzl files in the main repository. Ideally, it would just take a label and then it would work by default, but for the time being, this quick fix will do. I had to put in an evil hack to make load() statements work in the prelude, because we currently have no way to distinguish load() statements from the prelude and from the BUILD file. Again, a proper label-based load() would solve this. -- MOS_MIGRATED_REVID=101677502 --- .../devtools/build/lib/skyframe/SkylarkImportLookupValue.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupValue.java') 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 20579cce0d..9b307be7b8 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 @@ -58,6 +58,14 @@ 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()); @@ -79,7 +87,7 @@ public class SkylarkImportLookupValue implements SkyValue { private static SkyKey key(RepositoryName repo, PathFragment fileToImport) throws ASTLookupInputException { // Skylark import lookup keys need to be valid AST file lookup keys. - ASTFileLookupValue.checkInputArgument(fileToImport); + checkInputArgument(fileToImport); return new SkyKey( SkyFunctions.SKYLARK_IMPORTS_LOOKUP, new PackageIdentifier(repo, fileToImport)); -- cgit v1.2.3