2016-03-04 14:56:18 +01:00
|
|
|
/*
|
|
|
|
|
Copyright 2016 Statoil ASA.
|
|
|
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2016-12-05 12:57:59 +01:00
|
|
|
|
|
|
|
|
#if !defined(WIN32)
|
|
|
|
|
#define _POSIX_C_SOURCE 200112L
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-01-24 21:49:39 +01:00
|
|
|
#include <iostream>
|
2016-12-05 12:57:59 +01:00
|
|
|
#include <locale>
|
|
|
|
|
|
|
|
|
|
#include <boost/filesystem.hpp>
|
2016-01-24 21:49:39 +01:00
|
|
|
|
2015-04-23 11:31:10 +02:00
|
|
|
#include <opm/parser/eclipse/Generator/KeywordGenerator.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/Generator/KeywordLoader.hpp>
|
2014-04-08 01:44:27 +02:00
|
|
|
|
2013-09-14 21:44:20 +02:00
|
|
|
|
2015-04-23 11:31:10 +02:00
|
|
|
int main(int argc , char ** argv) {
|
2016-01-18 11:53:26 +01:00
|
|
|
if (argc == 7) {
|
2015-04-23 11:31:10 +02:00
|
|
|
const char * config_root = argv[1];
|
|
|
|
|
const char * source_file_name = argv[2];
|
2016-01-18 11:53:26 +01:00
|
|
|
const char * header_file_base_path = argv[3];
|
|
|
|
|
const char * header_file_name = argv[4];
|
|
|
|
|
const char * test_file_name = argv[5];
|
|
|
|
|
const char * output_files = argv[6];
|
2015-08-01 09:26:45 +02:00
|
|
|
bool verboseLoader = false;
|
|
|
|
|
bool verboseGenerator = true;
|
2014-04-08 01:44:27 +02:00
|
|
|
|
2016-12-05 12:57:59 +01:00
|
|
|
try {
|
|
|
|
|
/* sometimes the local env's locales are broken on POSIX. Boost <=
|
|
|
|
|
* 1.56 uses the std::locale("") constructor which respects user
|
|
|
|
|
* preferred locales, and might crash. If this is the case, and
|
|
|
|
|
* we're on a non-windows system (assuming POSIX), in case of an
|
|
|
|
|
* exception, set the environment to "C" and keep going.
|
|
|
|
|
*
|
|
|
|
|
* Can be removed once boost < 1.57 is no longer supported
|
|
|
|
|
*/
|
|
|
|
|
std::locale( "" );
|
|
|
|
|
} catch( const std::runtime_error& ) {
|
|
|
|
|
#if !defined(WIN32)
|
|
|
|
|
setenv( "LC_ALL", "C", 1 );
|
|
|
|
|
#endif
|
|
|
|
|
auto loc = boost::filesystem::path::imbue( std::locale::classic() );
|
|
|
|
|
boost::filesystem::path::imbue( loc );
|
|
|
|
|
std::cout << "User preferred locale setting is invalid "
|
|
|
|
|
<< "which breaks Boost <= 1.56 "
|
|
|
|
|
<< "- forcing to 'C' as workaround for Boost <= 1.56. "
|
|
|
|
|
<< "This workaround only applies to compile opm-parser, "
|
|
|
|
|
<< "but your locale settings seem BROKEN, "
|
|
|
|
|
<< "and opm-parser is likely NOT GOING TO WORK. "
|
|
|
|
|
<< "If you're on linux you can try setting the LANG "
|
|
|
|
|
<< "or LC_ALL environment variables to C or POSIX."
|
|
|
|
|
<< std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-01 09:26:45 +02:00
|
|
|
Opm::KeywordLoader loader(verboseLoader);
|
|
|
|
|
Opm::KeywordGenerator generator(verboseGenerator);
|
2015-04-23 11:31:10 +02:00
|
|
|
loader.loadMultipleKeywordDirectories( config_root );
|
2014-04-08 01:44:27 +02:00
|
|
|
|
2016-01-18 11:53:26 +01:00
|
|
|
const int num_output_files = std::atoi( output_files );
|
|
|
|
|
generator.updateSource(loader , source_file_name, num_output_files );
|
|
|
|
|
generator.updateHeader(loader, header_file_base_path, header_file_name );
|
2015-04-23 11:31:10 +02:00
|
|
|
generator.updateTest(loader , test_file_name );
|
2013-09-14 21:44:20 +02:00
|
|
|
|
2015-04-23 11:31:10 +02:00
|
|
|
exit(0);
|
|
|
|
|
} else {
|
2016-01-18 11:53:26 +01:00
|
|
|
std::cerr << "Error calling keyword generator: Expected arguments: <config_root> <source_file_name> <header_build_path> <header_file_name> <test_file_name> <num_output_files>" << std::endl;
|
2015-04-23 11:31:10 +02:00
|
|
|
exit(1);
|
2014-04-02 11:47:23 +02:00
|
|
|
}
|
2014-04-01 08:52:07 +02:00
|
|
|
}
|