kythe/cxx/tools/meta_index/meta_index.cc
// TODO(zarko): consider making smaller vnameses.json if it turns out that
// doing all the matching is too slow
consider making smaller vnameses.json if it turns out that
doing all the matching is too slow
consider making smaller vnameses . json if it turns out that doing all the matching is too slow
void Repositories::ExportIndexScript(const llvm::Twine &path,
                                     const llvm::Twine &vnames_json,
                                     const llvm::Twine &subgraph) {
  auto out_file = OpenFile(path.str().c_str(), "w");
  if (!out_file) {
    LOG(ERROR) << "can't open " << path.str();
    return;
  }
  auto write = [&out_file](const char *value) {
    ::fputs(value, out_file.get());
  };
  ::fprintf(out_file.get(), R"zz(#!/bin/bash
: "${KYTHE_GRAPHSTORE:?No KYTHE_GRAPHSTORE specified.}"
KYTHE_GRAPHSTORE="$(realpath ${KYTHE_GRAPHSTORE})"
export KYTHE_VNAMES="%s"
KYTHE_SUBGRAPH="%s"
)zz",
            vnames_json.str().c_str(), subgraph.str().c_str());
  for (const auto &repo : repositories_) {
    std::vector<std::string> index_args = repo->GetIndexArgs();
    if (index_args.empty()) {
      continue;
    }
    write("(cd kythe/ts && \\\n");
    write("  node build/lib/main.js --skipDefaultLib \\\n");
    for (const auto &arg : index_args) {
      ::fprintf(out_file.get(), "    %s \\\n", ShellQuote(arg).c_str());
    }
    write(" | /opt/kythe/tools/entrystream --read_json \\\n");
    write(" | /opt/kythe/tools/write_entries -graphstore \\\n");
    write("    \"${KYTHE_GRAPHSTORE}\")\n");
  }
  write(R"(
/opt/kythe/tools/write_entries -graphstore "${KYTHE_GRAPHSTORE}" \
    < "${KYTHE_SUBGRAPH}"
if [[ ! -z "${KYTHE_TABLES}" ]]; then
  /opt/kythe/tools/write_tables -graphstore "${KYTHE_GRAPHSTORE}" \
      -out="${KYTHE_TABLES}"
  if [[ ! -z "${KYTHE_LISTEN_AT}" ]]; then
    /opt/kythe/tools/http_server -serving_table "${KYTHE_TABLES}" \
        -public_resources="/opt/kythe/web/ui" \
        -listen="${KYTHE_LISTEN_AT}"
  fi
fi
exit 0
)");
}
void Repositories :: ExportIndexScript ( const llvm :: Twine & path , const llvm :: Twine & vnames_json , const llvm :: Twine & subgraph ) { auto out_file = OpenFile ( path . str ( ) . c_str ( ) , " " ) ; if ( ! out_file ) { LOG ( ERROR ) << " " << path . str ( ) ; return ; } auto write = [ & out_file ] ( const char * value ) { :: fputs ( value , out_file . get ( ) ) ; } ; :: fprintf ( out_file . get ( ) , R" zz ( #!/bin/bash
: "${KYTHE_GRAPHSTORE:?No KYTHE_GRAPHSTORE specified.}"
KYTHE_GRAPHSTORE="$(realpath ${KYTHE_GRAPHSTORE})"
export KYTHE_VNAMES="%s"
KYTHE_SUBGRAPH="%s"
 ) zz " , vnames_json . str ( ) . c_str ( ) , subgraph . str ( ) . c_str ( ) ) ; for ( const auto & repo : repositories_ ) { std :: vector < std :: string > index_args = repo -> GetIndexArgs ( ) ; if ( index_args . empty ( ) ) { continue ; } write ( " \\ \n " ) ; write ( " \\ \n " ) ; for ( const auto & arg : index_args ) { :: fprintf ( out_file . get ( ) , " \\ \n " , ShellQuote ( arg ) . c_str ( ) ) ; } write ( " \\ \n " ) ; write ( " \\ \n " ) ; write ( " \" \" \n " ) ; } write ( R" ( 
/opt/kythe/tools/write_entries -graphstore "${KYTHE_GRAPHSTORE}" \
    < "${KYTHE_SUBGRAPH}"
if [[ ! -z "${KYTHE_TABLES}" ]]; then
  /opt/kythe/tools/write_tables -graphstore "${KYTHE_GRAPHSTORE}" \
      -out="${KYTHE_TABLES}"
  if [[ ! -z "${KYTHE_LISTEN_AT}" ]]; then
    /opt/kythe/tools/http_server -serving_table "${KYTHE_TABLES}" \
        -public_resources="/opt/kythe/web/ui" \
        -listen="${KYTHE_LISTEN_AT}"
  fi
fi
exit 0
 ) " ) ; }
TODO(zarko): consider making smaller vnameses.json if it turns out that
doing all the matching is too slow
TODO ( zarko ) : consider making smaller vnameses . json if it turns out that doing all the matching is too slow