Esempio n. 1
0
 @Override
 public Label getDefault(Rule rule, BuildConfiguration configuration) {
   // If --proguard_top is not specified, null is returned. AndroidSdk will take care of
   // using
   // android_sdk.proguard then.
   return configuration.getFragment(AndroidConfiguration.class).getProguardLabel();
 }
 @Nullable
 private static CppConfiguration getCppConfiguration(ConfiguredTarget base) {
   BuildConfiguration configuration = base.getConfiguration();
   if (configuration != null) {
     return configuration.getFragment(CppConfiguration.class);
   }
   return null;
 }
 public CppCompileActionBuilder setDotdFile(PathFragment outputName, String extension) {
   if (CppFileTypes.mustProduceDotdFile(outputName.toString())) {
     if (configuration.getFragment(CppConfiguration.class).getInmemoryDotdFiles()) {
       // Just set the path, no artifact is constructed
       PathFragment file = FileSystemUtils.replaceExtension(outputName, extension);
       Root root = configuration.getBinDirectory();
       dotdFile = new DotdFile(root.getExecPath().getRelative(file));
     } else {
       dotdFile = new DotdFile(ruleContext.getRelatedArtifact(outputName, extension));
     }
   } else {
     dotdFile = null;
   }
   return this;
 }
 /**
  * Creates a builder for an owner that is not required to be rule.
  *
  * <p>If errors are found when creating the {@code CppCompileAction}, builders constructed this
  * way will throw a runtime exception.
  */
 @VisibleForTesting
 public CppCompileActionBuilder(
     ActionOwner owner,
     AnalysisEnvironment analysisEnvironment,
     Artifact sourceFile,
     Label sourceLabel,
     BuildConfiguration configuration) {
   this.owner = owner;
   this.actionContext = CppCompileActionContext.class;
   this.cppConfiguration = configuration.getFragment(CppConfiguration.class);
   this.analysisEnvironment = analysisEnvironment;
   this.sourceFile = sourceFile;
   this.sourceLabel = sourceLabel;
   this.configuration = configuration;
   this.mandatoryInputsBuilder = NestedSetBuilder.stableOrder();
   this.pluginInputsBuilder = NestedSetBuilder.stableOrder();
   this.lipoScannableMap = ImmutableMap.of();
 }
Esempio n. 5
0
 @Override
 public Label resolve(Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
   return configuration.getFragment(AndroidConfiguration.class).getSdk();
 }
Esempio n. 6
0
 @Override
 public Label getDefault(Rule rule, BuildConfiguration configuration) {
   return configuration.getFragment(JavaConfiguration.class).getToolchainLabel();
 }
Esempio n. 7
0
 @Override
 public List<Label> getDefault(Rule rule, BuildConfiguration configuration) {
   return ImmutableList.copyOf(
       configuration.getFragment(JavaConfiguration.class).getExtraProguardSpecs());
 }
Esempio n. 8
0
 @Override
 public Label getDefault(Rule rule, BuildConfiguration configuration) {
   return configuration.getFragment(JavaConfiguration.class).getProguardBinary();
 }
Esempio n. 9
0
 @Override
 public Label getDefault(Rule rule, BuildConfiguration configuration) {
   return configuration.getFragment(Jvm.class).getJvmLabel();
 }
Esempio n. 10
0
 @Override
 public Label getDefault(Rule rule, BuildConfiguration configuration) {
   return configuration.getFragment(AndroidConfiguration.class).getSdk();
 }
