@echo off
setlocal

set "CONFIG=%~1"
if "%CONFIG%"=="" set "CONFIG=Debug"

set "ROOT=%~dp0"
set "CCS_ECLIPSEC=C:\ti\ccs1230\ccs\eclipse\eclipsec.exe"
set "CCS_WORKSPACE=%ROOT%.ccs12_build_workspace"
set "TI_APPDATA_DIR=%ROOT%.ti_appdata"
set "PROJECT_DIR=%ROOT%UKSSTMS320F28335"

if not exist "%CCS_ECLIPSEC%" (
    echo CCS eclipsec.exe not found: %CCS_ECLIPSEC%
    exit /b 1
)

"%CCS_ECLIPSEC%" -noSplash -data "%CCS_WORKSPACE%" -application com.ti.ccstudio.apps.projectImport -ccs.location "%PROJECT_DIR%" -ccs.overwrite
if errorlevel 1 exit /b 1

"%CCS_ECLIPSEC%" -noSplash -data "%CCS_WORKSPACE%" -application com.ti.ccstudio.apps.projectBuild -ccs.projects UKSSTMS320F28335 -ccs.configuration "%CONFIG%" -ccs.buildType full -ccs.listProblems
exit /b %ERRORLEVEL%
