Search in sources :

Example 1 with AndroidBuckConfig

use of com.facebook.buck.android.AndroidBuckConfig in project buck by facebook.

the class KnownBuildRuleTypes method createBuilder.

@VisibleForTesting
static Builder createBuilder(BuckConfig config, ProjectFilesystem filesystem, ProcessExecutor processExecutor, AndroidDirectoryResolver androidDirectoryResolver) throws InterruptedException, IOException {
    Platform platform = Platform.detect();
    AndroidBuckConfig androidConfig = new AndroidBuckConfig(config, platform);
    Optional<String> ndkVersion = androidConfig.getNdkVersion();
    // out which one we will end up using.
    if (!ndkVersion.isPresent()) {
        ndkVersion = androidDirectoryResolver.getNdkVersion();
    }
    AppleConfig appleConfig = new AppleConfig(config);
    SwiftBuckConfig swiftBuckConfig = new SwiftBuckConfig(config);
    final ImmutableList<AppleCxxPlatform> appleCxxPlatforms = buildAppleCxxPlatforms(filesystem, appleConfig.getAppleDeveloperDirectorySupplier(processExecutor), appleConfig.getExtraToolchainPaths(), appleConfig.getExtraPlatformPaths(), config, appleConfig, swiftBuckConfig, processExecutor);
    final FlavorDomain<AppleCxxPlatform> platformFlavorsToAppleCxxPlatforms = FlavorDomain.from("Apple C++ Platform", appleCxxPlatforms);
    ImmutableMap.Builder<Flavor, SwiftPlatform> swiftPlatforms = ImmutableMap.builder();
    for (Flavor flavor : platformFlavorsToAppleCxxPlatforms.getFlavors()) {
        Optional<SwiftPlatform> swiftPlatformOptional = platformFlavorsToAppleCxxPlatforms.getValue(flavor).getSwiftPlatform();
        if (swiftPlatformOptional.isPresent()) {
            swiftPlatforms.put(flavor, swiftPlatformOptional.get());
        }
    }
    CxxBuckConfig cxxBuckConfig = new CxxBuckConfig(config);
    // Setup the NDK C/C++ platforms.
    Optional<Path> ndkRoot = androidDirectoryResolver.getNdkOrAbsent();
    ImmutableMap.Builder<NdkCxxPlatforms.TargetCpuType, NdkCxxPlatform> ndkCxxPlatformsBuilder = ImmutableMap.builder();
    if (ndkRoot.isPresent()) {
        NdkCxxPlatformCompiler.Type compilerType = androidConfig.getNdkCompiler().orElse(NdkCxxPlatforms.DEFAULT_COMPILER_TYPE);
        String gccVersion = androidConfig.getNdkGccVersion().orElse(NdkCxxPlatforms.getDefaultGccVersionForNdk(ndkVersion));
        String clangVersion = androidConfig.getNdkClangVersion().orElse(NdkCxxPlatforms.getDefaultClangVersionForNdk(ndkVersion));
        String compilerVersion = compilerType == NdkCxxPlatformCompiler.Type.GCC ? gccVersion : clangVersion;
        NdkCxxPlatformCompiler compiler = NdkCxxPlatformCompiler.builder().setType(compilerType).setVersion(compilerVersion).setGccVersion(gccVersion).build();
        ndkCxxPlatformsBuilder.putAll(NdkCxxPlatforms.getPlatforms(cxxBuckConfig, filesystem, ndkRoot.get(), compiler, androidConfig.getNdkCxxRuntime().orElse(NdkCxxPlatforms.DEFAULT_CXX_RUNTIME), androidConfig.getNdkAppPlatform().orElse(NdkCxxPlatforms.DEFAULT_TARGET_APP_PLATFORM), androidConfig.getNdkCpuAbis().orElse(NdkCxxPlatforms.DEFAULT_CPU_ABIS), platform));
    }
    ImmutableMap<NdkCxxPlatforms.TargetCpuType, NdkCxxPlatform> ndkCxxPlatforms = ndkCxxPlatformsBuilder.build();
    // Create a map of system platforms.
    ImmutableMap.Builder<Flavor, CxxPlatform> cxxSystemPlatformsBuilder = ImmutableMap.builder();
    // testing our Android NDK support for right now.
    for (NdkCxxPlatform ndkCxxPlatform : ndkCxxPlatforms.values()) {
        cxxSystemPlatformsBuilder.put(ndkCxxPlatform.getCxxPlatform().getFlavor(), ndkCxxPlatform.getCxxPlatform());
    }
    for (AppleCxxPlatform appleCxxPlatform : platformFlavorsToAppleCxxPlatforms.getValues()) {
        cxxSystemPlatformsBuilder.put(appleCxxPlatform.getCxxPlatform().getFlavor(), appleCxxPlatform.getCxxPlatform());
    }
    CxxPlatform defaultHostCxxPlatform = DefaultCxxPlatforms.build(platform, filesystem, cxxBuckConfig);
    cxxSystemPlatformsBuilder.put(defaultHostCxxPlatform.getFlavor(), defaultHostCxxPlatform);
    ImmutableMap<Flavor, CxxPlatform> cxxSystemPlatformsMap = cxxSystemPlatformsBuilder.build();
    // Add the host platform if needed (for example, when building on Linux).
    Flavor hostFlavor = CxxPlatforms.getHostFlavor();
    if (!cxxSystemPlatformsMap.containsKey(hostFlavor)) {
        cxxSystemPlatformsBuilder.put(hostFlavor, CxxPlatform.builder().from(defaultHostCxxPlatform).setFlavor(hostFlavor).build());
        cxxSystemPlatformsMap = cxxSystemPlatformsBuilder.build();
    }
    // Add platforms for each cxx flavor obtained from the buck config files
    // from sections of the form cxx#{flavor name}.
    // These platforms are overrides for existing system platforms.
    ImmutableSet<Flavor> possibleHostFlavors = CxxPlatforms.getAllPossibleHostFlavors();
    HashMap<Flavor, CxxPlatform> cxxOverridePlatformsMap = new HashMap<Flavor, CxxPlatform>(cxxSystemPlatformsMap);
    ImmutableSet<Flavor> cxxFlavors = CxxBuckConfig.getCxxFlavors(config);
    for (Flavor flavor : cxxFlavors) {
        CxxPlatform baseCxxPlatform = cxxSystemPlatformsMap.get(flavor);
        if (baseCxxPlatform == null) {
            if (possibleHostFlavors.contains(flavor)) {
                // If a flavor is for an alternate host, it's safe to skip.
                continue;
            }
            LOG.info("Applying \"%s\" overrides to default host platform", flavor);
            baseCxxPlatform = defaultHostCxxPlatform;
        }
        cxxOverridePlatformsMap.put(flavor, CxxPlatforms.copyPlatformWithFlavorAndConfig(baseCxxPlatform, platform, new CxxBuckConfig(config, flavor), flavor));
    }
    // Finalize our "default" host.
    // TODO(Ktwu) The host flavor should default to a concrete flavor
    // like "linux-x86_64", not "default".
    hostFlavor = DefaultCxxPlatforms.FLAVOR;
    Optional<String> hostCxxPlatformOverride = cxxBuckConfig.getHostPlatform();
    if (hostCxxPlatformOverride.isPresent()) {
        Flavor overrideFlavor = InternalFlavor.of(hostCxxPlatformOverride.get());
        if (cxxOverridePlatformsMap.containsKey(overrideFlavor)) {
            hostFlavor = overrideFlavor;
        }
    }
    CxxPlatform hostCxxPlatform = CxxPlatform.builder().from(cxxOverridePlatformsMap.get(hostFlavor)).setFlavor(DefaultCxxPlatforms.FLAVOR).build();
    cxxOverridePlatformsMap.put(DefaultCxxPlatforms.FLAVOR, hostCxxPlatform);
    ImmutableMap<Flavor, CxxPlatform> cxxPlatformsMap = ImmutableMap.<Flavor, CxxPlatform>builder().putAll(cxxOverridePlatformsMap).build();
    ExecutableFinder executableFinder = new ExecutableFinder();
    // Build up the final list of C/C++ platforms.
    FlavorDomain<CxxPlatform> cxxPlatforms = new FlavorDomain<>("C/C++ platform", cxxPlatformsMap);
    // Get the default target platform from config.
    CxxPlatform defaultCxxPlatform = CxxPlatforms.getConfigDefaultCxxPlatform(cxxBuckConfig, cxxPlatformsMap, hostCxxPlatform);
    DBuckConfig dBuckConfig = new DBuckConfig(config);
    ReactNativeBuckConfig reactNativeBuckConfig = new ReactNativeBuckConfig(config);
    RustBuckConfig rustBuckConfig = new RustBuckConfig(config);
    GoBuckConfig goBuckConfig = new GoBuckConfig(config, processExecutor, cxxPlatforms);
    HalideBuckConfig halideBuckConfig = new HalideBuckConfig(config);
    ProGuardConfig proGuardConfig = new ProGuardConfig(config);
    DxConfig dxConfig = new DxConfig(config);
    PythonBuckConfig pyConfig = new PythonBuckConfig(config, executableFinder);
    ImmutableList<PythonPlatform> pythonPlatformsList = pyConfig.getPythonPlatforms(processExecutor);
    FlavorDomain<PythonPlatform> pythonPlatforms = FlavorDomain.from("Python Platform", pythonPlatformsList);
    PythonBinaryDescription pythonBinaryDescription = new PythonBinaryDescription(pyConfig, pythonPlatforms, cxxBuckConfig, defaultCxxPlatform, cxxPlatforms);
    // Look up the timeout to apply to entire test rules.
    Optional<Long> defaultTestRuleTimeoutMs = config.getLong("test", "rule_timeout");
    // Prepare the downloader if we're allowing mid-build downloads
    Downloader downloader;
    DownloadConfig downloadConfig = new DownloadConfig(config);
    if (downloadConfig.isDownloadAtRuntimeOk()) {
        downloader = StackedDownloader.createFromConfig(config, androidDirectoryResolver.getSdkOrAbsent());
    } else {
        // Or just set one that blows up
        downloader = new ExplodingDownloader();
    }
    Builder builder = builder();
    JavaBuckConfig javaConfig = config.getView(JavaBuckConfig.class);
    JavacOptions defaultJavacOptions = javaConfig.getDefaultJavacOptions();
    JavaOptions defaultJavaOptions = javaConfig.getDefaultJavaOptions();
    JavaOptions defaultJavaOptionsForTests = javaConfig.getDefaultJavaOptionsForTests();
    KotlinBuckConfig kotlinBuckConfig = new KotlinBuckConfig(config);
    ScalaBuckConfig scalaConfig = new ScalaBuckConfig(config);
    InferBuckConfig inferBuckConfig = new InferBuckConfig(config);
    LuaConfig luaConfig = new LuaBuckConfig(config, executableFinder);
    CxxBinaryDescription cxxBinaryDescription = new CxxBinaryDescription(cxxBuckConfig, inferBuckConfig, defaultCxxPlatform, cxxPlatforms);
    CxxLibraryDescription cxxLibraryDescription = new CxxLibraryDescription(cxxBuckConfig, defaultCxxPlatform, inferBuckConfig, cxxPlatforms);
    FlavorDomain<SwiftPlatform> platformFlavorsToSwiftPlatforms = new FlavorDomain<>("Swift Platform", swiftPlatforms.build());
    SwiftLibraryDescription swiftLibraryDescription = new SwiftLibraryDescription(cxxBuckConfig, swiftBuckConfig, cxxPlatforms, platformFlavorsToSwiftPlatforms);
    builder.register(swiftLibraryDescription);
    CodeSignIdentityStore codeSignIdentityStore = CodeSignIdentityStore.fromSystem(processExecutor, appleConfig.getCodeSignIdentitiesCommand());
    ProvisioningProfileStore provisioningProfileStore = ProvisioningProfileStore.fromSearchPath(processExecutor, appleConfig.getProvisioningProfileReadCommand(), appleConfig.getProvisioningProfileSearchPath());
    AppleLibraryDescription appleLibraryDescription = new AppleLibraryDescription(cxxLibraryDescription, swiftLibraryDescription, platformFlavorsToAppleCxxPlatforms, defaultCxxPlatform, codeSignIdentityStore, provisioningProfileStore, appleConfig);
    builder.register(appleLibraryDescription);
    PrebuiltAppleFrameworkDescription appleFrameworkDescription = new PrebuiltAppleFrameworkDescription();
    builder.register(appleFrameworkDescription);
    AppleBinaryDescription appleBinaryDescription = new AppleBinaryDescription(cxxBinaryDescription, swiftLibraryDescription, platformFlavorsToAppleCxxPlatforms, codeSignIdentityStore, provisioningProfileStore, appleConfig);
    builder.register(appleBinaryDescription);
    HaskellBuckConfig haskellBuckConfig = new HaskellBuckConfig(config, executableFinder);
    builder.register(new HaskellLibraryDescription(haskellBuckConfig, cxxBuckConfig, cxxPlatforms));
    builder.register(new HaskellBinaryDescription(haskellBuckConfig, cxxPlatforms, defaultCxxPlatform));
    builder.register(new HaskellPrebuiltLibraryDescription());
    if (javaConfig.getDxThreadCount().isPresent()) {
        LOG.warn("java.dx_threads has been deprecated. Use dx.max_threads instead");
    }
    // Create an executor service exclusively for the smart dexing step.
    ListeningExecutorService dxExecutorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(dxConfig.getDxMaxThreadCount().orElse(javaConfig.getDxThreadCount().orElse(SmartDexingStep.determineOptimalThreadCount())), new CommandThreadFactory("SmartDexing")));
    builder.register(new AndroidAarDescription(new AndroidManifestDescription(), cxxBuckConfig, defaultJavacOptions, ndkCxxPlatforms));
    builder.register(new AndroidBinaryDescription(defaultJavaOptions, defaultJavacOptions, proGuardConfig, ndkCxxPlatforms, dxExecutorService, config, cxxBuckConfig, dxConfig));
    builder.register(new AndroidBuildConfigDescription(defaultJavacOptions));
    builder.register(new AndroidInstrumentationApkDescription(proGuardConfig, defaultJavacOptions, ndkCxxPlatforms, dxExecutorService, cxxBuckConfig, dxConfig));
    builder.register(new AndroidInstrumentationTestDescription(defaultJavaOptions, defaultTestRuleTimeoutMs));
    builder.register(new AndroidLibraryDescription(defaultJavacOptions, new DefaultAndroidLibraryCompilerFactory(scalaConfig, kotlinBuckConfig)));
    builder.register(new AndroidManifestDescription());
    builder.register(new AndroidPrebuiltAarDescription(defaultJavacOptions));
    builder.register(new AndroidReactNativeLibraryDescription(reactNativeBuckConfig));
    builder.register(new AndroidResourceDescription(config.isGrayscaleImageProcessingEnabled()));
    builder.register(new ApkGenruleDescription());
    builder.register(new AppleAssetCatalogDescription());
    builder.register(new ApplePackageDescription(appleConfig, defaultCxxPlatform, platformFlavorsToAppleCxxPlatforms));
    AppleBundleDescription appleBundleDescription = new AppleBundleDescription(appleBinaryDescription, appleLibraryDescription, cxxPlatforms, platformFlavorsToAppleCxxPlatforms, defaultCxxPlatform, codeSignIdentityStore, provisioningProfileStore, appleConfig);
    builder.register(appleBundleDescription);
    builder.register(new AppleResourceDescription());
    builder.register(new AppleTestDescription(appleConfig, appleLibraryDescription, cxxPlatforms, platformFlavorsToAppleCxxPlatforms, defaultCxxPlatform, codeSignIdentityStore, provisioningProfileStore, appleConfig.getAppleDeveloperDirectorySupplierForTests(processExecutor), defaultTestRuleTimeoutMs));
    builder.register(new CoreDataModelDescription());
    builder.register(new CsharpLibraryDescription());
    builder.register(cxxBinaryDescription);
    builder.register(cxxLibraryDescription);
    builder.register(new CxxGenruleDescription(cxxPlatforms));
    builder.register(new CxxLuaExtensionDescription(luaConfig, cxxBuckConfig, cxxPlatforms));
    builder.register(new CxxPythonExtensionDescription(pythonPlatforms, cxxBuckConfig, cxxPlatforms));
    builder.register(new CxxTestDescription(cxxBuckConfig, defaultCxxPlatform, cxxPlatforms, defaultTestRuleTimeoutMs));
    builder.register(new DBinaryDescription(dBuckConfig, cxxBuckConfig, defaultCxxPlatform));
    builder.register(new DLibraryDescription(dBuckConfig, cxxBuckConfig, defaultCxxPlatform));
    builder.register(new DTestDescription(dBuckConfig, cxxBuckConfig, defaultCxxPlatform, defaultTestRuleTimeoutMs));
    builder.register(new ExportFileDescription());
    builder.register(new GenruleDescription());
    builder.register(new GenAidlDescription());
    builder.register(new GoBinaryDescription(goBuckConfig));
    builder.register(new GoLibraryDescription(goBuckConfig));
    builder.register(new GoTestDescription(goBuckConfig, defaultTestRuleTimeoutMs));
    builder.register(new GraphqlLibraryDescription());
    GroovyBuckConfig groovyBuckConfig = new GroovyBuckConfig(config);
    builder.register(new GroovyLibraryDescription(groovyBuckConfig, defaultJavacOptions));
    builder.register(new GroovyTestDescription(groovyBuckConfig, defaultJavaOptionsForTests, defaultJavacOptions, defaultTestRuleTimeoutMs));
    builder.register(new GwtBinaryDescription(defaultJavaOptions));
    builder.register(new HalideLibraryDescription(cxxBuckConfig, defaultCxxPlatform, cxxPlatforms, halideBuckConfig));
    builder.register(new IosReactNativeLibraryDescription(reactNativeBuckConfig));
    builder.register(new JavaBinaryDescription(defaultJavaOptions, defaultJavacOptions, defaultCxxPlatform, javaConfig));
    builder.register(new JavaAnnotationProcessorDescription());
    builder.register(new JavaLibraryDescription(defaultJavacOptions));
    builder.register(new JavaTestDescription(defaultJavaOptionsForTests, defaultJavacOptions, defaultTestRuleTimeoutMs, defaultCxxPlatform));
    builder.register(new JsBundleDescription());
    builder.register(new JsLibraryDescription());
    builder.register(new KeystoreDescription());
    builder.register(new KotlinLibraryDescription(kotlinBuckConfig, defaultJavacOptions));
    builder.register(new KotlinTestDescription(kotlinBuckConfig, defaultJavaOptionsForTests, defaultJavacOptions, defaultTestRuleTimeoutMs));
    builder.register(new LuaBinaryDescription(luaConfig, cxxBuckConfig, defaultCxxPlatform, cxxPlatforms, pythonPlatforms));
    builder.register(new LuaLibraryDescription());
    builder.register(new NdkLibraryDescription(ndkVersion, ndkCxxPlatforms));
    OcamlBuckConfig ocamlBuckConfig = new OcamlBuckConfig(config, defaultCxxPlatform);
    builder.register(new OcamlBinaryDescription(ocamlBuckConfig));
    builder.register(new OcamlLibraryDescription(ocamlBuckConfig));
    builder.register(new PrebuiltCxxLibraryDescription(cxxBuckConfig, cxxPlatforms));
    builder.register(PrebuiltCxxLibraryGroupDescription.of());
    builder.register(new CxxPrecompiledHeaderDescription());
    builder.register(new PrebuiltDotnetLibraryDescription());
    builder.register(new PrebuiltJarDescription());
    builder.register(new PrebuiltNativeLibraryDescription());
    builder.register(new PrebuiltOcamlLibraryDescription());
    builder.register(new PrebuiltPythonLibraryDescription());
    builder.register(new ProjectConfigDescription());
    builder.register(pythonBinaryDescription);
    PythonLibraryDescription pythonLibraryDescription = new PythonLibraryDescription(pythonPlatforms, cxxPlatforms);
    builder.register(pythonLibraryDescription);
    builder.register(new PythonTestDescription(pythonBinaryDescription, pyConfig, pythonPlatforms, cxxBuckConfig, defaultCxxPlatform, defaultTestRuleTimeoutMs, cxxPlatforms));
    builder.register(new RemoteFileDescription(downloader));
    builder.register(new RobolectricTestDescription(defaultJavaOptionsForTests, defaultJavacOptions, defaultTestRuleTimeoutMs, defaultCxxPlatform));
    builder.register(new RustBinaryDescription(rustBuckConfig, cxxPlatforms, defaultCxxPlatform));
    builder.register(new RustLibraryDescription(rustBuckConfig, cxxPlatforms, defaultCxxPlatform));
    builder.register(new RustTestDescription(rustBuckConfig, cxxPlatforms, defaultCxxPlatform));
    builder.register(new PrebuiltRustLibraryDescription());
    builder.register(new ScalaLibraryDescription(scalaConfig));
    builder.register(new ScalaTestDescription(scalaConfig, defaultJavaOptionsForTests, defaultTestRuleTimeoutMs, defaultCxxPlatform));
    builder.register(new SceneKitAssetsDescription());
    builder.register(new ShBinaryDescription());
    builder.register(new ShTestDescription(defaultTestRuleTimeoutMs));
    builder.register(new WorkerToolDescription(config));
    builder.register(new XcodePostbuildScriptDescription());
    builder.register(new XcodePrebuildScriptDescription());
    builder.register(new XcodeWorkspaceConfigDescription());
    builder.register(new ZipFileDescription());
    builder.register(new TargetGroupDescription());
    builder.setCxxPlatforms(cxxPlatforms);
    builder.setDefaultCxxPlatform(defaultCxxPlatform);
    builder.register(VersionedAliasDescription.of());
    return builder;
}
Also used : JavaAnnotationProcessorDescription(com.facebook.buck.jvm.java.JavaAnnotationProcessorDescription) PythonPlatform(com.facebook.buck.python.PythonPlatform) Platform(com.facebook.buck.util.environment.Platform) AppleCxxPlatform(com.facebook.buck.apple.AppleCxxPlatform) SwiftPlatform(com.facebook.buck.swift.SwiftPlatform) NdkCxxPlatform(com.facebook.buck.android.NdkCxxPlatform) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) PrebuiltNativeLibraryDescription(com.facebook.buck.android.PrebuiltNativeLibraryDescription) GenruleDescription(com.facebook.buck.shell.GenruleDescription) ApkGenruleDescription(com.facebook.buck.android.ApkGenruleDescription) CxxGenruleDescription(com.facebook.buck.cxx.CxxGenruleDescription) ExplodingDownloader(com.facebook.buck.file.ExplodingDownloader) StackedDownloader(com.facebook.buck.file.StackedDownloader) Downloader(com.facebook.buck.file.Downloader) CxxGenruleDescription(com.facebook.buck.cxx.CxxGenruleDescription) ProGuardConfig(com.facebook.buck.android.ProGuardConfig) ScalaTestDescription(com.facebook.buck.jvm.scala.ScalaTestDescription) ScalaLibraryDescription(com.facebook.buck.jvm.scala.ScalaLibraryDescription) DownloadConfig(com.facebook.buck.cli.DownloadConfig) ShTestDescription(com.facebook.buck.shell.ShTestDescription) DTestDescription(com.facebook.buck.d.DTestDescription) AppleLibraryDescription(com.facebook.buck.apple.AppleLibraryDescription) LuaConfig(com.facebook.buck.lua.LuaConfig) JavaBinaryDescription(com.facebook.buck.jvm.java.JavaBinaryDescription) XcodePostbuildScriptDescription(com.facebook.buck.apple.XcodePostbuildScriptDescription) HaskellPrebuiltLibraryDescription(com.facebook.buck.haskell.HaskellPrebuiltLibraryDescription) ZipFileDescription(com.facebook.buck.zip.ZipFileDescription) KotlinTestDescription(com.facebook.buck.jvm.kotlin.KotlinTestDescription) ShBinaryDescription(com.facebook.buck.shell.ShBinaryDescription) PrebuiltAppleFrameworkDescription(com.facebook.buck.apple.PrebuiltAppleFrameworkDescription) GoLibraryDescription(com.facebook.buck.go.GoLibraryDescription) InternalFlavor(com.facebook.buck.model.InternalFlavor) Flavor(com.facebook.buck.model.Flavor) CodeSignIdentityStore(com.facebook.buck.apple.CodeSignIdentityStore) GoTestDescription(com.facebook.buck.go.GoTestDescription) GwtBinaryDescription(com.facebook.buck.gwt.GwtBinaryDescription) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) ApkGenruleDescription(com.facebook.buck.android.ApkGenruleDescription) CsharpLibraryDescription(com.facebook.buck.dotnet.CsharpLibraryDescription) SwiftPlatform(com.facebook.buck.swift.SwiftPlatform) PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) RustLibraryDescription(com.facebook.buck.rust.RustLibraryDescription) PrebuiltRustLibraryDescription(com.facebook.buck.rust.PrebuiltRustLibraryDescription) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) SceneKitAssetsDescription(com.facebook.buck.apple.SceneKitAssetsDescription) WorkerToolDescription(com.facebook.buck.shell.WorkerToolDescription) RustTestDescription(com.facebook.buck.rust.RustTestDescription) TargetGroupDescription(com.facebook.buck.groups.TargetGroupDescription) GenAidlDescription(com.facebook.buck.android.GenAidlDescription) CxxPrecompiledHeaderDescription(com.facebook.buck.cxx.CxxPrecompiledHeaderDescription) NdkCxxPlatformCompiler(com.facebook.buck.android.NdkCxxPlatformCompiler) LuaBinaryDescription(com.facebook.buck.lua.LuaBinaryDescription) NdkCxxPlatform(com.facebook.buck.android.NdkCxxPlatform) AppleTestDescription(com.facebook.buck.apple.AppleTestDescription) XcodeWorkspaceConfigDescription(com.facebook.buck.apple.XcodeWorkspaceConfigDescription) AndroidBinaryDescription(com.facebook.buck.android.AndroidBinaryDescription) LuaLibraryDescription(com.facebook.buck.lua.LuaLibraryDescription) ProvisioningProfileStore(com.facebook.buck.apple.ProvisioningProfileStore) PrebuiltJarDescription(com.facebook.buck.jvm.java.PrebuiltJarDescription) JsLibraryDescription(com.facebook.buck.js.JsLibraryDescription) Path(java.nio.file.Path) JavacOptions(com.facebook.buck.jvm.java.JavacOptions) PrebuiltPythonLibraryDescription(com.facebook.buck.python.PrebuiltPythonLibraryDescription) AppleResourceDescription(com.facebook.buck.apple.AppleResourceDescription) CxxLibraryDescription(com.facebook.buck.cxx.CxxLibraryDescription) PrebuiltCxxLibraryDescription(com.facebook.buck.cxx.PrebuiltCxxLibraryDescription) DLibraryDescription(com.facebook.buck.d.DLibraryDescription) JavaLibraryDescription(com.facebook.buck.jvm.java.JavaLibraryDescription) DBuckConfig(com.facebook.buck.d.DBuckConfig) AndroidReactNativeLibraryDescription(com.facebook.buck.js.AndroidReactNativeLibraryDescription) AndroidLibraryDescription(com.facebook.buck.android.AndroidLibraryDescription) AndroidPrebuiltAarDescription(com.facebook.buck.android.AndroidPrebuiltAarDescription) HaskellLibraryDescription(com.facebook.buck.haskell.HaskellLibraryDescription) KotlinLibraryDescription(com.facebook.buck.jvm.kotlin.KotlinLibraryDescription) ExplodingDownloader(com.facebook.buck.file.ExplodingDownloader) GoBinaryDescription(com.facebook.buck.go.GoBinaryDescription) PrebuiltRustLibraryDescription(com.facebook.buck.rust.PrebuiltRustLibraryDescription) KeystoreDescription(com.facebook.buck.jvm.java.KeystoreDescription) DxConfig(com.facebook.buck.android.DxConfig) JavaOptions(com.facebook.buck.jvm.java.JavaOptions) AppleBundleDescription(com.facebook.buck.apple.AppleBundleDescription) GroovyLibraryDescription(com.facebook.buck.jvm.groovy.GroovyLibraryDescription) AppleConfig(com.facebook.buck.apple.AppleConfig) CxxBinaryDescription(com.facebook.buck.cxx.CxxBinaryDescription) HashMap(java.util.HashMap) HaskellBuckConfig(com.facebook.buck.haskell.HaskellBuckConfig) RemoteFileDescription(com.facebook.buck.file.RemoteFileDescription) CoreDataModelDescription(com.facebook.buck.apple.CoreDataModelDescription) PrebuiltDotnetLibraryDescription(com.facebook.buck.dotnet.PrebuiltDotnetLibraryDescription) JavaBuckConfig(com.facebook.buck.jvm.java.JavaBuckConfig) IosReactNativeLibraryDescription(com.facebook.buck.js.IosReactNativeLibraryDescription) PrebuiltCxxLibraryDescription(com.facebook.buck.cxx.PrebuiltCxxLibraryDescription) AndroidResourceDescription(com.facebook.buck.android.AndroidResourceDescription) HalideBuckConfig(com.facebook.buck.halide.HalideBuckConfig) JsBundleDescription(com.facebook.buck.js.JsBundleDescription) XcodePrebuildScriptDescription(com.facebook.buck.apple.XcodePrebuildScriptDescription) CxxTestDescription(com.facebook.buck.cxx.CxxTestDescription) GroovyBuckConfig(com.facebook.buck.jvm.groovy.GroovyBuckConfig) HaskellBinaryDescription(com.facebook.buck.haskell.HaskellBinaryDescription) GroovyTestDescription(com.facebook.buck.jvm.groovy.GroovyTestDescription) HalideLibraryDescription(com.facebook.buck.halide.HalideLibraryDescription) PythonBinaryDescription(com.facebook.buck.python.PythonBinaryDescription) ImmutableMap(com.google.common.collect.ImmutableMap) AndroidManifestDescription(com.facebook.buck.android.AndroidManifestDescription) GraphqlLibraryDescription(com.facebook.buck.graphql.GraphqlLibraryDescription) ScalaBuckConfig(com.facebook.buck.jvm.scala.ScalaBuckConfig) AndroidInstrumentationApkDescription(com.facebook.buck.android.AndroidInstrumentationApkDescription) ApplePackageDescription(com.facebook.buck.apple.ApplePackageDescription) SwiftLibraryDescription(com.facebook.buck.swift.SwiftLibraryDescription) AndroidBuckConfig(com.facebook.buck.android.AndroidBuckConfig) AndroidAarDescription(com.facebook.buck.android.AndroidAarDescription) InferBuckConfig(com.facebook.buck.cxx.InferBuckConfig) PrebuiltOcamlLibraryDescription(com.facebook.buck.ocaml.PrebuiltOcamlLibraryDescription) RustBuckConfig(com.facebook.buck.rust.RustBuckConfig) DBinaryDescription(com.facebook.buck.d.DBinaryDescription) RobolectricTestDescription(com.facebook.buck.android.RobolectricTestDescription) FlavorDomain(com.facebook.buck.model.FlavorDomain) PythonLibraryDescription(com.facebook.buck.python.PythonLibraryDescription) PrebuiltPythonLibraryDescription(com.facebook.buck.python.PrebuiltPythonLibraryDescription) GoBuckConfig(com.facebook.buck.go.GoBuckConfig) CxxPythonExtensionDescription(com.facebook.buck.python.CxxPythonExtensionDescription) AppleAssetCatalogDescription(com.facebook.buck.apple.AppleAssetCatalogDescription) AppleBinaryDescription(com.facebook.buck.apple.AppleBinaryDescription) OcamlBuckConfig(com.facebook.buck.ocaml.OcamlBuckConfig) AppleCxxPlatform(com.facebook.buck.apple.AppleCxxPlatform) NdkCxxPlatform(com.facebook.buck.android.NdkCxxPlatform) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) CommandThreadFactory(com.facebook.buck.log.CommandThreadFactory) AndroidBuildConfigDescription(com.facebook.buck.android.AndroidBuildConfigDescription) PrebuiltOcamlLibraryDescription(com.facebook.buck.ocaml.PrebuiltOcamlLibraryDescription) OcamlLibraryDescription(com.facebook.buck.ocaml.OcamlLibraryDescription) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) KotlinBuckConfig(com.facebook.buck.jvm.kotlin.KotlinBuckConfig) RustBinaryDescription(com.facebook.buck.rust.RustBinaryDescription) CxxLuaExtensionDescription(com.facebook.buck.lua.CxxLuaExtensionDescription) ReactNativeBuckConfig(com.facebook.buck.js.ReactNativeBuckConfig) LuaBuckConfig(com.facebook.buck.lua.LuaBuckConfig) PythonPlatform(com.facebook.buck.python.PythonPlatform) AndroidInstrumentationTestDescription(com.facebook.buck.android.AndroidInstrumentationTestDescription) JavaTestDescription(com.facebook.buck.jvm.java.JavaTestDescription) OcamlBinaryDescription(com.facebook.buck.ocaml.OcamlBinaryDescription) SwiftBuckConfig(com.facebook.buck.swift.SwiftBuckConfig) AppleCxxPlatform(com.facebook.buck.apple.AppleCxxPlatform) DefaultAndroidLibraryCompilerFactory(com.facebook.buck.android.DefaultAndroidLibraryCompilerFactory) ExportFileDescription(com.facebook.buck.shell.ExportFileDescription) NdkLibraryDescription(com.facebook.buck.android.NdkLibraryDescription) PythonTestDescription(com.facebook.buck.python.PythonTestDescription) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with AndroidBuckConfig

