CppADCodeGen  HEAD
A C++ Algorithmic Differentiation Package with Source Code Generation
CppAD::cg::AbstractCCompiler< Base > Class Template Referenceabstract
Inheritance diagram for CppAD::cg::AbstractCCompiler< Base >:
Inheritance graph
Collaboration diagram for CppAD::cg::AbstractCCompiler< Base >:
Collaboration graph

Public Member Functions

 AbstractCCompiler (const std::string &compilerPath)
 
 AbstractCCompiler (const AbstractCCompiler &orig)=delete
 
AbstractCCompileroperator= (const AbstractCCompiler &rhs)=delete
 
std::string getCompilerPath () const
 
void setCompilerPath (const std::string &path)
 
const std::string & getTemporaryFolder () const override
 
void setTemporaryFolder (const std::string &tmpFolder) override
 
bool isSaveToDiskFirst () const override
 
void setSaveToDiskFirst (bool saveToDiskFirst) override
 
const std::string & getSourcesFolder () const override
 
void setSourcesFolder (const std::string &srcFolder) override
 
const std::set< std::string > & getObjectFiles () const override
 
const std::set< std::string > & getSourceFiles () const override
 
const std::vector< std::string > & getCompileFlags () const
 
void setCompileFlags (const std::vector< std::string > &compileFlags)
 
void addCompileFlag (const std::string &compileFlag)
 
const std::vector< std::string > & getLinkFlags () const
 
void setLinkFlags (const std::vector< std::string > &linkFlags)
 
void addLinkFlag (const std::string &linkFlag)
 
const std::vector< std::string > & getCompileLibFlags () const
 
void setCompileLibFlags (const std::vector< std::string > &compileLibFlags)
 
void addCompileLibFlag (const std::string &compileLibFlag)
 
bool isVerbose () const override
 
void setVerbose (bool verbose) override
 
void compileSources (const std::map< std::string, std::string > &sources, bool posIndepCode, JobTimer *timer=nullptr) override
 
virtual void compileSources (const std::map< std::string, std::string > &sources, bool posIndepCode, JobTimer *timer, const std::string &outputExtension, std::set< std::string > &outputFiles)
 
virtual void buildDynamic (const std::string &library, JobTimer *timer=nullptr) override=0
 
void cleanup () override
 

Protected Member Functions

virtual void compileSource (const std::string &source, const std::string &output, bool posIndepCode)=0
 
virtual void compileFile (const std::string &path, const std::string &output, bool posIndepCode)=0
 

Protected Attributes

std::string _path
 
std::string _tmpFolder
 
std::string _sourcesFolder
 
std::set< std::string > _ofiles
 
std::set< std::string > _sfiles
 
std::vector< std::string > _compileFlags
 
std::vector< std::string > _compileLibFlags
 
std::vector< std::string > _linkFlags
 
bool _verbose
 
bool _saveToDiskFirst
 

Detailed Description

template<class Base>
class CppAD::cg::AbstractCCompiler< Base >

Default implementation of a C compiler class used to create dynamic and static libraries

Author
Joao Leal

Definition at line 29 of file abstract_c_compiler.hpp.

Member Function Documentation

◆ buildDynamic()

template<class Base >
virtual void CppAD::cg::AbstractCCompiler< Base >::buildDynamic ( const std::string &  library,
JobTimer timer = nullptr 
)
overridepure virtual

Creates a dynamic library from a set of object files

Parameters
librarythe path to the dynamic library to be created

Implements CppAD::cg::CCompiler< Base >.

Implemented in CppAD::cg::ClangCompiler< Base >, and CppAD::cg::GccCompiler< Base >.

Referenced by CppAD::cg::AbstractCCompiler< Base >::compileSources().

◆ cleanup()

template<class Base >
void CppAD::cg::AbstractCCompiler< Base >::cleanup ( )
inlineoverridevirtual

