コード例 #1
0
ファイル: CxxTest.java プロジェクト: sdwilsh/buck
 public CxxTest(
     BuildRuleParams params,
     SourcePathResolver resolver,
     final ImmutableMap<String, String> toolEnv,
     final Supplier<ImmutableMap<String, String>> env,
     Supplier<ImmutableList<String>> args,
     ImmutableSortedSet<SourcePath> resources,
     Supplier<ImmutableSortedSet<BuildRule>> additionalDeps,
     ImmutableSet<Label> labels,
     ImmutableSet<String> contacts,
     boolean runTestSeparately,
     Optional<Long> testRuleTimeoutMs) {
   super(params, resolver);
   this.env =
       Suppliers.memoize(
           () -> {
             ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
             builder.putAll(toolEnv);
             builder.putAll(env.get());
             return builder.build();
           });
   this.args = Suppliers.memoize(args);
   this.resources = resources;
   this.additionalDeps = Suppliers.memoize(additionalDeps);
   this.labels = labels;
   this.contacts = contacts;
   this.runTestSeparately = runTestSeparately;
   this.testRuleTimeoutMs = testRuleTimeoutMs;
 }
コード例 #2
0
 protected Builder<P, D> addOperationalChangeSet(final RootedChangeSet<P, D> changeSet) {
   if (changeSet == null) {
     return this;
   }
   originalOperational.putAll(changeSet.getOriginal());
   createdOperational.putAll(changeSet.getCreated());
   updatedOperational.putAll(changeSet.getUpdated());
   removedOperational.addAll(changeSet.getRemoved());
   return this;
 }
コード例 #3
0
 public ImmutableMap<String, Object> getAllParams() {
   final ImmutableMap.Builder<String, Object> paramb = ImmutableMap.builder();
   for (CypherPart part : nodes.values()) {
     if (part.param != null) {
       paramb.putAll(part.param);
     }
   }
   for (CypherPart part : relationships) {
     if (part.param != null) {
       paramb.putAll(part.param);
     }
   }
   return paramb.build();
 }
コード例 #4
0
 /**
  * Adds all of the given entries to the built bimap. Duplicate keys or values are not allowed,
  * and will cause {@link #build} to fail.
  *
  * @throws NullPointerException if any key, value, or entry is null
  * @since 19.0
  */
 @CanIgnoreReturnValue
 @Beta
 @Override
 public Builder<K, V> putAll(Iterable<? extends Entry<? extends K, ? extends V>> entries) {
   super.putAll(entries);
   return this;
 }
コード例 #5
0
 /**
  * Resolves the headers in `sourceList` and puts them into `sources` for the specificed
  * `buildTarget`.
  */
 public static void putAllHeaders(
     SourceList sourceList,
     ImmutableMap.Builder<String, SourcePath> sources,
     SourcePathResolver pathResolver,
     String parameterName,
     BuildTarget buildTarget) {
   switch (sourceList.getType()) {
     case NAMED:
       sources.putAll(sourceList.getNamedSources().get());
       break;
     case UNNAMED:
       sources.putAll(
           pathResolver.getSourcePathNames(
               buildTarget, parameterName, sourceList.getUnnamedSources().get()));
       break;
   }
 }
コード例 #6
0
 public KeyValueStoreManagerAdapter(
     KeyValueStoreManager manager, Map<String, Integer> keyLengths) {
   this.manager = manager;
   ImmutableMap.Builder<String, Integer> mb = ImmutableMap.builder();
   if (keyLengths != null && !keyLengths.isEmpty()) mb.putAll(keyLengths);
   this.keyLengths = mb.build();
   features = manager.getFeatures().clone();
   features.supportsBatchMutation = false;
 }
コード例 #7
0
 @Override
 public Map<String, ? extends SearchParseElement> parseElements() {
   ImmutableMap.Builder<String, SearchParseElement> parseElements = ImmutableMap.builder();
   parseElements.put("fields", new FieldsParseElement());
   for (FetchSubPhase fetchSubPhase : fetchSubPhases) {
     parseElements.putAll(fetchSubPhase.parseElements());
   }
   return parseElements.build();
 }
コード例 #8
0
 /**
  * Parses one or more CSV format fixing series files.
  *
  * <p>If the files contain a duplicate entry an exception will be thrown.
  *
  * @param charSources the fixing series CSV character sources
  * @return the loaded fixing series, mapped by {@linkplain ObservableId observable ID}
  * @throws IllegalArgumentException if the files contain a duplicate entry
  */
 public static ImmutableMap<ObservableId, LocalDateDoubleTimeSeries> parse(
     Collection<CharSource> charSources) {
   // builder ensures keys can only be seen once
   ImmutableMap.Builder<ObservableId, LocalDateDoubleTimeSeries> builder = ImmutableMap.builder();
   for (CharSource charSource : charSources) {
     builder.putAll(parseSingle(charSource));
   }
   return builder.build();
 }
