Search in sources :

Example 1 with BuildJobStateCell

use of com.facebook.buck.distributed.thrift.BuildJobStateCell in project buck by facebook.

the class DistBuildCellIndexer method dumpCell.

private static BuildJobStateCell dumpCell(Cell cell) {
    BuildJobStateCell cellState = new BuildJobStateCell();
    cellState.setConfig(dumpConfig(cell.getBuckConfig()));
    cellState.setNameHint(cell.getRoot().getFileName().toString());
    return cellState;
}
Also used : BuildJobStateCell(com.facebook.buck.distributed.thrift.BuildJobStateCell)

Example 2 with BuildJobStateCell

use of com.facebook.buck.distributed.thrift.BuildJobStateCell 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);
}
Also used : Path(java.nio.file.Path) CellProvider(com.facebook.buck.rules.CellProvider) Config(com.facebook.buck.config.Config) BuckConfig(com.facebook.buck.cli.BuckConfig) RawConfig(com.facebook.buck.config.RawConfig) BuildJobStateBuckConfig(com.facebook.buck.distributed.thrift.BuildJobStateBuckConfig) ImmutableMap(com.google.common.collect.ImmutableMap) BuildJobStateCell(com.facebook.buck.distributed.thrift.BuildJobStateCell) BuckConfig(com.facebook.buck.cli.BuckConfig) BuildJobStateBuckConfig(com.facebook.buck.distributed.thrift.BuildJobStateBuckConfig) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) ImmutableBiMap(com.google.common.collect.ImmutableBiMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Cell(com.facebook.buck.rules.Cell) BuildJobStateCell(com.facebook.buck.distributed.thrift.BuildJobStateCell)

Aggregations

BuildJobStateCell (com.facebook.buck.distributed.thrift.BuildJobStateCell)2 BuckConfig (com.facebook.buck.cli.BuckConfig)1 Config (com.facebook.buck.config.Config)1 RawConfig (com.facebook.buck.config.RawConfig)1 BuildJobStateBuckConfig (com.facebook.buck.distributed.thrift.BuildJobStateBuckConfig)1 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)1 Cell (com.facebook.buck.rules.Cell)1 CellProvider (com.facebook.buck.rules.CellProvider)1 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Path (java.nio.file.Path)1 Map (java.util.Map)1