Search in sources :

Example 1 with DefaultProjectBuildFileParserFactory

use of com.facebook.buck.json.DefaultProjectBuildFileParserFactory in project buck by facebook.

the class Cell method createBuildFileParserFactory.

private ProjectBuildFileParserFactory createBuildFileParserFactory() {
    ParserConfig parserConfig = getBuckConfig().getView(ParserConfig.class);
    boolean useWatchmanGlob = parserConfig.getGlobHandler() == ParserConfig.GlobHandler.WATCHMAN && watchman.hasWildmatchGlob();
    boolean watchmanGlobStatResults = parserConfig.getWatchmanGlobSanityCheck() == ParserConfig.WatchmanGlobSanityCheck.STAT;
    boolean watchmanUseGlobGenerator = watchman.getCapabilities().contains(Watchman.Capability.GLOB_GENERATOR);
    boolean useMercurialGlob = parserConfig.getGlobHandler() == ParserConfig.GlobHandler.MERCURIAL;
    String pythonInterpreter = parserConfig.getPythonInterpreter(new ExecutableFinder());
    Optional<String> pythonModuleSearchPath = parserConfig.getPythonModuleSearchPath();
    return new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(getFilesystem().getRootPath()).setCellRoots(getCellPathResolver().getCellPaths()).setPythonInterpreter(pythonInterpreter).setPythonModuleSearchPath(pythonModuleSearchPath).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(filesystem.getIgnorePaths()).setBuildFileName(getBuildFileName()).setAutodepsFilesHaveSignatures(config.getIncludeAutodepsSignature()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(getAllDescriptions()).setUseWatchmanGlob(useWatchmanGlob).setWatchmanGlobStatResults(watchmanGlobStatResults).setWatchmanUseGlobGenerator(watchmanUseGlobGenerator).setWatchman(watchman).setWatchmanQueryTimeoutMs(parserConfig.getWatchmanQueryTimeoutMs()).setUseMercurialGlob(useMercurialGlob).setRawConfig(getBuckConfig().getRawConfigForParser()).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
}
Also used : ExecutableFinder(com.facebook.buck.io.ExecutableFinder) DefaultProjectBuildFileParserFactory(com.facebook.buck.json.DefaultProjectBuildFileParserFactory) ParserConfig(com.facebook.buck.parser.ParserConfig)

Example 2 with DefaultProjectBuildFileParserFactory

use of com.facebook.buck.json.DefaultProjectBuildFileParserFactory in project buck by facebook.

the class JavaSymbolFinderIntegrationTest method shouldFindTargetDefiningSymbol.

@Test
public void shouldFindTargetDefiningSymbol() throws IOException, InterruptedException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "symbol_finder", temporaryFolder);
    workspace.setUp();
    ProjectFilesystem projectFilesystem = new ProjectFilesystem(temporaryFolder.getRoot());
    ImmutableMap<String, String> environment = ImmutableMap.copyOf(System.getenv());
    Config rawConfig = Configs.createDefaultConfig(projectFilesystem.getRootPath());
    BuckConfig config = new BuckConfig(rawConfig, projectFilesystem, Architecture.detect(), Platform.detect(), environment, new DefaultCellPathResolver(projectFilesystem.getRootPath(), rawConfig));
    ParserConfig parserConfig = config.getView(ParserConfig.class);
    PythonBuckConfig pythonBuckConfig = new PythonBuckConfig(config, new ExecutableFinder());
    ImmutableSet<Description<?>> allDescriptions = KnownBuildRuleTypesTestUtil.getDefaultKnownBuildRuleTypes(projectFilesystem, environment).getAllDescriptions();
    SrcRootsFinder srcRootsFinder = new SrcRootsFinder(projectFilesystem);
    ProjectBuildFileParserFactory projectBuildFileParserFactory = new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(projectFilesystem.getRootPath()).setPythonInterpreter(pythonBuckConfig.getPythonInterpreter()).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(projectFilesystem.getIgnorePaths()).setBuildFileName(parserConfig.getBuildFileName()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(allDescriptions).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
    BuckEventBus buckEventBus = BuckEventBusFactory.newInstance();
    JavaSymbolFinder finder = new JavaSymbolFinder(projectFilesystem, srcRootsFinder, DEFAULT_JAVAC_OPTIONS, new ConstructorArgMarshaller(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())), projectBuildFileParserFactory, config, buckEventBus, new TestConsole(), environment);
    SetMultimap<String, BuildTarget> foundTargets = finder.findTargetsForSymbols(ImmutableSet.of("com.example.a.A"));
    assertEquals("JavaSymbolFinder failed to find the right target.", ImmutableSetMultimap.of("com.example.a.A", BuildTargetFactory.newInstance(projectFilesystem, "//java/com/example/a:a")), foundTargets);
}
Also used : PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) BuckEventBus(com.facebook.buck.event.BuckEventBus) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) DefaultCellPathResolver(com.facebook.buck.rules.DefaultCellPathResolver) Description(com.facebook.buck.rules.Description) Config(com.facebook.buck.config.Config) BuckConfig(com.facebook.buck.cli.BuckConfig) ParserConfig(com.facebook.buck.parser.ParserConfig) PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) DefaultProjectBuildFileParserFactory(com.facebook.buck.json.DefaultProjectBuildFileParserFactory) DefaultTypeCoercerFactory(com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory) ProjectBuildFileParserFactory(com.facebook.buck.json.ProjectBuildFileParserFactory) DefaultProjectBuildFileParserFactory(com.facebook.buck.json.DefaultProjectBuildFileParserFactory) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ConstructorArgMarshaller(com.facebook.buck.rules.ConstructorArgMarshaller) BuckConfig(com.facebook.buck.cli.BuckConfig) PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) BuildTarget(com.facebook.buck.model.BuildTarget) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TestConsole(com.facebook.buck.testutil.TestConsole) ParserConfig(com.facebook.buck.parser.ParserConfig) Test(org.junit.Test)

