2016-01-28 14:52:40 +01:00
|
|
|
/** @file
|
|
|
|
|
*
|
|
|
|
|
* @par History
|
|
|
|
|
*/
|
2015-11-11 00:23:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "compilercfg.h"
|
2018-01-29 21:55:48 +01:00
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2015-11-11 00:23:20 +01:00
|
|
|
#include "../clib/Program/ProgramConfig.h"
|
|
|
|
|
#include "../clib/cfgelem.h"
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "../clib/cfgfile.h"
|
2015-11-11 00:23:20 +01:00
|
|
|
#include "../clib/dirlist.h"
|
2018-01-01 21:49:30 +01:00
|
|
|
#include "../clib/fileutil.h"
|
2015-11-11 00:23:20 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
namespace Pol
|
|
|
|
|
{
|
|
|
|
|
namespace Bscript
|
|
|
|
|
{
|
|
|
|
|
void CompilerConfig::Read( const std::string& path )
|
|
|
|
|
{
|
|
|
|
|
Clib::ConfigFile cf( path.c_str() );
|
|
|
|
|
Clib::ConfigElem elem;
|
|
|
|
|
cf.readraw( elem );
|
|
|
|
|
|
|
|
|
|
PackageRoot.clear();
|
|
|
|
|
IncludeDirectory.clear();
|
|
|
|
|
|
|
|
|
|
std::string tmp;
|
|
|
|
|
while ( elem.remove_prop( "PackageRoot", &tmp ) )
|
|
|
|
|
{
|
|
|
|
|
PackageRoot.push_back( Clib::normalized_dir_form( tmp ) );
|
|
|
|
|
}
|
|
|
|
|
if ( elem.remove_prop( "IncludeDirectory", &tmp ) )
|
|
|
|
|
{
|
|
|
|
|
IncludeDirectory = Clib::normalized_dir_form( tmp );
|
|
|
|
|
}
|
|
|
|
|
ModuleDirectory = Clib::normalized_dir_form( elem.remove_string( "ModuleDirectory" ) );
|
|
|
|
|
PolScriptRoot = Clib::normalized_dir_form( elem.remove_string( "PolScriptRoot" ) );
|
|
|
|
|
GenerateListing = elem.remove_bool( "GenerateListing", false );
|
|
|
|
|
GenerateDebugInfo = elem.remove_bool( "GenerateDebugInfo", false );
|
|
|
|
|
GenerateDebugTextInfo = elem.remove_bool( "GenerateDebugTextInfo", false );
|
2020-07-28 22:12:12 -07:00
|
|
|
|
|
|
|
|
VerbosityLevel = elem.remove_int( "VerbosityLevel", 0 );
|
2016-02-19 19:26:35 +01:00
|
|
|
DisplayWarnings = elem.remove_bool( "DisplayWarnings", false );
|
|
|
|
|
CompileAspPages = elem.remove_bool( "CompileAspPages", false );
|
|
|
|
|
AutoCompileByDefault = elem.remove_bool( "AutoCompileByDefault", false );
|
|
|
|
|
UpdateOnlyOnAutoCompile = elem.remove_bool( "UpdateOnlyOnAutoCompile", false );
|
|
|
|
|
OnlyCompileUpdatedScripts = elem.remove_bool( "OnlyCompileUpdatedScripts", false );
|
|
|
|
|
DisplaySummary = elem.remove_bool( "DisplaySummary", false );
|
|
|
|
|
OptimizeObjectMembers = elem.remove_bool( "OptimizeObjectMembers", true );
|
|
|
|
|
ErrorOnWarning = elem.remove_bool( "ErrorOnWarning", false );
|
|
|
|
|
GenerateDependencyInfo = elem.remove_bool( "GenerateDependencyInfo", OnlyCompileUpdatedScripts );
|
|
|
|
|
|
|
|
|
|
DisplayUpToDateScripts = elem.remove_bool( "DisplayUpToDateScripts", true );
|
|
|
|
|
ThreadedCompilation = elem.remove_bool( "ThreadedCompilation", false );
|
2018-07-29 15:51:58 +02:00
|
|
|
NumberOfThreads = elem.remove_int( "NumberOfThreads", 0 );
|
2016-02-19 19:26:35 +01:00
|
|
|
ParanoiaWarnings = elem.remove_bool( "ParanoiaWarnings", false );
|
2019-10-07 21:01:26 +02:00
|
|
|
ErrorOnFileCaseMissmatch = elem.remove_bool( "ErrorOnFileCaseMissmatch", false );
|
2016-02-19 19:26:35 +01:00
|
|
|
|
2020-08-04 22:42:46 -07:00
|
|
|
UseCompiler2020 = elem.remove_bool( "UseCompiler2020", false );
|
2020-08-05 00:01:07 -07:00
|
|
|
CompareCompilerOutput = elem.remove_bool( "CompareCompilerOutput", false );
|
2020-08-16 17:22:16 -07:00
|
|
|
EmParseTreeCacheSize = elem.remove_int( "EmParseTreeCacheSize", 25 );
|
|
|
|
|
IncParseTreeCacheSize = elem.remove_int( "IncParseTreeCacheSize", 50 );
|
2020-08-04 22:42:46 -07:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
// This is where we TRY to validate full paths from what was provided in the
|
|
|
|
|
// ecompile.cfg. Maybe Turley or Shini can find the best way to do this in *nix.
|
2015-11-11 00:23:20 +01:00
|
|
|
#ifdef WIN32
|
2016-02-19 19:26:35 +01:00
|
|
|
std::string MyPath = path.c_str();
|
|
|
|
|
// If it's just "ecompile.cfg", let's change it to the exe's path which it SHOULD be
|
|
|
|
|
// with.
|
|
|
|
|
if ( stricmp( MyPath.c_str(), "ecompile.cfg" ) == 0 )
|
|
|
|
|
{
|
|
|
|
|
std::string workingDir = PROG_CONFIG::programDir();
|
|
|
|
|
|
|
|
|
|
// Let's find the NEXT-TO-LAST / in the path, and remove from there on. Oh yay!
|
|
|
|
|
// To bad we can't just force everyone to use ABSOLUTE PATHS NANDO. :o
|
|
|
|
|
MyPath = workingDir.substr( 0, workingDir.length() - 1 );
|
|
|
|
|
MyPath = MyPath.substr( 0, MyPath.find_last_of( '/' ) + 1 );
|
|
|
|
|
}
|
|
|
|
|
if ( IncludeDirectory.find( ':' ) == std::string::npos )
|
|
|
|
|
{
|
|
|
|
|
if ( IncludeDirectory.substr( 0, 1 ) !=
|
|
|
|
|
"." ) // Let's make sure they didn't try using this method
|
|
|
|
|
{
|
|
|
|
|
IncludeDirectory = MyPath + IncludeDirectory;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( ModuleDirectory.find( ':' ) == std::string::npos )
|
|
|
|
|
{
|
|
|
|
|
if ( ModuleDirectory.substr( 0, 1 ) !=
|
|
|
|
|
"." ) // Let's make sure they didn't try using this method
|
|
|
|
|
{
|
|
|
|
|
ModuleDirectory = MyPath + ModuleDirectory;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( PolScriptRoot.find( ':' ) == std::string::npos )
|
|
|
|
|
{
|
|
|
|
|
if ( PolScriptRoot.substr( 0, 1 ) != "." ) // Let's make sure they didn't try using this method
|
|
|
|
|
{
|
|
|
|
|
PolScriptRoot = MyPath + PolScriptRoot;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for ( unsigned pr = 0; pr < PackageRoot.size(); ++pr )
|
|
|
|
|
{
|
|
|
|
|
if ( PackageRoot[pr].find( ':' ) == std::string::npos )
|
|
|
|
|
{
|
|
|
|
|
if ( PackageRoot[pr].substr( 0, 1 ) !=
|
|
|
|
|
"." ) // Let's make sure they didn't try using this method
|
|
|
|
|
{
|
|
|
|
|
PackageRoot[pr] = MyPath + PackageRoot[pr];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-11-11 00:23:20 +01:00
|
|
|
|
|
|
|
|
#endif
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
2015-11-11 00:23:20 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
void CompilerConfig::SetDefaults()
|
|
|
|
|
{
|
|
|
|
|
const char* tmp;
|
2015-11-11 00:23:20 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
tmp = getenv( "ECOMPILE_PATH_EM" );
|
|
|
|
|
ModuleDirectory = tmp ? Clib::normalized_dir_form( tmp ) : PROG_CONFIG::programDir();
|
2015-11-11 00:23:20 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
tmp = getenv( "ECOMPILE_PATH_INC" );
|
|
|
|
|
IncludeDirectory = tmp ? Clib::normalized_dir_form( tmp ) : PROG_CONFIG::programDir();
|
2015-11-11 00:23:20 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
PolScriptRoot = IncludeDirectory;
|
2015-11-11 00:23:20 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
DisplayUpToDateScripts = true;
|
2020-08-16 17:22:16 -07:00
|
|
|
|
|
|
|
|
EmParseTreeCacheSize = 25;
|
|
|
|
|
IncParseTreeCacheSize = 50;
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
2015-11-11 00:23:20 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
CompilerConfig compilercfg;
|
2019-10-07 21:01:26 +02:00
|
|
|
} // namespace Bscript
|
|
|
|
|
} // namespace Pol
|