text: // Declares clang::SyntaxOnlyAction.
  #include "clang/Frontend/FrontendActions.h"
  #include "clang/Tooling/CommonOptionsParser.h"
  #include "clang/Tooling/Tooling.h"
  #include <iostream>
  #include <sstream>
  
  // Declares llvm::cl::extrahelp.
  #include "llvm/Support/CommandLine.h"
  #include "llvm/Support/FileSystem.h"
  #include "llvm/Support/Program.h"
  
  using namespace clang::tooling;
  using namespace llvm;
  
  #define COMPILER_NAME "eosio-cc"
  #include <compiler_options.hpp>
  
  int main(int argc, const char **argv) {
  
    // fix to show version info without having to have any other arguments
    for (int i=0; i < argc; i++) {
      if (argv[i] == std::string("-v")) {
        eosio::cdt::environment::exec_subprogram("clang-7", {"-v"});
        return 0;
      }
    }
  
    cl::SetVersionPrinter([](llvm::raw_ostream& os) {
          os << COMPILER_NAME << " version " << "1.5.0" << "\n";
    });
    cl::ParseCommandLineOptions(argc, argv, std::string(COMPILER_NAME)+" (Eosio C -> WebAssembly compiler)");
    Options opts = CreateOptions();
  
    // first compile
    if (!eosio::cdt::environment::exec_subprogram("clang-7", opts.comp_options))
       return -1;
  
    if ( !llvm::sys::fs::exists( opts.output_fn ) ) {
       return -1;
    }
    // then link
    //
    if (opts.link) {
       if (!eosio::cdt::environment::exec_subprogram("eosio-ld", opts.ld_options))
          return -1;
  
       if ( !llvm::sys::fs::exists( opts.output_fn ) ) {
          return -1;
       }
    }
    if (opts.abigen) {
        opts.abigen_options.emplace(opts.abigen_options.begin(), "-- -Wno-unused-command-line-argument");
        opts.abigen_options.emplace(opts.abigen_options.begin(), "-contract="+opts.abigen_contract);
        std::string abigen_output = opts.abigen_output.empty() ? opts.output_fn.substr(0, opts.output_fn.rfind(".wasm"))+".abi" : opts.abigen_output;
        opts.abigen_options.emplace(opts.abigen_options.begin(), "-output="+abigen_output);
        opts.abigen_options.insert(opts.abigen_options.begin(), opts.abigen_inputs);
        for ( auto res : opts.abigen_resources )
           opts.abigen_options.emplace(opts.abigen_options.begin(), res);
  
        if (!eosio::cdt::environment::exec_subprogram("eosio-abigen", opts.abigen_options))
           return -1;
    }
    return 0;
  }
  