use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class DistBuildState method load.
public static DistBuildState load(// e.g. the slave's .buckconfig
Optional<BuckConfig> localBuckConfig, BuildJobState jobState, Cell rootCell, KnownBuildRuleTypesFactory knownBuildRuleTypesFactory) throws IOException {
ProjectFilesystem rootCellFilesystem = rootCell.getFilesystem();
ImmutableMap.Builder<Path, BuckConfig> cellConfigs = ImmutableMap.builder();
ImmutableMap.Builder<Path, ProjectFilesystem> cellFilesystems = ImmutableMap.builder();
ImmutableMap.Builder<Integer, Path> cellIndex = ImmutableMap.builder();
Path sandboxPath = rootCellFilesystem.getRootPath().resolve(rootCellFilesystem.getBuckPaths().getRemoteSandboxDir());
rootCellFilesystem.mkdirs(sandboxPath);
Path uniqueBuildRoot = Files.createTempDirectory(sandboxPath, "build");
for (Map.Entry<Integer, BuildJobStateCell> remoteCellEntry : jobState.getCells().entrySet()) {
BuildJobStateCell remoteCell = remoteCellEntry.getValue();
Path cellRoot = uniqueBuildRoot.resolve(remoteCell.getNameHint());
Files.createDirectories(cellRoot);
Config config = createConfig(remoteCell.getConfig(), localBuckConfig);
ProjectFilesystem projectFilesystem = new ProjectFilesystem(cellRoot, config);
BuckConfig buckConfig = createBuckConfig(config, projectFilesystem, remoteCell.getConfig());
cellConfigs.put(cellRoot, buckConfig);
cellFilesystems.put(cellRoot, projectFilesystem);
cellIndex.put(remoteCellEntry.getKey(), cellRoot);
}
CellProvider cellProvider = CellProvider.createForDistributedBuild(cellConfigs.build(), cellFilesystems.build(), knownBuildRuleTypesFactory);
ImmutableBiMap<Integer, Cell> cells = ImmutableBiMap.copyOf(Maps.transformValues(cellIndex.build(), cellProvider::getCellByPath));
return new DistBuildState(jobState, cells);
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class CxxPlatformUtils method getDefaultPlatform.
public static CxxPlatform getDefaultPlatform(Path root) throws IOException {
Config rawConfig = Configs.createDefaultConfig(root);
BuckConfig buckConfig = new BuckConfig(rawConfig, new ProjectFilesystem(root), Architecture.detect(), Platform.detect(), ImmutableMap.of(), new DefaultCellPathResolver(root, rawConfig));
return DefaultCxxPlatforms.build(Platform.detect(), new ProjectFilesystem(root), new CxxBuckConfig(buckConfig));
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class CxxPlatformsTest method unknownDefaultPlatformSetInConfigFallsBackToSystemDefault.
@Test
public void unknownDefaultPlatformSetInConfigFallsBackToSystemDefault() {
ImmutableMap<String, ImmutableMap<String, String>> sections = ImmutableMap.of("cxx", ImmutableMap.of("default_platform", "borland_cxx_452"));
BuckConfig buckConfig = FakeBuckConfig.builder().setSections(sections).build();
assertThat(CxxPlatforms.getConfigDefaultCxxPlatform(new CxxBuckConfig(buckConfig), ImmutableMap.of(), CxxPlatformUtils.DEFAULT_PLATFORM), equalTo(CxxPlatformUtils.DEFAULT_PLATFORM));
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class RageConfigTest method testEmpty.
@Test
public void testEmpty() {
BuckConfig buckConfig = FakeBuckConfig.builder().build();
RageConfig config = RageConfig.of(buckConfig);
assertThat(config.getReportUploadPath(), Matchers.equalTo(RageConfig.UPLOAD_PATH));
assertThat(config.getFrontendConfig().get().tryCreatingClientSideSlb(clock, eventBus, threadFactory), Matchers.equalTo(Optional.empty()));
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class CellTest method shouldApplyCellConfigOverrides.
@Test
public void shouldApplyCellConfigOverrides() throws IOException, InterruptedException {
FileSystem vfs = Jimfs.newFileSystem(Configuration.unix());
Path root = vfs.getPath("/opt/local/");
Path cell1Root = root.resolve("repo1");
Files.createDirectories(cell1Root);
Path cell2Root = root.resolve("repo2");
Files.createDirectories(cell2Root);
Path cell3Root = root.resolve("repo3");
Files.createDirectories(cell3Root);
ProjectFilesystem filesystem1 = new ProjectFilesystem(cell1Root.toAbsolutePath());
ProjectFilesystem filesystem2 = new ProjectFilesystem(cell2Root.toAbsolutePath());
ProjectFilesystem filesystem3 = new ProjectFilesystem(cell3Root.toAbsolutePath());
BuckConfig config = FakeBuckConfig.builder().setFilesystem(filesystem1).setSections("[repositories]", "second = " + cell2Root.toString(), "third = " + cell3Root.toString()).build();
Files.write(cell2Root.resolve(".buckconfig"), ImmutableList.of("[repositories]", "third = " + cell3Root.toString()), StandardCharsets.UTF_8);
Cell cell1 = new TestCellBuilder().setBuckConfig(config).setFilesystem(filesystem1).setCellConfigOverride(CellConfig.builder().put(RelativeCellName.fromComponents("second"), "test", "value", "cell2").put(CellConfig.ALL_CELLS_OVERRIDE, "test", "common_value", "all").build()).build();
BuildTarget target = BuildTargetFactory.newInstance(filesystem2, "//does/not:matter");
Cell cell2 = cell1.getCell(target);
assertThat(cell2.getBuckConfig().getValue("test", "value"), Matchers.equalTo(Optional.of("cell2")));
BuildTarget target3 = BuildTargetFactory.newInstance(filesystem3, "//does/not:matter");
Cell cell3 = cell1.getCell(target3);
assertThat(cell3.getBuckConfig().getValue("test", "common_value"), Matchers.equalTo(Optional.of("all")));
}
Aggregations