#!/bin/sh

# compile-proto.sh
# AppleMediaServices
#
# Created by Daniel Jackson on 4/15/19.
# Copyright 2019 Apple Inc. All rights reserved.
# (Copied from PassKit)

cd `dirname $0`

PROTO_DIR=.

# LOOKUP=$PROTO_DIR/RequestTypeCodes.plist

AMS_OUTDIR=../Generated

rm -rf $AMS_OUTDIR/*

compile()
{
    PROTO="$1"
    OUTDIR="$2"
    
    shift
    shift
    
    echo
    echo +++++++ COMPILING $PROTO +++++++
    echo
    
    if [ ! -e "$OUTDIR" ] ; then
        mkdir -p "$OUTDIR"
    fi
    
    xcrun -sdk iphoneos.internal protocompiler \
        --outputDir $OUTDIR \
        --proto $PROTO $@ \
        --emitDeprecated=NO \
        --arc
        
    ret=$?        
    if [ "$ret" -ne "0" ] ; then
    	echo "Compilation failed with exit code $ret"
        exit $ret
    fi
}

compile $PROTO_DIR/AppleMediaServices.proto $AMS_OUTDIR

exit 0