コード例 #9
0
  private static void putAllSources(
      ImmutableSortedSet<SourceWithFlags> sourcesWithFlags,
      ImmutableMap.Builder<String, SourceWithFlags> sources,
      SourcePathResolver pathResolver,
      BuildTarget buildTarget) {

    sources.putAll(
        pathResolver.getSourcePathNames(
            buildTarget, "srcs", sourcesWithFlags, SourceWithFlags.TO_SOURCE_PATH));
  }
コード例 #10
0
 /**
  * Adds an item to the Project's metadata
  *
  * <p>Beyond it's use here it is also used as a cheap way of generating Operations to both test
  * the OperationApi and the pagination system.
  */
 public static Operation addItemToMetadata(
     ProjectApi projectApi, String projectName, String key, String value) {
   Project project = projectApi.get(projectName);
   assertNotNull(project);
   ImmutableMap.Builder<String, String> metadataBuilder = ImmutableMap.builder();
   metadataBuilder.putAll(project.getCommonInstanceMetadata().getItems());
   metadataBuilder.put(key, value);
   return projectApi.setCommonInstanceMetadata(
       projectName, metadataBuilder.build(), project.getCommonInstanceMetadata().getFingerprint());
 }
コード例 #11
0
 /**
  * Deletes an item from the Project's metadata
  *
  * <p>Beyond it's use here it is also used as a cheap way of generating Operation's to both test
  * the OperationApi and the pagination system.
  */
 public static Operation deleteItemFromMetadata(
     ProjectApi projectApi, String projectName, String key) {
   Project project = projectApi.get(projectName);
   assertNotNull(project);
   ImmutableMap.Builder<String, String> metadataBuilder = ImmutableMap.builder();
   metadataBuilder.putAll(
       Maps.filterKeys(project.getCommonInstanceMetadata().getItems(), not(equalTo(key))));
   return projectApi.setCommonInstanceMetadata(
       projectName, metadataBuilder.build(), project.getCommonInstanceMetadata().getFingerprint());
 }
コード例 #12
0
 /** success constructor */
 public ShardsSyncedFlushResult(
     ShardId shardId,
     String syncId,
     int totalShards,
     Map<ShardRouting, SyncedFlushService.SyncedFlushResponse> shardResponses) {
   this.failureReason = null;
   ImmutableMap.Builder<ShardRouting, SyncedFlushService.SyncedFlushResponse> builder =
       ImmutableMap.builder();
   this.shardResponses = builder.putAll(shardResponses).build();
   this.syncId = syncId;
   this.totalShards = totalShards;
   this.shardId = shardId;
 }
コード例 #13
0
  @Override
  public Map<String, Object> getPersistedConfig() {
    final Map<String, Object> inheritedConfig = super.getPersistedConfig();
    final ImmutableMap.Builder<String, Object> persistedConfig = ImmutableMap.builder();
    persistedConfig.putAll(inheritedConfig);
    persistedConfig.put("field", field);
    persistedConfig.put("stats_function", statsFunction);
    if (!isNullOrEmpty(streamId)) {
      persistedConfig.put("stream_id", streamId);
    }

    return persistedConfig.build();
  }
コード例 #14
0
ファイル: TestSupport.java プロジェクト: ahirreddy/bazel
  /**
   * Returns any additional providers that need to be exported to the rule context to the passed
   * builder.
   */
  public Map<Class<? extends TransitiveInfoProvider>, TransitiveInfoProvider> getExtraProviders() {
    AppleConfiguration configuration = ruleContext.getFragment(AppleConfiguration.class);

    ImmutableMap.Builder<String, String> envBuilder = ImmutableMap.builder();

    envBuilder.putAll(configuration.getEnvironmentForIosAction());

    if (ruleContext.getConfiguration().isCodeCoverageEnabled()) {
      envBuilder.put(
          "COVERAGE_GCOV_PATH",
          ruleContext.getHostPrerequisiteArtifact(":gcov").getExecPathString());
    }

    return ImmutableMap.<Class<? extends TransitiveInfoProvider>, TransitiveInfoProvider>of(
        TestEnvironmentProvider.class, new TestEnvironmentProvider(envBuilder.build()));
  }
コード例 #15
0
 protected Builder<P, D> addTransaction(
     final DataModification<P, D> data, final Predicate<P> keyFilter) {
   updatedOperational.putAll(Maps.filterKeys(data.getUpdatedOperationalData(), keyFilter));
   updatedConfiguration.putAll(Maps.filterKeys(data.getUpdatedConfigurationData(), keyFilter));
   originalConfiguration.putAll(Maps.filterKeys(data.getOriginalConfigurationData(), keyFilter));
   originalOperational.putAll(Maps.filterKeys(data.getOriginalOperationalData(), keyFilter));
   createdOperational.putAll(Maps.filterKeys(data.getCreatedOperationalData(), keyFilter));
   createdConfiguration.putAll(Maps.filterKeys(data.getCreatedConfigurationData(), keyFilter));
   removedOperational.addAll(Sets.filter(data.getRemovedOperationalData(), keyFilter));
   removedConfiguration.addAll(Sets.filter(data.getRemovedConfigurationData(), keyFilter));
   return this;
 }
