aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Kristina Chodorow <kchodorow@google.com>2015-10-06 03:54:45 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2015-10-06 07:04:18 +0000
commit9ce9b0f44d5176623c9b3a1837d596f74d97c7ed (patch)
tree8ef8ca7a33f3c8af9777152aeb4b983fe7bfec18 /src
parent3a509bdb1fd842f66b2efe75d6c619605904f8aa (diff)
*** Reason for rollback *** This is causing segfaults. *** Original change description *** Remove copy ctor and operator= from BlazeStartupOptions -- MOS_MIGRATED_REVID=104726824
Diffstat (limited to 'src')
-rw-r--r--src/main/cpp/BUILD1
-rw-r--r--src/main/cpp/blaze_startup_options.cc35
-rw-r--r--src/main/cpp/blaze_startup_options.h20
-rw-r--r--src/main/cpp/blaze_startup_options_common.cc29
-rw-r--r--src/main/cpp/extra_startup_options.h24
5 files changed, 80 insertions, 29 deletions
diff --git a/src/main/cpp/BUILD b/src/main/cpp/BUILD
index 6ea2bb3326..7954a67dab 100644
--- a/src/main/cpp/BUILD
+++ b/src/main/cpp/BUILD
@@ -50,7 +50,6 @@ cc_binary(
"blaze_startup_options.h",
"blaze_startup_options_common.cc",
"blaze_util_platform.h",
- "extra_startup_options.h",
"option_processor.cc",
"option_processor.h",
],
diff --git a/src/main/cpp/blaze_startup_options.cc b/src/main/cpp/blaze_startup_options.cc
index b5aa5ce42e..7e0a158b43 100644
--- a/src/main/cpp/blaze_startup_options.cc
+++ b/src/main/cpp/blaze_startup_options.cc
@@ -32,6 +32,41 @@ using std::vector;
struct StartupOptions {};
+BlazeStartupOptions::BlazeStartupOptions() {
+ Init();
+}
+
+BlazeStartupOptions::BlazeStartupOptions(const BlazeStartupOptions &rhs)
+ : output_base(rhs.output_base),
+ install_base(rhs.install_base),
+ output_root(rhs.output_root),
+ output_user_root(rhs.output_user_root),
+ block_for_lock(rhs.block_for_lock),
+ host_jvm_debug(rhs.host_jvm_debug),
+ host_jvm_profile(rhs.host_jvm_profile),
+ host_jvm_args(rhs.host_jvm_args),
+ batch(rhs.batch),
+ batch_cpu_scheduling(rhs.batch_cpu_scheduling),
+ io_nice_level(rhs.io_nice_level),
+ max_idle_secs(rhs.max_idle_secs),
+ skyframe(rhs.skyframe),
+ blaze_cpu(rhs.blaze_cpu),
+ watchfs(rhs.watchfs),
+ allow_configurable_attributes(rhs.allow_configurable_attributes),
+ option_sources(rhs.option_sources),
+ webstatus_port(rhs.webstatus_port),
+ invocation_policy(rhs.invocation_policy),
+ host_javabase(rhs.host_javabase) {}
+
+BlazeStartupOptions::~BlazeStartupOptions() {
+}
+
+BlazeStartupOptions& BlazeStartupOptions::operator=(
+ const BlazeStartupOptions &rhs) {
+ Copy(rhs, this);
+ return *this;
+}
+
string BlazeStartupOptions::GetProductName() {
return "Bazel";
}
diff --git a/src/main/cpp/blaze_startup_options.h b/src/main/cpp/blaze_startup_options.h
index f1ea54520f..f29ab3fcb0 100644
--- a/src/main/cpp/blaze_startup_options.h
+++ b/src/main/cpp/blaze_startup_options.h
@@ -15,16 +15,18 @@
#define BAZEL_SRC_MAIN_CPP_BLAZE_STARTUP_OPTIONS_H_
#include <map>
+#include <memory>
#include <string>
#include <vector>
-#include "src/main/cpp/extra_startup_options.h"
#include "src/main/cpp/util/exit_code.h"
namespace blaze {
using std::string;
+struct StartupOptions;
+
// This class holds the parsed startup options for Blaze.
// These options and their defaults must be kept in sync with those
// in java/com/google/devtools/build/lib/blaze/BlazeServerStartupOptions.
@@ -38,6 +40,9 @@ using std::string;
class BlazeStartupOptions {
public:
BlazeStartupOptions();
+ BlazeStartupOptions(const BlazeStartupOptions &rhs);
+ ~BlazeStartupOptions();
+ BlazeStartupOptions& operator=(const BlazeStartupOptions &rhs);
// Returns the capitalized name of this binary.
string GetProductName();
@@ -158,8 +163,9 @@ class BlazeStartupOptions {
std::map<string, string> option_sources;
// This can be used for site-specific startup options. For Bazel, this is
- // stubbed out.
- ExtraStartupOptions extra_options;
+ // stubbed
+ // out.
+ std::unique_ptr<StartupOptions> extra_options;
// Given the working directory, returns the nearest enclosing directory with a
// WORKSPACE file in it. If there is no such enclosing directory, returns "".
@@ -198,6 +204,14 @@ class BlazeStartupOptions {
private:
string host_javabase;
+ // Sets default values for members.
+ void Init();
+
+ // Copies member variables from rhs to lhs. This cannot use the compiler-
+ // generated copy constructor because extra_options is a unique_ptr and
+ // unique_ptr deletes its copy constructor.
+ void Copy(const BlazeStartupOptions &rhs, BlazeStartupOptions *lhs);
+
// Returns the directory to use for storing outputs.
string GetOutputRoot();
};
diff --git a/src/main/cpp/blaze_startup_options_common.cc b/src/main/cpp/blaze_startup_options_common.cc
index c151c7eedb..914f7ab4e5 100644
--- a/src/main/cpp/blaze_startup_options_common.cc
+++ b/src/main/cpp/blaze_startup_options_common.cc
@@ -26,7 +26,7 @@
namespace blaze {
-BlazeStartupOptions::BlazeStartupOptions() {
+void BlazeStartupOptions::Init() {
bool testing = getenv("TEST_TMPDIR") != NULL;
if (testing) {
output_root = MakeAbsolute(getenv("TEST_TMPDIR"));
@@ -61,6 +61,33 @@ string BlazeStartupOptions::GetHostJavabase() {
return host_javabase;
}
+void BlazeStartupOptions::Copy(
+ const BlazeStartupOptions &rhs, BlazeStartupOptions *lhs) {
+ assert(lhs);
+
+ lhs->output_base = rhs.output_base;
+ lhs->install_base = rhs.install_base;
+ lhs->output_root = rhs.output_root;
+ lhs->output_user_root = rhs.output_user_root;
+ lhs->block_for_lock = rhs.block_for_lock;
+ lhs->host_jvm_debug = rhs.host_jvm_debug;
+ lhs->host_jvm_profile = rhs.host_jvm_profile;
+ lhs->host_javabase = rhs.host_javabase;
+ lhs->host_jvm_args = rhs.host_jvm_args;
+ lhs->batch = rhs.batch;
+ lhs->batch_cpu_scheduling = rhs.batch_cpu_scheduling;
+ lhs->io_nice_level = rhs.io_nice_level;
+ lhs->max_idle_secs = rhs.max_idle_secs;
+ lhs->skyframe = rhs.skyframe;
+ lhs->blaze_cpu = rhs.blaze_cpu;
+ lhs->webstatus_port = rhs.webstatus_port;
+ lhs->watchfs = rhs.watchfs;
+ lhs->allow_configurable_attributes = rhs.allow_configurable_attributes;
+ lhs->fatal_event_bus_exceptions = rhs.fatal_event_bus_exceptions;
+ lhs->option_sources = rhs.option_sources;
+ lhs->invocation_policy = rhs.invocation_policy;
+}
+
blaze_exit_code::ExitCode BlazeStartupOptions::ProcessArg(
const string &argstr, const string &next_argstr, const string &rcfile,
bool *is_space_separated, string *error) {
diff --git a/src/main/cpp/extra_startup_options.h b/src/main/cpp/extra_startup_options.h
deleted file mode 100644
index b4394a1e5e..0000000000
--- a/src/main/cpp/extra_startup_options.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2015 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.
-#ifndef BAZEL_SRC_MAIN_CPP_BLAZE_EXTRA_STARTUP_OPTIONS_H_
-#define BAZEL_SRC_MAIN_CPP_BLAZE_EXTRA_STARTUP_OPTIONS_H_
-
-namespace blaze {
-
-struct ExtraStartupOptions {
-};
-
-}
-
-#endif // BAZEL_SRC_MAIN_CPP_BLAZE_EXTRA_STARTUP_OPTIONS_H_