THRIFT-1069. general: Add command line option to prevent thrift from inserting gen-* directories
This patch adds a -out switch that allows for an absolute path to be set for outputting generated code.
Patch: Jake Farrell
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1076000 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
index 440d151..0d05eed 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -60,13 +60,15 @@
t_program(std::string path, std::string name) :
path_(path),
name_(name),
- out_path_("./") {
+ out_path_("./"),
+ out_path_is_absolute_(false) {
scope_ = new t_scope();
}
t_program(std::string path) :
path_(path),
- out_path_("./") {
+ out_path_("./"),
+ out_path_is_absolute_(false) {
name_ = program_name(path);
scope_ = new t_scope();
}
@@ -77,6 +79,9 @@
// Output path accessor
const std::string& get_out_path() const { return out_path_; }
+ // Create gen-* dir accessor
+ bool is_out_path_absolute() { return out_path_is_absolute_; }
+
// Name accessor
const std::string& get_name() const { return name_; }
@@ -108,8 +113,9 @@
// Programs to include
const std::vector<t_program*>& get_includes() const { return includes_; }
- void set_out_path(std::string out_path) {
+ void set_out_path(std::string out_path, bool out_path_is_absolute) {
out_path_ = out_path;
+ out_path_is_absolute_ = out_path_is_absolute;
// Ensure that it ends with a trailing '/' (or '\' for windows machines)
char c = out_path_.at(out_path_.size() - 1);
if (!(c == '/' || c == '\\')) {
@@ -228,6 +234,9 @@
// Output directory
std::string out_path_;
+ // Output directory is absolute location for generated source (no gen-*)
+ bool out_path_is_absolute_;
+
// Namespace
std::string namespace_;