示例#1
0
  @Nullable
  private AspectValue createAspect(
      Environment env,
      AspectKey key,
      ConfiguredAspectFactory aspectFactory,
      RuleConfiguredTarget associatedTarget,
      Set<ConfigMatchingProvider> configConditions,
      ListMultimap<Attribute, ConfiguredTarget> directDeps,
      NestedSetBuilder<Package> transitivePackages)
      throws AspectFunctionException, InterruptedException {

    SkyframeBuildView view = buildViewProvider.getSkyframeBuildView();
    BuildConfiguration configuration = associatedTarget.getConfiguration();

    StoredEventHandler events = new StoredEventHandler();
    CachingAnalysisEnvironment analysisEnvironment =
        view.createAnalysisEnvironment(key, false, events, env, configuration);
    if (env.valuesMissing()) {
      return null;
    }

    ConfiguredAspect configuredAspect =
        view.getConfiguredTargetFactory()
            .createAspect(
                analysisEnvironment,
                associatedTarget,
                aspectFactory,
                key.getAspect(),
                directDeps,
                configConditions,
                view.getHostConfiguration(associatedTarget.getConfiguration()));

    events.replayOn(env.getListener());
    if (events.hasErrors()) {
      analysisEnvironment.disable(associatedTarget.getTarget());
      throw new AspectFunctionException(
          new AspectCreationException(
              "Analysis of target '" + associatedTarget.getLabel() + "' failed; build aborted"));
    }
    Preconditions.checkState(
        !analysisEnvironment.hasErrors(), "Analysis environment hasError() but no errors reported");

    if (env.valuesMissing()) {
      return null;
    }

    analysisEnvironment.disable(associatedTarget.getTarget());
    Preconditions.checkNotNull(configuredAspect);

    return new AspectValue(
        key,
        associatedTarget.getLabel(),
        associatedTarget.getTarget().getLocation(),
        configuredAspect,
        ImmutableList.copyOf(analysisEnvironment.getRegisteredActions()),
        transitivePackages.build());
  }
示例#2
0
 @Nullable
 public Aspect createAspect(
     AnalysisEnvironment env,
     RuleConfiguredTarget associatedTarget,
     ConfiguredAspectFactory aspectFactory,
     ListMultimap<Attribute, ConfiguredTarget> prerequisiteMap,
     Set<ConfigMatchingProvider> configConditions,
     AspectParameters aspectParameters) {
   return factory.createAspect(
       env,
       associatedTarget,
       aspectFactory,
       aspectParameters,
       prerequisiteMap,
       configConditions,
       getHostConfiguration(associatedTarget.getConfiguration()));
 }