Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 39c5d78b authored by Chris Warrington's avatar Chris Warrington Committed by Android (Google) Code Review
Browse files

Merge "AAPT2: Automatic Static Library Namespacing."

parents 948c50de 481f027d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -677,6 +677,10 @@ class CompileContext : public IAaptContext {
    return 0;
  }

  bool IsAutoNamespace() override {
    return false;
  }

 private:
  DISALLOW_COPY_AND_ASSIGN(CompileContext);

+4 −0
Original line number Diff line number Diff line
@@ -310,6 +310,10 @@ class Context : public IAaptContext {
    return 0u;
  }

  bool IsAutoNamespace() override {
    return false;
  }

  bool verbose_ = false;
  std::string package_;

+4 −0
Original line number Diff line number Diff line
@@ -64,6 +64,10 @@ class DiffContext : public IAaptContext {
    return 0;
  }

  bool IsAutoNamespace() override {
    return false;
  }

 private:
  std::string empty_;
  StdErrDiagnostics diagnostics_;
+4 −0
Original line number Diff line number Diff line
@@ -298,6 +298,10 @@ class DumpContext : public IAaptContext {
    return 0;
  }

  bool IsAutoNamespace() override {
    return false;
  }

 private:
  StdErrDiagnostics diagnostics_;
  bool verbose_ = false;
+24 −1
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ struct LinkOptions {

  // Static lib options.
  bool no_static_lib_packages = false;
  bool auto_namespace_static_lib = false;

  // AndroidManifest.xml massaging options.
  ManifestFixerOptions manifest_fixer_options;
@@ -193,6 +194,14 @@ class LinkContext : public IAaptContext {
    min_sdk_version_ = minSdk;
  }

  bool IsAutoNamespace() override {
    return auto_namespace_;
  }

  void SetAutoNamespace(bool val) {
    auto_namespace_ = val;
  }

 private:
  DISALLOW_COPY_AND_ASSIGN(LinkContext);

@@ -204,6 +213,7 @@ class LinkContext : public IAaptContext {
  SymbolTable symbols_;
  bool verbose_ = false;
  int min_sdk_version_ = 0;
  bool auto_namespace_ = false;
};

// A custom delegate that generates compatible pre-O IDs for use with feature splits.
@@ -2112,6 +2122,10 @@ int Link(const std::vector<StringPiece>& args, IDiagnostics* diagnostics) {
          .OptionalSwitch("--no-static-lib-packages",
                          "Merge all library resources under the app's package.",
                          &options.no_static_lib_packages)
          .OptionalSwitch("--auto-namespace-static-lib",
                          "Automatically namespace resource references when building a static\n"
                          "library.",
                          &options.auto_namespace_static_lib)
          .OptionalSwitch("--non-final-ids",
                          "Generates R.java without the final modifier. This is implied when\n"
                          "--static-lib is specified.",
@@ -2221,6 +2235,15 @@ int Link(const std::vector<StringPiece>& args, IDiagnostics* diagnostics) {
    options.output_format = OutputFormat::kProto;
  }

  if (options.auto_namespace_static_lib) {
    if (!static_lib) {
      context.GetDiagnostics()->Error(
          DiagMessage() << "--auto-namespace-static-lib can only be used with --static-lib");
      return 1;
    }
    context.SetAutoNamespace(true);
  }

  if (package_id) {
    if (context.GetPackageType() != PackageType::kApp) {
      context.GetDiagnostics()->Error(
Loading