Search in sources :

Example 11 with BuckConfig

use of com.facebook.buck.cli.BuckConfig in project buck by facebook.

the class DBuckConfigTest method testDLinkerFlagsOverridden.

@Test
public void testDLinkerFlagsOverridden() throws IOException {
    Path yooserBin = tmp.newFolder("yooser", "bin");
    Path yooserLib = tmp.newFolder("yooser", "lib");
    makeFakeExecutable(yooserBin, "dmd");
    Path phobos2So = yooserLib.resolve("libphobos2.so");
    Files.createFile(phobos2So);
    BuckConfig delegate = FakeBuckConfig.builder().setEnvironment(ImmutableMap.of("PATH", yooserBin.toRealPath().toString())).setSections("[d]", "linker_flags = -L/opt/doesnotexist/dmd/lib \"-L/path with spaces\"").build();
    DBuckConfig dBuckConfig = new DBuckConfig(delegate);
    ImmutableList<String> linkerFlags = dBuckConfig.getLinkerFlags();
    assertContains(linkerFlags, "-L/opt/doesnotexist/dmd/lib");
    assertContains(linkerFlags, "-L/path with spaces");
    assertDoesNotContain(linkerFlags, "-L" + yooserLib.toRealPath());
}
Also used : Path(java.nio.file.Path) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Test(org.junit.Test)

Example 12 with BuckConfig

use of com.facebook.buck.cli.BuckConfig in project buck by facebook.

the class DBuckConfigTest method testCompilerOverridden.

@Test
public void testCompilerOverridden() throws IOException {
    Path yooserBeen = tmp.newFolder("yooser", "been");
    makeFakeExecutable(yooserBeen, "dmd");
    Path ldc = makeFakeExecutable(yooserBeen, "ldc");
    BuckConfig delegate = FakeBuckConfig.builder().setEnvironment(ImmutableMap.of("PATH", yooserBeen.toRealPath().toString())).setSections("[d]", "compiler=" + ldc.toRealPath()).build();
    DBuckConfig dBuckConfig = new DBuckConfig(delegate);
    assertEquals(ldc.toRealPath().toString(), toolPath(dBuckConfig.getDCompiler()));
}
Also used : Path(java.nio.file.Path) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Test(org.junit.Test)

Example 13 with BuckConfig

use of com.facebook.buck.cli.BuckConfig in project buck by facebook.

the class DBuckConfigTest method testDRuntimeNearCompiler.

@Test
public void testDRuntimeNearCompiler() throws IOException {
    Path yooserBin = tmp.newFolder("yooser", "bin");
    Path yooserLib = tmp.newFolder("yooser", "lib");
    makeFakeExecutable(yooserBin, "dmd");
    Path phobos2So = yooserLib.resolve("libphobos2.so");
    Files.createFile(phobos2So);
    BuckConfig delegate = FakeBuckConfig.builder().setEnvironment(ImmutableMap.of("PATH", yooserBin.toRealPath().toString())).build();
    DBuckConfig dBuckConfig = new DBuckConfig(delegate);
    ImmutableList<String> linkerFlags = dBuckConfig.getLinkerFlags();
    assertContains(linkerFlags, "-L" + yooserLib.toRealPath());
}
Also used : Path(java.nio.file.Path) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Test(org.junit.Test)

Example 14 with BuckConfig

use of com.facebook.buck.cli.BuckConfig in project buck by facebook.

the class DistBuildStateTest method throwsOnPlatformMismatch.

@Test
public void throwsOnPlatformMismatch() throws IOException, InterruptedException {
    ProjectFilesystem filesystem = createJavaOnlyFilesystem("/opt/buck");
    Config config = new Config(ConfigBuilder.rawFromLines());
    BuckConfig buckConfig = new BuckConfig(config, filesystem, Architecture.MIPSEL, Platform.UNKNOWN, ImmutableMap.<String, String>builder().putAll(System.getenv()).put("envKey", "envValue").build(), new DefaultCellPathResolver(filesystem.getRootPath(), config));
    Cell cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(buckConfig).build();
    BuildJobState dump = DistBuildState.dump(new DistBuildCellIndexer(cell), emptyActionGraph(), createDefaultCodec(cell, Optional.empty()), createTargetGraph(filesystem), ImmutableSet.of(BuildTargetFactory.newInstance(filesystem.getRootPath(), "//:dummy")));
    expectedException.expect(IllegalStateException.class);
    DistBuildState.load(Optional.empty(), dump, cell, knownBuildRuleTypesFactory);
}
Also used : DefaultCellPathResolver(com.facebook.buck.rules.DefaultCellPathResolver) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Config(com.facebook.buck.config.Config) ParserConfig(com.facebook.buck.parser.ParserConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuildJobState(com.facebook.buck.distributed.thrift.BuildJobState) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Cell(com.facebook.buck.rules.Cell) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) Test(org.junit.Test)

Example 15 with BuckConfig

