use of com.facebook.buck.rules.CellProvider 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);
}
Aggregations