コード例 #16
0
ファイル: DocIndexMetaData.java プロジェクト: proofy/crate
 private ImmutableMap<ColumnIdent, String> getAnalyzers(
     ColumnIdent columnIdent, Map<String, Object> propertiesMap) {
   ImmutableMap.Builder<ColumnIdent, String> builder = ImmutableMap.builder();
   for (Map.Entry<String, Object> columnEntry : propertiesMap.entrySet()) {
     Map<String, Object> columnProperties = (Map) columnEntry.getValue();
     DataType columnDataType = getColumnDataType(columnProperties);
     ColumnIdent newIdent = childIdent(columnIdent, columnEntry.getKey());
     columnProperties = furtherColumnProperties(columnProperties);
     if (columnDataType == DataTypes.OBJECT
         || (columnDataType.id() == ArrayType.ID
             && ((ArrayType) columnDataType).innerType() == DataTypes.OBJECT)) {
       if (columnProperties.get("properties") != null) {
         builder.putAll(
             getAnalyzers(newIdent, (Map<String, Object>) columnProperties.get("properties")));
       }
     }
     String analyzer = (String) columnProperties.get("analyzer");
     if (analyzer != null) {
       builder.put(newIdent, analyzer);
     }
   }
   return builder.build();
 }
コード例 #17
0
 /**
  * Adds placeholders names and associated values for substitution.
  *
  * @return itself.
  */
 public Invoker setPlaceHolderValues(Map<String, String> keyValuePairs) {
   mPlaceHolders.putAll(keyValuePairs);
   return thisAsT();
 }
コード例 #18
0
 public Builder<P, D> putUpdatedOperational(final Map<? extends P, ? extends D> originalData) {
   updatedOperational.putAll(originalData);
   return this;
 }