Example 3 with DefaultProjectBuildFileParserFactory

use of com.facebook.buck.json.DefaultProjectBuildFileParserFactory in project buck by facebook.

the class ResolverIntegrationTest method createParser.

@BeforeClass
public static void createParser() {
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    BuckConfig buckConfig = FakeBuckConfig.builder().build();
    ParserConfig parserConfig = buckConfig.getView(ParserConfig.class);
    PythonBuckConfig pythonBuckConfig = new PythonBuckConfig(buckConfig, new ExecutableFinder());
    ImmutableSet<Description<?>> descriptions = ImmutableSet.of(new RemoteFileDescription(new ExplodingDownloader()), new PrebuiltJarDescription());
    DefaultProjectBuildFileParserFactory parserFactory = new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(filesystem.getRootPath()).setPythonInterpreter(pythonBuckConfig.getPythonInterpreter()).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(filesystem.getIgnorePaths()).setBuildFileName(parserConfig.getBuildFileName()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(descriptions).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
    buildFileParser = parserFactory.createParser(new ConstructorArgMarshaller(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())), new TestConsole(), ImmutableMap.of(), BuckEventBusFactory.newInstance(), /* ignoreBuckAutodepsFiles */
    false);
}
Also used : PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) PrebuiltJarDescription(com.facebook.buck.jvm.java.PrebuiltJarDescription) RemoteFileDescription(com.facebook.buck.file.RemoteFileDescription) Description(com.facebook.buck.rules.Description) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) RemoteFileDescription(com.facebook.buck.file.RemoteFileDescription) DefaultProjectBuildFileParserFactory(com.facebook.buck.json.DefaultProjectBuildFileParserFactory) DefaultTypeCoercerFactory(com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory) ExplodingDownloader(com.facebook.buck.file.ExplodingDownloader) ConstructorArgMarshaller(com.facebook.buck.rules.ConstructorArgMarshaller) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) PrebuiltJarDescription(com.facebook.buck.jvm.java.PrebuiltJarDescription) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TestConsole(com.facebook.buck.testutil.TestConsole) ParserConfig(com.facebook.buck.parser.ParserConfig) BeforeClass(org.junit.BeforeClass)