Esempio n. 11
0
  private LinkCommandLine(
      String actionName,
      BuildConfiguration configuration,
      ActionOwner owner,
      Artifact output,
      @Nullable Artifact interfaceOutput,
      ImmutableList<Artifact> buildInfoHeaderArtifacts,
      Iterable<? extends LinkerInput> linkerInputs,
      Iterable<? extends LinkerInput> runtimeInputs,
      LinkTargetType linkTargetType,
      LinkStaticness linkStaticness,
      ImmutableList<String> linkopts,
      ImmutableSet<String> features,
      ImmutableMap<Artifact, Artifact> linkstamps,
      ImmutableList<String> linkstampCompileOptions,
      @Nullable String fdoBuildStamp,
      @Nullable PathFragment runtimeSolibDir,
      boolean nativeDeps,
      boolean useTestOnlyFlags,
      boolean needWholeArchive,
      @Nullable Artifact paramFile,
      Artifact interfaceSoBuilder,
      List<String> noWholeArchiveFlags,
      CcToolchainFeatures.Variables variables,
      @Nullable FeatureConfiguration featureConfiguration) {

    this.actionName = actionName;
    this.configuration = Preconditions.checkNotNull(configuration);
    this.cppConfiguration = configuration.getFragment(CppConfiguration.class);
    this.variables = variables;
    this.featureConfiguration = featureConfiguration;
    this.owner = Preconditions.checkNotNull(owner);
    this.output = output;
    this.interfaceOutput = interfaceOutput;
    if (interfaceOutput != null) {
      Preconditions.checkNotNull(this.output);
    }

    this.buildInfoHeaderArtifacts = Preconditions.checkNotNull(buildInfoHeaderArtifacts);
    this.linkerInputs = Preconditions.checkNotNull(linkerInputs);
    this.runtimeInputs = Preconditions.checkNotNull(runtimeInputs);
    this.linkTargetType = Preconditions.checkNotNull(linkTargetType);
    this.linkStaticness = Preconditions.checkNotNull(linkStaticness);
    // For now, silently ignore linkopts if this is a static library link.
    this.linkopts =
        linkTargetType.isStaticLibraryLink()
            ? ImmutableList.<String>of()
            : Preconditions.checkNotNull(linkopts);
    this.features = Preconditions.checkNotNull(features);
    this.linkstamps = Preconditions.checkNotNull(linkstamps);
    this.linkstampCompileOptions = linkstampCompileOptions;
    this.fdoBuildStamp = fdoBuildStamp;
    this.runtimeSolibDir = runtimeSolibDir;
    this.nativeDeps = nativeDeps;
    this.useTestOnlyFlags = useTestOnlyFlags;
    this.paramFile = paramFile;
    this.noWholeArchiveFlags = noWholeArchiveFlags;

    // For now, silently ignore interfaceSoBuilder if we don't build an interface dynamic library.
    this.interfaceSoBuilder =
        ((linkTargetType == LinkTargetType.DYNAMIC_LIBRARY) && (interfaceOutput != null))
            ? Preconditions.checkNotNull(
                interfaceSoBuilder, "cannot build interface dynamic library without builder")
            : null;
  }
Esempio n. 12
0
  /**
   * Builds the Action as configured and returns the to be generated Artifact.
   *
   * <p>This method may be called multiple times to create multiple compile actions (usually after
   * calling some setters to modify the generated action).
   */
  public CppCompileAction build() {
    // Configuration can be null in tests.
    NestedSetBuilder<Artifact> realMandatoryInputsBuilder = NestedSetBuilder.compileOrder();
    realMandatoryInputsBuilder.addTransitive(mandatoryInputsBuilder.build());
    String filename = sourceFile.getFilename();
    // Assembler without C preprocessing can use the '.include' pseudo-op which is not
    // understood by the include scanner, so we'll disable scanning, and instead require
    // the declared sources to state (possibly overapproximate) the dependencies.
    // Assembler with preprocessing can also use '.include', but supporting both kinds
    // of inclusion for that use-case is ridiculous.
    boolean shouldScanIncludes =
        !CppFileTypes.ASSEMBLER.matches(filename)
            && configuration != null
            && configuration.getFragment(CppConfiguration.class).shouldScanIncludes();
    if (tempOutputFile == null && !shouldScanIncludes) {
      realMandatoryInputsBuilder.addTransitive(context.getDeclaredIncludeSrcs());
    }
    realMandatoryInputsBuilder.addTransitive(context.getAdditionalInputs());
    realMandatoryInputsBuilder.addTransitive(pluginInputsBuilder.build());
    realMandatoryInputsBuilder.add(sourceFile);
    boolean fake = tempOutputFile != null;

    // Copying the collections is needed to make the builder reusable.
    if (fake) {
      return new FakeCppCompileAction(
          owner,
          ImmutableList.copyOf(features),
          featureConfiguration,
          variables,
          sourceFile,
          shouldScanIncludes,
          sourceLabel,
          realMandatoryInputsBuilder.build(),
          outputFile,
          tempOutputFile,
          dotdFile,
          configuration,
          cppConfiguration,
          context,
          actionContext,
          ImmutableList.copyOf(copts),
          ImmutableList.copyOf(pluginOpts),
          getNocoptPredicate(nocopts),
          extraSystemIncludePrefixes,
          fdoBuildStamp,
          ruleContext,
          usePic);
    } else {
      NestedSet<Artifact> realMandatoryInputs = realMandatoryInputsBuilder.build();

      return new CppCompileAction(
          owner,
          ImmutableList.copyOf(features),
          featureConfiguration,
          variables,
          sourceFile,
          shouldScanIncludes,
          sourceLabel,
          realMandatoryInputs,
          outputFile,
          dotdFile,
          gcnoFile,
          getDwoFile(ruleContext, outputFile, cppConfiguration),
          optionalSourceFile,
          configuration,
          cppConfiguration,
          context,
          actionContext,
          ImmutableList.copyOf(copts),
          ImmutableList.copyOf(pluginOpts),
          getNocoptPredicate(nocopts),
          extraSystemIncludePrefixes,
          fdoBuildStamp,
          includeResolver,
          getLipoScannables(realMandatoryInputs),
          actionClassId,
          usePic,
          ruleContext);
    }
  }