2014-10-25 15:13:40 +00:00
|
|
|
/*
|
2016-11-18 23:13:20 +00:00
|
|
|
This file is part of solidity.
|
2014-10-25 15:13:40 +00:00
|
|
|
|
2016-11-18 23:13:20 +00:00
|
|
|
solidity is free software: you can redistribute it and/or modify
|
2014-10-25 15:13:40 +00:00
|
|
|
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.
|
|
|
|
|
2016-11-18 23:13:20 +00:00
|
|
|
solidity is distributed in the hope that it will be useful,
|
2014-10-25 15:13:40 +00:00
|
|
|
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
|
2016-11-18 23:13:20 +00:00
|
|
|
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
2014-10-25 15:13:40 +00:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @author Christian <c@ethdev.com>
|
|
|
|
* @date 2014
|
2014-10-25 16:30:43 +00:00
|
|
|
* Solidity commandline compiler.
|
2014-10-25 15:13:40 +00:00
|
|
|
*/
|
2014-10-10 14:37:54 +00:00
|
|
|
|
2014-12-09 16:39:34 +00:00
|
|
|
#include "CommandLineInterface.h"
|
2016-08-30 11:29:37 +00:00
|
|
|
#include <clocale>
|
2015-08-19 23:09:39 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <boost/exception/all.hpp>
|
|
|
|
|
|
|
|
using namespace std;
|
2014-12-08 15:42:56 +00:00
|
|
|
|
2016-08-30 19:32:30 +00:00
|
|
|
/*
|
2016-08-31 20:00:46 +00:00
|
|
|
The equivalent of setlocale(LC_ALL, "C") is called before any user code is run.
|
2016-08-30 19:32:30 +00:00
|
|
|
If the user has an invalid environment setting then it is possible for the call
|
|
|
|
to set locale to fail, so there are only two possible actions, the first is to
|
|
|
|
throw a runtime exception and cause the program to quit (default behaviour),
|
|
|
|
or the second is to modify the environment to something sensible (least
|
|
|
|
surprising behaviour).
|
|
|
|
|
|
|
|
The follow code produces the least surprising behaviour. It will use the user
|
|
|
|
specified default locale if it is valid, and if not then it will modify the
|
|
|
|
environment the process is running in to use a sensible default. This also means
|
|
|
|
that users do not need to install language packs for their OS.
|
|
|
|
*/
|
|
|
|
void setDefaultOrCLocale()
|
2016-08-30 15:13:21 +00:00
|
|
|
{
|
2016-08-30 19:32:30 +00:00
|
|
|
#if __unix__
|
2016-08-30 15:13:21 +00:00
|
|
|
if (!std::setlocale(LC_ALL, ""))
|
|
|
|
{
|
2016-08-30 11:29:37 +00:00
|
|
|
setenv("LC_ALL", "C", 1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-10-10 14:37:54 +00:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2016-08-30 19:32:30 +00:00
|
|
|
setDefaultOrCLocale();
|
2014-12-09 16:39:34 +00:00
|
|
|
dev::solidity::CommandLineInterface cli;
|
|
|
|
if (!cli.parseArguments(argc, argv))
|
|
|
|
return 1;
|
|
|
|
if (!cli.processInput())
|
|
|
|
return 1;
|
2017-03-10 18:11:01 +00:00
|
|
|
bool success = false;
|
2015-08-19 23:09:39 +00:00
|
|
|
try
|
|
|
|
{
|
2017-03-10 18:11:01 +00:00
|
|
|
success = cli.actOnInput();
|
2015-08-19 23:09:39 +00:00
|
|
|
}
|
|
|
|
catch (boost::exception const& _exception)
|
|
|
|
{
|
|
|
|
cerr << "Exception during output generation: " << boost::diagnostic_information(_exception) << endl;
|
2017-03-10 18:11:01 +00:00
|
|
|
success = false;
|
2015-08-19 23:09:39 +00:00
|
|
|
}
|
2014-12-08 14:05:23 +00:00
|
|
|
|
2017-03-10 18:11:01 +00:00
|
|
|
return success ? 0 : 1;
|
2014-10-10 14:37:54 +00:00
|
|
|
}
|