#!/bin/bash

source build/envsetup.sh

if [[ $HOSTNAME == granite ]]; then
    readonly devices=(rango tegu tokay felix panther bluejay)
elif [[ $HOSTNAME = raphael ]]; then
    readonly devices=(mustang comet akita tangorpro raven)
elif [[ $HOSTNAME = raptor ]]; then
    readonly devices=(blazer komodo husky lynx oriole)
elif [[ $HOSTNAME = vermeer ]]; then
    readonly devices=(frankel caiman shiba cheetah)
else
    echo invalid hostname >&2
    exit 1
fi

for device in ${devices[@]}; do
    rm -rf out || exit 1
    lunch $device-cur-user || exit 1
    if [[ $device = @(bluejay|raven|oriole) ]]; then
        m vendorbootimage target-files-package otatools-package || exit 1
    else
        m vendorbootimage vendorkernelbootimage target-files-package otatools-package || exit 1
    fi
    script/finalize.sh || exit 1
    rm -rf out || exit 1
done
