Skip to content

Commit

Permalink
Merge pull request #51 from dougbinks/master
Browse files Browse the repository at this point in the history
Per project / settings build directories and cmake additions.
  • Loading branch information
dougbinks committed Jan 4, 2015
2 parents 0bb3925 + 6140976 commit ab0b14e
Show file tree
Hide file tree
Showing 15 changed files with 232 additions and 123 deletions.
15 changes: 12 additions & 3 deletions Aurora/CMakeLists.txt
Expand Up @@ -102,10 +102,17 @@ if(BUILD_EXAMPLES)
set(ASSIMP_LIBRARIES assimp)
if(${CMAKE_CL_64})
set_target_properties( assimp PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/External/assimp/lib/assimp_release-dll_x64/assimp.lib )
file(COPY ${CMAKE_SOURCE_DIR}/External/assimp/bin/assimp_release-dll_win32/Assimp64.dll DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE})
set(ASSIMP_DLL ${CMAKE_SOURCE_DIR}/External/assimp/bin/assimp_release-dll_win32/Assimp64.dll)
else()
set_target_properties( assimp PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/External/assimp/lib/assimp_release-dll_win32/assimp.lib )
file(COPY ${CMAKE_SOURCE_DIR}/External/assimp/bin/assimp_release-dll_win32/Assimp32.dll DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE})
set(ASSIMP_DLL ${CMAKE_SOURCE_DIR}/External/assimp/bin/assimp_release-dll_win32/Assimp32.dll)
endif()
if(CMAKE_GENERATOR STREQUAL "NMake Makefiles")
file(COPY ${ASSIMP_DLL} DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
else()
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
file(COPY ${ASSIMP_DLL} DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${OUTPUTCONFIG})
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
endif()
endif()

Expand Down Expand Up @@ -136,5 +143,7 @@ if(BUILD_EXAMPLES)
${GLFW_LIBRARIES}
${ASSIMP_LIBRARIES}
)

if(MSVC)
set_target_properties(SimpleTest ConsoleExample PROPERTIES COMPILE_FLAGS "/FC")
endif()
endif()
59 changes: 30 additions & 29 deletions Aurora/RuntimeCompiler/BuildTool.cpp
Expand Up @@ -33,23 +33,22 @@ BuildTool::~BuildTool()
{
}

void BuildTool::Clean() const
void BuildTool::Clean( const FileSystemUtils::Path& temporaryPath_ ) const
{
// Remove any existing intermediate directory

FileSystemUtils::PathIterator pathIter( m_Compiler.GetRuntimeIntermediatePath() );
std::string obj_extension = m_Compiler.GetObjectFileExtension();
while( ++pathIter )
{
if( pathIter.GetPath().Extension() == obj_extension )
{
if( m_pLogger )
{
m_pLogger->LogInfo( "Deleting temp RCC++ obj file: %s\n", pathIter.GetPath().c_str() );
}
pathIter.GetPath().Remove();
}
}
FileSystemUtils::PathIterator pathIter( temporaryPath_ );
std::string obj_extension = m_Compiler.GetObjectFileExtension();
while( ++pathIter )
{
if( pathIter.GetPath().Extension() == obj_extension )
{
if( m_pLogger )
{
m_pLogger->LogInfo( "Deleting temp RCC++ obj file: %s\n", pathIter.GetPath().c_str() );
}
pathIter.GetPath().Remove();
}
}
}


Expand All @@ -59,28 +58,29 @@ void BuildTool::Initialise( ICompilerLogger * pLogger )
m_Compiler.Initialise(pLogger);
}

