// Copyright 2018 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 workspace_log;

option java_package = "com.google.devtools.build.lib.bazel.debug.proto";
option java_outer_classname = "WorkspaceLogProtos";

// Information on "Execute" event in repository_ctx.
message ExecuteEvent {
  // Command line arguments, with the first one being the command to execute.
  repeated string arguments = 2;

  // Timeout used for the command
  int32 timeout_seconds = 3;

  // Environment variables set for the execution. Note that this includes
  // variables specified by the user (as an input to Execute command),
  // as well as variables set indirectly through the rule environment
  map<string, string> environment = 4;

  // True if quiet execution was requested.
  bool quiet = 5;

  // Directory that would contain the output of the command.
  string output_directory = 6;
}

// Information on "Download" event in repository_ctx.
message DownloadEvent {
  // Url to download from. If multiple, treated as mirrors
  repeated string url = 1;
  // Output file
  string output = 2;
  // sha256, if speficied
  string sha256 = 3;
  // whether to make the resulting file executable
  bool executable = 4;
}

message DownloadAndExtractEvent {
  // Url(s) to download from
  repeated string url = 1;
  // Output file
  string output = 2;
  // sha256, if specified
  string sha256 = 3;
  // Archive type, if specified. Otherwise, inferred from URL.
  string type = 4;
  // A directory prefix to strip from extracted files.
  string strip_prefix = 5;
}

message WorkspaceEvent {
  // Location in the code (.bzl file) where the event originates.
  string location = 1;

  // Label of the rule whose evaluation caused this event.
  string rule = 2;

  oneof event {
    ExecuteEvent execute_event = 3;
    DownloadEvent download_event = 4;
    DownloadAndExtractEvent download_and_extract_event = 5;
  }
}
