Permalink
Browse files

Merge pull request #34 from dougbinks/master

Added support for source file discovery, and turning off RCC++ via RCCPPOFF macro or at runtime with improved autocompile disabling.
  • Loading branch information...
2 parents 3b9d3ed + 4f8a7b1 commit ea08383b7073249559350783cd6a6263e140f0f9 @dougbinks dougbinks committed Oct 19, 2013
@@ -87,13 +87,11 @@ Console::Console(Environment* pEnv, Rocket::Core::Context* pRocketContext)
AU_ASSERT(m_pEnv && m_pRocketContext);
Path basepath = Path(__FILE__).ParentPath();
+ basepath = m_pEnv->sys->pRuntimeObjectSystem->FindFile( basepath );
m_inputFile = basepath / Path(CONSOLE_INPUT_FILE);
m_contextFile = basepath / Path(CONSOLE_CONTEXT_FILE);
-#ifdef _WINDOWS_
- // make filename lowercase to avoid case sensitivity issues
- FileSystemUtils::ToLowerInPlace( m_contextFile.m_string );
-#endif
+ m_contextFile.ToOSCanonicalCase();
if( CreateConsoleContextFile() )
{
@@ -155,10 +155,10 @@ bool Game::Init()
m_pEnv->sys->pObjectFactorySystem->AddListener(this);
- m_pConsole = new Console(m_pEnv, m_pRocketContext);
m_EntityUpdateProtector.pEntitySystem = m_pEnv->sys->pEntitySystem;
m_pEnv->Init();
+ m_pConsole = new Console(m_pEnv, m_pRocketContext);
return true;
}
@@ -75,10 +75,7 @@ void FileChangeNotifier::Watch( const FileSystemUtils::Path& filename, IFileChan
{
FileSystemUtils::Path fixedFilename = filename.DelimitersToOSDefault(); // Note this doesn't handle ../
-#ifdef _WIN32
- // make filename lowercase to avoid case sensitivity issues with __FILE__ and ReadDirectoryChangesW output
- FileSystemUtils::ToLowerInPlace( fixedFilename.m_string );
-#endif
+ fixedFilename.ToOSCanonicalCase();
m_pFileMonitor->Watch(fixedFilename, this);
m_fileListenerMap[fixedFilename].insert(pListener);
@@ -117,16 +114,10 @@ void FileChangeNotifier::OnFileChange( const FileSystemUtils::Path& filename )
if (!bIgnoreFileChange)
{
- const FileSystemUtils::Path* pFilename = &filename;
+ FileSystemUtils::Path filePath = filename;
+ filePath.ToOSCanonicalCase();
-#ifdef _WIN32
- // make filename lowercase to avoid case sensitivity issues with __FILE__ and ReadDirectoryChangesW output
- FileSystemUtils::Path lowerFilename = filename;
- FileSystemUtils::ToLowerInPlace( lowerFilename.m_string );
- pFilename = &lowerFilename;
-#endif
-
- m_changedFileList.push_back(pFilename->m_string);
+ m_changedFileList.push_back(filePath.m_string);
if (!m_bRecompilePending)
{
@@ -71,6 +71,7 @@ namespace FileSystemUtils
: m_string( rhs_ )
{
}
+ virtual ~Path() {} // for RCC++
const char* c_str() const;
@@ -94,6 +95,7 @@ namespace FileSystemUtils
// returns a path cleaned of /../ by removing prior dir
Path GetCleanPath() const;
+ void ToOSCanonicalCase(); // lower case on Windows, preserve case on Linux
// replaces extension if one exists, or adds it if not
void ReplaceExtension( const std::string& ext );
@@ -394,6 +396,10 @@ namespace FileSystemUtils
{
return rhs_;
}
+ if( 0 == rhs_.m_string.length() )
+ {
+ return lhs_;
+ }
std::string strlhs = lhs_.m_string;
while( strlhs.length() && strlhs.find_last_of( FILESYSTEMUTILS_SEPERATORS ) == strlhs.length()-1 )
{
@@ -452,6 +458,13 @@ namespace FileSystemUtils
return path;
}
+ inline void Path::ToOSCanonicalCase()
+ {
+#ifdef _WIN32
+ ToLowerInPlace( m_string );
+#endif
+ }
+
class PathIterator
{
@@ -56,6 +56,11 @@ struct ITestBuildNotifier
virtual bool TestBuildWaitAndUpdate() = 0;
};
+namespace FileSystemUtils
+{
+ class Path;
+}
+
struct IRuntimeObjectSystem
{
// Initialise RuntimeObjectSystem. pLogger and pSystemTable should be deleted by creator.
@@ -108,6 +113,13 @@ struct IRuntimeObjectSystem
// tests touching each header which has RUNTIME_MODIFIABLE_INCLUDE.
// returns the number of errors - 0 if all passed.
virtual int TestBuildAllRuntimeHeaders( ITestBuildNotifier* callback, bool bTestFileTracking ) = 0;
+
+ // FindFile - attempts to find the file in a source directory
+ virtual FileSystemUtils::Path FindFile( const FileSystemUtils::Path& input ) = 0;
+
+ // AddPathToSourceSearch - adds a path to help source search. Can be called multiple times to add paths.
+ virtual void AddPathToSourceSearch( const char* path ) = 0;
+
};
#endif // IRUNTIMEOBJECTSYSTEM_INCLUDED
@@ -83,24 +83,30 @@ template<typename T> class TObjectConstructorConcrete: public IObjectConstructor
{
public:
TObjectConstructorConcrete(
+#ifndef RCCPPOFF
const char* Filename,
IRuntimeIncludeFileList* pIncludeFileList_,
IRuntimeSourceDependencyList* pSourceDependencyList_,
IRuntimeLinkLibraryList* pLinkLibraryList,
+#endif
bool bIsSingleton,
bool bIsAutoConstructSingleton)
: m_bIsSingleton( bIsSingleton )
, m_bIsAutoConstructSingleton( bIsAutoConstructSingleton )
+ , m_pModuleInterface(0)
+#ifndef RCCPPOFF
, m_FileName( Filename )
- , m_pIncludeFileList( pIncludeFileList_ )
- , m_pSourceDependencyList( pSourceDependencyList_ )
- , m_pLinkLibraryList( pLinkLibraryList )
- , m_pModuleInterface( 0 )
+ , m_pIncludeFileList(pIncludeFileList_)
+ , m_pSourceDependencyList(pSourceDependencyList_)
+ , m_pLinkLibraryList(pLinkLibraryList)
+#endif
{
+#ifndef RCCPPOFF
// add path to filename
#ifdef COMPILE_PATH
m_FileName = COMPILE_PATH + m_FileName;
#endif
+#endif
PerModuleInterface::GetInstance()->AddConstructor( this );
m_pModuleInterface = PerModuleInterface::GetInstance();
m_Id = InvalidId;
@@ -149,69 +155,89 @@ template<typename T> class TObjectConstructorConcrete: public IObjectConstructor
virtual const char* GetFileName()
{
+#ifndef RCCPPOFF
return m_FileName.c_str();
+#else
+ return 0;
+#endif
}
virtual const char* GetCompiledPath()
{
+#ifndef RCCPPOFF
#ifdef COMPILE_PATH
return COMPILE_PATH;
#else
return "";
#endif
+#else
+ return 0;
+#endif
}
virtual const char* GetIncludeFile( size_t Num_ ) const
{
+#ifndef RCCPPOFF
if( m_pIncludeFileList )
{
return m_pIncludeFileList->GetIncludeFile( Num_ );
}
+#endif
return 0;
}
virtual size_t GetMaxNumIncludeFiles() const
{
+#ifndef RCCPPOFF
if( m_pIncludeFileList )
{
return m_pIncludeFileList->MaxNum;
}
+#endif
return 0;
}
virtual const char* GetLinkLibrary( size_t Num_ ) const
{
+#ifndef RCCPPOFF
if( m_pLinkLibraryList )
{
return m_pLinkLibraryList->GetLinkLibrary( Num_ );
}
+#endif
return 0;
}
virtual size_t GetMaxNumLinkLibraries() const
{
+#ifndef RCCPPOFF
if( m_pLinkLibraryList )
{
return m_pLinkLibraryList->MaxNum;
}
+#endif
return 0;
}
virtual const char* GetSourceDependency( size_t Num_ ) const
{
+#ifndef RCCPPOFF
if( m_pSourceDependencyList )
{
return m_pSourceDependencyList->GetSourceDependency( Num_ );
}
+#endif
return 0;
}
virtual size_t GetMaxNumSourceDependencies() const
{
+#ifndef RCCPPOFF
if( m_pSourceDependencyList )
{
return m_pSourceDependencyList->MaxNum;
}
+#endif
return 0;
}
@@ -265,16 +291,18 @@ template<typename T> class TObjectConstructorConcrete: public IObjectConstructor
}
}
private:
- bool m_bIsSingleton;
- bool m_bIsAutoConstructSingleton;
- std::string m_FileName;
+ bool m_bIsSingleton;
+ bool m_bIsAutoConstructSingleton;
std::vector<T*> m_ConstructedObjects;
std::vector<PerTypeObjectId> m_FreeIds;
ConstructorId m_Id;
+ PerModuleInterface* m_pModuleInterface;
+#ifndef RCCPPOFF
+ std::string m_FileName;
IRuntimeIncludeFileList* m_pIncludeFileList;
- IRuntimeSourceDependencyList* m_pSourceDependencyList;
+ IRuntimeSourceDependencyList* m_pSourceDependencyList;
IRuntimeLinkLibraryList* m_pLinkLibraryList;
- PerModuleInterface* m_pModuleInterface;
+#endif
};
@@ -320,14 +348,20 @@ template<typename T> class TActual: public T
PerTypeObjectId m_Id;
static TObjectConstructorConcrete<TActual> m_Constructor;
};
-
-#define REGISTERBASE( T, bIsSingleton, bIsAutoConstructSingleton ) \
- static RuntimeIncludeFiles< __COUNTER__ > g_includeFileList_##T; \
- static RuntimeSourceDependency< __COUNTER__ > g_sourceDependencyList_##T; \
- static RuntimeLinkLibrary< __COUNTER__ > g_linkLibraryList_##T; \
-template<> TObjectConstructorConcrete< TActual< T > > TActual< T >::m_Constructor( __FILE__, &g_includeFileList_##T, &g_sourceDependencyList_##T, &g_linkLibraryList_##T, bIsSingleton, bIsAutoConstructSingleton );\
-template<> const char* TActual< T >::GetTypeNameStatic() { return #T; } \
-template class TActual< T >;
+#ifndef RCCPPOFF
+ #define REGISTERBASE( T, bIsSingleton, bIsAutoConstructSingleton ) \
+ static RuntimeIncludeFiles< __COUNTER__ > g_includeFileList_##T; \
+ static RuntimeSourceDependency< __COUNTER__ > g_sourceDependencyList_##T; \
+ static RuntimeLinkLibrary< __COUNTER__ > g_linkLibraryList_##T; \
+ template<> TObjectConstructorConcrete< TActual< T > > TActual< T >::m_Constructor( __FILE__, &g_includeFileList_##T, &g_sourceDependencyList_##T, &g_linkLibraryList_##T, bIsSingleton, bIsAutoConstructSingleton );\
+ template<> const char* TActual< T >::GetTypeNameStatic() { return #T; } \
+ template class TActual< T >;
+#else
+ #define REGISTERBASE( T, bIsSingleton, bIsAutoConstructSingleton ) \
+ template<> TObjectConstructorConcrete< TActual< T > > TActual< T >::m_Constructor( bIsSingleton, bIsAutoConstructSingleton); \
+ template<> const char* TActual< T >::GetTypeNameStatic() { return #T; } \
+ template class TActual< T >;
+#endif
//NOTE: the file macro will only emit the full path if /FC option is used in visual studio or /ZI (Which forces /FC)
#define REGISTERCLASS( T ) REGISTERBASE( T, false, false )
@@ -22,6 +22,8 @@
#include <stddef.h>
+#ifndef RCCPPOFF
+
//NOTE: the file macro will only emit the full path if /FC option is used in visual studio or /ZI (Which forces /FC)
//Following creates a list of files which are runtime modifiable, to be used in headers
//requires use of __COUNTER__ predefined macro, which is in gcc 4.3+, clang/llvm and MSVC
@@ -103,5 +105,8 @@ template<> struct RuntimeIncludeFiles<0> : public IRuntimeIncludeFileList
#define RUNTIME_MODIFIABLE_INCLUDE namespace { RUNTIME_MODIFIABLE_INCLUDE_BASE( __COUNTER__ ) }
}
+#else
+#define RUNTIME_MODIFIABLE_INCLUDE
+#endif //RCCPPOFF
#endif //RUNTIMEINCLUDE_INCLUDED
@@ -20,6 +20,8 @@
#ifndef RUNTIMELINKLIBRARY_INCLUDED
#define RUNTIMELINKLIBRARY_INCLUDED
+
+#ifndef RCCPPOFF
//NOTE: the file macro will only emit the full path if /FC option is used in visual studio or /ZI (Which forces /FC)
//Following creates a list of files which are runtime modifiable, to be used in headers
//requires use of __COUNTER__ predefined macro, which is in gcc 4.3+, clang/llvm and MSVC
@@ -101,5 +103,9 @@ template<> struct RuntimeLinkLibrary<0> : public IRuntimeLinkLibraryList
#define RUNTIME_COMPILER_LINKLIBRARY( LIBRARY ) namespace { RUNTIME_COMPILER_LINKLIBRARY_BASE( LIBRARY, __COUNTER__ ) }
}
+#else
+#define RUNTIME_COMPILER_LINKLIBRARY( LIBRARY )
+#endif //RCCPPOFF
+
#endif //RUNTIMELINKLIBRARY_INCLUDED
Oops, something went wrong.

0 comments on commit ea08383

Please sign in to comment.