1#!/usr/bin/env bash
2
3# Copyright 2018 The Fuchsia Authors
4#
5# Use of this source code is governed by a MIT-style
6# license that can be found in the LICENSE file or at
7# https://opensource.org/licenses/MIT
8
9function HELP {
10    echo "help:"
11    echo "-a <arch>            : arm64, or x64"
12    echo "-A                   : use ASan build"
13    echo "-C                   : use Clang build"
14    echo "-l                   : use ThinLTO build"
15    echo "-L                   : use LTO build"
16    echo "-q                   : build quietly"
17    echo "-v                   : build verbosely"
18    echo "-r                   : build release build"
19    echo "-d                   : build unoptimized, with full debug symbols"
20    echo "-h for help"
21    echo "all arguments after -- are passed to make directly"
22    exit 1
23}
24
25DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
26
27ARGS=
28ARCH=
29QUIET=0
30
31while getopts a:ACdhlLqrv FLAG; do
32    case $FLAG in
33        a) ARCH=${OPTARG};;
34        A) ARGS+=" USE_ASAN=true USE_CLANG=true";;
35        C) ARGS+=" USE_CLANG=true";;
36        d) ARGS+=" DEBUG_HARD=1";;
37        l) ARGS+=" USE_THINLTO=true";;
38        L) ARGS+=" USE_LTO=true";;
39        q) ARGS+=" QUIET=1";;
40        r) ARGS+=" DEBUG=0";;
41        v) ARGS+=" NOECHO=";;
42        h) HELP ;;
43        \?)
44            echo unrecognized option
45            HELP
46    esac
47done
48shift $((OPTIND-1))
49
50if [[ ! ${ARCH} ]]; then
51    echo no arch specified!
52    HELP
53fi
54
55exec ${DIR}/make-parallel ${ARCH} ${ARGS} "$@"
56