コード例 #19
0
ファイル: KnownBuildRuleTypes.java プロジェクト: luthink/buck
  @VisibleForTesting
  static Builder createBuilder(
      BuckConfig config,
      ProcessExecutor processExecutor,
      AndroidDirectoryResolver androidDirectoryResolver,
      Optional<Path> testTempDirOverride)
      throws InterruptedException, IOException {

    Platform platform = Platform.detect();

    AndroidBuckConfig androidConfig = new AndroidBuckConfig(config, platform);
    Optional<String> ndkVersion = androidConfig.getNdkVersion();
    // If a NDK version isn't specified, we've got to reach into the runtime environment to find
    // out which one we will end up using.
    if (!ndkVersion.isPresent()) {
      ndkVersion = androidDirectoryResolver.getNdkVersion();
    }

    AppleConfig appleConfig = new AppleConfig(config);
    final AppleBundle.DebugInfoFormat defaultDebugInfoFormat = appleConfig.getDebugInfoFormat();

    ImmutableMap.Builder<Flavor, AppleCxxPlatform> platformFlavorsToAppleCxxPlatformsBuilder =
        ImmutableMap.builder();
    buildAppleCxxPlatforms(
        appleConfig.getAppleDeveloperDirectorySupplier(processExecutor),
        appleConfig.getExtraToolchainPaths(),
        appleConfig.getExtraPlatformPaths(),
        config,
        appleConfig,
        platformFlavorsToAppleCxxPlatformsBuilder);
    ImmutableMap<Flavor, AppleCxxPlatform> platformFlavorsToAppleCxxPlatforms =
        platformFlavorsToAppleCxxPlatformsBuilder.build();

    // Setup the NDK C/C++ platforms.
    Optional<Path> ndkRoot = androidDirectoryResolver.findAndroidNdkDir();
    ImmutableMap.Builder<NdkCxxPlatforms.TargetCpuType, NdkCxxPlatform> ndkCxxPlatformsBuilder =
        ImmutableMap.builder();
    if (ndkRoot.isPresent()) {
      NdkCxxPlatforms.Compiler.Type compilerType =
          androidConfig.getNdkCompiler().or(NdkCxxPlatforms.DEFAULT_COMPILER_TYPE);
      String gccVersion = androidConfig.getNdkGccVersion().or(NdkCxxPlatforms.DEFAULT_GCC_VERSION);
      NdkCxxPlatforms.Compiler compiler =
          ImmutableNdkCxxPlatforms.Compiler.builder()
              .setType(compilerType)
              .setVersion(
                  compilerType == NdkCxxPlatforms.Compiler.Type.GCC
                      ? gccVersion
                      : androidConfig
                          .getNdkClangVersion()
                          .or(NdkCxxPlatforms.DEFAULT_CLANG_VERSION))
              .setGccVersion(gccVersion)
              .build();
      ndkCxxPlatformsBuilder.putAll(
          NdkCxxPlatforms.getPlatforms(
              new ProjectFilesystem(ndkRoot.get()),
              compiler,
              androidConfig.getNdkCxxRuntime().or(NdkCxxPlatforms.DEFAULT_CXX_RUNTIME),
              androidConfig.getNdkAppPlatform().or(NdkCxxPlatforms.DEFAULT_TARGET_APP_PLATFORM),
              androidConfig.getNdkCpuAbis().or(NdkCxxPlatforms.DEFAULT_CPU_ABIS),
              platform));
    }
    ImmutableMap<NdkCxxPlatforms.TargetCpuType, NdkCxxPlatform> ndkCxxPlatforms =
        ndkCxxPlatformsBuilder.build();

    // Construct the C/C++ config wrapping the buck config.
    CxxBuckConfig cxxBuckConfig = new CxxBuckConfig(config);
    ImmutableMap.Builder<Flavor, CxxPlatform> cxxPlatformsBuilder = ImmutableMap.builder();

    // If an Android NDK is present, add platforms for that.  This is mostly useful for
    // testing our Android NDK support for right now.
    for (NdkCxxPlatform ndkCxxPlatform : ndkCxxPlatforms.values()) {
      cxxPlatformsBuilder.put(
          ndkCxxPlatform.getCxxPlatform().getFlavor(), ndkCxxPlatform.getCxxPlatform());
    }

    for (Map.Entry<Flavor, AppleCxxPlatform> entry :
        platformFlavorsToAppleCxxPlatforms.entrySet()) {
      cxxPlatformsBuilder.put(entry.getKey(), entry.getValue().getCxxPlatform());
    }

    // Add the default, config-defined C/C++ platform.
    CxxPlatform systemDefaultCxxPlatform = DefaultCxxPlatforms.build(platform, cxxBuckConfig);
    cxxPlatformsBuilder.put(systemDefaultCxxPlatform.getFlavor(), systemDefaultCxxPlatform);
    ImmutableMap<Flavor, CxxPlatform> cxxPlatformsMap = cxxPlatformsBuilder.build();

    // Get the default platform from config.
    CxxPlatform defaultCxxPlatform =
        CxxPlatforms.getConfigDefaultCxxPlatform(
            cxxBuckConfig, cxxPlatformsMap, systemDefaultCxxPlatform);

    // Add platforms for each cxx flavor obtained from the buck config files
    // from sections of the form cxx#{flavor name}
    ImmutableSet<Flavor> cxxFlavors = CxxBuckConfig.getCxxFlavors(config);
    for (Flavor flavor : cxxFlavors) {
      CxxBuckConfig flavoredCxxBuckConfig = new CxxBuckConfig(config, flavor);
      CxxPlatform defaultPlatformForFlavor =
          CxxPlatforms.getConfigDefaultCxxPlatform(
              flavoredCxxBuckConfig, cxxPlatformsMap, systemDefaultCxxPlatform);
      cxxPlatformsBuilder.put(
          flavor,
          CxxPlatforms.copyPlatformWithFlavorAndConfig(
              defaultPlatformForFlavor, flavoredCxxBuckConfig, flavor));
    }

    cxxPlatformsMap = cxxPlatformsBuilder.build();

    // Build up the final list of C/C++ platforms.
    FlavorDomain<CxxPlatform> cxxPlatforms = new FlavorDomain<>("C/C++ platform", cxxPlatformsMap);

    DBuckConfig dBuckConfig = new DBuckConfig(config);

    ReactNativeBuckConfig reactNativeBuckConfig = new ReactNativeBuckConfig(config);

    RustBuckConfig rustBuckConfig = new RustBuckConfig(config);

    GoBuckConfig goBuckConfig = new GoBuckConfig(config, processExecutor);

    HalideBuckConfig halideBuckConfig = new HalideBuckConfig(config);

    ProGuardConfig proGuardConfig = new ProGuardConfig(config);

    PythonBuckConfig pyConfig = new PythonBuckConfig(config, new ExecutableFinder());
    ImmutableList<PythonPlatform> pythonPlatformsList =
        pyConfig.getPythonPlatforms(processExecutor);
    ImmutableMap.Builder<Flavor, PythonPlatform> pythonPlatformsMapBuilder = ImmutableMap.builder();
    for (PythonPlatform pythonPlatform : pythonPlatformsList) {
      pythonPlatformsMapBuilder.put(pythonPlatform.getFlavor(), pythonPlatform);
    }
    ImmutableMap<Flavor, PythonPlatform> pythonPlatformsMap = pythonPlatformsMapBuilder.build();
    FlavorDomain<PythonPlatform> pythonPlatforms =
        new FlavorDomain<>("Python Platform", pythonPlatformsMap);
    PythonBinaryDescription pythonBinaryDescription =
        new PythonBinaryDescription(pyConfig, pythonPlatforms, 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.findAndroidSdkDirSafe());
    } else {
      // Or just set one that blows up
      downloader = new ExplodingDownloader();
    }

    Builder builder = builder();

    JavaBuckConfig javaConfig = new JavaBuckConfig(config);
    JavacOptions defaultJavacOptions = javaConfig.getDefaultJavacOptions();

    InferBuckConfig inferBuckConfig = new InferBuckConfig(config);

    CxxBinaryDescription cxxBinaryDescription =
        new CxxBinaryDescription(
            inferBuckConfig, defaultCxxPlatform, cxxPlatforms, cxxBuckConfig.getPreprocessMode());

    CxxLibraryDescription cxxLibraryDescription =
        new CxxLibraryDescription(
            cxxBuckConfig, inferBuckConfig, cxxPlatforms, cxxBuckConfig.getPreprocessMode());

    CodeSignIdentityStore codeSignIdentityStore = CodeSignIdentityStore.fromSystem(processExecutor);
    ProvisioningProfileStore provisioningProfileStore =
        ProvisioningProfileStore.fromSearchPath(appleConfig.getProvisioningProfileSearchPath());

    AppleLibraryDescription appleLibraryDescription =
        new AppleLibraryDescription(
            cxxLibraryDescription,
            cxxPlatforms,
            platformFlavorsToAppleCxxPlatforms,
            defaultCxxPlatform,
            codeSignIdentityStore,
            provisioningProfileStore,
            defaultDebugInfoFormat);
    builder.register(appleLibraryDescription);

    AppleBinaryDescription appleBinaryDescription =
        new AppleBinaryDescription(
            cxxBinaryDescription,
            cxxPlatforms,
            platformFlavorsToAppleCxxPlatforms,
            defaultCxxPlatform,
            codeSignIdentityStore,
            provisioningProfileStore,
            defaultDebugInfoFormat);
    builder.register(appleBinaryDescription);

    // Create an executor service exclusively for the smart dexing step.
    ListeningExecutorService dxExecutorService =
        MoreExecutors.listeningDecorator(
            Executors.newFixedThreadPool(
                SmartDexingStep.determineOptimalThreadCount(),
                new CommandThreadFactory("SmartDexing")));

    builder.register(new AndroidAarDescription(new AndroidManifestDescription(), ndkCxxPlatforms));
    builder.register(
        new AndroidBinaryDescription(
            defaultJavacOptions, proGuardConfig, ndkCxxPlatforms, dxExecutorService));
    builder.register(new AndroidBuildConfigDescription(defaultJavacOptions));
    builder.register(
        new AndroidInstrumentationApkDescription(
            proGuardConfig, defaultJavacOptions, ndkCxxPlatforms, dxExecutorService));
    builder.register(new AndroidInstrumentationTestDescription(defaultTestRuleTimeoutMs));
    builder.register(new AndroidLibraryDescription(defaultJavacOptions));
    builder.register(new AndroidManifestDescription());
    builder.register(new AndroidPrebuiltAarDescription(defaultJavacOptions));
    builder.register(new AndroidReactNativeLibraryDescription(reactNativeBuckConfig));
    builder.register(new AndroidResourceDescription());
    builder.register(new ApkGenruleDescription());
    builder.register(new AppleAssetCatalogDescription());
    builder.register(new ApplePackageDescription());
    AppleBundleDescription appleBundleDescription =
        new AppleBundleDescription(
            appleBinaryDescription,
            appleLibraryDescription,
            cxxPlatforms,
            platformFlavorsToAppleCxxPlatforms,
            defaultCxxPlatform,
            codeSignIdentityStore,
            provisioningProfileStore,
            defaultDebugInfoFormat);
    builder.register(appleBundleDescription);
    builder.register(new AppleResourceDescription());
    builder.register(
        new AppleTestDescription(
            appleConfig,
            appleBundleDescription,
            appleLibraryDescription,
            cxxPlatforms,
            platformFlavorsToAppleCxxPlatforms,
            defaultCxxPlatform,
            codeSignIdentityStore,
            provisioningProfileStore,
            appleConfig.getAppleDeveloperDirectorySupplier(processExecutor)));
    builder.register(new CoreDataModelDescription());
    builder.register(new CSharpLibraryDescription());
    builder.register(cxxBinaryDescription);
    builder.register(cxxLibraryDescription);
    builder.register(
        new CxxPythonExtensionDescription(pythonPlatforms, cxxBuckConfig, cxxPlatforms));
    builder.register(
        new CxxTestDescription(
            cxxBuckConfig, defaultCxxPlatform, cxxPlatforms, defaultTestRuleTimeoutMs));
    builder.register(new DBinaryDescription(dBuckConfig, defaultCxxPlatform));
    builder.register(new DLibraryDescription(dBuckConfig));
    builder.register(
        new DTestDescription(dBuckConfig, defaultTestRuleTimeoutMs, defaultCxxPlatform));
    builder.register(new ExportFileDescription());
    builder.register(new GenruleDescription());
    builder.register(new GenAidlDescription());
    builder.register(new GoBinaryDescription(goBuckConfig, defaultCxxPlatform));
    builder.register(new GoLibraryDescription(goBuckConfig));
    builder.register(
        new GoTestDescription(goBuckConfig, defaultTestRuleTimeoutMs, defaultCxxPlatform));
    builder.register(new GwtBinaryDescription());
    builder.register(
        new HalideLibraryDescription(
            cxxPlatforms, cxxBuckConfig.getPreprocessMode(), halideBuckConfig));
    builder.register(new IosReactNativeLibraryDescription(reactNativeBuckConfig));
    builder.register(new JavaBinaryDescription(defaultJavacOptions, defaultCxxPlatform));
    builder.register(new JavaLibraryDescription(defaultJavacOptions));
    builder.register(
        new JavaTestDescription(
            defaultJavacOptions,
            defaultTestRuleTimeoutMs,
            defaultCxxPlatform,
            testTempDirOverride));
    builder.register(new KeystoreDescription());
    builder.register(new NdkLibraryDescription(ndkVersion, ndkCxxPlatforms));
    OCamlBuckConfig ocamlBuckConfig = new OCamlBuckConfig(platform, config);
    builder.register(new OCamlBinaryDescription(ocamlBuckConfig));
    builder.register(new OCamlLibraryDescription(ocamlBuckConfig));
    builder.register(new PrebuiltCxxLibraryDescription(cxxPlatforms));
    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);
    builder.register(new PythonLibraryDescription());
    builder.register(
        new PythonTestDescription(
            pythonBinaryDescription,
            pyConfig,
            pythonPlatforms,
            defaultCxxPlatform,
            defaultTestRuleTimeoutMs,
            cxxPlatforms));
    builder.register(new RemoteFileDescription(downloader));
    builder.register(
        new RobolectricTestDescription(
            defaultJavacOptions,
            defaultTestRuleTimeoutMs,
            defaultCxxPlatform,
            testTempDirOverride));
    builder.register(new RustBinaryDescription(rustBuckConfig));
    builder.register(new RustLibraryDescription(rustBuckConfig));
    builder.register(new ShBinaryDescription());
    builder.register(new ShTestDescription());
    ThriftBuckConfig thriftBuckConfig = new ThriftBuckConfig(config);
    builder.register(
        new ThriftLibraryDescription(
            thriftBuckConfig,
            ImmutableList.of(
                new ThriftJavaEnhancer(thriftBuckConfig, defaultJavacOptions),
                new ThriftCxxEnhancer(thriftBuckConfig, cxxLibraryDescription, /* cpp2 */ false),
                new ThriftCxxEnhancer(thriftBuckConfig, cxxLibraryDescription, /* cpp2 */ true),
                new ThriftPythonEnhancer(thriftBuckConfig, ThriftPythonEnhancer.Type.NORMAL),
                new ThriftPythonEnhancer(thriftBuckConfig, ThriftPythonEnhancer.Type.TWISTED))));
    builder.register(new XcodePostbuildScriptDescription());
    builder.register(new XcodePrebuildScriptDescription());
    builder.register(new XcodeWorkspaceConfigDescription());
    builder.register(new ZipDescription());

    builder.setCxxPlatforms(cxxPlatforms);
    builder.setDefaultCxxPlatform(defaultCxxPlatform);

    return builder;
  }
