THRIFT-1552 Include paths for c/c++ should be prefixed with 'thrift/'

To ensure there are no include path collisions the C and C++ header
include paths should include 'thrift' as the root leaf. This will
prevent having to place /usr/include/thrift into the compilers include
header search path, which might otherwise result in the compiler
accidentally picking up headers that it shouldn't.

e.g. #include <foo/bar.h> should be #include <thrift/foo/bar.h>

Change-Id: I48f2b0f549bda0fc81e85506ac857adc800b98a1

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1325674 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/compiler.vcxproj b/compiler/cpp/compiler.vcxproj
index a01f3f2..16ea2c0 100644
--- a/compiler/cpp/compiler.vcxproj
+++ b/compiler/cpp/compiler.vcxproj
@@ -19,66 +19,66 @@
     </ProjectConfiguration>
   </ItemGroup>
   <ItemGroup>
-    <ClInclude Include="src\generate\t_generator.h" />
-    <ClInclude Include="src\generate\t_generator_registry.h" />
-    <ClInclude Include="src\generate\t_oop_generator.h" />
-    <ClInclude Include="src\globals.h" />
-    <ClInclude Include="src\main.h" />
-    <ClInclude Include="src\md5.h" />
-    <ClInclude Include="src\parse\t_base_type.h" />
-    <ClInclude Include="src\parse\t_const.h" />
-    <ClInclude Include="src\parse\t_const_value.h" />
-    <ClInclude Include="src\parse\t_container.h" />
-    <ClInclude Include="src\parse\t_doc.h" />
-    <ClInclude Include="src\parse\t_enum.h" />
-    <ClInclude Include="src\parse\t_enum_value.h" />
-    <ClInclude Include="src\parse\t_field.h" />
-    <ClInclude Include="src\parse\t_function.h" />
-    <ClInclude Include="src\parse\t_list.h" />
-    <ClInclude Include="src\parse\t_map.h" />
-    <ClInclude Include="src\parse\t_program.h" />
-    <ClInclude Include="src\parse\t_scope.h" />
-    <ClInclude Include="src\parse\t_service.h" />
-    <ClInclude Include="src\parse\t_set.h" />
-    <ClInclude Include="src\parse\t_struct.h" />
-    <ClInclude Include="src\parse\t_type.h" />
-    <ClInclude Include="src\parse\t_typedef.h" />
-    <ClInclude Include="src\platform.h" />
-    <ClInclude Include="src\thrifty.h" />
-    <ClInclude Include="src\windows\config.h" />
-    <ClInclude Include="src\windows\version.h" />
+    <ClInclude Include="src\thrift\generate\t_generator.h" />
+    <ClInclude Include="src\thrift\generate\t_generator_registry.h" />
+    <ClInclude Include="src\thrift\generate\t_oop_generator.h" />
+    <ClInclude Include="src\thrift\globals.h" />
+    <ClInclude Include="src\thrift\main.h" />
+    <ClInclude Include="src\thrift\md5.h" />
+    <ClInclude Include="src\thrift\parse\t_base_type.h" />
+    <ClInclude Include="src\thrift\parse\t_const.h" />
+    <ClInclude Include="src\thrift\parse\t_const_value.h" />
+    <ClInclude Include="src\thrift\parse\t_container.h" />
+    <ClInclude Include="src\thrift\parse\t_doc.h" />
+    <ClInclude Include="src\thrift\parse\t_enum.h" />
+    <ClInclude Include="src\thrift\parse\t_enum_value.h" />
+    <ClInclude Include="src\thrift\parse\t_field.h" />
+    <ClInclude Include="src\thrift\parse\t_function.h" />
+    <ClInclude Include="src\thrift\parse\t_list.h" />
+    <ClInclude Include="src\thrift\parse\t_map.h" />
+    <ClInclude Include="src\thrift\parse\t_program.h" />
+    <ClInclude Include="src\thrift\parse\t_scope.h" />
+    <ClInclude Include="src\thrift\parse\t_service.h" />
+    <ClInclude Include="src\thrift\parse\t_set.h" />
+    <ClInclude Include="src\thrift\parse\t_struct.h" />
+    <ClInclude Include="src\thrift\parse\t_type.h" />
+    <ClInclude Include="src\thrift\parse\t_typedef.h" />
+    <ClInclude Include="src\thrift\platform.h" />
+    <ClInclude Include="src\thrift\thrifty.h" />
+    <ClInclude Include="src\thrift\windows\config.h" />
+    <ClInclude Include="src\thrift\windows\version.h" />
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="src\generate\t_as3_generator.cc" />
-    <ClCompile Include="src\generate\t_cocoa_generator.cc" />
-    <ClCompile Include="src\generate\t_cpp_generator.cc" />
-    <ClCompile Include="src\generate\t_csharp_generator.cc" />
-    <ClCompile Include="src\generate\t_c_glib_generator.cc" />
-    <ClCompile Include="src\generate\t_erl_generator.cc" />
-    <ClCompile Include="src\generate\t_generator.cc" />
-    <ClCompile Include="src\generate\t_go_generator.cc" />
-    <ClCompile Include="src\generate\t_hs_generator.cc" />
-    <ClCompile Include="src\generate\t_html_generator.cc" />
-    <ClCompile Include="src\generate\t_javame_generator.cc" />
-    <ClCompile Include="src\generate\t_java_generator.cc" />
-    <ClCompile Include="src\generate\t_js_generator.cc" />
-    <ClCompile Include="src\generate\t_ocaml_generator.cc" />
-    <ClCompile Include="src\generate\t_perl_generator.cc" />
-    <ClCompile Include="src\generate\t_php_generator.cc" />
-    <ClCompile Include="src\generate\t_py_generator.cc" />
-    <ClCompile Include="src\generate\t_rb_generator.cc" />
-    <ClCompile Include="src\generate\t_st_generator.cc" />
-    <ClCompile Include="src\generate\t_xsd_generator.cc" />
-    <ClCompile Include="src\main.cc" />
-    <ClCompile Include="src\md5.c" />
-    <ClCompile Include="src\parse\parse.cc" />
-    <ClCompile Include="src\thriftl.cc" />
-    <ClCompile Include="src\thrifty.cc" />
+    <ClCompile Include="src\thrift\generate\t_as3_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_cocoa_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_cpp_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_csharp_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_c_glib_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_erl_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_go_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_hs_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_html_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_javame_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_java_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_js_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_ocaml_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_perl_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_php_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_py_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_rb_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_st_generator.cc" />
+    <ClCompile Include="src\thrift\generate\t_xsd_generator.cc" />
+    <ClCompile Include="src\thrift\main.cc" />
+    <ClCompile Include="src\thrift\md5.c" />
+    <ClCompile Include="src\thrift\parse\parse.cc" />
+    <ClCompile Include="src\thrift\thriftl.cc" />
+    <ClCompile Include="src\thrift\thrifty.cc" />
   </ItemGroup>
   <ItemGroup>
     <None Include="README_WINDOWS" />
