1#!/bin/bash 2 3# Copyright 2016, Data61, CSIRO 4# 5# This software may be distributed and modified according to the terms of 6# the BSD 2-Clause license. Note that NO WARRANTY is provided. 7# See "LICENSE_BSD2.txt" for details. 8# 9# @TAG(DATA61_BSD) 10 11# Bash 'strict' mode 12set -euo pipefail 13IFS=$'\n\t' 14 15DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 16 17function show_architectures () { 18 ( 19 cd "$DIR" 20 ARCHES= 21 shopt -s nullglob 22 for EXE in */c-parser; do 23 ARCHES="$ARCHES ${EXE%/c-parser}" 24 done 25 if [ -z "$ARCHES" ]; then 26 echo "There are no standalone C-parser architectures currently built." 27 echo "Try running 'make' in $DIR" 28 else 29 echo "Available architectures are:$ARCHES" 30 echo "Please supply an architecture name as the first argument." 31 fi 32 ) 33 exit 1 34} 35 36if [ $# -eq 0 ]; then 37 show_architectures 38fi 39 40ARCH="$1"; shift 41EXE="$DIR/$ARCH/c-parser" 42 43if [ ! -x "$EXE" ]; then 44 echo "Unknown architecture $ARCH" >&2 45 show_architectures 46fi 47 48exec "$EXE" "$@" 49