use of com.facebook.buck.android.AndroidBuckConfig in project buck by facebook.

the class Main method runMainWithExitCode.

/**
   * @param buildId an identifier for this command execution.
   * @param context an optional NGContext that is present if running inside a Nailgun server.
   * @param initTimestamp Value of System.nanoTime() when process got main()/nailMain() invoked.
   * @param unexpandedCommandLineArgs command line arguments
   * @return an exit code or {@code null} if this is a process that should not exit
   */
@SuppressWarnings("PMD.PrematureDeclaration")
public int runMainWithExitCode(BuildId buildId, Path projectRoot, Optional<NGContext> context, ImmutableMap<String, String> clientEnvironment, CommandMode commandMode, WatchmanWatcher.FreshInstanceAction watchmanFreshInstanceAction, final long initTimestamp, String... unexpandedCommandLineArgs) throws IOException, InterruptedException {
    String[] args = BuckArgsMethods.expandAtFiles(unexpandedCommandLineArgs);
    // Parse the command line args.
    BuckCommand command = new BuckCommand();
    AdditionalOptionsCmdLineParser cmdLineParser = new AdditionalOptionsCmdLineParser(command);
    try {
        cmdLineParser.parseArgument(args);
    } catch (CmdLineException e) {
        // Can't go through the console for prettification since that needs the BuckConfig, and that
        // needs to be created with the overrides, which are parsed from the command line here, which
        // required the console to print the message that parsing has failed. So just write to stderr
        // and be done with it.
        stdErr.println(e.getLocalizedMessage());
        stdErr.println("For help see 'buck --help'.");
        return 1;
    }
    {
        // Return help strings fast if the command is a help request.
        OptionalInt result = command.runHelp(stdErr);
        if (result.isPresent()) {
            return result.getAsInt();
        }
    }
    // Setup logging.
    if (commandMode.isLoggingEnabled()) {
        // Reset logging each time we run a command while daemonized.
        // This will cause us to write a new log per command.
        LOG.debug("Rotating log.");
        LogConfig.flushLogs();
        LogConfig.setupLogging(command.getLogConfig());
        if (LOG.isDebugEnabled()) {
            Long gitCommitTimestamp = Long.getLong("buck.git_commit_timestamp");
            String buildDateStr;
            if (gitCommitTimestamp == null) {
                buildDateStr = "(unknown)";
            } else {
                buildDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", Locale.US).format(new Date(TimeUnit.SECONDS.toMillis(gitCommitTimestamp)));
            }
            String buildRev = System.getProperty("buck.git_commit", "(unknown)");
            LOG.debug("Starting up (build date %s, rev %s), args: %s", buildDateStr, buildRev, Arrays.toString(args));
            LOG.debug("System properties: %s", System.getProperties());
        }
    }
    // Setup filesystem and buck config.
    Path canonicalRootPath = projectRoot.toRealPath().normalize();
    Config config = Configs.createDefaultConfig(canonicalRootPath, command.getConfigOverrides().getForCell(RelativeCellName.ROOT_CELL_NAME));
    ProjectFilesystem filesystem = new ProjectFilesystem(canonicalRootPath, config);
    DefaultCellPathResolver cellPathResolver = new DefaultCellPathResolver(filesystem.getRootPath(), config);
    BuckConfig buckConfig = new BuckConfig(config, filesystem, architecture, platform, clientEnvironment, cellPathResolver);
    ImmutableSet<Path> projectWatchList = ImmutableSet.<Path>builder().add(canonicalRootPath).addAll(buckConfig.getView(ParserConfig.class).getWatchCells() ? cellPathResolver.getTransitivePathMapping().values() : ImmutableList.of()).build();
    Optional<ImmutableList<String>> allowedJavaSpecificiationVersions = buckConfig.getAllowedJavaSpecificationVersions();
    if (allowedJavaSpecificiationVersions.isPresent()) {
        String specificationVersion = System.getProperty("java.specification.version");
        boolean javaSpecificationVersionIsAllowed = allowedJavaSpecificiationVersions.get().contains(specificationVersion);
        if (!javaSpecificationVersionIsAllowed) {
            throw new HumanReadableException("Current Java version '%s' is not in the allowed java specification versions:\n%s", specificationVersion, Joiner.on(", ").join(allowedJavaSpecificiationVersions.get()));
        }
    }
    // Setup the console.
    Verbosity verbosity = VerbosityParser.parse(args);
    Optional<String> color;
    if (context.isPresent() && (context.get().getEnv() != null)) {
        String colorString = context.get().getEnv().getProperty(BUCKD_COLOR_DEFAULT_ENV_VAR);
        color = Optional.ofNullable(colorString);
    } else {
        color = Optional.empty();
    }
    final Console console = new Console(verbosity, stdOut, stdErr, buckConfig.createAnsi(color));
    // No more early outs: if this command is not read only, acquire the command semaphore to
    // become the only executing read/write command.
    // This must happen immediately before the try block to ensure that the semaphore is released.
    boolean commandSemaphoreAcquired = false;
    boolean shouldCleanUpTrash = false;
    if (!command.isReadOnly()) {
        commandSemaphoreAcquired = commandSemaphore.tryAcquire();
        if (!commandSemaphoreAcquired) {
            LOG.warn("Buck server was busy executing a command. Maybe retrying later will help.");
            return BUSY_EXIT_CODE;
        }
    }
    try {
        if (commandSemaphoreAcquired) {
            commandSemaphoreNgClient = context;
        }
        if (!command.isReadOnly()) {
            Optional<String> currentVersion = filesystem.readFileIfItExists(filesystem.getBuckPaths().getCurrentVersionFile());
            BuckPaths unconfiguredPaths = filesystem.getBuckPaths().withConfiguredBuckOut(filesystem.getBuckPaths().getBuckOut());
            if (!currentVersion.isPresent() || !currentVersion.get().equals(BuckVersion.getVersion()) || (filesystem.exists(unconfiguredPaths.getGenDir(), LinkOption.NOFOLLOW_LINKS) && (filesystem.isSymLink(unconfiguredPaths.getGenDir()) ^ buckConfig.getBuckOutCompatLink()))) {
                // Migrate any version-dependent directories (which might be huge) to a trash directory
                // so we can delete it asynchronously after the command is done.
                moveToTrash(filesystem, console, buildId, filesystem.getBuckPaths().getAnnotationDir(), filesystem.getBuckPaths().getGenDir(), filesystem.getBuckPaths().getScratchDir(), filesystem.getBuckPaths().getResDir());
                shouldCleanUpTrash = true;
                filesystem.mkdirs(filesystem.getBuckPaths().getCurrentVersionFile().getParent());
                filesystem.writeContentsToPath(BuckVersion.getVersion(), filesystem.getBuckPaths().getCurrentVersionFile());
            }
        }
        AndroidBuckConfig androidBuckConfig = new AndroidBuckConfig(buckConfig, platform);
        AndroidDirectoryResolver androidDirectoryResolver = new DefaultAndroidDirectoryResolver(filesystem.getRootPath().getFileSystem(), clientEnvironment, androidBuckConfig.getBuildToolsVersion(), androidBuckConfig.getNdkVersion());
        ProcessExecutor processExecutor = new DefaultProcessExecutor(console);
        Clock clock;
        boolean enableThreadCpuTime = buckConfig.getBooleanValue("build", "enable_thread_cpu_time", true);
        if (BUCKD_LAUNCH_TIME_NANOS.isPresent()) {
            long nanosEpoch = Long.parseLong(BUCKD_LAUNCH_TIME_NANOS.get(), 10);
            LOG.verbose("Using nanos epoch: %d", nanosEpoch);
            clock = new NanosAdjustedClock(nanosEpoch, enableThreadCpuTime);
        } else {
            clock = new DefaultClock(enableThreadCpuTime);
        }
        ParserConfig parserConfig = buckConfig.getView(ParserConfig.class);
        try (Watchman watchman = buildWatchman(context, parserConfig, projectWatchList, clientEnvironment, console, clock)) {
            final boolean isDaemon = context.isPresent() && (watchman != Watchman.NULL_WATCHMAN);
            if (!isDaemon && shouldCleanUpTrash) {
                // Clean up the trash on a background thread if this was a
                // non-buckd read-write command. (We don't bother waiting
                // for it to complete; the thread is a daemon thread which
                // will just be terminated at shutdown time.)
                TRASH_CLEANER.startCleaningDirectory(filesystem.getBuckPaths().getTrashDir());
            }
            KnownBuildRuleTypesFactory factory = new KnownBuildRuleTypesFactory(processExecutor, androidDirectoryResolver);
            Cell rootCell = CellProvider.createForLocalBuild(filesystem, watchman, buckConfig, command.getConfigOverrides(), factory).getCellByPath(filesystem.getRootPath());
            int exitCode;
            ImmutableList<BuckEventListener> eventListeners = ImmutableList.of();
            ExecutionEnvironment executionEnvironment = new DefaultExecutionEnvironment(clientEnvironment, System.getProperties());
            ImmutableList.Builder<ProjectFileHashCache> allCaches = ImmutableList.builder();
            // Build up the hash cache, which is a collection of the stateful cell cache and some
            // per-run caches.
            //
            // TODO(Coneko, ruibm, andrewjcg): Determine whether we can use the existing filesystem
            // object that is in scope instead of creating a new rootCellProjectFilesystem. The primary
            // difference appears to be that filesystem is created with a Config that is used to produce
            // ImmutableSet<PathOrGlobMatcher> and BuckPaths for the ProjectFilesystem, whereas this one
            // uses the defaults.
            ProjectFilesystem rootCellProjectFilesystem = ProjectFilesystem.createNewOrThrowHumanReadableException(rootCell.getFilesystem().getRootPath());
            if (isDaemon) {
                allCaches.addAll(getFileHashCachesFromDaemon(rootCell));
            } else {
                getTransitiveCells(rootCell).stream().map(cell -> DefaultFileHashCache.createDefaultFileHashCache(cell.getFilesystem())).forEach(allCaches::add);
                allCaches.add(DefaultFileHashCache.createBuckOutFileHashCache(rootCellProjectFilesystem, rootCell.getFilesystem().getBuckPaths().getBuckOut()));
            }
            // A cache which caches hashes of cell-relative paths which may have been ignore by
            // the main cell cache, and only serves to prevent rehashing the same file multiple
            // times in a single run.
            allCaches.add(DefaultFileHashCache.createDefaultFileHashCache(rootCellProjectFilesystem));
            allCaches.addAll(DefaultFileHashCache.createOsRootDirectoriesCaches());
            StackedFileHashCache fileHashCache = new StackedFileHashCache(allCaches.build());
            Optional<WebServer> webServer = getWebServerIfDaemon(context, rootCell);
            Optional<ConcurrentMap<String, WorkerProcessPool>> persistentWorkerPools = getPersistentWorkerPoolsIfDaemon(context, rootCell);
            TestConfig testConfig = new TestConfig(buckConfig);
            ArtifactCacheBuckConfig cacheBuckConfig = new ArtifactCacheBuckConfig(buckConfig);
            ExecutorService diskIoExecutorService = MostExecutors.newSingleThreadExecutor("Disk I/O");
            ListeningExecutorService httpWriteExecutorService = getHttpWriteExecutorService(cacheBuckConfig);
            ScheduledExecutorService counterAggregatorExecutor = Executors.newSingleThreadScheduledExecutor(new CommandThreadFactory("CounterAggregatorThread"));
            VersionControlStatsGenerator vcStatsGenerator;
            // Eventually, we'll want to get allow websocket and/or nailgun clients to specify locale
            // when connecting. For now, we'll use the default from the server environment.
            Locale locale = Locale.getDefault();
            // Create a cached thread pool for cpu intensive tasks
            Map<ExecutorPool, ListeningExecutorService> executors = new HashMap<>();
            executors.put(ExecutorPool.CPU, listeningDecorator(Executors.newCachedThreadPool()));
            // Create a thread pool for network I/O tasks
            executors.put(ExecutorPool.NETWORK, newDirectExecutorService());
            executors.put(ExecutorPool.PROJECT, listeningDecorator(MostExecutors.newMultiThreadExecutor("Project", buckConfig.getNumThreads())));
            // Create and register the event buses that should listen to broadcast events.
            // If the build doesn't have a daemon create a new instance.
            BroadcastEventListener broadcastEventListener = getBroadcastEventListener(isDaemon, rootCell, objectMapper);
            // The order of resources in the try-with-resources block is important: the BuckEventBus
            // must be the last resource, so that it is closed first and can deliver its queued events
            // to the other resources before they are closed.
            InvocationInfo invocationInfo = InvocationInfo.of(buildId, isSuperConsoleEnabled(console), isDaemon, command.getSubCommandNameForLogging(), filesystem.getBuckPaths().getLogDir());
            try (GlobalStateManager.LoggerIsMappedToThreadScope loggerThreadMappingScope = GlobalStateManager.singleton().setupLoggers(invocationInfo, console.getStdErr(), stdErr, verbosity);
                AbstractConsoleEventBusListener consoleListener = createConsoleEventListener(clock, new SuperConsoleConfig(buckConfig), console, testConfig.getResultSummaryVerbosity(), executionEnvironment, webServer, locale, filesystem.getBuckPaths().getLogDir().resolve("test.log"));
                AsyncCloseable asyncCloseable = new AsyncCloseable(diskIoExecutorService);
                BuckEventBus buildEventBus = new BuckEventBus(clock, buildId);
                BroadcastEventListener.BroadcastEventBusClosable broadcastEventBusClosable = broadcastEventListener.addEventBus(buildEventBus);
                // stderr.
                Closeable logErrorToEventBus = loggerThreadMappingScope.setWriter(createWriterForConsole(consoleListener));
                // NOTE: This will only run during the lifetime of the process and will flush on close.
                CounterRegistry counterRegistry = new CounterRegistryImpl(counterAggregatorExecutor, buildEventBus, buckConfig.getCountersFirstFlushIntervalMillis(), buckConfig.getCountersFlushIntervalMillis());
                PerfStatsTracking perfStatsTracking = new PerfStatsTracking(buildEventBus, invocationInfo);
                ProcessTracker processTracker = buckConfig.isProcessTrackerEnabled() && platform != Platform.WINDOWS ? new ProcessTracker(buildEventBus, invocationInfo, isDaemon, buckConfig.isProcessTrackerDeepEnabled()) : null) {
                LOG.debug(invocationInfo.toLogLine(args));
                buildEventBus.register(HANG_MONITOR.getHangMonitor());
                ArtifactCaches artifactCacheFactory = new ArtifactCaches(cacheBuckConfig, buildEventBus, filesystem, executionEnvironment.getWifiSsid(), httpWriteExecutorService, Optional.of(asyncCloseable));
                ProgressEstimator progressEstimator = new ProgressEstimator(filesystem.resolve(filesystem.getBuckPaths().getBuckOut()).resolve(ProgressEstimator.PROGRESS_ESTIMATIONS_JSON), buildEventBus, objectMapper);
                consoleListener.setProgressEstimator(progressEstimator);
                BuildEnvironmentDescription buildEnvironmentDescription = getBuildEnvironmentDescription(executionEnvironment, buckConfig);
                Iterable<BuckEventListener> commandEventListeners = command.getSubcommand().isPresent() ? command.getSubcommand().get().getEventListeners(invocationInfo.getLogDirectoryPath(), filesystem) : ImmutableList.of();
                Supplier<BuckEventListener> missingSymbolsListenerSupplier = () -> {
                    return MissingSymbolsHandler.createListener(rootCell.getFilesystem(), rootCell.getKnownBuildRuleTypes().getAllDescriptions(), rootCell.getBuckConfig(), buildEventBus, console, buckConfig.getView(JavaBuckConfig.class).getDefaultJavacOptions(), clientEnvironment);
                };
                eventListeners = addEventListeners(buildEventBus, rootCell.getFilesystem(), invocationInfo, rootCell.getBuckConfig(), webServer, clock, consoleListener, missingSymbolsListenerSupplier, counterRegistry, commandEventListeners);
                if (commandMode == CommandMode.RELEASE && buckConfig.isPublicAnnouncementsEnabled()) {
                    PublicAnnouncementManager announcementManager = new PublicAnnouncementManager(clock, buildEventBus, consoleListener, buckConfig.getRepository().orElse("unknown"), new RemoteLogBuckConfig(buckConfig), executors.get(ExecutorPool.CPU));
                    announcementManager.getAndPostAnnouncements();
                }
                // This needs to be after the registration of the event listener so they can pick it up.
                if (watchmanFreshInstanceAction == WatchmanWatcher.FreshInstanceAction.NONE) {
                    buildEventBus.post(DaemonEvent.newDaemonInstance());
                }
                if (command.subcommand instanceof AbstractCommand) {
                    AbstractCommand subcommand = (AbstractCommand) command.subcommand;
                    VersionControlBuckConfig vcBuckConfig = new VersionControlBuckConfig(buckConfig);
                    if (!commandMode.equals(CommandMode.TEST) && (subcommand.isSourceControlStatsGatheringEnabled() || vcBuckConfig.shouldGenerateStatistics())) {
                        vcStatsGenerator = new VersionControlStatsGenerator(diskIoExecutorService, new DefaultVersionControlCmdLineInterfaceFactory(rootCell.getFilesystem().getRootPath(), new PrintStreamProcessExecutorFactory(), vcBuckConfig, buckConfig.getEnvironment()), buildEventBus);
                        vcStatsGenerator.generateStatsAsync();
                    }
                }
                ImmutableList<String> remainingArgs = args.length > 1 ? ImmutableList.copyOf(Arrays.copyOfRange(args, 1, args.length)) : ImmutableList.of();
                CommandEvent.Started startedEvent = CommandEvent.started(args.length > 0 ? args[0] : "", remainingArgs, isDaemon, getBuckPID());
                buildEventBus.post(startedEvent);
                // Create or get Parser and invalidate cached command parameters.
                Parser parser = null;
                VersionedTargetGraphCache versionedTargetGraphCache = null;
                ActionGraphCache actionGraphCache = null;
                Optional<RuleKeyCacheRecycler<RuleKey>> defaultRuleKeyFactoryCacheRecycler = Optional.empty();
                if (isDaemon) {
                    try {
                        Daemon daemon = getDaemon(rootCell, objectMapper);
                        WatchmanWatcher watchmanWatcher = createWatchmanWatcher(daemon, watchman.getProjectWatches(), daemon.getFileEventBus(), ImmutableSet.<PathOrGlobMatcher>builder().addAll(filesystem.getIgnorePaths()).addAll(DEFAULT_IGNORE_GLOBS).build(), watchman);
                        parser = getParserFromDaemon(context, rootCell, startedEvent, buildEventBus, watchmanWatcher, watchmanFreshInstanceAction);
                        versionedTargetGraphCache = daemon.getVersionedTargetGraphCache();
                        actionGraphCache = daemon.getActionGraphCache();
                        if (buckConfig.getRuleKeyCaching()) {
                            LOG.debug("Using rule key calculation caching");
                            defaultRuleKeyFactoryCacheRecycler = Optional.of(daemon.getDefaultRuleKeyFactoryCacheRecycler());
                        }
                    } catch (WatchmanWatcherException | IOException e) {
                        buildEventBus.post(ConsoleEvent.warning("Watchman threw an exception while parsing file changes.\n%s", e.getMessage()));
                    }
                }
                if (versionedTargetGraphCache == null) {
                    versionedTargetGraphCache = new VersionedTargetGraphCache();
                }
                if (actionGraphCache == null) {
                    actionGraphCache = new ActionGraphCache(broadcastEventListener);
                }
                if (parser == null) {
                    TypeCoercerFactory typeCoercerFactory = new DefaultTypeCoercerFactory(objectMapper);
                    parser = new Parser(broadcastEventListener, rootCell.getBuckConfig().getView(ParserConfig.class), typeCoercerFactory, new ConstructorArgMarshaller(typeCoercerFactory));
                }
                // Because the Parser is potentially constructed before the CounterRegistry,
                // we need to manually register its counters after it's created.
                //
                // The counters will be unregistered once the counter registry is closed.
                counterRegistry.registerCounters(parser.getCounters());
                JavaUtilsLoggingBuildListener.ensureLogFileIsWritten(rootCell.getFilesystem());
                Optional<ProcessManager> processManager;
                if (platform == Platform.WINDOWS) {
                    processManager = Optional.empty();
                } else {
                    processManager = Optional.of(new PkillProcessManager(processExecutor));
                }
                Supplier<AndroidPlatformTarget> androidPlatformTargetSupplier = createAndroidPlatformTargetSupplier(androidDirectoryResolver, androidBuckConfig, buildEventBus);
                // event-listener.
                if (command.subcommand instanceof AbstractCommand) {
                    AbstractCommand subcommand = (AbstractCommand) command.subcommand;
                    Optional<Path> eventsOutputPath = subcommand.getEventsOutputPath();
                    if (eventsOutputPath.isPresent()) {
                        BuckEventListener listener = new FileSerializationEventBusListener(eventsOutputPath.get(), objectMapper);
                        buildEventBus.register(listener);
                    }
                }
                buildEventBus.post(new BuckInitializationDurationEvent(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - initTimestamp)));
                try {
                    exitCode = command.run(CommandRunnerParams.builder().setConsole(console).setStdIn(stdIn).setCell(rootCell).setAndroidPlatformTargetSupplier(androidPlatformTargetSupplier).setArtifactCacheFactory(artifactCacheFactory).setBuckEventBus(buildEventBus).setParser(parser).setPlatform(platform).setEnvironment(clientEnvironment).setJavaPackageFinder(rootCell.getBuckConfig().getView(JavaBuckConfig.class).createDefaultJavaPackageFinder()).setObjectMapper(objectMapper).setClock(clock).setProcessManager(processManager).setPersistentWorkerPools(persistentWorkerPools).setWebServer(webServer).setBuckConfig(buckConfig).setFileHashCache(fileHashCache).setExecutors(executors).setBuildEnvironmentDescription(buildEnvironmentDescription).setVersionedTargetGraphCache(versionedTargetGraphCache).setActionGraphCache(actionGraphCache).setKnownBuildRuleTypesFactory(factory).setInvocationInfo(Optional.of(invocationInfo)).setDefaultRuleKeyFactoryCacheRecycler(defaultRuleKeyFactoryCacheRecycler).build());
                } catch (InterruptedException | ClosedByInterruptException e) {
                    exitCode = INTERRUPTED_EXIT_CODE;
                    buildEventBus.post(CommandEvent.interrupted(startedEvent, INTERRUPTED_EXIT_CODE));
                    throw e;
                }
                // Let's avoid an infinite loop
                if (exitCode == BUSY_EXIT_CODE) {
                    // Some loss of info here, but better than looping
                    exitCode = FAIL_EXIT_CODE;
                    LOG.error("Buck return with exit code %d which we use to indicate busy status. " + "This is probably propagating an exit code from a sub process or tool. " + "Coercing to %d to avoid retries.", BUSY_EXIT_CODE, FAIL_EXIT_CODE);
                }
                // Wait for HTTP writes to complete.
                closeHttpExecutorService(cacheBuckConfig, Optional.of(buildEventBus), httpWriteExecutorService);
                closeExecutorService("CounterAggregatorExecutor", counterAggregatorExecutor, COUNTER_AGGREGATOR_SERVICE_TIMEOUT_SECONDS);
                buildEventBus.post(CommandEvent.finished(startedEvent, exitCode));
            } catch (Throwable t) {
                LOG.debug(t, "Failing build on exception.");
                closeHttpExecutorService(cacheBuckConfig, Optional.empty(), httpWriteExecutorService);
                closeDiskIoExecutorService(diskIoExecutorService);
                flushEventListeners(console, buildId, eventListeners);
                throw t;
            } finally {
                if (commandSemaphoreAcquired) {
                    commandSemaphoreNgClient = Optional.empty();
                    BgProcessKiller.disarm();
                    // Allow another command to execute while outputting traces.
                    commandSemaphore.release();
                    commandSemaphoreAcquired = false;
                }
                if (isDaemon && shouldCleanUpTrash) {
                    // Clean up the trash in the background if this was a buckd
                    // read-write command. (We don't bother waiting for it to
                    // complete; the cleaner will ensure subsequent cleans are
                    // serialized with this one.)
                    TRASH_CLEANER.startCleaningDirectory(filesystem.getBuckPaths().getTrashDir());
                }
                // shut down the cached thread pools
                for (ExecutorPool p : executors.keySet()) {
                    closeExecutorService(p.toString(), executors.get(p), EXECUTOR_SERVICES_TIMEOUT_SECONDS);
                }
            }
            if (context.isPresent() && !rootCell.getBuckConfig().getFlushEventsBeforeExit()) {
                // Avoid client exit triggering client disconnection handling.
                context.get().in.close();
                // Allow nailgun client to exit while outputting traces.
                context.get().exit(exitCode);
            }
            closeDiskIoExecutorService(diskIoExecutorService);
            flushEventListeners(console, buildId, eventListeners);
            return exitCode;
        }
    } finally {
        if (commandSemaphoreAcquired) {
            commandSemaphoreNgClient = Optional.empty();
            BgProcessKiller.disarm();
            commandSemaphore.release();
        }
    }
}
Also used : OverlappingFileLockException(java.nio.channels.OverlappingFileLockException) BroadcastEventListener(com.facebook.buck.event.listener.BroadcastEventListener) Arrays(java.util.Arrays) ArtifactCache(com.facebook.buck.artifact_cache.ArtifactCache) RelativeCellName(com.facebook.buck.rules.RelativeCellName) ObjectMappers(com.facebook.buck.util.ObjectMappers) TypeCoercerFactory(com.facebook.buck.rules.coercer.TypeCoercerFactory) Ansi(com.facebook.buck.util.Ansi) NGListeningAddress(com.martiansoftware.nailgun.NGListeningAddress) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) URLClassLoader(java.net.URLClassLoader) WatchedFileHashCache(com.facebook.buck.util.cache.WatchedFileHashCache) BuildId(com.facebook.buck.model.BuildId) RuleKey(com.facebook.buck.rules.RuleKey) WorkerProcessPool(com.facebook.buck.shell.WorkerProcessPool) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) InterruptionFailedException(com.facebook.buck.util.InterruptionFailedException) Duration(java.time.Duration) Map(java.util.Map) ChromeTraceBuildListener(com.facebook.buck.event.listener.ChromeTraceBuildListener) DefaultTypeCoercerFactory(com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory) LastErrorException(com.sun.jna.LastErrorException) ClassPath(com.google.common.reflect.ClassPath) Path(java.nio.file.Path) ConsoleHandlerState(com.facebook.buck.log.ConsoleHandlerState) WatchmanWatcherException(com.facebook.buck.util.WatchmanWatcherException) AndroidPlatformTarget(com.facebook.buck.android.AndroidPlatformTarget) Verbosity(com.facebook.buck.util.Verbosity) NonReentrantSystemExit(com.facebook.buck.util.shutdown.NonReentrantSystemExit) TestResultSummaryVerbosity(com.facebook.buck.test.TestResultSummaryVerbosity) Native(com.sun.jna.Native) SuperConsoleConfig(com.facebook.buck.event.listener.SuperConsoleConfig) Set(java.util.Set) PathOrGlobMatcher(com.facebook.buck.io.PathOrGlobMatcher) Executors(java.util.concurrent.Executors) CommandThreadFactory(com.facebook.buck.log.CommandThreadFactory) KnownBuildRuleTypesFactory(com.facebook.buck.rules.KnownBuildRuleTypesFactory) ClosedByInterruptException(java.nio.channels.ClosedByInterruptException) LoggingBuildListener(com.facebook.buck.event.listener.LoggingBuildListener) WatchmanWatcher(com.facebook.buck.util.WatchmanWatcher) NanosAdjustedClock(com.facebook.buck.timing.NanosAdjustedClock) ArtifactCacheBuckConfig(com.facebook.buck.artifact_cache.ArtifactCacheBuckConfig) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) Joiner(com.google.common.base.Joiner) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) BuckEventBus(com.facebook.buck.event.BuckEventBus) DefaultExecutionEnvironment(com.facebook.buck.util.environment.DefaultExecutionEnvironment) WebServer(com.facebook.buck.httpserver.WebServer) ProjectFileHashCache(com.facebook.buck.util.cache.ProjectFileHashCache) Config(com.facebook.buck.config.Config) FileSerializationEventBusListener(com.facebook.buck.event.listener.FileSerializationEventBusListener) MoreExecutors.newDirectExecutorService(com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService) RuleKeyCacheRecycler(com.facebook.buck.rules.keys.RuleKeyCacheRecycler) SimpleDateFormat(java.text.SimpleDateFormat) GlobalStateManager(com.facebook.buck.log.GlobalStateManager) TestConfig(com.facebook.buck.test.TestConfig) Watchman(com.facebook.buck.io.Watchman) ArtifactCaches(com.facebook.buck.artifact_cache.ArtifactCaches) ConsoleEvent(com.facebook.buck.event.ConsoleEvent) BuckVersion(com.facebook.buck.model.BuckVersion) StandardCopyOption(java.nio.file.StandardCopyOption) AndroidBuckConfig(com.facebook.buck.android.AndroidBuckConfig) ParserConfig(com.facebook.buck.parser.ParserConfig) DefaultClock(com.facebook.buck.timing.DefaultClock) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ManagementFactory(java.lang.management.ManagementFactory) Nullable(javax.annotation.Nullable) BgProcessKiller(com.facebook.buck.util.BgProcessKiller) MachineReadableLoggerListener(com.facebook.buck.event.listener.MachineReadableLoggerListener) VersionControlBuckConfig(com.facebook.buck.util.versioncontrol.VersionControlBuckConfig) IOException(java.io.IOException) BuckArgsMethods(com.facebook.buck.util.BuckArgsMethods) Architecture(com.facebook.buck.util.environment.Architecture) Pointer(com.sun.jna.Pointer) Paths(java.nio.file.Paths) DefaultAndroidDirectoryResolver(com.facebook.buck.android.DefaultAndroidDirectoryResolver) ProcessTracker(com.facebook.buck.util.perf.ProcessTracker) DaemonEvent(com.facebook.buck.event.DaemonEvent) Preconditions(com.google.common.base.Preconditions) ProcessManager(com.facebook.buck.util.ProcessManager) VersionControlStatsGenerator(com.facebook.buck.util.versioncontrol.VersionControlStatsGenerator) ProjectWatch(com.facebook.buck.io.ProjectWatch) NoSuchFileException(java.nio.file.NoSuchFileException) SuperConsoleEventBusListener(com.facebook.buck.event.listener.SuperConsoleEventBusListener) URL(java.net.URL) Date(java.util.Date) PrintStreamProcessExecutorFactory(com.facebook.buck.util.PrintStreamProcessExecutorFactory) JavaBuckConfig(com.facebook.buck.jvm.java.JavaBuckConfig) ImmutableCollection(com.google.common.collect.ImmutableCollection) RichStream(com.facebook.buck.util.RichStream) FileLock(java.nio.channels.FileLock) JavaUtilsLoggingBuildListener(com.facebook.buck.event.listener.JavaUtilsLoggingBuildListener) NGServer(com.martiansoftware.nailgun.NGServer) PkillProcessManager(com.facebook.buck.util.PkillProcessManager) AnsiEnvironmentChecking(com.facebook.buck.util.AnsiEnvironmentChecking) Locale(java.util.Locale) VersionedTargetGraphCache(com.facebook.buck.versions.VersionedTargetGraphCache) Clock(com.facebook.buck.timing.Clock) NoAndroidSdkException(com.facebook.buck.android.NoAndroidSdkException) Cell(com.facebook.buck.rules.Cell) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) TimeZone(java.util.TimeZone) Platform(com.facebook.buck.util.environment.Platform) StandardOpenOption(java.nio.file.StandardOpenOption) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Configs(com.facebook.buck.config.Configs) UUID(java.util.UUID) DefaultCellPathResolver(com.facebook.buck.rules.DefaultCellPathResolver) DefaultFileHashCache(com.facebook.buck.util.cache.DefaultFileHashCache) BuckPaths(com.facebook.buck.io.BuckPaths) WatchmanDiagnosticEventListener(com.facebook.buck.io.WatchmanDiagnosticEventListener) FileNotFoundException(java.io.FileNotFoundException) CmdLineException(org.kohsuke.args4j.CmdLineException) ConstructorArgMarshaller(com.facebook.buck.rules.ConstructorArgMarshaller) CounterRegistryImpl(com.facebook.buck.counters.CounterRegistryImpl) SimpleConsoleEventBusListener(com.facebook.buck.event.listener.SimpleConsoleEventBusListener) ExecutorPool(com.facebook.buck.step.ExecutorPool) AndroidDirectoryResolver(com.facebook.buck.android.AndroidDirectoryResolver) Optional(java.util.Optional) IntByReference(com.sun.jna.ptr.IntByReference) InvocationInfo(com.facebook.buck.log.InvocationInfo) MoreExecutors.listeningDecorator(com.google.common.util.concurrent.MoreExecutors.listeningDecorator) LogConfig(com.facebook.buck.log.LogConfig) BuckEventListener(com.facebook.buck.event.BuckEventListener) CounterRegistry(com.facebook.buck.counters.CounterRegistry) Supplier(com.google.common.base.Supplier) RemoteLogBuckConfig(com.facebook.buck.util.network.RemoteLogBuckConfig) HashMap(java.util.HashMap) OptionalInt(java.util.OptionalInt) BuildEnvironmentDescription(com.facebook.buck.util.environment.BuildEnvironmentDescription) Libc(com.facebook.buck.util.Libc) ConcurrentMap(java.util.concurrent.ConcurrentMap) EventBus(com.google.common.eventbus.EventBus) HashSet(java.util.HashSet) PublicAnnouncementManager(com.facebook.buck.event.listener.PublicAnnouncementManager) LinkOption(java.nio.file.LinkOption) HttpArtifactCacheEvent(com.facebook.buck.artifact_cache.HttpArtifactCacheEvent) ImmutableList(com.google.common.collect.ImmutableList) CommandMode(com.facebook.buck.util.environment.CommandMode) AsynchronousDirectoryContentsCleaner(com.facebook.buck.io.AsynchronousDirectoryContentsCleaner) WatchmanCursor(com.facebook.buck.io.WatchmanCursor) ExecutionEnvironment(com.facebook.buck.util.environment.ExecutionEnvironment) ExecutorService(java.util.concurrent.ExecutorService) ActionGraphCache(com.facebook.buck.rules.ActionGraphCache) PerfStatsTracking(com.facebook.buck.util.perf.PerfStatsTracking) PrintStream(java.io.PrintStream) Logger(com.facebook.buck.log.Logger) NGContext(com.martiansoftware.nailgun.NGContext) Parser(com.facebook.buck.parser.Parser) LoadBalancerEventsListener(com.facebook.buck.event.listener.LoadBalancerEventsListener) DefaultRuleKeyCache(com.facebook.buck.rules.keys.DefaultRuleKeyCache) MalformedURLException(java.net.MalformedURLException) Semaphore(java.util.concurrent.Semaphore) CacheRateStatsListener(com.facebook.buck.event.listener.CacheRateStatsListener) CellProvider(com.facebook.buck.rules.CellProvider) MostExecutors(com.facebook.buck.util.concurrent.MostExecutors) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Console(com.facebook.buck.util.Console) HumanReadableException(com.facebook.buck.util.HumanReadableException) BuckInitializationDurationEvent(com.facebook.buck.event.BuckInitializationDurationEvent) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) TimeUnit(java.util.concurrent.TimeUnit) ProgressEstimator(com.facebook.buck.event.listener.ProgressEstimator) BuckIsDyingException(com.facebook.buck.util.BuckIsDyingException) Closeable(java.io.Closeable) RuleKeyLoggerListener(com.facebook.buck.event.listener.RuleKeyLoggerListener) DefaultVersionControlCmdLineInterfaceFactory(com.facebook.buck.util.versioncontrol.DefaultVersionControlCmdLineInterfaceFactory) AtomicMoveNotSupportedException(java.nio.file.AtomicMoveNotSupportedException) AsyncCloseable(com.facebook.buck.util.AsyncCloseable) VisibleForTesting(com.google.common.annotations.VisibleForTesting) MoreFiles(com.facebook.buck.io.MoreFiles) FileChannel(java.nio.channels.FileChannel) CommandEvent(com.facebook.buck.event.CommandEvent) AbstractConsoleEventBusListener(com.facebook.buck.event.listener.AbstractConsoleEventBusListener) InputStream(java.io.InputStream) BuckEventBus(com.facebook.buck.event.BuckEventBus) RemoteLogBuckConfig(com.facebook.buck.util.network.RemoteLogBuckConfig) CounterRegistryImpl(com.facebook.buck.counters.CounterRegistryImpl) WatchmanWatcherException(com.facebook.buck.util.WatchmanWatcherException) BuckEventListener(com.facebook.buck.event.BuckEventListener) NanosAdjustedClock(com.facebook.buck.timing.NanosAdjustedClock) DefaultClock(com.facebook.buck.timing.DefaultClock) Clock(com.facebook.buck.timing.Clock) ClosedByInterruptException(java.nio.channels.ClosedByInterruptException) Watchman(com.facebook.buck.io.Watchman) SuperConsoleConfig(com.facebook.buck.event.listener.SuperConsoleConfig) ArtifactCacheBuckConfig(com.facebook.buck.artifact_cache.ArtifactCacheBuckConfig) AndroidBuckConfig(com.facebook.buck.android.AndroidBuckConfig) VersionControlBuckConfig(com.facebook.buck.util.versioncontrol.VersionControlBuckConfig) JavaBuckConfig(com.facebook.buck.jvm.java.JavaBuckConfig) RemoteLogBuckConfig(com.facebook.buck.util.network.RemoteLogBuckConfig) DefaultClock(com.facebook.buck.timing.DefaultClock) ProjectFileHashCache(com.facebook.buck.util.cache.ProjectFileHashCache) PerfStatsTracking(com.facebook.buck.util.perf.PerfStatsTracking) DefaultAndroidDirectoryResolver(com.facebook.buck.android.DefaultAndroidDirectoryResolver) AndroidDirectoryResolver(com.facebook.buck.android.AndroidDirectoryResolver) BuildEnvironmentDescription(com.facebook.buck.util.environment.BuildEnvironmentDescription) DefaultExecutionEnvironment(com.facebook.buck.util.environment.DefaultExecutionEnvironment) BroadcastEventListener(com.facebook.buck.event.listener.BroadcastEventListener) DefaultTypeCoercerFactory(com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) Parser(com.facebook.buck.parser.Parser) WatchmanWatcher(com.facebook.buck.util.WatchmanWatcher) NanosAdjustedClock(com.facebook.buck.timing.NanosAdjustedClock) ConstructorArgMarshaller(com.facebook.buck.rules.ConstructorArgMarshaller) WebServer(com.facebook.buck.httpserver.WebServer) ExecutorPool(com.facebook.buck.step.ExecutorPool) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) CmdLineException(org.kohsuke.args4j.CmdLineException) ImmutableList(com.google.common.collect.ImmutableList) KnownBuildRuleTypesFactory(com.facebook.buck.rules.KnownBuildRuleTypesFactory) VersionControlBuckConfig(com.facebook.buck.util.versioncontrol.VersionControlBuckConfig) TypeCoercerFactory(com.facebook.buck.rules.coercer.TypeCoercerFactory) DefaultTypeCoercerFactory(com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory) BuckPaths(com.facebook.buck.io.BuckPaths) ProcessManager(com.facebook.buck.util.ProcessManager) PkillProcessManager(com.facebook.buck.util.PkillProcessManager) ClassPath(com.google.common.reflect.ClassPath) Path(java.nio.file.Path) DefaultVersionControlCmdLineInterfaceFactory(com.facebook.buck.util.versioncontrol.DefaultVersionControlCmdLineInterfaceFactory) FileSerializationEventBusListener(com.facebook.buck.event.listener.FileSerializationEventBusListener) ProgressEstimator(com.facebook.buck.event.listener.ProgressEstimator) OptionalInt(java.util.OptionalInt) IOException(java.io.IOException) ActionGraphCache(com.facebook.buck.rules.ActionGraphCache) PkillProcessManager(com.facebook.buck.util.PkillProcessManager) PathOrGlobMatcher(com.facebook.buck.io.PathOrGlobMatcher) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) ProcessTracker(com.facebook.buck.util.perf.ProcessTracker) Locale(java.util.Locale) InvocationInfo(com.facebook.buck.log.InvocationInfo) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Closeable(java.io.Closeable) AsyncCloseable(com.facebook.buck.util.AsyncCloseable) JavaBuckConfig(com.facebook.buck.jvm.java.JavaBuckConfig) Verbosity(com.facebook.buck.util.Verbosity) TestResultSummaryVerbosity(com.facebook.buck.test.TestResultSummaryVerbosity) ArtifactCacheBuckConfig(com.facebook.buck.artifact_cache.ArtifactCacheBuckConfig) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) PrintStreamProcessExecutorFactory(com.facebook.buck.util.PrintStreamProcessExecutorFactory) Cell(com.facebook.buck.rules.Cell) CounterRegistry(com.facebook.buck.counters.CounterRegistry) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TestConfig(com.facebook.buck.test.TestConfig) ArtifactCaches(com.facebook.buck.artifact_cache.ArtifactCaches) ConcurrentMap(java.util.concurrent.ConcurrentMap) GlobalStateManager(com.facebook.buck.log.GlobalStateManager) AndroidPlatformTarget(com.facebook.buck.android.AndroidPlatformTarget) AbstractConsoleEventBusListener(com.facebook.buck.event.listener.AbstractConsoleEventBusListener) AndroidBuckConfig(com.facebook.buck.android.AndroidBuckConfig) DefaultExecutionEnvironment(com.facebook.buck.util.environment.DefaultExecutionEnvironment) ExecutionEnvironment(com.facebook.buck.util.environment.ExecutionEnvironment) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) PublicAnnouncementManager(com.facebook.buck.event.listener.PublicAnnouncementManager) SuperConsoleConfig(com.facebook.buck.event.listener.SuperConsoleConfig) ArtifactCacheBuckConfig(com.facebook.buck.artifact_cache.ArtifactCacheBuckConfig) Config(com.facebook.buck.config.Config) TestConfig(com.facebook.buck.test.TestConfig) AndroidBuckConfig(com.facebook.buck.android.AndroidBuckConfig) ParserConfig(com.facebook.buck.parser.ParserConfig) VersionControlBuckConfig(com.facebook.buck.util.versioncontrol.VersionControlBuckConfig) JavaBuckConfig(com.facebook.buck.jvm.java.JavaBuckConfig) LogConfig(com.facebook.buck.log.LogConfig) RemoteLogBuckConfig(com.facebook.buck.util.network.RemoteLogBuckConfig) VersionedTargetGraphCache(com.facebook.buck.versions.VersionedTargetGraphCache) AsyncCloseable(com.facebook.buck.util.AsyncCloseable) Console(com.facebook.buck.util.Console) CommandEvent(com.facebook.buck.event.CommandEvent) VersionControlStatsGenerator(com.facebook.buck.util.versioncontrol.VersionControlStatsGenerator) BuckInitializationDurationEvent(com.facebook.buck.event.BuckInitializationDurationEvent) DefaultCellPathResolver(com.facebook.buck.rules.DefaultCellPathResolver) DefaultAndroidDirectoryResolver(com.facebook.buck.android.DefaultAndroidDirectoryResolver) CommandThreadFactory(com.facebook.buck.log.CommandThreadFactory) Date(java.util.Date) HumanReadableException(com.facebook.buck.util.HumanReadableException) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) MoreExecutors.newDirectExecutorService(com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService) RuleKeyCacheRecycler(com.facebook.buck.rules.keys.RuleKeyCacheRecycler) SimpleDateFormat(java.text.SimpleDateFormat) ParserConfig(com.facebook.buck.parser.ParserConfig)

