Search in sources :

Example 6 with BuckConfig

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

the class AppleConfigTest method getSpecifiedAppleDeveloperDirectorySupplier.

@Test
public void getSpecifiedAppleDeveloperDirectorySupplier() {
    BuckConfig buckConfig = FakeBuckConfig.builder().setSections(ImmutableMap.of("apple", ImmutableMap.of("xcode_developer_dir", "/path/to/somewhere"))).build();
    AppleConfig config = new AppleConfig(buckConfig);
    Supplier<Optional<Path>> supplier = config.getAppleDeveloperDirectorySupplier(new FakeProcessExecutor());
    assertNotNull(supplier);
    assertEquals(Optional.of(Paths.get("/path/to/somewhere")), supplier.get());
    // Developer directory for tests should fall back to developer dir if not separately specified.
    Supplier<Optional<Path>> supplierForTests = config.getAppleDeveloperDirectorySupplierForTests(new FakeProcessExecutor());
    assertNotNull(supplierForTests);
    assertEquals(Optional.of(Paths.get("/path/to/somewhere")), supplierForTests.get());
}
Also used : FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Optional(java.util.Optional) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) Test(org.junit.Test)

Example 7 with BuckConfig

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

the class ProjectGeneratorTest method setUp.

@Before
public void setUp() throws InterruptedException, IOException {
    assumeTrue(Platform.detect() == Platform.MACOS || Platform.detect() == Platform.LINUX);
    clock = new SettableFakeClock(0, 0);
    fakeProjectFilesystem = new FakeProjectFilesystem(clock);
    projectCell = (new TestCellBuilder()).setFilesystem(fakeProjectFilesystem).build();
    projectFilesystem = projectCell.getFilesystem();
    rootPath = projectFilesystem.getRootPath();
    // Add files and directories used to test resources.
    projectFilesystem.createParentDirs(Paths.get("foodir", "foo.png"));
    projectFilesystem.writeContentsToPath("", Paths.get("foodir", "foo.png"));
    projectFilesystem.writeContentsToPath("", Paths.get("bar.png"));
    fakeProjectFilesystem.touch(Paths.get("Base.lproj", "Bar.storyboard"));
    halideBuckConfig = HalideLibraryBuilder.createDefaultHalideConfig(fakeProjectFilesystem);
    ImmutableMap<String, ImmutableMap<String, String>> sections = ImmutableMap.of("cxx", ImmutableMap.of("cflags", "-Wno-deprecated -Wno-conversion", "cxxflags", "-Wundeclared-selector -Wno-objc-designated-initializers"), "apple", ImmutableMap.of("force_dsym_mode_in_build_with_buck", "false"), "swift", ImmutableMap.of("version", "1.23"));
    BuckConfig config = FakeBuckConfig.builder().setSections(sections).build();
    cxxBuckConfig = new CxxBuckConfig(config);
    appleConfig = new AppleConfig(config);
    swiftBuckConfig = new SwiftBuckConfig(config);
}
Also used : AppleConfig(com.facebook.buck.apple.AppleConfig) ReactNativeBuckConfig(com.facebook.buck.js.ReactNativeBuckConfig) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) SwiftBuckConfig(com.facebook.buck.swift.SwiftBuckConfig) HalideBuckConfig(com.facebook.buck.halide.HalideBuckConfig) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) SettableFakeClock(com.facebook.buck.timing.SettableFakeClock) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSString(com.dd.plist.NSString) SwiftBuckConfig(com.facebook.buck.swift.SwiftBuckConfig) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) ImmutableMap(com.google.common.collect.ImmutableMap) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) Before(org.junit.Before)

Example 8 with BuckConfig

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

the class CxxPlatformsTest method returnsKnownDefaultPlatformSetInConfig.

@Test
public void returnsKnownDefaultPlatformSetInConfig() {
    ImmutableMap<String, ImmutableMap<String, String>> sections = ImmutableMap.of("cxx", ImmutableMap.of("default_platform", "borland_cxx_452"));
    CompilerProvider compiler = new CompilerProvider(Paths.get("borland"), Optional.of(CxxToolProvider.Type.GCC));
    PreprocessorProvider preprocessor = new PreprocessorProvider(Paths.get("borland"), Optional.of(CxxToolProvider.Type.GCC));
    CxxPlatform borlandCxx452Platform = CxxPlatform.builder().setFlavor(InternalFlavor.of("borland_cxx_452")).setAs(compiler).setAspp(preprocessor).setCc(compiler).setCpp(preprocessor).setCxx(compiler).setCxxpp(preprocessor).setLd(new DefaultLinkerProvider(LinkerProvider.Type.GNU, new ConstantToolProvider(new HashedFileTool(Paths.get("borland"))))).setStrip(new HashedFileTool(Paths.get("borland"))).setSymbolNameTool(new PosixNmSymbolNameTool(new HashedFileTool(Paths.get("borland")))).setAr(new GnuArchiver(new HashedFileTool(Paths.get("borland")))).setRanlib(new HashedFileTool(Paths.get("borland"))).setSharedLibraryExtension("so").setSharedLibraryVersionedExtensionFormat(".so.%s").setStaticLibraryExtension("a").setObjectFileExtension("so").setCompilerDebugPathSanitizer(CxxPlatformUtils.DEFAULT_COMPILER_DEBUG_PATH_SANITIZER).setAssemblerDebugPathSanitizer(CxxPlatformUtils.DEFAULT_ASSEMBLER_DEBUG_PATH_SANITIZER).setHeaderVerification(CxxPlatformUtils.DEFAULT_PLATFORM.getHeaderVerification()).build();
    BuckConfig buckConfig = FakeBuckConfig.builder().setSections(sections).build();
    assertThat(CxxPlatforms.getConfigDefaultCxxPlatform(new CxxBuckConfig(buckConfig), ImmutableMap.of(borlandCxx452Platform.getFlavor(), borlandCxx452Platform), CxxPlatformUtils.DEFAULT_PLATFORM), equalTo(borlandCxx452Platform));
}
Also used : ConstantToolProvider(com.facebook.buck.rules.ConstantToolProvider) ImmutableMap(com.google.common.collect.ImmutableMap) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) HashedFileTool(com.facebook.buck.rules.HashedFileTool) Test(org.junit.Test)

Example 9 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 10 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)

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