#!/bin/bash

usage="$(basename "$0") [-r RootPath] [-p platform] -- program to generate xcode project for iOS simulator ARM64 (arm64) (MacOS ARM host)

where:
    -r Path to ODA main source root
    -p Platform name (e.g. iOS_17.0sim, see platform in archive name)
    
Note: cmake command-line shall be installed in the host, e.g. 'brew install cmake'"

if [ $# -eq 0 ]
  then
  echo "$usage" >&2
  exit 1
fi

while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do case $1 in
   -r )
     shift; RootPath=$1
     ;;
   -p )
     shift; Platform=$1
     ;;
   \?) printf "illegal option: -%s\n" "$OPTARG" >&2
     echo "$usage" >&2
     exit 1
     ;;
   esac; shift;
done

cmake -DRootPath=$RootPath -DODA_PLATFORM=$Platform -DCMAKE_TOOLCHAIN_FILE=./ios.toolchain.cmake -DPLATFORM=SIMULATORARM64 -H. -Bbuild.iossimARM64 -GXcode

