#!/bin/bash

APP_NAME="APP"

APP_CODE_SIGN_IDENTITY="iPhone Distribution: XXXX (XXXX)"

APP_PROVISIONING_PROFILE="/workspace/tmp/daily/adHoc.mobileprovision"

APP_PLIST="/workspace/tmp/daily/export.plist"

#TODAY=`date +%Y%m%d`

TODAY="20170527"

SVN_URL=""$TODAY

DIR_SRC=""

DIR_WORK="/workspace/tmp/daily"

DIR_DAILY=$DIR_WORK/$TODAY

DIR_DAILY_SVN=$DIR_DAILY/svn

DIR_DAILY_SRC=$DIR_DAILY/src

DIR_DAILY_BUILD=$DIR_DAILY/build

DIR_DAILY_ARCHIVE=$DIR_DAILY/archive

DIR_DAILY_IPA=$DIR_DAILY/ipa

# 1 准备环境  rmdir, mkdir

function clean(){

    echo $DIR_DAILY

    if [ -d $DIR_DAILY ]

       then `rm -fr $DIR_DAILY`

    fi

    

}

function mkdirs(){

    echo 

mkdir -p $DIR_DAILY_SVN

mkdir -p $DIR_DAILY_SRC

mkdir -p $DIR_DAILY_BUILD

mkdir -p $DIR_DAILY_ARCHIVE

mkdir -p $DIR_DAILY_IPA

}

function initEnv(){

    clean

    mkdirs

}

function ipa(){

    xcodebuild -exportArchive  -archivePath $DIR_DAILY_ARCHIVE/$APP_NAME.xcarchive -exportPath $DIR_DAILY_IPA  -exportOptionsPlist $APP_PLIST CODE_SIGN_IDENTITY=$APP_CODE_SIGN_IDENTITY PROVISIONING_PROFILE=$APP_PROVISIONING_PROFILE

}

function checkOut(){

./exportProject.sh checkOut $SVN_URL $DIR_DAILY_SVN

./exportProject.sh unzipSrc $SVN_URL $DIR_DAILY_SVN

}

function main(){

    initEnv

    checkOut

    

    buildCC

    buildWorkFlow

    buildMP

    

}

 

#运行命令行参数中第一个参数所指定的Shell函数

$@