Пример #1
0
  public ApplicationManifest createSplitManifest(
      RuleContext ruleContext, String splitName, boolean hasCode) {
    // aapt insists that manifests be called AndroidManifest.xml, even though they have to be
    // explicitly designated as manifests on the command line
    Artifact result =
        AndroidBinary.getDxArtifact(ruleContext, "split_" + splitName + "/AndroidManifest.xml");
    SpawnAction.Builder builder =
        new SpawnAction.Builder()
            .setExecutable(
                ruleContext.getExecutablePrerequisite("$build_split_manifest", Mode.HOST))
            .setProgressMessage("Creating manifest for split " + splitName)
            .setMnemonic("AndroidBuildSplitManifest")
            .addArgument("--main_manifest")
            .addInputArgument(manifest)
            .addArgument("--split_manifest")
            .addOutputArgument(result)
            .addArgument("--split")
            .addArgument(splitName)
            .addArgument(hasCode ? "--hascode" : "--nohascode");

    String overridePackage = getOverridePackage(ruleContext);
    if (overridePackage != null) {
      builder.addArgument("--override_package").addArgument(overridePackage);
    }

    ruleContext.registerAction(builder.build(ruleContext));
    return new ApplicationManifest(result);
  }
Пример #2
0
  public ApplicationManifest addStubApplication(RuleContext ruleContext) {

    Artifact stubManifest =
        ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.STUB_APPLICATON_MANIFEST);

    SpawnAction.Builder builder =
        new SpawnAction.Builder()
            .setExecutable(ruleContext.getExecutablePrerequisite("$stubify_manifest", Mode.HOST))
            .setProgressMessage("Injecting stub application")
            .setMnemonic("InjectStubApplication")
            .addArgument("--input_manifest")
            .addInputArgument(manifest)
            .addArgument("--output_manifest")
            .addOutputArgument(stubManifest)
            .addArgument("--output_datafile")
            .addOutputArgument(
                ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.STUB_APPLICATION_DATA));

    String overridePackage = getOverridePackage(ruleContext);
    if (overridePackage != null) {
      builder.addArgument("--override_package");
      builder.addArgument(overridePackage);
    }

    ruleContext.registerAction(builder.build(ruleContext));

    return new ApplicationManifest(stubManifest);
  }
  private static Action[] makePackageManifestAction(
      RuleContext ruleContext, Artifact packageManifest, Collection<Artifact> sourceFiles) {

    return new SpawnAction.Builder()
        .addInputs(sourceFiles)
        .addOutput(packageManifest)
        .setExecutable(ruleContext.getExecutablePrerequisite("$packageParser", Mode.HOST))
        .setCommandLine(
            CustomCommandLine.builder()
                .addExecPath("--output_manifest", packageManifest)
                .addJoinStrings("--sources", ":", toSerializedArtifactLocations(sourceFiles))
                .build())
        .useParameterFile(ParameterFileType.SHELL_QUOTED)
        .setProgressMessage("Parsing java package strings for " + ruleContext.getRule())
        .setMnemonic("JavaPackageManifest")
        .build(ruleContext);
  }
Пример #4
0
  private void createJarJarActions(
      JavaTargetAttributes.Builder attributes,
      ImmutableList.Builder<Artifact> jarsProducedForRuntime,
      Iterable<ResourceContainer> resourceContainers,
      String originalPackage,
      Artifact binaryResourcesJar) {
    // Now use jarjar for the rest of the resources. We need to make a copy
    // of the final generated resources for each of the targets included in
    // the transitive closure of this binary.
    for (ResourceContainer otherContainer : resourceContainers) {
      if (otherContainer.getLabel().equals(ruleContext.getLabel())) {
        continue;
      }

      Artifact resourcesJar = createResourceJarArtifact(ruleContext, otherContainer, ".jar");
      // combined resource constants copy needs to come before library classes that may contain
      // their local resource constants
      attributes.addRuntimeClassPathEntry(resourcesJar);

      Artifact jarJarRuleFile =
          createResourceJarArtifact(ruleContext, otherContainer, ".jar_jarjar_rules.txt");

      String jarJarRule =
          String.format("rule %s.* %s.@1", originalPackage, otherContainer.getJavaPackage());
      ruleContext.registerAction(
          new FileWriteAction(ruleContext.getActionOwner(), jarJarRuleFile, jarJarRule, false));

      FilesToRunProvider jarjar = ruleContext.getExecutablePrerequisite("$jarjar_bin", Mode.HOST);

      ruleContext.registerAction(
          new SpawnAction.Builder()
              .setExecutable(jarjar)
              .addArgument("process")
              .addInputArgument(jarJarRuleFile)
              .addInputArgument(binaryResourcesJar)
              .addOutputArgument(resourcesJar)
              .setProgressMessage("Repackaging jar")
              .setMnemonic("AndroidRepackageJar")
              .build(ruleContext));
      jarsProducedForRuntime.add(resourcesJar);
    }
  }
Пример #5
0
  private void registerXcodegenActions(XcodeProvider.Project project) {
    Artifact controlFile =
        ObjcRuleClasses.intermediateArtifacts(ruleContext).pbxprojControlArtifact();

    ruleContext.registerAction(
        new BinaryFileWriteAction(
            ruleContext.getActionOwner(),
            controlFile,
            xcodegenControlFileBytes(project),
            /*makeExecutable=*/ false));

    ruleContext.registerAction(
        new SpawnAction.Builder()
            .setMnemonic("GenerateXcodeproj")
            .setExecutable(ruleContext.getExecutablePrerequisite("$xcodegen", Mode.HOST))
            .addArgument("--control")
            .addInputArgument(controlFile)
            .addOutput(ruleContext.getImplicitOutputArtifact(XcodeSupport.PBXPROJ))
            .addTransitiveInputs(project.getInputsToXcodegen())
            .build(ruleContext));
  }
Пример #6
0
 /** Returns the location of the swiftstdlibtoolwrapper. */
 FilesToRunProvider swiftStdlibToolWrapper() {
   return ruleContext.getExecutablePrerequisite("$swiftstdlibtoolwrapper", Mode.HOST);
 }
Пример #7
0
 FilesToRunProvider bundleMergeExecutable() {
   return checkNotNull(ruleContext.getExecutablePrerequisite("$bundlemerge", Mode.HOST));
 }