Pol  Revision:4b29d2b
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  NumberOfThreads = elem.remove_int( "NumberOfThreads", 0 );
57  ParanoiaWarnings = elem.remove_bool( "ParanoiaWarnings", false );
58 
59 // This is where we TRY to validate full paths from what was provided in the
60 // ecompile.cfg. Maybe Turley or Shini can find the best way to do this in *nix.
61 #ifdef WIN32
62  std::string MyPath = path.c_str();
63  // If it's just "ecompile.cfg", let's change it to the exe's path which it SHOULD be
64  // with.
65  if ( stricmp( MyPath.c_str(), "ecompile.cfg" ) == 0 )
66  {
67  std::string workingDir = PROG_CONFIG::programDir();
68 
69  // Let's find the NEXT-TO-LAST / in the path, and remove from there on. Oh yay!
70  // To bad we can't just force everyone to use ABSOLUTE PATHS NANDO. :o
71  MyPath = workingDir.substr( 0, workingDir.length() - 1 );
72  MyPath = MyPath.substr( 0, MyPath.find_last_of( '/' ) + 1 );
73  }
74  if ( IncludeDirectory.find( ':' ) == std::string::npos )
75  {
76  if ( IncludeDirectory.substr( 0, 1 ) !=
77  "." ) // Let's make sure they didn't try using this method
78  {
80  }
81  }
82  if ( ModuleDirectory.find( ':' ) == std::string::npos )
83  {
84  if ( ModuleDirectory.substr( 0, 1 ) !=
85  "." ) // Let's make sure they didn't try using this method
86  {
88  }
89  }
90  if ( PolScriptRoot.find( ':' ) == std::string::npos )
91  {
92  if ( PolScriptRoot.substr( 0, 1 ) != "." ) // Let's make sure they didn't try using this method
93  {
94  PolScriptRoot = MyPath + PolScriptRoot;
95  }
96  }
97  for ( unsigned pr = 0; pr < PackageRoot.size(); ++pr )
98  {
99  if ( PackageRoot[pr].find( ':' ) == std::string::npos )
100  {
101  if ( PackageRoot[pr].substr( 0, 1 ) !=
102  "." ) // Let's make sure they didn't try using this method
103  {
104  PackageRoot[pr] = MyPath + PackageRoot[pr];
105  }
106  }
107  }
108 
109 #endif
110 }
111 
113 {
114  const char* tmp;
115 
116  tmp = getenv( "ECOMPILE_PATH_EM" );
117  ModuleDirectory = tmp ? Clib::normalized_dir_form( tmp ) : PROG_CONFIG::programDir();
118 
119  tmp = getenv( "ECOMPILE_PATH_INC" );
120  IncludeDirectory = tmp ? Clib::normalized_dir_form( tmp ) : PROG_CONFIG::programDir();
121 
123 
124  DisplayUpToDateScripts = true;
125 }
126 
128 }
129 }
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