use of com.facebook.buck.cli.BuckConfig in project buck by facebook.

the class DistBuildStateTest method worksCrossCell.

@Test
public void worksCrossCell() throws IOException, InterruptedException {
    ProjectFilesystem parentFs = createJavaOnlyFilesystem("/saving");
    Path cell1Root = parentFs.resolve("cell1");
    Path cell2Root = parentFs.resolve("cell2");
    parentFs.mkdirs(cell1Root);
    parentFs.mkdirs(cell2Root);
    ProjectFilesystem cell1Filesystem = new ProjectFilesystem(cell1Root);
    ProjectFilesystem cell2Filesystem = new ProjectFilesystem(cell2Root);
    Config config = new Config(ConfigBuilder.rawFromLines("[cache]", "repository=somerepo", "[repositories]", "cell2 = " + cell2Root.toString()));
    BuckConfig buckConfig = new BuckConfig(config, cell1Filesystem, Architecture.detect(), Platform.detect(), ImmutableMap.<String, String>builder().putAll(System.getenv()).put("envKey", "envValue").build(), new DefaultCellPathResolver(cell1Root, config));
    Cell rootCellWhenSaving = new TestCellBuilder().setFilesystem(cell1Filesystem).setBuckConfig(buckConfig).build();
    BuildJobState dump = DistBuildState.dump(new DistBuildCellIndexer(rootCellWhenSaving), emptyActionGraph(), createDefaultCodec(rootCellWhenSaving, Optional.empty()), createCrossCellTargetGraph(cell1Filesystem, cell2Filesystem), ImmutableSet.of(BuildTargetFactory.newInstance(cell1Filesystem.getRootPath(), "//:dummy")));
    Cell rootCellWhenLoading = new TestCellBuilder().setFilesystem(createJavaOnlyFilesystem("/loading")).build();
    Config localConfig = new Config(ConfigBuilder.rawFromLines("[cache]", "slb_server_pool=http://someserver:8080"));
    BuckConfig localBuckConfig = new BuckConfig(localConfig, cell1Filesystem, Architecture.detect(), Platform.detect(), ImmutableMap.<String, String>builder().putAll(System.getenv()).put("envKey", "envValue").build(), new DefaultCellPathResolver(cell1Root, localConfig));
    DistBuildState distributedBuildState = DistBuildState.load(Optional.of(localBuckConfig), dump, rootCellWhenLoading, knownBuildRuleTypesFactory);
    ImmutableMap<Integer, Cell> cells = distributedBuildState.getCells();
    assertThat(cells, Matchers.aMapWithSize(2));
    BuckConfig rootCellBuckConfig = cells.get(0).getBuckConfig();
    Optional<ImmutableMap<String, String>> cacheSection = rootCellBuckConfig.getSection("cache");
    assertTrue(cacheSection.isPresent());
    assertTrue(cacheSection.get().containsKey("repository"));
    assertThat(cacheSection.get().get("repository"), Matchers.equalTo("somerepo"));
    assertThat(cacheSection.get().get("slb_server_pool"), Matchers.equalTo("http://someserver:8080"));
}
Also used : Path(java.nio.file.Path) PathSourcePath(com.facebook.buck.rules.PathSourcePath) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) DefaultCellPathResolver(com.facebook.buck.rules.DefaultCellPathResolver) BuckConfig(com.facebook.buck.cli.BuckConfig) Config(com.facebook.buck.config.Config) ParserConfig(com.facebook.buck.parser.ParserConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuildJobState(com.facebook.buck.distributed.thrift.BuildJobState) ImmutableMap(com.google.common.collect.ImmutableMap) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Cell(com.facebook.buck.rules.Cell) Test(org.junit.Test)

Aggregations

BuckConfig (com.facebook.buck.cli.BuckConfig)98 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)89 Test (org.junit.Test)74 Path (java.nio.file.Path)46 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)37 TestCellBuilder (com.facebook.buck.rules.TestCellBuilder)29 PathSourcePath (com.facebook.buck.rules.PathSourcePath)27 Cell (com.facebook.buck.rules.Cell)22 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)17 ImmutableMap (com.google.common.collect.ImmutableMap)17 Config (com.facebook.buck.config.Config)15 DefaultCellPathResolver (com.facebook.buck.rules.DefaultCellPathResolver)14 BuildTarget (com.facebook.buck.model.BuildTarget)12 FakeAndroidDirectoryResolver (com.facebook.buck.android.FakeAndroidDirectoryResolver)9 ParserConfig (com.facebook.buck.parser.ParserConfig)8 ConstructorArgMarshaller (com.facebook.buck.rules.ConstructorArgMarshaller)7 DefaultTypeCoercerFactory (com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory)7 TestConsole (com.facebook.buck.testutil.TestConsole)7 Optional (java.util.Optional)7 BuildJobState (com.facebook.buck.distributed.thrift.BuildJobState)6