Example 4 with DefaultProjectBuildFileParserFactory

use of com.facebook.buck.json.DefaultProjectBuildFileParserFactory in project buck by facebook.

the class MissingSymbolsHandler method create.

public static MissingSymbolsHandler create(ProjectFilesystem projectFilesystem, ImmutableSet<Description<?>> descriptions, BuckConfig config, BuckEventBus buckEventBus, Console console, JavacOptions javacOptions, ImmutableMap<String, String> environment) {
    SrcRootsFinder srcRootsFinder = new SrcRootsFinder(projectFilesystem);
    ParserConfig parserConfig = config.getView(ParserConfig.class);
    PythonBuckConfig pythonBuckConfig = new PythonBuckConfig(config, new ExecutableFinder());
    ProjectBuildFileParserFactory projectBuildFileParserFactory = new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(projectFilesystem.getRootPath()).setPythonInterpreter(pythonBuckConfig.getPythonInterpreter()).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(projectFilesystem.getIgnorePaths()).setBuildFileName(parserConfig.getBuildFileName()).setAutodepsFilesHaveSignatures(config.getIncludeAutodepsSignature()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(descriptions).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
    JavaSymbolFinder javaSymbolFinder = new JavaSymbolFinder(projectFilesystem, srcRootsFinder, javacOptions, new ConstructorArgMarshaller(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())), projectBuildFileParserFactory, config, buckEventBus, console, environment);
    return new MissingSymbolsHandler(console, javaSymbolFinder, parserConfig.getBuildFileName());
}
Also used : PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) ProjectBuildFileParserFactory(com.facebook.buck.json.ProjectBuildFileParserFactory) DefaultProjectBuildFileParserFactory(com.facebook.buck.json.DefaultProjectBuildFileParserFactory) ConstructorArgMarshaller(com.facebook.buck.rules.ConstructorArgMarshaller) DefaultProjectBuildFileParserFactory(com.facebook.buck.json.DefaultProjectBuildFileParserFactory) JavaSymbolFinder(com.facebook.buck.jvm.java.JavaSymbolFinder) DefaultTypeCoercerFactory(com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory) ParserConfig(com.facebook.buck.parser.ParserConfig) SrcRootsFinder(com.facebook.buck.jvm.java.SrcRootsFinder)

Aggregations

ExecutableFinder (com.facebook.buck.io.ExecutableFinder)4 DefaultProjectBuildFileParserFactory (com.facebook.buck.json.DefaultProjectBuildFileParserFactory)4 ParserConfig (com.facebook.buck.parser.ParserConfig)4 PythonBuckConfig (com.facebook.buck.python.PythonBuckConfig)3 ConstructorArgMarshaller (com.facebook.buck.rules.ConstructorArgMarshaller)3 DefaultTypeCoercerFactory (com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory)3 BuckConfig (com.facebook.buck.cli.BuckConfig)2 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)2 ProjectBuildFileParserFactory (com.facebook.buck.json.ProjectBuildFileParserFactory)2 Description (com.facebook.buck.rules.Description)2 TestConsole (com.facebook.buck.testutil.TestConsole)2 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)1 Config (com.facebook.buck.config.Config)1 BuckEventBus (com.facebook.buck.event.BuckEventBus)1 ExplodingDownloader (com.facebook.buck.file.ExplodingDownloader)1 RemoteFileDescription (com.facebook.buck.file.RemoteFileDescription)1 JavaSymbolFinder (com.facebook.buck.jvm.java.JavaSymbolFinder)1 PrebuiltJarDescription (com.facebook.buck.jvm.java.PrebuiltJarDescription)1 SrcRootsFinder (com.facebook.buck.jvm.java.SrcRootsFinder)1 BuildTarget (com.facebook.buck.model.BuildTarget)1