6 :: TclKit Download Tool
\r
12 REM SET __ECHO2=ECHO
\r
13 REM SET __ECHO3=ECHO
\r
14 IF NOT DEFINED _AECHO (SET _AECHO=REM)
\r
15 IF NOT DEFINED _CECHO (SET _CECHO=REM)
\r
16 IF NOT DEFINED _VECHO (SET _VECHO=REM)
\r
19 IF DEFINED __ECHO SET OVERWRITE=^^^>
\r
22 IF DEFINED __ECHO SET APPEND=^^^>^^^>
\r
26 IF DEFINED PROCESSOR (
\r
27 CALL :fn_UnquoteVariable PROCESSOR
\r
32 SET PROCESSOR=%PROCESSOR:AMD64=x64%
\r
34 %_VECHO% Processor = '%PROCESSOR%'
\r
42 IF NOT DEFINED ENVDIR (
\r
46 %_VECHO% EnvDir = '%ENVDIR%'
\r
49 SET TOOLS=%TOOLS:~0,-1%
\r
51 %_VECHO% Tools = '%TOOLS%'
\r
53 IF NOT DEFINED windir (
\r
54 ECHO The windir environment variable must be set first.
\r
58 %_VECHO% WinDir = '%windir%'
\r
60 IF NOT DEFINED TEMP (
\r
61 ECHO The TEMP environment variable must be set first.
\r
65 %_VECHO% Temp = '%TEMP%'
\r
67 IF NOT DEFINED TCLKIT_URI (
\r
68 SET TCLKIT_URI=https://urn.to/r/tclsh/
\r
71 %_VECHO% TclKitUri = '%TCLKIT_URI%'
\r
73 IF NOT DEFINED TCLKIT_PATCHLEVEL (
\r
74 SET TCLKIT_PATCHLEVEL=8.6.6
\r
77 %_VECHO% TclKitPatchLevel = '%TCLKIT_PATCHLEVEL%'
\r
79 IF NOT DEFINED TCLKIT_EXE_PATCHLEVEL (
\r
80 SET TCLKIT_EXE_PATCHLEVEL=8.6.4
\r
83 %_VECHO% TclKitExePatchLevel = '%TCLKIT_EXE_PATCHLEVEL%'
\r
85 IF /I "%PROCESSOR%" == "x86" (
\r
86 CALL :fn_TclKitX86Variables
\r
91 ) ELSE IF /I "%PROCESSOR%" == "x64" (
\r
92 CALL :fn_TclKitX64Variables
\r
101 %_VECHO% TclKitVersion = '%TCLKIT_VERSION%'
\r
102 %_VECHO% TclKitPatchLevel = '%TCLKIT_PATCHLEVEL%'
\r
103 %_VECHO% TclKitExePatchLevel = '%TCLKIT_EXE_PATCHLEVEL%'
\r
104 %_VECHO% TclKitNoEnv = '%TCLKIT_NOENV%'
\r
105 %_VECHO% TclKitNoSdk = '%TCLKIT_NOSDK%'
\r
106 %_VECHO% TclKitExe = '%TCLKIT_EXE%'
\r
107 %_VECHO% TclKitLib = '%TCLKIT_LIB%'
\r
108 %_VECHO% TclKitLibStub = '%TCLKIT_LIB_STUB%'
\r
109 %_VECHO% TclKitSdk = '%TCLKIT_SDK%'
\r
110 %_VECHO% TclKitSdkZip = '%TCLKIT_SDK_ZIP%'
\r
111 %_VECHO% TclKitFiles = '%TCLKIT_FILES%'
\r
113 CALL :fn_ResetErrorLevel
\r
115 FOR %%T IN (csc.exe) DO (
\r
116 SET %%T_PATH=%%~dp$PATH:T
\r
119 %_VECHO% Csc.exe_PATH = '%csc.exe_PATH%'
\r
121 IF DEFINED csc.exe_PATH (
\r
122 GOTO skip_addToPath
\r
125 IF DEFINED FRAMEWORKDIR (
\r
126 REM Use the existing .NET Framework directory...
\r
127 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v2.0.50727" (
\r
128 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework64\v2.0.50727
\r
129 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v3.5" (
\r
130 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework64\v3.5
\r
131 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v4.0.30319" (
\r
132 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework64\v4.0.30319
\r
133 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v2.0.50727" (
\r
134 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework\v2.0.50727
\r
135 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v3.5" (
\r
136 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework\v3.5
\r
137 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v4.0.30319" (
\r
138 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework\v4.0.30319
\r
140 ECHO No suitable version of the .NET Framework appears to be installed.
\r
144 %_VECHO% FrameworkDir = '%FRAMEWORKDIR%'
\r
146 IF NOT EXIST "%FRAMEWORKDIR%\csc.exe" (
\r
147 ECHO The file "%FRAMEWORKDIR%\csc.exe" is missing.
\r
151 CALL :fn_PrependToPath FRAMEWORKDIR
\r
155 IF NOT EXIST "%TEMP%\GetFile.exe" (
\r
156 %__ECHO% csc.exe "/out:%TEMP%\GetFile.exe" /target:exe "%TOOLS%\GetFile.cs"
\r
159 ECHO Compilation of "%TOOLS%\GetFile.cs" failed.
\r
164 FOR %%F IN (%TCLKIT_FILES%) DO (
\r
165 IF NOT EXIST "%TEMP%\%%F" (
\r
166 %__ECHO% "%TEMP%\GetFile.exe" "%TCLKIT_URI%%%F"
\r
169 ECHO Download of "%%F" from "%TCLKIT_URI%" failed.
\r
175 IF DEFINED TCLKIT_NOENV GOTO skip_sdkUnZip
\r
176 IF DEFINED TCLKIT_NOSDK GOTO skip_sdkUnZip
\r
178 IF NOT EXIST "%TEMP%\%TCLKIT_SDK%" (
\r
179 %__ECHO% MKDIR "%TEMP%\%TCLKIT_SDK%"
\r
182 ECHO Could not create directory "%TEMP%\%TCLKIT_SDK%".
\r
187 %__ECHO% "%TEMP%\unzip.exe" -n "%TEMP%\%TCLKIT_SDK_ZIP%" -d "%TEMP%\%TCLKIT_SDK%"
\r
190 ECHO Could not unzip "%TEMP%\%TCLKIT_SDK_ZIP%" to "%TEMP%\%TCLKIT_SDK%".
\r
196 IF DEFINED TCLKIT_NOENV GOTO skip_sdkEnvironment
\r
198 %__ECHO% ECHO SET TCLSH_CMD=%TEMP%\%TCLKIT_EXE%%OVERWRITE%"%ENVDIR%\SetTclKitEnv.bat"
\r
200 IF DEFINED TCLKIT_NOSDK GOTO skip_sdkVariables
\r
202 %__ECHO% ECHO SET TCLINCDIR=%TEMP%\%TCLKIT_SDK%\include%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
\r
203 %__ECHO% ECHO SET TCLLIBDIR=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
\r
204 %__ECHO% ECHO SET LIBTCLPATH=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
\r
205 %__ECHO% ECHO SET LIBTCL=%TCLKIT_LIB%%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
\r
206 %__ECHO% ECHO SET LIBTCLSTUB=%TCLKIT_LIB_STUB%%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
\r
211 ECHO Wrote "%ENVDIR%\SetTclKitEnv.bat".
\r
212 ECHO Please run it to set the necessary Tcl environment variables.
\r
215 :skip_sdkEnvironment
\r
219 :fn_TclKitX86Variables
\r
221 REM NOTE: By default, use latest available version of the TclKit SDK
\r
222 REM for x86. However, the "default" TclKit executable for x86
\r
223 REM is still used here because it is the only one "well-known"
\r
224 REM to be available for download.
\r
226 IF NOT DEFINED TCLKIT_PATCHLEVEL (
\r
227 ECHO The TCLKIT_PATCHLEVEL environment variable must be set first.
\r
228 CALL :fn_SetErrorLevel
\r
231 SET TCLKIT_VERSION=%TCLKIT_PATCHLEVEL:.=%
\r
232 SET TCLKIT_VERSION=%TCLKIT_VERSION:~0,2%
\r
233 IF DEFINED TCLKIT_EXE_PATCHLEVEL (
\r
234 SET TCLKIT_EXE=tclkit-%TCLKIT_EXE_PATCHLEVEL%.exe
\r
236 SET TCLKIT_EXE=tclkit-%TCLKIT_PATCHLEVEL%.exe
\r
238 SET TCLKIT_LIB=libtclkit%TCLKIT_PATCHLEVEL:.=%.lib
\r
239 SET TCLKIT_LIB_STUB=libtclstub%TCLKIT_VERSION:.=%.a
\r
240 SET TCLKIT_SDK=libtclkit-sdk-x86-%TCLKIT_PATCHLEVEL%
\r
241 SET TCLKIT_SDK_ZIP=%TCLKIT_SDK%.zip
\r
242 SET TCLKIT_FILES=%TCLKIT_EXE%
\r
243 IF NOT DEFINED TCLKIT_NOENV IF NOT DEFINED TCLKIT_NOSDK (
\r
244 SET TCLKIT_FILES=%TCLKIT_FILES% unzip.exe %TCLKIT_SDK_ZIP%
\r
248 :fn_TclKitX64Variables
\r
250 REM NOTE: By default, use latest available version of the TclKit SDK
\r
251 REM for x64. However, the "default" TclKit executable for x86
\r
252 REM is still used here because it is the only one "well-known"
\r
253 REM to be available for download.
\r
255 IF NOT DEFINED TCLKIT_PATCHLEVEL (
\r
256 ECHO The TCLKIT_PATCHLEVEL environment variable must be set first.
\r
257 CALL :fn_SetErrorLevel
\r
260 SET TCLKIT_VERSION=%TCLKIT_PATCHLEVEL:.=%
\r
261 SET TCLKIT_VERSION=%TCLKIT_VERSION:~0,2%
\r
262 IF DEFINED TCLKIT_EXE_PATCHLEVEL (
\r
263 SET TCLKIT_EXE=tclkit-%TCLKIT_EXE_PATCHLEVEL%.exe
\r
265 SET TCLKIT_EXE=tclkit-%TCLKIT_PATCHLEVEL%.exe
\r
267 SET TCLKIT_LIB=libtclkit%TCLKIT_PATCHLEVEL:.=%.lib
\r
268 SET TCLKIT_LIB_STUB=libtclstub%TCLKIT_VERSION:.=%.a
\r
269 SET TCLKIT_SDK=libtclkit-sdk-x64-%TCLKIT_PATCHLEVEL%
\r
270 SET TCLKIT_SDK_ZIP=%TCLKIT_SDK%.zip
\r
271 SET TCLKIT_FILES=%TCLKIT_EXE%
\r
272 IF NOT DEFINED TCLKIT_NOENV IF NOT DEFINED TCLKIT_NOSDK (
\r
273 SET TCLKIT_FILES=%TCLKIT_FILES% unzip.exe %TCLKIT_SDK_ZIP%
\r
277 :fn_UnquoteVariable
\r
278 IF NOT DEFINED %1 GOTO :EOF
\r
280 SET __ECHO_CMD=ECHO %%%1%%
\r
281 FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO (
\r
284 SET VALUE=%VALUE:"=%
\r
286 ENDLOCAL && SET %1=%VALUE%
\r
290 IF NOT DEFINED %1 GOTO :EOF
\r
292 SET __ECHO_CMD=ECHO %%%1%%
\r
293 FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO (
\r
296 SET VALUE=%VALUE:"=%
\r
298 ENDLOCAL && SET PATH=%VALUE%;%PATH%
\r
301 :fn_ResetErrorLevel
\r
306 VERIFY MAYBE 2> NUL
\r
311 ECHO Usage: %~nx0 ^<processor^>
\r
313 ECHO The only supported values for processor are "x86" and "x64".
\r
317 CALL :fn_SetErrorLevel
\r
320 ECHO Failure, errors were encountered.
\r
324 CALL :fn_ResetErrorLevel
\r
327 ECHO Success, no errors were encountered.
\r
331 %__ECHO% EXIT /B %ERRORLEVEL%
\r