@echo off

set CYGWIN=nodosfilewarning   

echo ============================================================   
echo get toolchain path...

:ADMIN
if /I "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto AMD64
if /I "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto AMD64
rem ============================================   
         FOR /F "tokens=2*" %%A IN ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\ChipON\ChipONCC32  /v Path ') DO (set  pInstallDir=%%B)        
rem ============================================
goto END
:AMD64
rem ============================================
         FOR /F "tokens=2*" %%A IN ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\ChipON\ChipONCC32  /v Path ') DO (set  pInstallDir=%%B)     
rem ###########################################################################################
:END
echo toolchain path: %pInstallDir%



rem ###########################################################################################
set TL_PATH=%~dp0
set PATH=%TL_PATH%;%PATH%;%pInstallDir%\ccr1_issue\bin;%pInstallDir%\kf32\bin;%pInstallDir%\common;
rem ###########################################################################################

cd /d %~dp0 

rem # in file to config the default value,like project name,or some normal can set here 
rem -p x  or  --path=x   workspace
rem -n x or --name=x  projectname
rem -m x or --mode=x  outputfile  like release or debug ..
rem -c x  or --chip=x  the chipname
rem -t x or  --toolpath=x mian toolchain path
rem -s x or  toolsel=x  like ccr1_issue
rem -l x or --ld=x       the script file for link

echo ====default output the build message in file .or modify the  kf32_makefile.py  with the var====

rem python kf32_makefile.py -p 'D:/workspace32' --name=1233 --mode=Release -c KF32F350MQV -s ccr1_issue -l ../KF32F350MQV .ld

python kf32_makefile.py

rem ###########################################################################################
rem echo ----------------end----------------------------------------------------------------------
pause
