1 #ifndef CPPAD_CG_DYNAMIC_LIBRARY_PROCESSOR_INCLUDED 2 #define CPPAD_CG_DYNAMIC_LIBRARY_PROCESSOR_INCLUDED 54 std::string libraryName =
"cppad_cg_model") :
56 _libraryName(
std::move(libraryName)) {
73 CPPADCG_ASSERT_KNOWN(!libraryName.empty(),
"Library name cannot be empty")
75 _libraryName = libraryName;
84 return _customLibExtension.get();
93 _customLibExtension.reset(
new std::string(libraryExtension));
100 _customLibExtension.reset();
113 inline const std::map<std::string, std::string>&
getOptions()
const {
126 bool loadLib =
true) {
130 this->modelLibraryHelper_->startingJob(
"", JobTimer::DYNAMIC_MODEL_LIBRARY);
132 const std::map<std::string, ModelCSourceGen < Base>*>&models = this->modelLibraryHelper_->getModels();
134 for (
const auto& p : models) {
135 const std::map<std::string, std::string>& modelSources = this->getSources(*p.second);
137 this->modelLibraryHelper_->startingJob(
"", JobTimer::COMPILING_FOR_MODEL);
138 compiler.
compileSources(modelSources,
true, this->modelLibraryHelper_);
139 this->modelLibraryHelper_->finishedJob();
142 const std::map<std::string, std::string>& sources = this->getLibrarySources();
143 compiler.
compileSources(sources,
true, this->modelLibraryHelper_);
145 const std::map<std::string, std::string>& customSource = this->modelLibraryHelper_->getCustomSources();
146 compiler.
compileSources(customSource,
true, this->modelLibraryHelper_);
149 if (_customLibExtension !=
nullptr)
154 compiler.
buildDynamic(libname, this->modelLibraryHelper_);
162 this->modelLibraryHelper_->finishedJob();
165 return loadDynamicLibrary();
167 return std::unique_ptr<DynamicLib<Base>> (
nullptr);
187 this->modelLibraryHelper_->startingJob(
"", JobTimer::STATIC_MODEL_LIBRARY);
189 const std::map<std::string, ModelCSourceGen<Base>*>& models = this->modelLibraryHelper_->getModels();
191 for (
const auto& p : models) {
192 const std::map<std::string, std::string>& modelSources = this->getSources(*p.second);
194 this->modelLibraryHelper_->startingJob(
"", JobTimer::COMPILING_FOR_MODEL);
195 compiler.
compileSources(modelSources, posIndepCode, this->modelLibraryHelper_);
196 this->modelLibraryHelper_->finishedJob();
199 const std::map<std::string, std::string>& sources = this->getLibrarySources();
200 compiler.
compileSources(sources, posIndepCode, this->modelLibraryHelper_);
202 const std::map<std::string, std::string>& customSource = this->modelLibraryHelper_->getCustomSources();
203 compiler.
compileSources(customSource, posIndepCode, this->modelLibraryHelper_);
206 if (_customLibExtension !=
nullptr)
211 ar.create(libname, compiler.getObjectFiles(), this->modelLibraryHelper_);
218 this->modelLibraryHelper_->finishedJob();
224 virtual std::unique_ptr<DynamicLib<Base>> loadDynamicLibrary();
DynamicModelLibraryProcessor(ModelLibraryCSourceGen< Base > &modelLibGen, std::string libraryName="cppad_cg_model")
virtual void compileSources(const std::map< std::string, std::string > &sources, bool posIndepCode, JobTimer *timer=nullptr)=0
const std::string & getLibraryName() const
std::map< std::string, std::string > & getOptions()
virtual void buildDynamic(const std::string &library, JobTimer *timer=nullptr)=0
std::unique_ptr< const std::string > _customLibExtension
void setCustomLibraryExtension(const std::string &libraryExtension)
void removeCustomLibraryExtension()
std::map< std::string, std::string > _options
void setLibraryName(const std::string &libraryName)
std::unique_ptr< DynamicLib< Base > > createDynamicLibrary(CCompiler< Base > &compiler, bool loadLib=true)
const std::map< std::string, std::string > & getOptions() const
void createStaticLibrary(CCompiler< Base > &compiler, Archiver &ar, bool posIndepCode)
const std::string * getCustomLibraryExtension() const