Pol  Revision:3cfda13
compilercfg.cpp
Go to the documentation of this file.
1 
7 #include "compilercfg.h"
8 
9 #include <stdlib.h>
10 
11 #include "../clib/Program/ProgramConfig.h"
12 #include "../clib/cfgelem.h"
13 #include "../clib/cfgfile.h"
14 #include "../clib/dirlist.h"
15 #include "../clib/fileutil.h"
16 
17 namespace Pol
18 {
19 namespace Bscript
20 {
21 void CompilerConfig::Read( const std::string& path )
22 {
23  Clib::ConfigFile cf( path.c_str() );
24  Clib::ConfigElem elem;
25  cf.readraw( elem );
26 
27  PackageRoot.clear();
28  IncludeDirectory.clear();
29 
30  std::string tmp;
31  while ( elem.remove_prop( "PackageRoot", &tmp ) )
32  {
33  PackageRoot.push_back( Clib::normalized_dir_form( tmp ) );
34  }
35  if ( elem.remove_prop( "IncludeDirectory", &tmp ) )
36  {
38  }
39  ModuleDirectory = Clib::normalized_dir_form( elem.remove_string( "ModuleDirectory" ) );
40  PolScriptRoot = Clib::normalized_dir_form( elem.remove_string( "PolScriptRoot" ) );
41  GenerateListing = elem.remove_bool( "GenerateListing", false );
42  GenerateDebugInfo = elem.remove_bool( "GenerateDebugInfo", false );
43  GenerateDebugTextInfo = elem.remove_bool( "GenerateDebugTextInfo", false );
44  DisplayWarnings = elem.remove_bool( "DisplayWarnings", false );
45  CompileAspPages = elem.remove_bool( "CompileAspPages", false );
46  AutoCompileByDefault = elem.remove_bool( "AutoCompileByDefault", false );
47  UpdateOnlyOnAutoCompile = elem.remove_bool( "UpdateOnlyOnAutoCompile", false );
48  OnlyCompileUpdatedScripts = elem.remove_bool( "OnlyCompileUpdatedScripts", false );
49  DisplaySummary = elem.remove_bool( "DisplaySummary", false );
50  OptimizeObjectMembers = elem.remove_bool( "OptimizeObjectMembers", true );
51  ErrorOnWarning = elem.remove_bool( "ErrorOnWarning", false );
52  GenerateDependencyInfo = elem.remove_bool( "GenerateDependencyInfo", OnlyCompileUpdatedScripts );
53 
54  DisplayUpToDateScripts = elem.remove_bool( "DisplayUpToDateScripts", true );
55  ThreadedCompilation = elem.remove_bool( "ThreadedCompilation", false );
56  ParanoiaWarnings = elem.remove_bool( "ParanoiaWarnings", false );
57 
58 // This is where we TRY to validate full paths from what was provided in the
59 // ecompile.cfg. Maybe Turley or Shini can find the best way to do this in *nix.
60 #ifdef WIN32
61  std::string MyPath = path.c_str();
62  // If it's just "ecompile.cfg", let's change it to the exe's path which it SHOULD be
63  // with.
64  if ( stricmp( MyPath.c_str(), "ecompile.cfg" ) == 0 )
65  {
66  std::string workingDir = PROG_CONFIG::programDir();
67 
68  // Let's find the NEXT-TO-LAST / in the path, and remove from there on. Oh yay!
69  // To bad we can't just force everyone to use ABSOLUTE PATHS NANDO. :o
70  MyPath = workingDir.substr( 0, workingDir.length() - 1 );
71  MyPath = MyPath.substr( 0, MyPath.find_last_of( '/' ) + 1 );
72  }
73  if ( IncludeDirectory.find( ':' ) == std::string::npos )
74  {
75  if ( IncludeDirectory.substr( 0, 1 ) !=
76  "." ) // Let's make sure they didn't try using this method
77  {
79  }
80  }
81  if ( ModuleDirectory.find( ':' ) == std::string::npos )
82  {
83  if ( ModuleDirectory.substr( 0, 1 ) !=
84  "." ) // Let's make sure they didn't try using this method
85  {
87  }
88  }
89  if ( PolScriptRoot.find( ':' ) == std::string::npos )
90  {
91  if ( PolScriptRoot.substr( 0, 1 ) != "." ) // Let's make sure they didn't try using this method
92  {
93  PolScriptRoot = MyPath + PolScriptRoot;
94  }
95  }
96  for ( unsigned pr = 0; pr < PackageRoot.size(); ++pr )
97  {
98  if ( PackageRoot[pr].find( ':' ) == std::string::npos )
99  {
100  if ( PackageRoot[pr].substr( 0, 1 ) !=
101  "." ) // Let's make sure they didn't try using this method
102  {
103  PackageRoot[pr] = MyPath + PackageRoot[pr];
104  }
105  }
106  }
107 
108 #endif
109 }
110 
112 {
113  const char* tmp;
114 
115  tmp = getenv( "ECOMPILE_PATH_EM" );
116  ModuleDirectory = tmp ? Clib::normalized_dir_form( tmp ) : PROG_CONFIG::programDir();
117 
118  tmp = getenv( "ECOMPILE_PATH_INC" );
119  IncludeDirectory = tmp ? Clib::normalized_dir_form( tmp ) : PROG_CONFIG::programDir();
120 
122 
123  DisplayUpToDateScripts = true;
124 }
125 
127 }
128 }
CompilerConfig compilercfg
std::vector< std::string > PackageRoot
Definition: compilercfg.h:19
std::string normalized_dir_form(const std::string &istr)
Definition: fileutil.cpp:25
Definition: berror.cpp:12
void Read(const std::string &path)
Definition: compilercfg.cpp:21