Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 1 | // Copyright 2016 The Bazel Authors. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | // |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 15 | // global_variables.h: The global state in the blaze.cc Blaze client. |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 16 | // |
| 17 | |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 18 | #ifndef BAZEL_SRC_MAIN_CPP_GLOBAL_VARIABLES_H_ |
| 19 | #define BAZEL_SRC_MAIN_CPP_GLOBAL_VARIABLES_H_ |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 20 | |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 21 | #include <sys/types.h> |
| 22 | #include <string> |
| 23 | #include <vector> |
| 24 | |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 25 | namespace blaze { |
| 26 | |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 27 | class OptionProcessor; |
| 28 | class StartupOptions; |
| 29 | |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 30 | // The reason for a blaze server restart. |
Thiago Farina | 36c1d15 | 2016-05-04 14:24:14 +0000 | [diff] [blame] | 31 | // Keep in sync with logging.proto. |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 32 | enum RestartReason { NO_RESTART = 0, NO_DAEMON, NEW_VERSION, NEW_OPTIONS }; |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 33 | |
| 34 | struct GlobalVariables { |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 35 | GlobalVariables(OptionProcessor *option_processor); |
| 36 | |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 37 | // Used to make concurrent invocations of this program safe. |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 38 | std::string lockfile; // = <output_base>/lock |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 39 | |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 40 | std::string jvm_log_file; // = <output_base>/server/jvm.out |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 41 | |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 42 | std::string cwd; |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 43 | |
| 44 | // The nearest enclosing workspace directory, starting from cwd. |
| 45 | // If not under a workspace directory, this is equal to cwd. |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 46 | std::string workspace; |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 47 | |
| 48 | // Option processor responsible for parsing RC files and converting them into |
| 49 | // the argument list passed on to the server. |
Julio Merino | 2877485 | 2016-09-14 16:59:46 +0000 | [diff] [blame] | 50 | OptionProcessor *option_processor; |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 51 | |
Eric Fellheimer | 3a695f3 | 2016-05-11 17:26:30 +0000 | [diff] [blame] | 52 | // The path of the JVM executable that should be used to launch Blaze. |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 53 | std::string jvm_path; |
Eric Fellheimer | 3a695f3 | 2016-05-11 17:26:30 +0000 | [diff] [blame] | 54 | |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 55 | pid_t server_pid; |
| 56 | |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 57 | // Contains the relative paths of all the files in the attached zip, and is |
Thiago Farina | 3820e8d | 2016-04-05 23:52:40 +0000 | [diff] [blame] | 58 | // populated during GetInstallBase(). |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 59 | std::vector<std::string> extracted_binaries; |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 60 | |
Thiago Farina | 36c1d15 | 2016-05-04 14:24:14 +0000 | [diff] [blame] | 61 | // Parsed startup options. |
Julio Merino | 2877485 | 2016-09-14 16:59:46 +0000 | [diff] [blame] | 62 | StartupOptions *options; // TODO(jmmv): This should really be const. |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 63 | |
Thiago Farina | 36c1d15 | 2016-05-04 14:24:14 +0000 | [diff] [blame] | 64 | // The time in ms the launcher spends before sending the request to the blaze |
| 65 | // server. |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 66 | uint64_t startup_time; |
| 67 | |
Thiago Farina | 36c1d15 | 2016-05-04 14:24:14 +0000 | [diff] [blame] | 68 | // The time in ms spent on extracting the new blaze version. |
| 69 | // This is part of startup_time. |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 70 | uint64_t extract_data_time; |
| 71 | |
Thiago Farina | 36c1d15 | 2016-05-04 14:24:14 +0000 | [diff] [blame] | 72 | // The time in ms a command had to wait on a busy Blaze server process. |
| 73 | // This is part of startup_time. |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 74 | uint64_t command_wait_time; |
| 75 | |
Thiago Farina | 36c1d15 | 2016-05-04 14:24:14 +0000 | [diff] [blame] | 76 | // The reason for the server restart. |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 77 | RestartReason restart_reason; |
| 78 | |
Thiago Farina | 36c1d15 | 2016-05-04 14:24:14 +0000 | [diff] [blame] | 79 | // The absolute path of the blaze binary. |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 80 | std::string binary_path; |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 81 | |
| 82 | // MD5 hash of the Blaze binary (includes deploy.jar, extracted binaries, and |
| 83 | // anything else that ends up under the install_base). |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 84 | std::string install_md5; |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | } // namespace blaze |
Thiago Farina | 319fd3a | 2016-01-14 19:42:24 +0000 | [diff] [blame] | 88 | |
Thiago Farina | 676cb9f | 2016-10-06 11:00:43 +0000 | [diff] [blame] | 89 | #endif // BAZEL_SRC_MAIN_CPP_GLOBAL_VARIABLES_H_ |