// Copyright 2017 Google Inc. 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.

// copy from https://googleplex-android.googlesource.com/platform/build/soong/+/afa116d431cea6fc77cea243f1b024daf8596a64/ui/status/ninja_frontend/frontend.proto

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

package ninja;
option go_package = "go.chromium.org/build/siso/toolsupport/soongutil/proto";

message Status {
  message TotalEdges {
    // New value for total edges in the build.
    optional uint32 total_edges = 1;
  }

  message BuildStarted {
    // Number of jobs Ninja will run in parallel.
    optional uint32 parallelism = 1;
    // Verbose value passed to ninja.
    optional bool verbose = 2;
    // Critical path's running time in milliseconds
    optional uint32 critical_path_time = 3;
    // Total running time of every need-to-build edge in milliseconds
    optional uint32 estimated_total_time = 4;
  }

  message BuildFinished {
  }

  message EdgeStarted {
    // Edge identification number, unique to a Ninja run.
    optional uint32 id = 1;
    // Edge start time in milliseconds since Ninja started.
    optional uint32 start_time = 2;
    // List of edge inputs.
    repeated string inputs = 3;
    // List of edge outputs.
    repeated string outputs = 4;
    // Description field from the edge.
    optional string desc = 5;
    // Command field from the edge.
    optional string command = 6;
    // Edge uses console.
    optional bool console = 7;
    // Changed inputs since last build.
    repeated string changed_inputs = 8;
  }

  message EdgeFinished {
    // Edge identification number, unique to a Ninja run.
    optional uint32 id = 1;
    // Edge end time in milliseconds since Ninja started.
    optional uint32 end_time = 2;
    // Exit status (0 for success).
    optional sint32 status = 3;
    // Edge output, may contain ANSI codes.
    optional string output = 4;
    // Number of milliseconds spent executing in user mode
    optional uint32 user_time = 5;
    // Number of milliseconds spent executing in kernel mode
    optional uint32 system_time = 6;
    // Max resident set size in kB
    optional uint64 max_rss_kb = 7;
    // Minor page faults
    optional uint64 minor_page_faults = 8;
    // Major page faults
    optional uint64 major_page_faults = 9;
    // IO input in kB
    optional uint64 io_input_kb = 10;
    // IO output in kB
    optional uint64 io_output_kb = 11;
    // Voluntary context switches
    optional uint64 voluntary_context_switches = 12;
    // Involuntary context switches
    optional uint64 involuntary_context_switches = 13;
    // Arbitrary tags for build system profiling (module names and types, rule
    // names, etc). Format of the string is implementation defined.
    optional string tags = 14;
    // True if edge was canceled.
    optional bool canceled = 15;
  }

  message Message {
    enum Level {
      INFO = 0;
      WARNING = 1;
      ERROR = 2;
      DEBUG = 3;
    }
    // Message priority level (DEBUG, INFO, WARNING, ERROR).
    optional Level level = 1 [default = INFO];
    // Info/warning/error message from Ninja.
    optional string message = 2;
  }

  optional TotalEdges total_edges = 1;
  optional BuildStarted build_started = 2;
  optional BuildFinished build_finished = 3;
  optional EdgeStarted edge_started = 4;
  optional EdgeFinished edge_finished = 5;
  optional Message message = 6;
}