-    <None Include="src\thriftl.ll" />
-    <None Include="src\thrifty.yy" />
+    <None Include="src\thrift\thriftl.ll" />
+    <None Include="src\thrift\thrifty.yy" />
   </ItemGroup>
   <PropertyGroup Label="Globals">
     <ProjectGuid>{89975A1A-F799-4556-98B8-64E30AB39A90}</ProjectGuid>
@@ -126,25 +126,25 @@
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>true</LinkIncremental>
-    <IncludePath>$(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(IncludePath)</IncludePath>
+    <IncludePath>$(ProjectDir)\src\thrift\;$(ProjectDir)\src\windows\;$(IncludePath)</IncludePath>
     <TargetName>thrift</TargetName>
     <ExecutablePath>$(ExecutablePath);C:\Program Files (x86)\Git\bin</ExecutablePath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <LinkIncremental>true</LinkIncremental>
-    <IncludePath>$(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(IncludePath)</IncludePath>
+    <IncludePath>$(ProjectDir)\src\thrift\;$(ProjectDir)\src\windows\;$(IncludePath)</IncludePath>
     <TargetName>thrift</TargetName>
     <ExecutablePath>$(ExecutablePath);C:\Program Files (x86)\Git\bin</ExecutablePath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <LinkIncremental>false</LinkIncremental>
-    <IncludePath>$(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(IncludePath)</IncludePath>
+    <IncludePath>$(ProjectDir)\src\thrift\;$(ProjectDir)\src\windows\;$(IncludePath)</IncludePath>
     <TargetName>thrift</TargetName>
     <ExecutablePath>$(ExecutablePath);C:\Program Files (x86)\Git\bin</ExecutablePath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <LinkIncremental>false</LinkIncremental>
-    <IncludePath>$(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(IncludePath)</IncludePath>
+    <IncludePath>$(ProjectDir)\src\thrift\;$(ProjectDir)\src\windows\;$(IncludePath)</IncludePath>
     <TargetName>thrift</TargetName>
     <ExecutablePath>$(ExecutablePath);C:\Program Files (x86)\Git\bin</ExecutablePath>
   </PropertyGroup>
@@ -163,8 +163,8 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
     </Link>
     <PreBuildEvent>
-      <Command>flex -o "src/thriftl.cc" src/thriftl.ll
-bison -y -o "src/thrifty.cc" --defines="src/thrifty.h" src/thrifty.yy</Command>
+      <Command>flex -o "src\thrift\thriftl.cc" src/thriftl.ll
+bison -y -o "src\thrift\thrifty.cc" --defines="src/thrifty.h" src/thrifty.yy</Command>
     </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -182,8 +182,8 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
     </Link>
     <PreBuildEvent>
-      <Command>flex -o "src/thriftl.cc" src/thriftl.ll
-bison -y -o "src/thrifty.cc" --defines="src/thrifty.h" src/thrifty.yy</Command>
+      <Command>flex -o "src\thrift\thriftl.cc" src/thriftl.ll
+bison -y -o "src\thrift\thrifty.cc" --defines="src/thrifty.h" src/thrifty.yy</Command>
     </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -205,8 +205,8 @@
       <OptimizeReferences>true</OptimizeReferences>
     </Link>
     <PreBuildEvent>
-      <Command>flex -o "src/thriftl.cc" src/thriftl.ll
-bison -y -o "src/thrifty.cc" --defines="src/thrifty.h" src/thrifty.yy</Command>
+      <Command>flex -o "src\thrift\thriftl.cc" src/thriftl.ll
+bison -y -o "src\thrift\thrifty.cc" --defines="src/thrifty.h" src/thrifty.yy</Command>
     </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -228,8 +228,8 @@
       <OptimizeReferences>true</OptimizeReferences>
     </Link>
     <PreBuildEvent>
-      <Command>flex -o "src/thriftl.cc" src/thriftl.ll
-bison -y -o "src/thrifty.cc" --defines="src/thrifty.h" src/thrifty.yy</Command>
+      <Command>flex -o "src\thrift\thriftl.cc" src/thriftl.ll
+bison -y -o "src\thrift\thrifty.cc" --defines="src/thrifty.h" src/thrifty.yy</Command>
     </PreBuildEvent>
   </ItemDefinitionGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
diff --git a/compiler/cpp/src/generate/t_c_glib_generator.cc b/compiler/cpp/src/generate/t_c_glib_generator.cc
index d1fc702..d22b723 100644
--- a/compiler/cpp/src/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/generate/t_c_glib_generator.cc
@@ -186,7 +186,7 @@
     "/* base includes */" << endl <<
     "#include <glib-object.h>" << endl <<
     "#include <thrift_struct.h>" << endl <<
-    "#include <protocol/thrift_protocol.h>" << endl;
+    "#include <thrift/protocol/thrift_protocol.h>" << endl;
 
   /* include other thrift includes */
   const vector<t_program *> &includes = program_->get_includes();
@@ -217,7 +217,7 @@
     endl <<
     "#include \"" << this->nspace_lc << program_name_u << 
         "_types.h\"" << endl <<
-    "#include <thrift.h>" << endl <<
+    "#include <thrift/thrift.h>" << endl <<
     endl;
 
   f_types_ <<
@@ -410,7 +410,7 @@
   // include the headers
   f_service_ <<
     "#include <string.h>" << endl <<
-    "#include <thrift.h>" << endl <<
+    "#include <thrift/thrift.h>" << endl <<
     "#include <thrift_application_exception.h>" << endl <<
     "#include \"" << filename << ".h\"" << endl <<
     endl;
diff --git a/compiler/cpp/src/generate/t_cpp_generator.cc b/compiler/cpp/src/generate/t_cpp_generator.cc
index 6b3f4b6..3bc6a81 100755
--- a/compiler/cpp/src/generate/t_cpp_generator.cc
+++ b/compiler/cpp/src/generate/t_cpp_generator.cc
@@ -343,10 +343,10 @@
 
   // Include base types
   f_types_ <<
-    "#include <Thrift.h>" << endl <<
-    "#include <TApplicationException.h>" << endl <<
-    "#include <protocol/TProtocol.h>" << endl <<
-    "#include <transport/TTransport.h>" << endl <<
+    "#include <thrift/Thrift.h>" << endl <<
+    "#include <thrift/TApplicationException.h>" << endl <<
+    "#include <thrift/protocol/TProtocol.h>" << endl <<
+    "#include <thrift/transport/TTransport.h>" << endl <<
     endl;
 
   // Include other Thrift includes
@@ -392,7 +392,7 @@
   // the definition of TypeSpec.
   if (gen_dense_) {
     f_types_impl_ <<
-      "#include <TReflectionLocal.h>" << endl <<
+      "#include <thrift/TReflectionLocal.h>" << endl <<
       endl;
   }
 
@@ -1571,17 +1571,17 @@
     endl;
   if (gen_cob_style_) {
     f_header_ <<
-      "#include <transport/TBufferTransports.h>" << endl << // TMemoryBuffer
+      "#include <thrift/transport/TBufferTransports.h>" << endl << // TMemoryBuffer
       "#include <tr1/functional>" << endl <<
       "namespace apache { namespace thrift { namespace async {" << endl <<
       "class TAsyncChannel;" << endl <<
       "}}}" << endl;
   }
   f_header_ <<
-    "#include <TDispatchProcessor.h>" << endl;
+    "#include <thrift/TDispatchProcessor.h>" << endl;
   if (gen_cob_style_) {
     f_header_ <<
-      "#include <async/TAsyncDispatchProcessor.h>" << endl;
+      "#include <thrift/async/TAsyncDispatchProcessor.h>" << endl;
   }
   f_header_ <<
     "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
@@ -1608,7 +1608,7 @@
     "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl;
   if (gen_cob_style_) {
     f_service_ <<
-      "#include \"async/TAsyncChannel.h\"" << endl;
+      "#include \"thrift/async/TAsyncChannel.h\"" << endl;
   }
   if (gen_templates_) {
     f_service_ <<
@@ -1630,7 +1630,7 @@
 
     if (gen_cob_style_) {
       f_service_tcc_ <<
-        "#include \"async/TAsyncChannel.h\"" << endl;
+        "#include \"thrift/async/TAsyncChannel.h\"" << endl;
     }
   }
 
@@ -1974,8 +1974,8 @@
     "// that would otherwise introduce unwanted latency." << endl <<
     endl <<
     "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl <<
-    "#include <protocol/TBinaryProtocol.h>" << endl <<
-    "#include <async/TEventServer.h>" << endl <<
+    "#include <thrift/protocol/TBinaryProtocol.h>" << endl <<
+    "#include <thrift/async/TEventServer.h>" << endl <<
     endl <<
     "using namespace ::apache::thrift;" << endl <<
     "using namespace ::apache::thrift::protocol;" << endl <<
@@ -3703,10 +3703,10 @@
     "// You should copy it to another filename to avoid overwriting it." << endl <<
     endl <<
     "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl <<
-    "#include <protocol/TBinaryProtocol.h>" << endl <<
-    "#include <server/TSimpleServer.h>" << endl <<
-    "#include <transport/TServerSocket.h>" << endl <<
-    "#include <transport/TBufferTransports.h>" << endl <<
+    "#include <thrift/protocol/TBinaryProtocol.h>" << endl <<
+    "#include <thrift/server/TSimpleServer.h>" << endl <<
+    "#include <thrift/transport/TServerSocket.h>" << endl <<
+    "#include <thrift/transport/TBufferTransports.h>" << endl <<
     endl <<
     "using namespace ::apache::thrift;" << endl <<
     "using namespace ::apache::thrift::protocol;" << endl <<