// Copyright 2023 Google LLC
//
// 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 proxy;

import "google/protobuf/timestamp.proto";

option go_package = "github.com/bazelbuild/reclient/api/proxy";

message DepsDatabase {
  // List of FileInfo objects in the database.
  repeated FileInfo files = 1;

  // List of dependencies.
  repeated Deps deps = 2;

  // Reproxy version string.
  string version = 3;
}

message FileInfo {
  // The absolute path of the file.
  string abs_path = 1;
  // The digest of the relevant content of the file. Relevant content is the
  // content of file that impacts dependencies directly or transitively. This
  // assumes a stable function that maps the entire contents of a file to the
  // relevant contents of a file.
  string digest = 2;
  // The mtime of the file.
  google.protobuf.Timestamp mtime = 3;
}

message Deps {
  // The source file being compiled.
  FileInfo src_file = 1;
  // The hash of the command.
  string command_digest = 2;
  // Timestamp the command cache entry was last referenced.
  google.protobuf.Timestamp last_used = 3;
  // List of unique IDs referring to input files in the DepsDatabase.
  repeated int64 dep_ids = 4;
}
