diff --git a/tools/dioscc.cpp b/tools/dioscc.cpp new file mode 100644 index 0000000000000000000000000000000000000000..40346935029f5e8fcbd51f47f241ad9e8d19bc61 --- /dev/null +++ b/tools/dioscc.cpp @@ -0,0 +1,52 @@ +// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- + +/* + * (c) 2017 Jan Horáček <me@apophis.cz> + * (c) 2017-2019 Zuzana Baranová <xbaranov@fi.muni.cz> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <divine/cc/cc1.hpp> //CompileError +#include <divine/cc/native.hpp> +#include <divine/rt/dios-cc.hpp> +#include <divine/rt/runtime.hpp> +#include <divine/ui/version.hpp> + + +using namespace divine; + +/* usage: same as gcc */ +int main( int argc, char **argv ) +{ + try { + rt::NativeDiosCC nativeCC( { argv + 1, argv + argc } ); + nativeCC.set_cxx( brick::string::endsWith( argv[0], "divc++" ) ); + auto& po = nativeCC._po; + + if ( po.hasHelp || po.hasVersion ) + { + nativeCC.print_info( ui::version() ); + return 0; + } + + return nativeCC.run(); + + } catch ( cc::CompileError &err ) { + std::cerr << err.what() << std::endl; + return 1; + } catch ( std::runtime_error &err ) { + std::cerr << "compilation failed: " << err.what() << std::endl; + return 2; + } +}