kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/docs/schema/example-base.sh (about) 1 #!/bin/bash -e 2 # Copyright 2014 The Kythe Authors. All rights reserved. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 # This script verifies and formats a single Kythe example, which is expected 17 # to be piped in on standard input. 18 # 19 # Usage: example.sh asciidoc-backend asciidoc-style-name language test-label 20 # where asciidoc-backend is the asciidoc target (currently ignored; 21 # we emit only HTML) 22 # asciidoc-style-name is the asciidoc style used to invoke the filter 23 # language is the language passed to the filter 24 # (supported are C++ and Java) 25 # test-label is the (potentially space-containing) short text 26 # label describing the test. 27 28 export ROOT="$PWD" 29 export SCHEMA_ROOT="$PWD/kythe/docs/schema" 30 cd "$OUTDIR" 31 32 export CXX_INDEXER_BIN= 33 export GO_INDEXER_BIN= 34 export JAVA_INDEXER_BIN= 35 export JAVA_EXTRACTOR_BIN= 36 export VERIFIER_BIN= 37 export SHASUM_TOOL= 38 39 export LANGUAGE="$3" 40 export LABEL="$4" 41 export SHOWGRAPH="$5" 42 export DIV_STYLE="$6" 43 export VERIFIER_ARGS="$7" 44 export KYTHE_CORPUS="kythe" 45 46 47 error() { 48 echo "[ FAILED $1: $LABEL ]" >&2 49 exit 1 50 } 51 export -f error 52 53 export TMP 54 TMP="$(mktemp -d 2>/dev/null || mktemp -d -t 'kythetest')" 55 trap 'rm -rf "$TMP"' EXIT ERR INT 56 57 case "$LANGUAGE" in 58 Java) 59 "$SCHEMA_ROOT/example-java.sh" ;; 60 C++) 61 "$SCHEMA_ROOT/example-cxx.sh" ;; 62 Go) 63 "$SCHEMA_ROOT/example-go.sh" ;; 64 ObjC) 65 "$SCHEMA_ROOT/example-objc.sh" ;; 66 dot) 67 "$SCHEMA_ROOT/example-dot.sh" ;; 68 clike) 69 "$SCHEMA_ROOT/example-clike.sh" ;; 70 *) 71 echo "ERROR: unsupported language specified for example: $LANGUAGE" 72 exit 1 ;; 73 esac