public class SkylarkProjectBuildFileParser extends Object implements ProjectBuildFileParser, UserDefinedRuleLoader
NOTE: This parser is still a work in progress and does not support some functions provided by
Python DSL parser like include_defs, so use in production at your own risk.
| Modifier and Type | Field and Description |
|---|---|
protected BuckGlobals |
buckGlobals |
protected com.google.devtools.build.lib.events.EventHandler |
eventHandler |
protected com.google.devtools.build.lib.vfs.FileSystem |
fileSystem |
protected ProjectBuildFileParserOptions |
options |
| Modifier | Constructor and Description |
|---|---|
protected |
SkylarkProjectBuildFileParser(SkylarkProjectBuildFileParser other) |
| Modifier and Type | Method and Description |
|---|---|
protected com.facebook.buck.skylark.parser.ExtensionData |
buildExtensionData(com.facebook.buck.skylark.parser.AbstractSkylarkFileParser.ExtensionLoadState load)
Given fully loaded extension represented by
ExtensionLoadState, evaluates extension and
returns ExtensionData |
void |
close() |
protected com.google.devtools.build.lib.cmdline.Label |
createContainingLabel(String basePath) |
com.google.common.collect.ImmutableSortedSet<String> |
getIncludedFiles(Path parseFile)
Collects the loaded files and extensions when parsing the
parseFile build spec. |
BuildFileManifest |
getManifest(Path buildFile)
Collect all information from a particular, along with metadata about the information, for
example which other files were also parsed.
|
boolean |
globResultsMatchCurrentState(Path buildFile,
com.google.common.collect.ImmutableList<GlobSpecWithResult> existingGlobsWithResults)
Checks if existing
GlobSpecs with results are the same as current state in the file
system. |
protected com.google.common.collect.ImmutableList<com.facebook.buck.skylark.parser.ExtensionData> |
loadExtensions(com.google.devtools.build.lib.cmdline.Label containingLabel,
com.google.common.collect.ImmutableList<com.google.devtools.build.lib.syntax.SkylarkImport> skylarkImports)
Loads all extensions identified by corresponding
SkylarkImports. |
void |
loadExtensionsForUserDefinedRules(Path buildFile,
BuildFileManifest manifest)
Loads all of the extensions mentioned in a build manifest
|
protected ParseResult |
parse(Path parseFile) |
protected com.google.devtools.build.lib.syntax.BuildFileAST |
readSkylarkAST(com.google.devtools.build.lib.vfs.Path path,
FileKind fileKind)
Reads file and returns abstract syntax tree for that file.
|
void |
reportProfile()
Reports profile information captured while parsing build files.
|
static SkylarkProjectBuildFileParser |
using(ProjectBuildFileParserOptions options,
BuckEventBus buckEventBus,
com.google.devtools.build.lib.vfs.FileSystem fileSystem,
BuckGlobals buckGlobals,
com.google.devtools.build.lib.events.EventHandler eventHandler,
GlobberFactory globberFactory)
Create an instance of Skylark project build file parser using provided options.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, getIncludedFilesprotected final com.google.devtools.build.lib.vfs.FileSystem fileSystem
protected final ProjectBuildFileParserOptions options
protected final com.google.devtools.build.lib.events.EventHandler eventHandler
protected final BuckGlobals buckGlobals
protected SkylarkProjectBuildFileParser(SkylarkProjectBuildFileParser other)
public static SkylarkProjectBuildFileParser using(ProjectBuildFileParserOptions options, BuckEventBus buckEventBus, com.google.devtools.build.lib.vfs.FileSystem fileSystem, BuckGlobals buckGlobals, com.google.devtools.build.lib.events.EventHandler eventHandler, GlobberFactory globberFactory)
public BuildFileManifest getManifest(Path buildFile) throws BuildFileParseException, InterruptedException, IOException
FileParsergetManifest in interface FileParser<BuildFileManifest>buildFile - should be an absolute path to a file. Must have rootPath as its prefix.BuildFileParseExceptionInterruptedExceptionIOExceptionpublic void reportProfile()
ProjectBuildFileParserreportProfile in interface ProjectBuildFileParserpublic boolean globResultsMatchCurrentState(Path buildFile, com.google.common.collect.ImmutableList<GlobSpecWithResult> existingGlobsWithResults) throws IOException, InterruptedException
ProjectBuildFileParserGlobSpecs with results are the same as current state in the file
system.globResultsMatchCurrentState in interface ProjectBuildFileParserbuildFile - the buildFile location to be used by the Globber.existingGlobsWithResults - the existing (deserialized) GlobSpecWithResult to check
the file system state against.true if glob expansion produces results matching previously recorded ones,
false otherwise.IOExceptionInterruptedExceptionpublic void loadExtensionsForUserDefinedRules(Path buildFile, BuildFileManifest manifest)
UserDefinedRuleLoaderloadExtensionsForUserDefinedRules in interface UserDefinedRuleLoaderbuildFile - The full path to the build filemanifest - The manifest from parsing a build fileprotected ParseResult parse(Path parseFile) throws IOException, BuildFileParseException, InterruptedException
parseFile.IOExceptionBuildFileParseExceptionInterruptedExceptionprotected com.google.devtools.build.lib.cmdline.Label createContainingLabel(String basePath)
protected com.google.devtools.build.lib.syntax.BuildFileAST readSkylarkAST(com.google.devtools.build.lib.vfs.Path path,
FileKind fileKind)
throws IOException
path - file path to read the data from.IOExceptionprotected com.google.common.collect.ImmutableList<com.facebook.buck.skylark.parser.ExtensionData> loadExtensions(com.google.devtools.build.lib.cmdline.Label containingLabel,
com.google.common.collect.ImmutableList<com.google.devtools.build.lib.syntax.SkylarkImport> skylarkImports)
throws BuildFileParseException,
IOException,
InterruptedException
SkylarkImports.protected com.facebook.buck.skylark.parser.ExtensionData buildExtensionData(com.facebook.buck.skylark.parser.AbstractSkylarkFileParser.ExtensionLoadState load)
throws InterruptedException
ExtensionLoadState, evaluates extension and
returns ExtensionDataload - ExtensionLoadState representing loaded extensionInterruptedExceptionpublic com.google.common.collect.ImmutableSortedSet<String> getIncludedFiles(Path parseFile) throws BuildFileParseException, InterruptedException, IOException
FileParserparseFile build spec.getIncludedFiles in interface FileParser<T extends FileManifest>parseFile - should be an absolute path to a file. Must have rootPath as its prefix.BuildFileParseExceptionInterruptedExceptionIOExceptionpublic void close()
throws BuildFileParseException
close in interface FileParser<T extends FileManifest>close in interface AutoCloseableBuildFileParseException