use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class GroovyBuckConfigTest method createGroovyConfig.
private GroovyBuckConfig createGroovyConfig(ImmutableMap<String, String> environment, ImmutableMap<String, ImmutableMap<String, String>> rawConfig) {
ProjectFilesystem projectFilesystem = new ProjectFilesystem(temporaryFolder.getRoot());
Config config = new Config(RawConfig.of(rawConfig));
BuckConfig buckConfig = new BuckConfig(config, projectFilesystem, Architecture.detect(), Platform.detect(), environment, new DefaultCellPathResolver(projectFilesystem.getRootPath(), config));
return new GroovyBuckConfig(buckConfig);
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class LuaBinaryIntegrationTest method getLuaBuckConfig.
private LuaBuckConfig getLuaBuckConfig() throws IOException {
Config rawConfig = Configs.createDefaultConfig(tmp.getRoot());
BuckConfig buckConfig = new BuckConfig(rawConfig, new ProjectFilesystem(tmp.getRoot()), Architecture.detect(), Platform.detect(), ImmutableMap.of(), new DefaultCellPathResolver(tmp.getRoot(), rawConfig));
return new LuaBuckConfig(buckConfig, new FakeExecutableFinder(ImmutableList.of()));
}
use of com.facebook.buck.cli.BuckConfig 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);
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DistBuildStateTest method canReconstructConfig.
@Test
public void canReconstructConfig() throws IOException, InterruptedException {
ProjectFilesystem filesystem = createJavaOnlyFilesystem("/saving");
Config config = new Config(ConfigBuilder.rawFromLines());
BuckConfig buckConfig = new BuckConfig(config, filesystem, Architecture.detect(), Platform.detect(), ImmutableMap.<String, String>builder().putAll(System.getenv()).put("envKey", "envValue").build(), new DefaultCellPathResolver(filesystem.getRootPath(), config));
Cell rootCellWhenSaving = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(buckConfig).build();
BuildJobState dump = DistBuildState.dump(new DistBuildCellIndexer(rootCellWhenSaving), emptyActionGraph(), createDefaultCodec(rootCellWhenSaving, Optional.empty()), createTargetGraph(filesystem), ImmutableSet.of(BuildTargetFactory.newInstance(filesystem.getRootPath(), "//:dummy")));
Cell rootCellWhenLoading = new TestCellBuilder().setFilesystem(createJavaOnlyFilesystem("/loading")).build();
DistBuildState distributedBuildState = DistBuildState.load(Optional.empty(), dump, rootCellWhenLoading, knownBuildRuleTypesFactory);
ImmutableMap<Integer, Cell> cells = distributedBuildState.getCells();
assertThat(cells, Matchers.aMapWithSize(1));
assertThat(cells.get(0).getBuckConfig(), Matchers.equalTo(buckConfig));
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DistBuildStateTest method canReconstructGraphAndTopLevelBuildTargets.
@Test
public void canReconstructGraphAndTopLevelBuildTargets() throws Exception {
ProjectWorkspace projectWorkspace = TestDataHelper.createProjectWorkspaceForScenario(this, "simple_java_target", temporaryFolder);
projectWorkspace.setUp();
Cell cell = projectWorkspace.asCell();
ProjectFilesystem projectFilesystem = cell.getFilesystem();
projectFilesystem.mkdirs(projectFilesystem.getBuckPaths().getBuckOut());
BuckConfig buckConfig = cell.getBuckConfig();
TypeCoercerFactory typeCoercerFactory = new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance());
ConstructorArgMarshaller constructorArgMarshaller = new ConstructorArgMarshaller(typeCoercerFactory);
Parser parser = new Parser(new BroadcastEventListener(), buckConfig.getView(ParserConfig.class), typeCoercerFactory, constructorArgMarshaller);
TargetGraph targetGraph = parser.buildTargetGraph(BuckEventBusFactory.newInstance(), cell, /* enableProfiling */
false, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()), ImmutableSet.of(BuildTargetFactory.newInstance(projectFilesystem.getRootPath(), "//:lib1"), BuildTargetFactory.newInstance(projectFilesystem.getRootPath(), "//:lib2"), BuildTargetFactory.newInstance(projectFilesystem.getRootPath(), "//:lib3")));
DistBuildTargetGraphCodec targetGraphCodec = createDefaultCodec(cell, Optional.of(parser));
BuildJobState dump = DistBuildState.dump(new DistBuildCellIndexer(cell), emptyActionGraph(), targetGraphCodec, targetGraph, ImmutableSet.of(BuildTargetFactory.newInstance(projectFilesystem.getRootPath(), "//:lib1"), BuildTargetFactory.newInstance(projectFilesystem.getRootPath(), "//:lib2")));
Cell rootCellWhenLoading = new TestCellBuilder().setFilesystem(createJavaOnlyFilesystem("/loading")).build();
DistBuildState distributedBuildState = DistBuildState.load(Optional.empty(), dump, rootCellWhenLoading, knownBuildRuleTypesFactory);
ProjectFilesystem reconstructedCellFilesystem = distributedBuildState.getCells().get(0).getFilesystem();
TargetGraph reconstructedGraph = distributedBuildState.createTargetGraph(targetGraphCodec).getTargetGraph();
assertEquals(reconstructedGraph.getNodes().stream().map(targetNode -> targetNode.castArg(JavaLibraryDescription.Arg.class).get()).sorted().map(targetNode -> targetNode.getConstructorArg().srcs).collect(Collectors.toList()), Lists.newArrayList("A.java", "B.java", "C.java").stream().map(f -> reconstructedCellFilesystem.getPath(f)).map(p -> new PathSourcePath(reconstructedCellFilesystem, p)).map(ImmutableSortedSet::of).collect(Collectors.toList()));
}
Aggregations