Deletes the previously compiled object files and clears of files to include in a dynamic library

Implements CppAD::cg::CCompiler< Base >.

Reimplemented in CppAD::cg::ClangCompiler< Base >.

Definition at line 254 of file abstract_c_compiler.hpp.

Referenced by CppAD::cg::ClangCompiler< Base >::cleanup().

◆ compileFile()

template<class Base >
virtual void CppAD::cg::AbstractCCompiler< Base >::compileFile ( const std::string &  path,
const std::string &  output,
bool  posIndepCode 
)
protectedpure virtual

Compiles a single source file into an object file.

Parameters
paththe path to the source file
outputthe compiled output file name (the object file path)

Implemented in CppAD::cg::ClangCompiler< Base >, and CppAD::cg::GccCompiler< Base >.

Referenced by CppAD::cg::AbstractCCompiler< Base >::cleanup(), and CppAD::cg::AbstractCCompiler< Base >::compileSources().

◆ compileSource()

template<class Base >
virtual void CppAD::cg::AbstractCCompiler< Base >::compileSource ( const std::string &  source,
const std::string &  output,
bool  posIndepCode 
)
protectedpure virtual

Compiles a single source file into an object file.

Parameters
sourcethe content of the source file
outputthe compiled output file name (the object file path)

Implemented in CppAD::cg::ClangCompiler< Base >, and CppAD::cg::GccCompiler< Base >.

Referenced by CppAD::cg::AbstractCCompiler< Base >::cleanup(), and CppAD::cg::AbstractCCompiler< Base >::compileSources().

◆ compileSources()

template<class Base >
void CppAD::cg::AbstractCCompiler< Base >::compileSources ( const std::map< std::string, std::string > &  sources,
bool  posIndepCode,
JobTimer timer = nullptr 
)
inlineoverridevirtual

Compiles the provided C source code.

Parameters
librarythe path of the dynamic library to be created
sourcesmaps the names to the content of the source files
posIndepCodewhether or not to create position-independent code for dynamic linking

Implements CppAD::cg::CCompiler< Base >.

Definition at line 146 of file abstract_c_compiler.hpp.

◆ getSourcesFolder()

template<class Base >
const std::string& CppAD::cg::AbstractCCompiler< Base >::getSourcesFolder ( ) const
inlineoverridevirtual

Provides the path to a folder where the source files should be created when the option to save files to disk is active.

Returns
path to a folder.

Implements CppAD::cg::CCompiler< Base >.

Definition at line 78 of file abstract_c_compiler.hpp.

◆ getTemporaryFolder()

template<class Base >
const std::string& CppAD::cg::AbstractCCompiler< Base >::getTemporaryFolder ( ) const
inlineoverridevirtual

Provides the path to a temporary folder that should not exist (it will be deleted after the dynamic library is created)

Returns
path to a temporary folder.

Implements CppAD::cg::CCompiler< Base >.

Definition at line 62 of file abstract_c_compiler.hpp.

◆ setSourcesFolder()

template<class Base >
void CppAD::cg::AbstractCCompiler< Base >::setSourcesFolder ( const std::string &  srcFolder)
inlineoverridevirtual

Defines the path to a folder where the source files should be created when the option to save files to disk is active.

Parameters
srcFolderpath to the folder.

Implements CppAD::cg::CCompiler< Base >.

Definition at line 82 of file abstract_c_compiler.hpp.

◆ setTemporaryFolder()

template<class Base >
void CppAD::cg::AbstractCCompiler< Base >::setTemporaryFolder ( const std::string &  tmpFolder)
inlineoverridevirtual

Defines the path to a temporary folder that should not exist (it will be deleted after the dynamic library is created)

Parameters
tmpFolderpath to a temporary folder.

Implements CppAD::cg::CCompiler< Base >.

Definition at line 66 of file abstract_c_compiler.hpp.


The documentation for this class was generated from the following file: