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
GlobSpec s 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
SkylarkImport s. |
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, wait
close, getIncludedFiles
protected 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
FileParser
getManifest
in interface FileParser<BuildFileManifest>
buildFile
- should be an absolute path to a file. Must have rootPath as its prefix.BuildFileParseException
InterruptedException
IOException
public void reportProfile()
ProjectBuildFileParser
reportProfile
in interface ProjectBuildFileParser
public boolean globResultsMatchCurrentState(Path buildFile, com.google.common.collect.ImmutableList<GlobSpecWithResult> existingGlobsWithResults) throws IOException, InterruptedException
ProjectBuildFileParser
GlobSpec
s with results are the same as current state in the file
system.globResultsMatchCurrentState
in interface ProjectBuildFileParser
buildFile
- 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.IOException
InterruptedException
public void loadExtensionsForUserDefinedRules(Path buildFile, BuildFileManifest manifest)
UserDefinedRuleLoader
loadExtensionsForUserDefinedRules
in interface UserDefinedRuleLoader
buildFile
- The full path to the build filemanifest
- The manifest from parsing a build fileprotected ParseResult parse(Path parseFile) throws IOException, BuildFileParseException, InterruptedException
parseFile
.IOException
BuildFileParseException
InterruptedException
protected 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.IOException
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) throws BuildFileParseException, IOException, InterruptedException
SkylarkImport
s.protected com.facebook.buck.skylark.parser.ExtensionData buildExtensionData(com.facebook.buck.skylark.parser.AbstractSkylarkFileParser.ExtensionLoadState load) throws InterruptedException
ExtensionLoadState
, evaluates extension and
returns ExtensionData
load
- ExtensionLoadState
representing loaded extensionInterruptedException
public com.google.common.collect.ImmutableSortedSet<String> getIncludedFiles(Path parseFile) throws BuildFileParseException, InterruptedException, IOException
FileParser
parseFile
build spec.getIncludedFiles
in interface FileParser<T extends FileManifest>
parseFile
- should be an absolute path to a file. Must have rootPath as its prefix.BuildFileParseException
InterruptedException
IOException
public void close() throws BuildFileParseException
close
in interface FileParser<T extends FileManifest>
close
in interface AutoCloseable
BuildFileParseException