// Copyright 2015 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 = "proto2";

package devtools.xcode;
option java_outer_classname = "BundleMergeProtos";
option java_package = "com.google.devtools.build.xcode.bundlemerge.proto";

// Contains all the arguments necessary to drive the BundleMerge tool,
// including the path to the output file and extra files to include in the
// bundle.
// Next Id: 17
message Control {
  // Previously used fields.
  reserved 1, 3, 9, 11, 13;

  // The single info.plist file to be bundled into the archive. This plist will
  // not be modified by bundlemerge.
  optional string bundle_info_plist_file = 16;

  // Path to the .ipa file to write. This is the final application bundle. Note
  // this is ignored for nested bundles.
  optional string out_file = 2;

  // One of the symbols in the com.google.devtools.build.xcode.common.Platform
  // (e.g. "DEVICE", "SIMULATOR").
  optional string platform = 4;

  // The version of the SDK used to build the app.
  optional string sdk_version = 5;

  // Earliest iOS version on which the app will run.
  optional string minimum_os_version = 6;

  // The directory inside which all files are placed in the final bundle.
  // For the top-most bundle, this is generally "Payload/{app_name}.app". If
  // this bundle is nested, then this bundle_root is relative to to the parent's
  // bundle_root.
  optional string bundle_root = 7;

  // All files to put in the bundle besides automatically-generated files such
  // as Info.plist and PkgInfo. This should include the application binary.
  repeated BundleFile bundle_file = 8;

  // Zip files to merge with the final zip. Note that bundle_root is ignored
  // when merging zips, so to place items in the bundle root, you should do one
  // of the following:
  // 1. make the merge_zips have entries that are named "{bundle_root}/foo"
  //    rather than just "foo"
  // 2. set the root property on the MergeZip protobuf to {bundle_root}
  // Note that the paths of these zips are always relative to the zip file root
  // - they are not relative to the containing bundle.
  repeated MergeZip merge_zip = 10;

  // Bundles that are nested within this one. bundle_root in these bundles is
  // relative to the containing bundle's bundle_root.
  repeated Control nested_bundle = 12;

  // A reverse-DNS string identifier for this bundle.
  optional string primary_bundle_identifier = 14;

  // A fallback bundle identifier used when primary is not filled.
  optional string fallback_bundle_identifier = 15;
}

// Represents a zip file to merge with the final zip.
message MergeZip {
  // The prefix to prepend to every entry name before putting it in the final
  // zip. For instance, "Payload/Foo.app/" (notice the final slash).
  optional string entry_name_prefix = 1;

  // The path to the source file to merge.
  optional string source_path = 2;
}

message BundleFile {
  // The path of the file to put in the bundle.
  optional string source_file = 1;

  // The path of the file in the bundle, relative to the bundle root.
  optional string bundle_path = 2;

  // The external file attribute field in the central directory record in the
  // .zip file. If omitted, the ZipInputEntry.DEFAULT_EXTERNAL_FILE_ATTRIBUTE
  // constant is used.
  optional int32 external_file_attribute = 3;
}