void BuildTool::BuildModule( const std::vector<FileToBuild>& buildFileList,
const std::vector<FileSystemUtils::Path>& includeDirList,
const std::vector<FileSystemUtils::Path>& libraryDirList,
const std::vector<FileSystemUtils::Path>& linkLibraryList,
void BuildTool::BuildModule( const std::vector<FileToBuild>& buildFileList_,
const std::vector<FileSystemUtils::Path>& includeDirList_,
const std::vector<FileSystemUtils::Path>& libraryDirList_,
const std::vector<FileSystemUtils::Path>& linkLibraryList_,
RCppOptimizationLevel optimizationLevel_,
const char* pCompileOptions,
const char* pLinkOptions,
const FileSystemUtils::Path& moduleName )
const char* pCompileOptions_,
const char* pLinkOptions_,
const FileSystemUtils::Path& moduleName_,
const FileSystemUtils::Path& intermediatePath_ )
{
// Initial version is very basic, simply compiles them.
Path objectFileExtension = m_Compiler.GetObjectFileExtension();
vector<Path> compileFileList; // List of files we pass to the compiler
compileFileList.reserve( buildFileList.size() );
compileFileList.reserve( buildFileList_.size() );
vector<Path> forcedCompileFileList; // List of files which must be compiled even if object file exists
vector<Path> nonForcedCompileFileList; // List of files which can be linked if already compiled

// Seperate into seperate file lists of force and non-forced,
// so we can ensure we don't have the same file in both
for( size_t i = 0; i < buildFileList.size(); ++i )
for( size_t i = 0; i < buildFileList_.size(); ++i )
{
Path buildFile = buildFileList[i].filePath;
if( buildFileList[i].forceCompile )
Path buildFile = buildFileList_[i].filePath;
if( buildFileList_[i].forceCompile )
{
if( find( forcedCompileFileList.begin(), forcedCompileFileList.end(), buildFile ) == forcedCompileFileList.end() )
{
Expand All @@ -102,15 +102,16 @@ void BuildTool::BuildModule( const std::vector<FileToBuild>& buildFileList,
compileFileList.push_back( forcedCompileFileList[i] );
}

// runtime folder needs to be aware of compilation level and debug/

// Add non forced files, but only if they don't exist in forced compile list
Path runtimeFolder = m_Compiler.GetRuntimeIntermediatePath();
for( size_t i = 0; i < nonForcedCompileFileList.size(); ++i )
{
Path buildFile = nonForcedCompileFileList[i];
if( find( forcedCompileFileList.begin(), forcedCompileFileList.end(), buildFile ) == forcedCompileFileList.end() )
{
// Check if we have a pre-compiled object version of this file, and if so use that.
Path objectFileName = runtimeFolder/buildFile.Filename();
Path objectFileName = intermediatePath_ / buildFile.Filename();
objectFileName.ReplaceExtension(objectFileExtension.c_str());

if( objectFileName.Exists() && buildFile.Exists() )
Expand All @@ -126,5 +127,5 @@ void BuildTool::BuildModule( const std::vector<FileToBuild>& buildFileList,
}
}

m_Compiler.RunCompile( compileFileList, includeDirList, libraryDirList, linkLibraryList, optimizationLevel_, pCompileOptions, pLinkOptions, moduleName );
m_Compiler.RunCompile( compileFileList, includeDirList_, libraryDirList_, linkLibraryList_, optimizationLevel_, pCompileOptions_, pLinkOptions_, moduleName_, intermediatePath_ );
}
17 changes: 9 additions & 8 deletions Aurora/RuntimeCompiler/BuildTool.h
Expand Up @@ -31,7 +31,7 @@ class BuildTool
void Initialise( ICompilerLogger * pLogger );

// Clean - cleans up the intermediate files
void Clean() const;
void Clean( const FileSystemUtils::Path& temporaryPath_ ) const;

struct FileToBuild
{
Expand All @@ -49,14 +49,15 @@ class BuildTool
bool forceCompile; //if true the file is compiled even if object file is present
};

void BuildModule( const std::vector<FileToBuild>& buildFileList,
const std::vector<FileSystemUtils::Path>& includeDirList,
const std::vector<FileSystemUtils::Path>& libraryDirList,
const std::vector<FileSystemUtils::Path>& linkLibraryList,
void BuildModule( const std::vector<FileToBuild>& buildFileList_,
const std::vector<FileSystemUtils::Path>& includeDirList_,
const std::vector<FileSystemUtils::Path>& libraryDirList_,
const std::vector<FileSystemUtils::Path>& linkLibraryList_,
RCppOptimizationLevel optimizationLevel_,
const char* pCompileOptions,
const char* pLinkOptions,
const FileSystemUtils::Path& moduleName );
const char* pCompileOptions_,
const char* pLinkOptions_,
const FileSystemUtils::Path& moduleName_,
const FileSystemUtils::Path& intermediatePath_ );
bool GetIsComplete()
{
return m_Compiler.GetIsComplete();
Expand Down
31 changes: 27 additions & 4 deletions Aurora/RuntimeCompiler/CompileOptions.h
Expand Up @@ -20,7 +20,30 @@
enum RCppOptimizationLevel
{
RCCPPOPTIMIZATIONLEVEL_DEFAULT = 0, // RCCPPOPTIMIZATIONLEVEL_DEBUG in DEBUG, RCCPPOPTIMIZATIONLEVEL_PERF in release. This is the default state.
RCCPPOPTIMIZATIONLEVEL_DEBUG, // Low optimization, improve debug experiece. Default in DEBUG
RCCPPOPTIMIZATIONLEVEL_PERF, // Optimization for performance, debug experience may suffer. Default in RELEASE
RCCPPOPTIMIZATIONLEVEL_NOT_SET, // No optimization set in compile, so either underlying compiler default or set through SetAdditionalCompileOptions
};
RCCPPOPTIMIZATIONLEVEL_DEBUG, // Low optimization, improve debug experiece. Default in DEBUG
RCCPPOPTIMIZATIONLEVEL_PERF, // Optimization for performance, debug experience may suffer. Default in RELEASE
RCCPPOPTIMIZATIONLEVEL_NOT_SET, // No optimization set in compile, so either underlying compiler default or set through SetAdditionalCompileOptions
RCCPPOPTIMIZATIONLEVEL_SIZE, // Size of enum, do not use to set opt level
};

static const char* RCppOptimizationLevelStrings[] =
{
"DEFAULT",
"DEBUG",
"PERF",
"NOT_SET",
};

// GetActualOptimizationLevel - translates DEFAULT into DEUG or PERF
inline RCppOptimizationLevel GetActualOptimizationLevel( RCppOptimizationLevel optimizationLevel_ )
{
if( RCCPPOPTIMIZATIONLEVEL_DEFAULT == optimizationLevel_ )
{
#ifdef _DEBUG
optimizationLevel_ = RCCPPOPTIMIZATIONLEVEL_DEBUG;
#else
optimizationLevel_ = RCCPPOPTIMIZATIONLEVEL_PERF;
#endif
}
return optimizationLevel_;
}
4 changes: 2 additions & 2 deletions Aurora/RuntimeCompiler/Compiler.h
Expand Up @@ -55,9 +55,9 @@ class Compiler
RCppOptimizationLevel optimizationLevel_,
const char* pCompileOptions,
const char* pLinkOptions,
const FileSystemUtils::Path& outputFile );
const FileSystemUtils::Path& outputFile,
const FileSystemUtils::Path& intermediatePath );
bool GetIsComplete() const;
FileSystemUtils::Path GetRuntimeIntermediatePath() const;
private:
PlatformCompilerImplData* m_pImplData;
bool m_bFastCompileMode;
Expand Down
22 changes: 5 additions & 17 deletions Aurora/RuntimeCompiler/Compiler_PlatformPosix.cpp
Expand Up @@ -50,7 +50,6 @@ class PlatformCompilerImplData
m_PipeStdErr[1] = 1;
}

std::string m_intermediatePath;
volatile bool m_bCompileIsComplete;
ICompilerLogger* m_pLogger;
pid_t m_ChildForCompilationPID;
Expand Down Expand Up @@ -118,12 +117,6 @@ void Compiler::Initialise( ICompilerLogger * pLogger )
{
m_pImplData = new PlatformCompilerImplData;
m_pImplData->m_pLogger = pLogger;
m_pImplData->m_intermediatePath = "./Runtime";
}

FileSystemUtils::Path Compiler::GetRuntimeIntermediatePath() const
{
return m_pImplData->m_intermediatePath;
}

void Compiler::RunCompile( const std::vector<FileSystemUtils::Path>& filesToCompile,
Expand All @@ -133,7 +126,8 @@ void Compiler::RunCompile( const std::vector<FileSystemUtils::Path>& filesToComp
RCppOptimizationLevel optimizationLevel_,
const char* pCompileOptions,
const char* pLinkOptions,
const FileSystemUtils::Path& outputFile )
const FileSystemUtils::Path& outputFile,
const FileSystemUtils::Path& intermediatePath )
{
//NOTE: Currently doesn't check if a prior compile is ongoing or not, which could lead to memory leaks
m_pImplData->m_bCompileIsComplete = false;
Expand Down Expand Up @@ -195,15 +189,7 @@ void Compiler::RunCompile( const std::vector<FileSystemUtils::Path>& filesToComp
compileString += "-m32 ";
#endif

if( RCCPPOPTIMIZATIONLEVEL_DEFAULT == optimizationLevel_ )
{
#ifdef DEBUG
optimizationLevel_ = RCCPPOPTIMIZATIONLEVEL_DEBUG;
#else
optimizationLevel_ = RCCPPOPTIMIZATIONLEVEL_PERF;
#endif
}

optimizationLevel_ = GetActualOptimizationLevel( optimizationLevel_ );
switch( optimizationLevel_ )
{
case RCCPPOPTIMIZATIONLEVEL_DEFAULT:
Expand Down Expand Up @@ -237,11 +223,13 @@ void Compiler::RunCompile( const std::vector<FileSystemUtils::Path>& filesToComp
if( pCompileOptions )
{
compileString += pCompileOptions;
compileString += " ";
}
if( pLinkOptions && strlen(pLinkOptions) )
{
compileString += "-Wl,";
compileString += pLinkOptions;
compileString += " ";
}

// files to compile
Expand Down

0 comments on commit ab0b14e

Please sign in to comment.