@echo off
setlocal enabledelayedexpansion
set ide_path=%~dp0
set prevLine=
set vmConst=-vm
set emptyVar=
:updateIniAndExecute
call :readInfo
call :setExecPath
call :updateIniFile
call :setEclipseOptions
goto executeCommand
:readInfo
set sdkInfoPath=%ide_path%..\sdk.info
set JDK_PATH=%ide_path%..\jdk
set iniPath=%ide_path%eclipse.ini
rem extracting the paths from sdk.info
for /F "delims=" %%a in (!sdkInfoPath!) do (
set paths=%%a
for /f "tokens=1,2 delims==" %%b in ("!paths!") do (
if %%b==TIZEN_SDK_DATA_PATH (
set sdkDataPath=%%c
)
if %%b==JDK_PATH (
set sdkInfoJDKPath=%%c
)
if %%b==TIZEN_SDK_INSTALLED_PATH (
set sdkPath=%%c
)
)
)
goto eof
:createLogFile
set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%
set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
set year=%date:~-4%
set month=%date:~3,2%
if "%month:~0,1%" == " " set month=0%month:~1,1%
set day=%date:~0,2%
if "%day:~0,1%" == " " set day=0%day:~1,1%
set fileName=idelaunch_%year%%month%%day%%hour%%min%%secs%.txt
set "logFilePath=%sdkDataPath%\ide\logs"
if not exist %logFilePath% (
mkdir -p "%logFilePath%\%fileName%"
)
set "logFile=%logFilePath%\%fileName%"
set logFileCreated=true
goto eof
:updateLogFile
if !logFileCreated!==false (
call :createLogFile
)
call echo %1>>!logFile!
goto eof
:setExecPath
rem set the java exec path to be used
rem update JAVA_EXEC if JDK_PATH specified and exists in sdk.info
set "logFileCreated=false"
if exist "%sdkInfoJDKPath%" (
rem jdk directory exixts
set JDK_PATH=%sdkInfoJDKPath%
call :updateLogFile "Using Sdk.info java at !JDK_PATH!"
) else (
if not !sdkInfoJDKPath!==!emptyVar! (
call :updateLogFile "Jdk specified in sdk.info:!sdkInfoJDKPath! does not exist."
)
)
if not exist "!JDK_PATH!" (
set JAVA_EXEC=javaw.exe
call :updateLogFile "Using System java"
) else (
set JAVA_EXEC=!JDK_PATH!\bin\javaw.exe
)
goto eof
:updateIniFile
for /f "delims=" %%i in ('type "!iniPath!" ^& break ^> "!iniPath!" ') do (
set "line=%%i"
if !prevLine!==!vmConst! (
call echo !JAVA_EXEC!>> "!iniPath!"
) else (
call echo !line!>> "!iniPath!"
)
set prevLine=!line!
)
goto eof
:setEclipseOptions
if exist "%ide_path%\init" (
set eclipse_options=-clean
) else (
set eclipse_options=
)
goto eof
:executeCommand
set Path=%sdk_path%\tools\mingw\bin;%sdk_path%\tools\mingw\msys\1.0\bin;%Path%
%ide_path%\eclipse.exe %eclipse_options% %*
goto eof
:eof