Aggregations

AndroidBuckConfig (com.facebook.buck.android.AndroidBuckConfig)2 JavaBuckConfig (com.facebook.buck.jvm.java.JavaBuckConfig)2 CommandThreadFactory (com.facebook.buck.log.CommandThreadFactory)2 Platform (com.facebook.buck.util.environment.Platform)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)2 Path (java.nio.file.Path)2 HashMap (java.util.HashMap)2 AndroidAarDescription (com.facebook.buck.android.AndroidAarDescription)1 AndroidBinaryDescription (com.facebook.buck.android.AndroidBinaryDescription)1 AndroidBuildConfigDescription (com.facebook.buck.android.AndroidBuildConfigDescription)1 AndroidDirectoryResolver (com.facebook.buck.android.AndroidDirectoryResolver)1 AndroidInstrumentationApkDescription (com.facebook.buck.android.AndroidInstrumentationApkDescription)1 AndroidInstrumentationTestDescription (com.facebook.buck.android.AndroidInstrumentationTestDescription)1 AndroidLibraryDescription (com.facebook.buck.android.AndroidLibraryDescription)1 AndroidManifestDescription (com.facebook.buck.android.AndroidManifestDescription)1 AndroidPlatformTarget (com.facebook.buck.android.AndroidPlatformTarget)1 AndroidPrebuiltAarDescription (com.facebook.buck.android.AndroidPrebuiltAarDescription)1 AndroidResourceDescription (com.facebook.buck.android.AndroidResourceDescription)1