From eb44094ed24de3a139a21dd6804d99e0acb8caf6 Mon Sep 17 00:00:00 2001 From: Greg Estren Date: Mon, 12 Sep 2016 23:38:51 +0000 Subject: Automated [] rollback of commit dfb2c73eda3d2dd8787ea9b2d0a03b49dfa2acc5. *** Reason for rollback *** commit 4a45d92130a6b1306a3840d006df165b8040a6cf and everything after in [] breaks the Blaze nightlies *** Original change description *** Inject the product name via the per-product main.cc files. Instead of using a compile-time PRODUCT_NAME constant and complex Build rules to set the correct product name for Blaze and Bazel, use the new main.cc files to inject the appropriate value. -- MOS_MIGRATED_REVID=132934596 --- src/main/cpp/main.cc | 5 ++--- src/main/cpp/startup_options.cc | 13 ++++++++++--- src/main/cpp/startup_options.h | 6 ++---- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src/main') diff --git a/src/main/cpp/main.cc b/src/main/cpp/main.cc index 26036e5fe8..c58b826661 100644 --- a/src/main/cpp/main.cc +++ b/src/main/cpp/main.cc @@ -19,8 +19,7 @@ #include "src/main/cpp/startup_options.h" int main(int argc, const char *argv[]) { - std::unique_ptr startup_options( - new blaze::StartupOptions(blaze::BAZEL_PRODUCT_NAME)); return blaze::Main(argc, argv, - new blaze::OptionProcessor(std::move(startup_options))); + new blaze::OptionProcessor( + std::unique_ptr(new blaze::StartupOptions()))); } diff --git a/src/main/cpp/startup_options.cc b/src/main/cpp/startup_options.cc index d88fa52a6b..156cda916d 100644 --- a/src/main/cpp/startup_options.cc +++ b/src/main/cpp/startup_options.cc @@ -28,12 +28,15 @@ #include "src/main/cpp/util/numbers.h" #include "src/main/cpp/util/strings.h" +#ifndef PRODUCT_NAME +#define PRODUCT_NAME "Bazel" +#endif + namespace blaze { using std::vector; -StartupOptions::StartupOptions(const string& product_name) : - product_name(product_name) { +StartupOptions::StartupOptions() { Init(); } @@ -49,7 +52,11 @@ void StartupOptions::Init() { output_root = GetOutputRoot(); } - string product_name_lower = product_name; + // TODO(jmmv): Now that we have per-product main.cc files, inject the + // product_name at construction time instead of using preprocessor + // definitions. + product_name = PRODUCT_NAME; + string product_name_lower = PRODUCT_NAME; blaze_util::ToLower(&product_name_lower); output_user_root = blaze_util::JoinPath( output_root, "_" + product_name_lower + "_" + GetUserName()); diff --git a/src/main/cpp/startup_options.h b/src/main/cpp/startup_options.h index d47d043f1a..d1f33308cb 100644 --- a/src/main/cpp/startup_options.h +++ b/src/main/cpp/startup_options.h @@ -25,8 +25,6 @@ namespace blaze { using std::string; -constexpr char BAZEL_PRODUCT_NAME[] = "Bazel"; - // This class holds the parsed startup options for Blaze. // These options and their defaults must be kept in sync with those in // src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java. @@ -39,7 +37,7 @@ constexpr char BAZEL_PRODUCT_NAME[] = "Bazel"; // names also don't conform to the style guide. class StartupOptions { public: - explicit StartupOptions(const string& product_name); + StartupOptions(); virtual ~StartupOptions(); // Parses a single argument, either from the command line or from the .blazerc @@ -117,7 +115,7 @@ class StartupOptions { const std::vector &user_options, string *error) const; // The capitalized name of this binary. - const string product_name; + string product_name; // Blaze's output base. Everything is relative to this. See // the BlazeDirectories Java class for details. -- cgit v1.2.3