@ECHO OFF
::
:: GetTclKit.bat --
::
:: TclKit Download Tool
::
SETLOCAL
REM SET __ECHO=ECHO
REM SET __ECHO2=ECHO
REM SET __ECHO3=ECHO
IF NOT DEFINED _AECHO
IF NOT DEFINED _CECHO
IF NOT DEFINED _CECHO2
IF NOT DEFINED _CECHO3
IF NOT DEFINED _VECHO
SET OVERWRITE=^>
IF DEFINED __ECHO SET OVERWRITE=^^^>
SET APPEND=^>^>
IF DEFINED __ECHO SET APPEND=^^^>^^^>
SET PROCESSOR=%1
IF DEFINED PROCESSOR ELSE
SET PROCESSOR=%PROCESSOR:%
%_VECHO% Processor = '%PROCESSOR%'
SET DUMMY2=%2
IF DEFINED DUMMY2
IF NOT DEFINED ENVDIR
%_VECHO% EnvDir = '%ENVDIR%'
SET TOOLS=%~dp0
SET TOOLS=%TOOLS:~%
%_VECHO% Tools = '%TOOLS%'
IF NOT DEFINED windir
%_VECHO% WinDir = '%windir%'
IF NOT DEFINED TEMP
%_VECHO% Temp = '%TEMP%'
IF NOT DEFINED TCLKIT_URI
%_VECHO% TclKitUri = '%TCLKIT_URI%'
IF NOT DEFINED TCLKIT_PATCHLEVEL
%_VECHO% TclKitPatchLevel = '%TCLKIT_PATCHLEVEL%'
IF NOT DEFINED TCLKIT_EXE_PATCHLEVEL
%_VECHO% TclKitExePatchLevel = '%TCLKIT_EXE_PATCHLEVEL%'
IF /I "%PROCESSOR%" == "x86" ELSE IF /I "%PROCESSOR%" == "x64" ELSE
%_VECHO% TclKitVersion = '%TCLKIT_VERSION%'
%_VECHO% TclKitPatchLevel = '%TCLKIT_PATCHLEVEL%'
%_VECHO% TclKitExePatchLevel = '%TCLKIT_EXE_PATCHLEVEL%'
%_VECHO% TclKitNoEnv = '%TCLKIT_NOENV%'
%_VECHO% TclKitNoSdk = '%TCLKIT_NOSDK%'
%_VECHO% TclKitExe = '%TCLKIT_EXE%'
%_VECHO% TclKitLib = '%TCLKIT_LIB%'
%_VECHO% TclKitLibStub = '%TCLKIT_LIB_STUB%'
%_VECHO% TclKitSdk = '%TCLKIT_SDK%'
%_VECHO% TclKitSdkZip = '%TCLKIT_SDK_ZIP%'
%_VECHO% TclKitFiles = '%TCLKIT_FILES%'
CALL :fn_ResetErrorLevel
FOR %%T IN DO
%_VECHO% Csc.exe_PATH = '%csc.exe_PATH%'
IF DEFINED csc.exe_PATH
IF DEFINED FRAMEWORKDIR ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v2.0.50727" ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v3.5" ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v4.0.30319" ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v2.0.50727" ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v3.5" ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v4.0.30319" ELSE
%_VECHO% FrameworkDir = '%FRAMEWORKDIR%'
IF NOT EXIST "%FRAMEWORKDIR%\csc.exe"
CALL :fn_PrependToPath FRAMEWORKDIR
:skip_addToPath
IF NOT EXIST "%TEMP%\GetFile.exe"
FOR %%F IN DO
IF DEFINED TCLKIT_NOENV GOTO skip_sdkUnZip
IF DEFINED TCLKIT_NOSDK GOTO skip_sdkUnZip
IF NOT EXIST "%TEMP%\%TCLKIT_SDK%"
%__ECHO% "%TEMP%\unzip.exe" -n "%TEMP%\%TCLKIT_SDK_ZIP%" -d "%TEMP%\%TCLKIT_SDK%"
IF ERRORLEVEL 1
:skip_sdkUnZip
IF DEFINED TCLKIT_NOENV GOTO skip_sdkEnvironment
%__ECHO% ECHO SET TCLSH_CMD=%TEMP%\%TCLKIT_EXE%%OVERWRITE%"%ENVDIR%\SetTclKitEnv.bat"
IF DEFINED TCLKIT_NOSDK GOTO skip_sdkVariables
%__ECHO% ECHO SET TCLINCDIR=%TEMP%\%TCLKIT_SDK%\include%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
%__ECHO% ECHO SET TCLLIBDIR=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
%__ECHO% ECHO SET LIBTCLPATH=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
%__ECHO% ECHO SET LIBTCL=%TCLKIT_LIB%%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
%__ECHO% ECHO SET LIBTCLSTUB=%TCLKIT_LIB_STUB%%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
:skip_sdkVariables
ECHO.
ECHO Wrote "%ENVDIR%\SetTclKitEnv.bat".
ECHO Please run it to set the necessary Tcl environment variables.
ECHO.
:skip_sdkEnvironment
GOTO no_errors
:fn_TclKitX86Variables
REM
REM NOTE: By default, use latest available version of the TclKit SDK
REM for x86. However, the "default" TclKit executable for x86
REM is still used here because it is the only one "well-known"
REM to be available for download.
REM
IF NOT DEFINED TCLKIT_PATCHLEVEL
SET TCLKIT_VERSION=%TCLKIT_PATCHLEVEL:%
SET TCLKIT_VERSION=%TCLKIT_VERSION:~%
IF DEFINED TCLKIT_EXE_PATCHLEVEL ELSE
SET TCLKIT_LIB=libtclkit%TCLKIT_PATCHLEVEL:%.lib
SET TCLKIT_LIB_STUB=libtclstub%TCLKIT_VERSION:%.a
SET TCLKIT_SDK=libtclkit-sdk-x86-%TCLKIT_PATCHLEVEL%
SET TCLKIT_SDK_ZIP=%TCLKIT_SDK%.zip
SET TCLKIT_FILES=%TCLKIT_EXE%
IF NOT DEFINED TCLKIT_NOENV IF NOT DEFINED TCLKIT_NOSDK
GOTO :EOF
:fn_TclKitX64Variables
REM
REM NOTE: By default, use latest available version of the TclKit SDK
REM for x64. However, the "default" TclKit executable for x86
REM is still used here because it is the only one "well-known"
REM to be available for download.
REM
IF NOT DEFINED TCLKIT_PATCHLEVEL
SET TCLKIT_VERSION=%TCLKIT_PATCHLEVEL:%
SET TCLKIT_VERSION=%TCLKIT_VERSION:~%
IF DEFINED TCLKIT_EXE_PATCHLEVEL ELSE
SET TCLKIT_LIB=libtclkit%TCLKIT_PATCHLEVEL:%.lib
SET TCLKIT_LIB_STUB=libtclstub%TCLKIT_VERSION:%.a
SET TCLKIT_SDK=libtclkit-sdk-x64-%TCLKIT_PATCHLEVEL%
SET TCLKIT_SDK_ZIP=%TCLKIT_SDK%.zip
SET TCLKIT_FILES=%TCLKIT_EXE%
IF NOT DEFINED TCLKIT_NOENV IF NOT DEFINED TCLKIT_NOSDK
GOTO :EOF
:fn_UnquoteVariable
IF NOT DEFINED %1 GOTO :EOF
SETLOCAL
SET __ECHO_CMD=ECHO %%%1%%
FOR /F "delims=" %%V IN DO
SET VALUE=%VALUE:%
REM "
ENDLOCAL && SET %1=%VALUE%
GOTO :EOF
:fn_PrependToPath
IF NOT DEFINED %1 GOTO :EOF
SETLOCAL
SET __ECHO_CMD=ECHO %%%1%%
FOR /F "delims=" %%V IN DO
SET VALUE=%VALUE:%
REM "
ENDLOCAL && SET PATH=%VALUE%;%PATH%
GOTO :EOF
:fn_ResetErrorLevel
VERIFY > NUL
GOTO :EOF
:fn_SetErrorLevel
VERIFY MAYBE 2> NUL
GOTO :EOF
:usage
ECHO.
ECHO Usage: %~nx0 ^<processor^>
ECHO.
ECHO The only supported values for processor are "x86" and "x64".
GOTO errors
:errors
CALL :fn_SetErrorLevel
ENDLOCAL
ECHO.
ECHO Failure, errors were encountered.
GOTO end_of_file
:no_errors
CALL :fn_ResetErrorLevel
ENDLOCAL
ECHO.
ECHO Success, no errors were encountered.
GOTO end_of_file
:end_of_file
%__ECHO% EXIT /B %ERRORLEVEL%