-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow certain
native
functions in initializers
RELNOTES: The following functions on `native` can now be used in rule initializers: `repo_name`, `package_name`, `package_relative_label`, `module_name`, `module_version`.
- Loading branch information
Showing
9 changed files
with
172 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/google/devtools/build/lib/packages/InitializerStarlarkContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.google.devtools.build.lib.packages; | ||
|
||
import com.google.devtools.build.lib.cmdline.PackageIdentifier; | ||
import com.google.devtools.build.lib.packages.LabelConverter; | ||
import com.google.devtools.build.lib.packages.Package; | ||
import com.google.devtools.build.lib.packages.SymbolGenerator; | ||
import com.google.devtools.build.lib.packages.TargetDefinitionContext; | ||
|
||
import java.util.Optional; | ||
|
||
public final class InitializerStarlarkContext extends TargetDefinitionContext { | ||
private final Package.Builder pkgBuilder; | ||
|
||
public InitializerStarlarkContext(Package.Builder pkgBuilder) { | ||
super(Phase.INITIALIZER, new SymbolGenerator<>(new Object())); | ||
this.pkgBuilder = pkgBuilder; | ||
} | ||
|
||
@Override | ||
PackageIdentifier getPackageIdentifier() { | ||
return pkgBuilder.getPackageIdentifier(); | ||
} | ||
|
||
@Override | ||
Optional<String> getAssociatedModuleName() { | ||
return pkgBuilder.getAssociatedModuleName(); | ||
} | ||
|
||
@Override | ||
Optional<String> getAssociatedModuleVersion() { | ||
return pkgBuilder.getAssociatedModuleVersion(); | ||
} | ||
|
||
@Override | ||
public LabelConverter getLabelConverter() { | ||
return pkgBuilder.getLabelConverter(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters