Thrift-1859: Generated error c++ code with -out and include_prefix param
Client: cpp
Patch: Jingxu Chen
Updates output directory to no longer include gen-cpp folder when using -out.
diff --git a/compiler/cpp/src/generate/t_cpp_generator.cc b/compiler/cpp/src/generate/t_cpp_generator.cc
index 34a112d..9eaf7ad 100644
--- a/compiler/cpp/src/generate/t_cpp_generator.cc
+++ b/compiler/cpp/src/generate/t_cpp_generator.cc
@@ -2147,11 +2147,11 @@
indent() << "size_t sz = ifaces_.size();" << endl <<
indent() << "size_t i = 0;" << endl <<
indent() << "for (; i < (sz - 1); ++i) {" << endl;
- indent_up();
- f_header_ <<
+ indent_up();
+ f_header_ <<
indent() << call << ";" << endl;
- indent_down();
- f_header_ <<
+ indent_down();
+ f_header_ <<
indent() << "}" << endl;
if (!(*f_iter)->get_returntype()->is_void()) {
@@ -4615,7 +4615,9 @@
string::size_type last_slash = string::npos;
if ((last_slash = include_prefix.rfind("/")) != string::npos) {
- return include_prefix.substr(0, last_slash) + "/" + out_dir_base_ + "/";
+ return include_prefix.substr(0, last_slash) +
+ (get_program()->is_out_path_absolute() ? "/" : "/" + out_dir_base_ + "/");
+
}
return "";
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
index 60a47d0..12fcf0e 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -80,7 +80,7 @@
const std::string& get_out_path() const { return out_path_; }
// Create gen-* dir accessor
- bool is_out_path_absolute() { return out_path_is_absolute_; }
+ const bool is_out_path_absolute() const { return out_path_is_absolute_; }
// Name accessor
const std::string& get_name() const { return name_; }