Commit 07c6de6f authored by Manuel Grizonnet's avatar Manuel Grizonnet

ENH: add parameter to OTBconfigfile

parent 0eb68b5d
...@@ -22,6 +22,7 @@ PURPOSE. See the above copyright notices for more information. ...@@ -22,6 +22,7 @@ PURPOSE. See the above copyright notices for more information.
#include <fstream> #include <fstream>
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <vector>
/** /**
* @brief main application for generating the otb.conf file. * @brief main application for generating the otb.conf file.
...@@ -32,87 +33,52 @@ PURPOSE. See the above copyright notices for more information. ...@@ -32,87 +33,52 @@ PURPOSE. See the above copyright notices for more information.
*/ */
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
if (argc != 3) const unsigned int nbParameters = 3;
{ // if (argc != 5)
exit(1); // {
} // exit(1);
// }
std::ofstream os(argv[1]); std::ofstream os(argv[1]);
if (!os) if (!os)
{ {
exit(1); exit(1);
} }
/*
// Get the version. This is now passed in from the make file.
std::string versionString = "Version ";
versionString += argv[2];
std::string versionNumber = argv[2];
std::string majorVersion;
std::string minorVersion = "0";
std::string releaseVersion = "0";
std::string::size_type pos1 = std::string::npos;
std::string::size_type pos2 = std::string::npos;
pos1 = versionNumber.find(".", 0); std::vector <std::string> paramVector;
if(pos1 != std::string::npos)
/* write available parameters to a vector */
for (unsigned int i=0;i<nbParameters;++i)
{ {
majorVersion = std::string(versionNumber.begin(), if ( argc >= ( i+3 ) )
versionNumber.begin()+pos1); {
pos2 = versionNumber.find(".", pos1+1); /** Get the default parameter (from cmake)*/
if(pos2 != std::string::npos) paramVector.push_back( argv[i+2] );
{ }
minorVersion = std::string(versionNumber.begin()+pos1+1, else
versionNumber.begin()+pos2); {
releaseVersion = std::string(versionNumber.begin()+pos2+1, /** Set param="" if the parameter is not available*/
versionNumber.end()); paramVector.push_back("");
} }
} }
else
{ // std::string language(argv[2]);
majorVersion = versionNumber; // std::string activateStreaming(argv[3]);
} // std::string sizeStreaming(argv[4]);
// Get the build date in the format of (yyyymmdd).
char s[11];
s[10] = '\0';
time_t t;
time(&t);
tm* lt = localtime(&t);
strftime(s, 11, "(%Y%m%d)", lt);
std::string date = s;
// Write the header file.
os << "// Auto generated by version-config - DO NOT EDIT\n"
<< "#ifndef ossimVersion_HEADER\n"
<< "#define ossimVersion_HEADER\n"
<< "\n"
<< "#include <ossim/ossimConfig.h>\n"
<< "\n"
<< "#ifndef OSSIM_VERSION\n"
<< "# define OSSIM_VERSION " << "\"" << versionString << "\"\n"
<< "# define OSSIM_VERSION_NUMBER " << "\"" << versionNumber << "\"\n"
<< "# define OSSIM_MAJOR_VERSION_NUMBER " << majorVersion << "\n"
<< "# define OSSIM_MINOR_VERSION_NUMBER " << minorVersion << "\n"
<< "# define OSSIM_RELEASE_NUMBER " << releaseVersion << "\n"
<< "#endif\n"
<< "\n"
<< "// date format = (yyyymmdd)\n"
<< "#ifndef OSSIM_BUILD_DATE\n"
<< "# define OSSIM_BUILD_DATE " << "\"" << date << "\"\n"
<< "#endif\n"
<< "\n"
<< "#endif /* End of #ifndef ossimVersion_HEADER "
<< std::endl;
*/
std::string language(argv[2]);
os << "#Auto generated by config-properties \n" os << "#Auto generated by config-properties \n"
<< "#Language \n"
<< "OTB_LANG=" << "OTB_LANG="
<< language << paramVector[0]
<< "\n"
<< "OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING="
<< paramVector[1]
<< "\n"
<< "OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING="
<< paramVector[2]
<< "\n" << "\n"
<< "# end of config file properties generation" << "#End of config file properties generation"
<< std::endl; << std::endl;
os.close(); os.close();
std::cout << "wrote file: " << argv[1] << std::endl; std::cout << "wrote file: " << argv[1] << std::endl;
......
...@@ -1136,5 +1136,5 @@ ADD_CUSTOM_COMMAND( ...@@ -1136,5 +1136,5 @@ ADD_CUSTOM_COMMAND(
TARGET GenerateConfigProperties TARGET GenerateConfigProperties
POST_BUILD POST_BUILD
COMMAND GenerateConfigProperties COMMAND GenerateConfigProperties
ARGS "${otbconfigfile_DEFAULT}" "${OTB_LANG}" ARGS "${otbconfigfile_DEFAULT}" "${OTB_LANG}" "${OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING}" "${OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING}"
COMMENT "Generating ${otbconfigfile_DEFAULT}" ) COMMENT "Generating ${otbconfigfile_DEFAULT}" )
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment