Home | History | Annotate | Download | only in studio
      1 #!/bin/bash -e
      2 # Takes kythe indexer output and processes it into servable format
      3 # And brings up a webserver (port 8080) to inspect the data.
      4 #
      5 # This is not used for normal production runs as processing on a single
      6 # machine is very slow (our index output is currently around 20GB).
      7 #
      8 # Instead the processing is done with a MapReduce job.
      9 
     10 # Path to the kyth binaries.
     11 KYTHE_ROOT="$(readlink -f prebuilts/tools/linux-x86_64/kythe)"
     12 
     13 # Get the output path for the kythe artifacts.
     14 OUT="$1"
     15 OUT_ENTRIES="${OUT}/entries"
     16 OUT_GRAPHSTORE="${OUT}/graphstore"
     17 OUT_SERVING="${OUT}/serving"
     18 if [ -z "${OUT}" ]; then
     19   echo Usage: $0 \<out_dir\>
     20   echo  e.g. $0 $HOME/studio_kythe
     21   echo
     22   echo $0 must be launched from the root of the studio branch.
     23   exit 1
     24 fi
     25 
     26 # if the graphstore has not been created, create it from the
     27 # entries created using "build_studio_kythe.sh"
     28 if [ ! -d "${OUT_GRAPHSTORE}" ]; then
     29 
     30   # delete all empty files as the write_entries tool is not happy with
     31   # empty files
     32   find "${OUT_ENTRIES}" -empty -type f -delete
     33   ENTRIES=$(find "${OUT_ENTRIES}" -name *.entries \
     34     -exec realpath {} \;)
     35 
     36   for ENTRY in ${ENTRIES}; do
     37     "${KYTHE_ROOT}/tools/write_entries" \
     38       --graphstore "leveldb:${OUT_GRAPHSTORE}" < "${ENTRY}"
     39   done;
     40 fi
     41 
     42 # If no serving table exists yet, create it from the graphstore.
     43 if [ ! -d "${OUT_SERVING}" ]; then
     44   "${KYTHE_ROOT}/tools/write_tables" \
     45     --graphstore "${OUT_GRAPHSTORE}" \
     46     --out "${OUT_SERVING}"
     47 fi
     48 
     49 # Start the kythe webserver for the serving table.
     50 "${KYTHE_ROOT}/tools/http_server" \
     51   --public_resources "${KYTHE_ROOT}/web/ui" \
     52   --listen localhost:8080 \
     53   --serving_table "${OUT_SERVING}"