コード例 #20
0
    @Override
    public PlanNode rewriteJoin(
        JoinNode node, Expression inheritedPredicate, PlanRewriter<Expression> planRewriter) {
      boolean isCrossJoin = (node.getType() == JoinNode.Type.CROSS);

      // See if we can rewrite outer joins in terms of a plain inner join
      node = tryNormalizeToInnerJoin(node, inheritedPredicate);

      Expression leftEffectivePredicate = EffectivePredicateExtractor.extract(node.getLeft());
      Expression rightEffectivePredicate = EffectivePredicateExtractor.extract(node.getRight());
      Expression joinPredicate = extractJoinPredicate(node);

      Expression leftPredicate;
      Expression rightPredicate;
      Expression postJoinPredicate;
      Expression newJoinPredicate;

      switch (node.getType()) {
        case INNER:
          InnerJoinPushDownResult innerJoinPushDownResult =
              processInnerJoin(
                  inheritedPredicate,
                  leftEffectivePredicate,
                  rightEffectivePredicate,
                  joinPredicate,
                  node.getLeft().getOutputSymbols());
          leftPredicate = innerJoinPushDownResult.getLeftPredicate();
          rightPredicate = innerJoinPushDownResult.getRightPredicate();
          postJoinPredicate = innerJoinPushDownResult.getPostJoinPredicate();
          newJoinPredicate = innerJoinPushDownResult.getJoinPredicate();
          break;
        case LEFT:
          OuterJoinPushDownResult leftOuterJoinPushDownResult =
              processOuterJoin(
                  inheritedPredicate,
                  leftEffectivePredicate,
                  rightEffectivePredicate,
                  joinPredicate,
                  node.getLeft().getOutputSymbols());
          leftPredicate = leftOuterJoinPushDownResult.getOuterJoinPredicate();
          rightPredicate = leftOuterJoinPushDownResult.getInnerJoinPredicate();
          postJoinPredicate = leftOuterJoinPushDownResult.getPostJoinPredicate();
          newJoinPredicate = joinPredicate; // Use the same as the original
          break;
        case RIGHT:
          OuterJoinPushDownResult rightOuterJoinPushDownResult =
              processOuterJoin(
                  inheritedPredicate,
                  rightEffectivePredicate,
                  leftEffectivePredicate,
                  joinPredicate,
                  node.getRight().getOutputSymbols());
          leftPredicate = rightOuterJoinPushDownResult.getInnerJoinPredicate();
          rightPredicate = rightOuterJoinPushDownResult.getOuterJoinPredicate();
          postJoinPredicate = rightOuterJoinPushDownResult.getPostJoinPredicate();
          newJoinPredicate = joinPredicate; // Use the same as the original
          break;
        default:
          throw new UnsupportedOperationException("Unsupported join type: " + node.getType());
      }

      PlanNode leftSource = planRewriter.rewrite(node.getLeft(), leftPredicate);
      PlanNode rightSource = planRewriter.rewrite(node.getRight(), rightPredicate);

      PlanNode output = node;
      if (leftSource != node.getLeft()
          || rightSource != node.getRight()
          || !newJoinPredicate.equals(joinPredicate)) {
        List<JoinNode.EquiJoinClause> criteria = node.getCriteria();

        // Rewrite criteria and add projections if there is a new join predicate

        if (!newJoinPredicate.equals(joinPredicate) || isCrossJoin) {
          // Create identity projections for all existing symbols
          ImmutableMap.Builder<Symbol, Expression> leftProjections = ImmutableMap.builder();
          leftProjections.putAll(
              IterableTransformer.<Symbol>on(node.getLeft().getOutputSymbols())
                  .toMap(symbolToQualifiedNameReference())
                  .map());
          ImmutableMap.Builder<Symbol, Expression> rightProjections = ImmutableMap.builder();
          rightProjections.putAll(
              IterableTransformer.<Symbol>on(node.getRight().getOutputSymbols())
                  .toMap(symbolToQualifiedNameReference())
                  .map());

          // HACK! we don't support cross joins right now, so put in a simple fake join predicate
          // instead if all of the join clauses got simplified out
          // TODO: remove this code when cross join support is added
          Iterable<Expression> simplifiedJoinConjuncts =
              transform(extractConjuncts(newJoinPredicate), simplifyExpressions());
          simplifiedJoinConjuncts =
              filter(
                  simplifiedJoinConjuncts,
                  not(Predicates.<Expression>equalTo(BooleanLiteral.TRUE_LITERAL)));
          if (Iterables.isEmpty(simplifiedJoinConjuncts)) {
            simplifiedJoinConjuncts =
                ImmutableList.<Expression>of(
                    new ComparisonExpression(
                        ComparisonExpression.Type.EQUAL,
                        new LongLiteral("0"),
                        new LongLiteral("0")));
          }

          // Create new projections for the new join clauses
          ImmutableList.Builder<JoinNode.EquiJoinClause> builder = ImmutableList.builder();
          for (Expression conjunct : simplifiedJoinConjuncts) {
            checkState(
                joinEqualityExpression(node.getLeft().getOutputSymbols()).apply(conjunct),
                "Expected join predicate to be a valid join equality");

            ComparisonExpression equality = (ComparisonExpression) conjunct;

            boolean alignedComparison =
                Iterables.all(
                    DependencyExtractor.extractUnique(equality.getLeft()),
                    in(node.getLeft().getOutputSymbols()));
            Expression leftExpression =
                (alignedComparison) ? equality.getLeft() : equality.getRight();
            Expression rightExpression =
                (alignedComparison) ? equality.getRight() : equality.getLeft();

            Symbol leftSymbol =
                symbolAllocator.newSymbol(leftExpression, extractType(leftExpression));
            leftProjections.put(leftSymbol, leftExpression);
            Symbol rightSymbol =
                symbolAllocator.newSymbol(rightExpression, extractType(rightExpression));
            rightProjections.put(rightSymbol, rightExpression);

            builder.add(new JoinNode.EquiJoinClause(leftSymbol, rightSymbol));
          }

          leftSource =
              new ProjectNode(idAllocator.getNextId(), leftSource, leftProjections.build());
          rightSource =
              new ProjectNode(idAllocator.getNextId(), rightSource, rightProjections.build());
          criteria = builder.build();
        }
        output = new JoinNode(node.getId(), node.getType(), leftSource, rightSource, criteria);
      }
      if (!postJoinPredicate.equals(BooleanLiteral.TRUE_LITERAL)) {
        output = new FilterNode(idAllocator.getNextId(), output, postJoinPredicate);
      }
      return output;
    }
