2015-10-09 20:36:06 +03:00
|
|
|
@ECHO OFF
|
|
|
|
|
|
|
|
::
|
|
|
|
:: GetTclKit.bat --
|
|
|
|
::
|
|
|
|
:: TclKit Download Tool
|
|
|
|
::
|
|
|
|
|
|
|
|
SETLOCAL
|
|
|
|
|
|
|
|
REM SET __ECHO=ECHO
|
|
|
|
REM SET __ECHO2=ECHO
|
|
|
|
REM SET __ECHO3=ECHO
|
|
|
|
IF NOT DEFINED _AECHO (SET _AECHO=REM)
|
|
|
|
IF NOT DEFINED _CECHO (SET _CECHO=REM)
|
|
|
|
IF NOT DEFINED _VECHO (SET _VECHO=REM)
|
|
|
|
|
|
|
|
SET OVERWRITE=^>
|
|
|
|
IF DEFINED __ECHO SET OVERWRITE=^^^>
|
|
|
|
|
|
|
|
SET APPEND=^>^>
|
|
|
|
IF DEFINED __ECHO SET APPEND=^^^>^^^>
|
|
|
|
|
|
|
|
SET PROCESSOR=%1
|
|
|
|
|
|
|
|
IF DEFINED PROCESSOR (
|
|
|
|
CALL :fn_UnquoteVariable PROCESSOR
|
|
|
|
) ELSE (
|
|
|
|
GOTO usage
|
|
|
|
)
|
|
|
|
|
|
|
|
%_VECHO% Processor = '%PROCESSOR%'
|
|
|
|
|
|
|
|
SET DUMMY2=%2
|
|
|
|
|
|
|
|
IF DEFINED DUMMY2 (
|
|
|
|
GOTO usage
|
|
|
|
)
|
|
|
|
|
|
|
|
SET ROOT=%~dp0\..
|
|
|
|
SET ROOT=%ROOT:\\=\%
|
|
|
|
|
|
|
|
%_VECHO% Root = '%ROOT%'
|
|
|
|
|
|
|
|
SET TOOLS=%~dp0
|
|
|
|
SET TOOLS=%TOOLS:~0,-1%
|
|
|
|
|
|
|
|
%_VECHO% Tools = '%TOOLS%'
|
|
|
|
|
|
|
|
IF NOT DEFINED windir (
|
|
|
|
ECHO The windir environment variable must be set first.
|
|
|
|
GOTO errors
|
|
|
|
)
|
|
|
|
|
|
|
|
%_VECHO% WinDir = '%windir%'
|
|
|
|
|
|
|
|
IF NOT DEFINED TEMP (
|
|
|
|
ECHO The TEMP environment variable must be set first.
|
|
|
|
GOTO errors
|
|
|
|
)
|
|
|
|
|
|
|
|
%_VECHO% Temp = '%TEMP%'
|
|
|
|
|
2015-10-09 21:48:47 +03:00
|
|
|
IF NOT DEFINED TCLKIT_URI (
|
2015-12-08 03:47:32 +03:00
|
|
|
SET TCLKIT_URI=https://tclsh.com/
|
2015-10-09 21:48:47 +03:00
|
|
|
)
|
2015-10-09 20:36:06 +03:00
|
|
|
|
|
|
|
%_VECHO% TclKitUri = '%TCLKIT_URI%'
|
|
|
|
|
|
|
|
IF /I "%PROCESSOR%" == "x86" (
|
|
|
|
CALL :fn_TclKitX86Variables
|
|
|
|
) ELSE IF /I "%PROCESSOR%" == "x64" (
|
|
|
|
CALL :fn_TclKitX64Variables
|
|
|
|
) ELSE (
|
|
|
|
GOTO usage
|
|
|
|
)
|
|
|
|
|
2015-10-11 02:39:55 +03:00
|
|
|
%_VECHO% TclKitVersion = '%TCLKIT_VERSION%'
|
2015-10-09 20:36:06 +03:00
|
|
|
%_VECHO% TclKitPatchLevel = '%TCLKIT_PATCHLEVEL%'
|
2016-09-18 01:46:13 +03:00
|
|
|
%_VECHO% TclKitNoEnv = '%TCLKIT_NOENV%'
|
2015-10-09 20:36:06 +03:00
|
|
|
%_VECHO% TclKitNoSdk = '%TCLKIT_NOSDK%'
|
|
|
|
%_VECHO% TclKitExe = '%TCLKIT_EXE%'
|
|
|
|
%_VECHO% TclKitLib = '%TCLKIT_LIB%'
|
2015-10-11 02:39:55 +03:00
|
|
|
%_VECHO% TclKitLibStub = '%TCLKIT_LIB_STUB%'
|
2015-10-09 20:36:06 +03:00
|
|
|
%_VECHO% TclKitSdk = '%TCLKIT_SDK%'
|
|
|
|
%_VECHO% TclKitSdkZip = '%TCLKIT_SDK_ZIP%'
|
|
|
|
%_VECHO% TclKitFiles = '%TCLKIT_FILES%'
|
|
|
|
|
|
|
|
CALL :fn_ResetErrorLevel
|
|
|
|
|
|
|
|
FOR %%T IN (csc.exe) DO (
|
|
|
|
SET %%T_PATH=%%~dp$PATH:T
|
|
|
|
)
|
|
|
|
|
|
|
|
%_VECHO% Csc.exe_PATH = '%csc.exe_PATH%'
|
|
|
|
|
|
|
|
IF DEFINED csc.exe_PATH (
|
|
|
|
GOTO skip_addToPath
|
|
|
|
)
|
|
|
|
|
|
|
|
IF DEFINED FRAMEWORKDIR (
|
|
|
|
REM Use the existing .NET Framework directory...
|
|
|
|
) ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v2.0.50727" (
|
|
|
|
SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework64\v2.0.50727
|
|
|
|
) ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v3.5" (
|
|
|
|
SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework64\v3.5
|
|
|
|
) ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v4.0.30319" (
|
|
|
|
SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework64\v4.0.30319
|
|
|
|
) ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v2.0.50727" (
|
|
|
|
SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework\v2.0.50727
|
|
|
|
) ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v3.5" (
|
|
|
|
SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework\v3.5
|
|
|
|
) ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v4.0.30319" (
|
|
|
|
SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework\v4.0.30319
|
|
|
|
) ELSE (
|
|
|
|
ECHO No suitable version of the .NET Framework appears to be installed.
|
|
|
|
GOTO errors
|
|
|
|
)
|
|
|
|
|
|
|
|
%_VECHO% FrameworkDir = '%FRAMEWORKDIR%'
|
|
|
|
|
|
|
|
IF NOT EXIST "%FRAMEWORKDIR%\csc.exe" (
|
|
|
|
ECHO The file "%FRAMEWORKDIR%\csc.exe" is missing.
|
|
|
|
GOTO errors
|
|
|
|
)
|
|
|
|
|
2017-02-27 20:16:27 +03:00
|
|
|
CALL :fn_PrependToPath FRAMEWORKDIR
|
2015-10-09 20:36:06 +03:00
|
|
|
|
|
|
|
:skip_addToPath
|
|
|
|
|
2015-10-11 02:39:55 +03:00
|
|
|
IF NOT EXIST "%TEMP%\GetFile.exe" (
|
|
|
|
%__ECHO% csc.exe "/out:%TEMP%\GetFile.exe" /target:exe "%TOOLS%\GetFile.cs"
|
2015-10-09 20:36:06 +03:00
|
|
|
|
2015-10-11 02:39:55 +03:00
|
|
|
IF ERRORLEVEL 1 (
|
|
|
|
ECHO Compilation of "%TOOLS%\GetFile.cs" failed.
|
|
|
|
GOTO errors
|
|
|
|
)
|
2015-10-09 20:36:06 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
FOR %%F IN (%TCLKIT_FILES%) DO (
|
2015-10-10 03:53:28 +03:00
|
|
|
IF NOT EXIST "%TEMP%\%%F" (
|
2015-10-09 20:36:06 +03:00
|
|
|
%__ECHO% "%TEMP%\GetFile.exe" "%TCLKIT_URI%%%F"
|
|
|
|
|
|
|
|
IF ERRORLEVEL 1 (
|
|
|
|
ECHO Download of "%%F" from "%TCLKIT_URI%" failed.
|
|
|
|
GOTO errors
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2016-09-18 01:46:13 +03:00
|
|
|
IF DEFINED TCLKIT_NOENV GOTO skip_sdkUnZip
|
2015-10-09 20:36:06 +03:00
|
|
|
IF DEFINED TCLKIT_NOSDK GOTO skip_sdkUnZip
|
|
|
|
|
|
|
|
IF NOT EXIST "%TEMP%\%TCLKIT_SDK%" (
|
|
|
|
%__ECHO% MKDIR "%TEMP%\%TCLKIT_SDK%"
|
|
|
|
|
|
|
|
IF ERRORLEVEL 1 (
|
|
|
|
ECHO Could not create directory "%TEMP%\%TCLKIT_SDK%".
|
|
|
|
GOTO errors
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2015-10-10 03:53:28 +03:00
|
|
|
%__ECHO% "%TEMP%\unzip.exe" -n "%TEMP%\%TCLKIT_SDK_ZIP%" -d "%TEMP%\%TCLKIT_SDK%"
|
2015-10-09 20:36:06 +03:00
|
|
|
|
|
|
|
IF ERRORLEVEL 1 (
|
|
|
|
ECHO Could not unzip "%TEMP%\%TCLKIT_SDK_ZIP%" to "%TEMP%\%TCLKIT_SDK%".
|
|
|
|
GOTO errors
|
|
|
|
)
|
|
|
|
|
|
|
|
:skip_sdkUnZip
|
|
|
|
|
2016-09-18 01:46:13 +03:00
|
|
|
IF DEFINED TCLKIT_NOENV GOTO skip_sdkEnvironment
|
|
|
|
|
2015-10-09 20:36:06 +03:00
|
|
|
%__ECHO% ECHO SET TCLSH_CMD=%TEMP%\%TCLKIT_EXE%%OVERWRITE%"%ROOT%\SetTclKitEnv.bat"
|
|
|
|
|
|
|
|
IF DEFINED TCLKIT_NOSDK GOTO skip_sdkVariables
|
|
|
|
|
|
|
|
%__ECHO% ECHO SET TCLINCDIR=%TEMP%\%TCLKIT_SDK%\include%APPEND%"%ROOT%\SetTclKitEnv.bat"
|
|
|
|
%__ECHO% ECHO SET TCLLIBDIR=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ROOT%\SetTclKitEnv.bat"
|
2015-10-15 02:04:08 +03:00
|
|
|
%__ECHO% ECHO SET LIBTCLPATH=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ROOT%\SetTclKitEnv.bat"
|
2015-10-09 20:36:06 +03:00
|
|
|
%__ECHO% ECHO SET LIBTCL=%TCLKIT_LIB%%APPEND%"%ROOT%\SetTclKitEnv.bat"
|
2015-10-11 02:39:55 +03:00
|
|
|
%__ECHO% ECHO SET LIBTCLSTUB=%TCLKIT_LIB_STUB%%APPEND%"%ROOT%\SetTclKitEnv.bat"
|
2015-10-09 20:36:06 +03:00
|
|
|
|
|
|
|
:skip_sdkVariables
|
|
|
|
|
2015-10-10 03:53:28 +03:00
|
|
|
ECHO.
|
|
|
|
ECHO Wrote "%ROOT%\SetTclKitEnv.bat".
|
|
|
|
ECHO Please run it to set the necessary Tcl environment variables.
|
|
|
|
ECHO.
|
|
|
|
|
2016-09-18 01:46:13 +03:00
|
|
|
:skip_sdkEnvironment
|
|
|
|
|
2015-10-09 20:36:06 +03:00
|
|
|
GOTO no_errors
|
|
|
|
|
|
|
|
:fn_TclKitX86Variables
|
|
|
|
IF NOT DEFINED TCLKIT_PATCHLEVEL (
|
|
|
|
SET TCLKIT_PATCHLEVEL=8.6.4
|
|
|
|
)
|
2015-10-11 02:39:55 +03:00
|
|
|
SET TCLKIT_VERSION=%TCLKIT_PATCHLEVEL:.=%
|
|
|
|
SET TCLKIT_VERSION=%TCLKIT_VERSION:~0,2%
|
2015-10-09 20:36:06 +03:00
|
|
|
SET TCLKIT_EXE=tclkit-%TCLKIT_PATCHLEVEL%.exe
|
|
|
|
SET TCLKIT_LIB=libtclkit%TCLKIT_PATCHLEVEL:.=%.lib
|
2015-10-11 02:39:55 +03:00
|
|
|
SET TCLKIT_LIB_STUB=libtclstub%TCLKIT_VERSION:.=%.a
|
2015-10-09 20:36:06 +03:00
|
|
|
SET TCLKIT_SDK=libtclkit-sdk-x86-%TCLKIT_PATCHLEVEL%
|
|
|
|
SET TCLKIT_SDK_ZIP=%TCLKIT_SDK%.zip
|
2015-10-12 06:44:39 +03:00
|
|
|
SET TCLKIT_FILES=%TCLKIT_EXE%
|
2016-09-18 01:46:13 +03:00
|
|
|
IF NOT DEFINED TCLKIT_NOENV IF NOT DEFINED TCLKIT_NOSDK (
|
2015-10-12 06:44:39 +03:00
|
|
|
SET TCLKIT_FILES=%TCLKIT_FILES% unzip.exe %TCLKIT_SDK_ZIP%
|
|
|
|
)
|
2015-10-09 20:36:06 +03:00
|
|
|
GOTO :EOF
|
|
|
|
|
|
|
|
:fn_TclKitX64Variables
|
|
|
|
IF NOT DEFINED TCLKIT_PATCHLEVEL (
|
|
|
|
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
|
|
|
|
SET TCLKIT_PATCHLEVEL=8.6.3
|
|
|
|
SET TCLKIT_EXE=tclkit-8.6.4.exe
|
|
|
|
) ELSE (
|
|
|
|
SET TCLKIT_EXE=tclkit-%TCLKIT_PATCHLEVEL%.exe
|
|
|
|
)
|
2015-10-11 02:39:55 +03:00
|
|
|
SET TCLKIT_VERSION=%TCLKIT_PATCHLEVEL:.=%
|
|
|
|
SET TCLKIT_VERSION=%TCLKIT_VERSION:~0,2%
|
2015-10-09 20:36:06 +03:00
|
|
|
SET TCLKIT_LIB=libtclkit%TCLKIT_PATCHLEVEL:.=%.lib
|
2015-10-11 02:39:55 +03:00
|
|
|
SET TCLKIT_LIB_STUB=libtclstub%TCLKIT_VERSION:.=%.a
|
2015-10-09 20:36:06 +03:00
|
|
|
SET TCLKIT_SDK=libtclkit-sdk-x64-%TCLKIT_PATCHLEVEL%
|
|
|
|
SET TCLKIT_SDK_ZIP=%TCLKIT_SDK%.zip
|
2015-10-12 06:44:39 +03:00
|
|
|
SET TCLKIT_FILES=%TCLKIT_EXE%
|
2016-09-18 01:46:13 +03:00
|
|
|
IF NOT DEFINED TCLKIT_NOENV IF NOT DEFINED TCLKIT_NOSDK (
|
2015-10-12 06:44:39 +03:00
|
|
|
SET TCLKIT_FILES=%TCLKIT_FILES% unzip.exe %TCLKIT_SDK_ZIP%
|
|
|
|
)
|
2015-10-09 20:36:06 +03:00
|
|
|
GOTO :EOF
|
|
|
|
|
|
|
|
:fn_UnquoteVariable
|
|
|
|
IF NOT DEFINED %1 GOTO :EOF
|
|
|
|
SETLOCAL
|
|
|
|
SET __ECHO_CMD=ECHO %%%1%%
|
|
|
|
FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO (
|
|
|
|
SET VALUE=%%V
|
|
|
|
)
|
|
|
|
SET VALUE=%VALUE:"=%
|
|
|
|
REM "
|
|
|
|
ENDLOCAL && SET %1=%VALUE%
|
|
|
|
GOTO :EOF
|
|
|
|
|
2017-02-27 20:16:27 +03:00
|
|
|
:fn_PrependToPath
|
|
|
|
IF NOT DEFINED %1 GOTO :EOF
|
|
|
|
SETLOCAL
|
|
|
|
SET __ECHO_CMD=ECHO %%%1%%
|
|
|
|
FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO (
|
|
|
|
SET VALUE=%%V
|
|
|
|
)
|
|
|
|
SET VALUE=%VALUE:"=%
|
|
|
|
REM "
|
|
|
|
ENDLOCAL && SET PATH=%VALUE%;%PATH%
|
|
|
|
GOTO :EOF
|
|
|
|
|
2015-10-09 20:36:06 +03:00
|
|
|
: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%
|