Search in sources :

Example 56 with BuckConfig

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

the class JavaBuckConfigTest method whenJavacIsSetInBuckConfigConfiguredRulesCreateJavaLibraryRuleWithJavacSet.

@Test
public void whenJavacIsSetInBuckConfigConfiguredRulesCreateJavaLibraryRuleWithJavacSet() throws IOException, NoSuchBuildTargetException, InterruptedException {
    final String javac = temporaryFolder.newExecutableFile().toString();
    ImmutableMap<String, ImmutableMap<String, String>> sections = ImmutableMap.of("tools", ImmutableMap.of("javac", javac));
    BuckConfig buckConfig = FakeBuckConfig.builder().setFilesystem(defaultFilesystem).setSections(sections).build();
    JavaBuckConfig javaConfig = buckConfig.getView(JavaBuckConfig.class);
    JavacOptions javacOptions = javaConfig.getDefaultJavacOptions();
    assertEquals(javac, ((ExternalJavac) javacOptions.getJavac()).getShortName());
}
Also used : BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 57 with BuckConfig

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

the class KnownBuildRuleTypesTest method canOverrideMultipleHostPlatforms.

@Test
public void canOverrideMultipleHostPlatforms() throws Exception {
    ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
    ImmutableMap<String, ImmutableMap<String, String>> sections = ImmutableMap.of("cxx#linux-x86_64", ImmutableMap.of("cache_links", "true"), "cxx#macosx-x86_64", ImmutableMap.of("cache_links", "true"), "cxx#windows-x86_64", ImmutableMap.of("cache_links", "true"));
    BuckConfig buckConfig = FakeBuckConfig.builder().setSections(sections).build();
    // It should be legal to override multiple host platforms even though
    // only one will be practically used in a build.
    KnownBuildRuleTypes.createBuilder(buckConfig, filesystem, createExecutor(), new FakeAndroidDirectoryResolver()).build();
}
Also used : FakeAndroidDirectoryResolver(com.facebook.buck.android.FakeAndroidDirectoryResolver) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 58 with BuckConfig

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

the class ProjectWorkspace method asCell.

public Cell asCell() throws IOException, InterruptedException {
    ProjectFilesystemAndConfig filesystemAndConfig = projectFilesystemAndConfig.get();
    ProjectFilesystem filesystem = filesystemAndConfig.projectFilesystem;
    Config config = filesystemAndConfig.config;
    TestConsole console = new TestConsole();
    ImmutableMap<String, String> env = ImmutableMap.copyOf(System.getenv());
    DefaultAndroidDirectoryResolver directoryResolver = new DefaultAndroidDirectoryResolver(filesystem.getRootPath().getFileSystem(), env, Optional.empty(), Optional.empty());
    return CellProvider.createForLocalBuild(filesystem, Watchman.NULL_WATCHMAN, new BuckConfig(config, filesystem, Architecture.detect(), Platform.detect(), env, new DefaultCellPathResolver(filesystem.getRootPath(), config)), CellConfig.of(), new KnownBuildRuleTypesFactory(new DefaultProcessExecutor(console), directoryResolver)).getCellByPath(filesystem.getRootPath());
}
Also used : DefaultCellPathResolver(com.facebook.buck.rules.DefaultCellPathResolver) DefaultAndroidDirectoryResolver(com.facebook.buck.android.DefaultAndroidDirectoryResolver) BuckConfig(com.facebook.buck.cli.BuckConfig) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) BuckConfig(com.facebook.buck.cli.BuckConfig) Config(com.facebook.buck.config.Config) CellConfig(com.facebook.buck.config.CellConfig) KnownBuildRuleTypesFactory(com.facebook.buck.rules.KnownBuildRuleTypesFactory) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TestConsole(com.facebook.buck.testutil.TestConsole)

Example 59 with BuckConfig

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

the class Build method createConfiguredBuckOutSymlinks.

/**
   * When the user overrides the configured buck-out directory via the `.buckconfig` and also sets
   * the `project.buck_out_compat_link` setting to `true`, we symlink the original output path
   * (`buck-out/`) to this newly configured location for backwards compatibility.
   */
private void createConfiguredBuckOutSymlinks() throws IOException {
    for (Cell cell : getAllCells()) {
        BuckConfig buckConfig = cell.getBuckConfig();
        ProjectFilesystem filesystem = cell.getFilesystem();
        BuckPaths configuredPaths = filesystem.getBuckPaths();
        if (!configuredPaths.getConfiguredBuckOut().equals(configuredPaths.getBuckOut()) && buckConfig.getBuckOutCompatLink() && Platform.detect() != Platform.WINDOWS) {
            BuckPaths unconfiguredPaths = configuredPaths.withConfiguredBuckOut(configuredPaths.getBuckOut());
            ImmutableMap<Path, Path> paths = ImmutableMap.of(unconfiguredPaths.getGenDir(), configuredPaths.getGenDir(), unconfiguredPaths.getScratchDir(), configuredPaths.getScratchDir());
            for (Map.Entry<Path, Path> entry : paths.entrySet()) {
                filesystem.deleteRecursivelyIfExists(entry.getKey());
                filesystem.createSymLink(entry.getKey(), entry.getKey().getParent().relativize(entry.getValue()), /* force */
                false);
            }
        }
    }
}
Also used : Path(java.nio.file.Path) BuckPaths(com.facebook.buck.io.BuckPaths) BuckConfig(com.facebook.buck.cli.BuckConfig) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Cell(com.facebook.buck.rules.Cell) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) LinkedHashMap(java.util.LinkedHashMap)

Example 60 with BuckConfig

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

the class AppleNativeIntegrationTestUtils method isSwiftAvailable.

public static boolean isSwiftAvailable(ApplePlatform platform) {
    BuckConfig buckConfig = FakeBuckConfig.builder().build();
    ImmutableMap<AppleSdk, AppleSdkPaths> sdkPaths = discoverSystemSdkPaths(buckConfig);
    Optional<AppleSdk> anySdkOptional = anySdkForPlatform(platform, sdkPaths);
    if (!anySdkOptional.isPresent()) {
        return false;
    }
    AppleSdk anySdk = anySdkOptional.get();
    AppleCxxPlatform appleCxxPlatform = AppleCxxPlatforms.build(new FakeProjectFilesystem(), anySdk, "fakeversion", "fakearch", sdkPaths.get(anySdk), buckConfig, new AppleConfig(buckConfig), Optional.of(new DefaultProcessExecutor(Console.createNullConsole())), Optional.empty());
    return appleCxxPlatform.getSwiftPlatform().isPresent();
}
Also used : BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem)

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