コード例 #21
0
 /**
  * Associates all of the given map's keys and values in the built bimap. Duplicate keys or
  * values are not allowed, and will cause {@link #build} to fail.
  *
  * @throws NullPointerException if any key or value in {@code map} is null
  */
 @CanIgnoreReturnValue
 @Override
 public Builder<K, V> putAll(Map<? extends K, ? extends V> map) {
   super.putAll(map);
   return this;
 }
コード例 #22
0
  public static ImmutableList<CxxPreprocessorInput> collectCxxPreprocessorInput(
      TargetGraph targetGraph,
      BuildRuleParams params,
      CxxPlatform cxxPlatform,
      ImmutableMultimap<CxxSource.Type, String> preprocessorFlags,
      ImmutableList<HeaderSymlinkTree> headerSymlinkTrees,
      ImmutableSet<Path> frameworkSearchPaths,
      Iterable<CxxPreprocessorInput> cxxPreprocessorInputFromDeps) {

    // Add the private includes of any rules which list this rule as a test.
    BuildTarget targetWithoutFlavor =
        BuildTarget.of(params.getBuildTarget().getUnflavoredBuildTarget());
    ImmutableList.Builder<CxxPreprocessorInput> cxxPreprocessorInputFromTestedRulesBuilder =
        ImmutableList.builder();
    for (BuildRule rule : params.getDeps()) {
      if (rule instanceof NativeTestable) {
        NativeTestable testable = (NativeTestable) rule;
        if (testable.isTestedBy(targetWithoutFlavor)) {
          LOG.debug(
              "Adding private includes of tested rule %s to testing rule %s",
              rule.getBuildTarget(), params.getBuildTarget());
          cxxPreprocessorInputFromTestedRulesBuilder.add(
              testable.getCxxPreprocessorInput(targetGraph, cxxPlatform, HeaderVisibility.PRIVATE));
        }
      }
    }

    ImmutableList<CxxPreprocessorInput> cxxPreprocessorInputFromTestedRules =
        cxxPreprocessorInputFromTestedRulesBuilder.build();
    LOG.verbose(
        "Rules tested by target %s added private includes %s",
        params.getBuildTarget(), cxxPreprocessorInputFromTestedRules);

    ImmutableMap.Builder<Path, SourcePath> allLinks = ImmutableMap.builder();
    ImmutableMap.Builder<Path, SourcePath> allFullLinks = ImmutableMap.builder();
    ImmutableList.Builder<Path> allIncludeRoots = ImmutableList.builder();
    ImmutableSet.Builder<Path> allHeaderMaps = ImmutableSet.builder();
    for (HeaderSymlinkTree headerSymlinkTree : headerSymlinkTrees) {
      allLinks.putAll(headerSymlinkTree.getLinks());
      allFullLinks.putAll(headerSymlinkTree.getFullLinks());
      allIncludeRoots.add(headerSymlinkTree.getIncludePath());
      allHeaderMaps.addAll(headerSymlinkTree.getHeaderMap().asSet());
    }

    CxxPreprocessorInput localPreprocessorInput =
        CxxPreprocessorInput.builder()
            .addAllRules(Iterables.transform(headerSymlinkTrees, HasBuildTarget.TO_TARGET))
            .putAllPreprocessorFlags(preprocessorFlags)
            .setIncludes(
                CxxHeaders.builder()
                    .putAllNameToPathMap(allLinks.build())
                    .putAllFullNameToPathMap(allFullLinks.build())
                    .build())
            .addAllIncludeRoots(allIncludeRoots.build())
            .addAllHeaderMaps(allHeaderMaps.build())
            .addAllFrameworkRoots(frameworkSearchPaths)
            .build();

    return ImmutableList.<CxxPreprocessorInput>builder()
        .add(localPreprocessorInput)
        .addAll(cxxPreprocessorInputFromDeps)
        .addAll(cxxPreprocessorInputFromTestedRules)
        .build();
  }
コード例 #23
0
 /**
  * Set a bunch of properties for the Pack200 algorithm. See {@link java.util.jar.Pack200 } for a
  * list of supported properties.
  *
  * @param props properties to set
  */
 public Builder putAllPack200Props(Map<String, String> props) {
   pack200Props.putAll(checkNotNull(props, "props"));
   return this;
 }
コード例 #24
0
ファイル: Backend.java プロジェクト: roy-luoll/titan
 /**
  * Get information about all registered {@link IndexProvider}s.
  *
  * @return
  */
 public Map<String, IndexInformation> getIndexInformation() {
   ImmutableMap.Builder<String, IndexInformation> copy = ImmutableMap.builder();
   copy.putAll(indexes);
   copy.put(Titan.Token.STANDARD_INDEX, StandardIndexInformation.INSTANCE);
   return copy.build();
 }