@echo off
echo Prepare IAR outputs to C for MSP-EXP430G2 Host

REM Convert all target devices (x)
set Target[0]=G2553_UART
REM Convert all Apps (y)
set App[0]=App1
set App[1]=App2

REM Loop to convert all projects, configurations and target devices
for %%x in (0) do (
    call echo:
    call echo ********** Copy and Build %%Target[%%x]%%  **********
    call echo:
    for %%y in (0,1) do (
        REM  copy /Y "..\Target\G2553_UART\IAR\App1_MSPBoot\BSLBased_UART\Exe\App1_MSPBoot.txt" 		                            App_Outputs\App1_G2553_UART_BSLBased_G2Host.txt
        call copy /Y "..\Target\%%Target[%%x]%%\IAR\%%App[%%y]%%_MSPBoot\BSLBased_UART\Exe\%%App[%%y]%%_MSPBoot.txt" 		App_Outputs\%%App[%%y]%%_%%Target[%%x]%%_BSLBased_G2Host.txt
        REM  430txt2C.pl "App_Outputs\App1_G2553_UART_BSLBased_G2Host.txt"    "App_Outputs\App1_G2553_UART_BSLBased_G2Host.c" App1
        call 430txt2C.pl "App_Outputs\%%App[%%y]%%_%%Target[%%x]%%_BSLBased_G2Host.txt"    "App_Outputs\%%App[%%y]%%_%%Target[%%x]%%_BSLBased_G2Host.c" %%App[%%y]%%
        REM  copy /Y "App_Outputs\App1_G2553_UART_BSLBased_G2Host.c" ..\Host\MSP-EXP430G2\Src\TargetApps
        call copy /Y "App_Outputs\%%App[%%y]%%_%%Target[%%x]%%_BSLBased_G2Host.c" ..\Host\MSP-EXP430G2\Src\TargetApps
    )
)

