// Copyright 2016 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";
package blaze.apk_manifest;

option java_package = "com.google.devtools.build.lib.rules.android.apkmanifest";

message Artifact {
  // This path is relative to "bazel info execution_root"
  string exec_root_path = 1;
  bytes hash = 2;
  // The label of the rule that produced this artifact.
  string label = 3;
}

message NativeLib {
  repeated Artifact native_libs = 1;
  string arch = 2;
}

message AndroidSdk {
  string aapt = 1;
  string adb = 2;
  string aidl = 3;
  string android_jar = 4;
  string annotations_jar = 5;
  string apkbuilder = 6;
  string dx = 7;
  string framework_aidl = 8;
  string jack = 9;
  string jill = 10;
  string main_dex_classes = 11;
  string main_dex_list_creator = 12;
  string proguard = 13;
  string resource_extractor = 14;
  string shrinked_android_jar = 15;
  string zipalign = 16;
  string build_tools_version = 17; // assume latest if not set
  string apksigner = 18;
}

// Information about a resource referenced from AndroidManifest.xml.
message AndroidManifestResource {

  message ValueHash {

    // The qualifier for the value of the resource, e.g. for localization or
    // device properties like hdpi, xhdpi, etc.
    string qualifier = 1;

    // A hash of the value of the resource (e.g. the hash of the string value
    // of a resource if it's a string), or if the resource points to a file, a
    // hash of the file (e.g. if the resource is an image, then a hash of the
    // image file).
    bytes hash = 2;
  }

  // The name of the resource, e.g. "app_name" in "@string/app_name".
  string name = 1;

  // The type of the resource, e.g. "string" in "@string/app_name".
  string type = 2;

  repeated ValueHash value_hashes = 3;
}

message ApkManifest {

  // Information about the AndroidSdk
  AndroidSdk android_sdk = 1;

  // All the jars containing the classes that would be dex and go into the APK
  repeated Artifact jars = 2;

  // The .ap_ that contains the resources that go into the APK
  Artifact resource_apk = 3;

  // The native library files that go into the APK
  repeated NativeLib native_lib = 4;

  // The final merged AndroidManifest.xml file (in text, i.e. non-binary, XML)
  Artifact android_manifest = 5;

  // Information about resources referenced from AndroidManifest.xml.
  repeated AndroidManifestResource android_manifest_resources = 6;

  // Location of the debug keystore file.
  Artifact debug_keystore = 7;
}
