[thrift] Output dir selection + updated TSCons

Summary: Allows setting the output directory via the new '-o dir' cmdline option.

  TSCons is updated to use this to put the output in the right place no matter
  the cwd, so doing dependent builds from different directories won't break.

Reviewed By: martin
Test Plan: mkdir /tmp/honk; thrift -cpp -java -javabean -php -phpi -py -rb -xsd -perl -erl -ocaml -hs -cocoa -o /tmp/honk Tablet.thrift
Revert: svn


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665311 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
index f7516a3..224c9d5 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -46,12 +46,14 @@
  public:
   t_program(std::string path, std::string name) :
     path_(path),
-    name_(name) {
+    name_(name),
+    out_path_("./") {
     scope_ = new t_scope();
   }
 
   t_program(std::string path) :
-    path_(path) {
+    path_(path),
+    out_path_("./") {
     name_ = program_name(path);
     scope_ = new t_scope();
   }
@@ -59,6 +61,9 @@
   // Path accessor
   const std::string& get_path() const { return path_; }
 
+  // Output path accessor
+  const std::string& get_out_path() const { return out_path_; }
+
   // Name accessor
   const std::string& get_name() const { return name_; }
 
@@ -84,6 +89,15 @@
   // Programs to include
   const std::vector<t_program*>& get_includes() const { return includes_; }
 
+  void set_out_path(std::string out_path) {
+    out_path_ = out_path;
+    // Ensure that it ends with a trailing '/' (or '\' for windows machines)
+    char c = out_path_.at(out_path_.size() - 1);
+    if (!(c == '/' || c == '\\')) {
+      out_path_.push_back('/');
+    }
+  }
+
   // Scoping and namespacing
   void set_namespace(std::string name) {
     namespace_ = name;
@@ -186,6 +200,9 @@
   // Name
   std::string name_;
 
+  // Output directory
+  std::string out_path_;
+
   // Namespace
   std::string namespace_;