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 _CECHO2 (SET _CECHO2=REM)
\r
17 IF NOT DEFINED _CECHO3 (SET _CECHO3=REM)
\r
18 IF NOT DEFINED _VECHO (SET _VECHO=REM)
\r
21 IF DEFINED __ECHO SET OVERWRITE=^^^>
\r
24 IF DEFINED __ECHO SET APPEND=^^^>^^^>
\r
28 IF DEFINED PROCESSOR (
\r
29 CALL :fn_UnquoteVariable PROCESSOR
\r
34 SET PROCESSOR=%PROCESSOR:AMD64=x64%
\r
36 %_VECHO% Processor = '%PROCESSOR%'
\r
44 IF NOT DEFINED ENVDIR (
\r
48 %_VECHO% EnvDir = '%ENVDIR%'
\r
51 SET TOOLS=%TOOLS:~0,-1%
\r
53 %_VECHO% Tools = '%TOOLS%'
\r
55 IF NOT DEFINED windir (
\r
56 ECHO The windir environment variable must be set first.
\r
60 %_VECHO% WinDir = '%windir%'
\r
62 IF NOT DEFINED TEMP (
\r
63 ECHO The TEMP environment variable must be set first.
\r
67 %_VECHO% Temp = '%TEMP%'
\r
69 IF NOT DEFINED TCLKIT_URI (
\r
70 SET TCLKIT_URI=https://urn.to/r/tclsh/
\r
73 %_VECHO% TclKitUri = '%TCLKIT_URI%'
\r
75 IF NOT DEFINED TCLKIT_PATCHLEVEL (
\r
76 SET TCLKIT_PATCHLEVEL=8.6.6
\r
79 %_VECHO% TclKitPatchLevel = '%TCLKIT_PATCHLEVEL%'
\r
81 IF NOT DEFINED TCLKIT_EXE_PATCHLEVEL (
\r
82 SET TCLKIT_EXE_PATCHLEVEL=8.6.4
\r
85 %_VECHO% TclKitExePatchLevel = '%TCLKIT_EXE_PATCHLEVEL%'
\r
87 IF /I "%PROCESSOR%" == "x86" (
\r
88 CALL :fn_TclKitX86Variables
\r
93 ) ELSE IF /I "%PROCESSOR%" == "x64" (
\r
94 CALL :fn_TclKitX64Variables
\r
103 %_VECHO% TclKitVersion = '%TCLKIT_VERSION%'
\r
104 %_VECHO% TclKitPatchLevel = '%TCLKIT_PATCHLEVEL%'
\r
105 %_VECHO% TclKitExePatchLevel = '%TCLKIT_EXE_PATCHLEVEL%'
\r
106 %_VECHO% TclKitNoEnv = '%TCLKIT_NOENV%'
\r
107 %_VECHO% TclKitNoSdk = '%TCLKIT_NOSDK%'
\r
108 %_VECHO% TclKitExe = '%TCLKIT_EXE%'
\r
109 %_VECHO% TclKitLib = '%TCLKIT_LIB%'
\r
110 %_VECHO% TclKitLibStub = '%TCLKIT_LIB_STUB%'
\r
111 %_VECHO% TclKitSdk = '%TCLKIT_SDK%'
\r
112 %_VECHO% TclKitSdkZip = '%TCLKIT_SDK_ZIP%'
\r
113 %_VECHO% TclKitFiles = '%TCLKIT_FILES%'
\r
115 CALL :fn_ResetErrorLevel
\r
117 FOR %%T IN (csc.exe) DO (
\r
118 SET %%T_PATH=%%~dp$PATH:T
\r
121 %_VECHO% Csc.exe_PATH = '%csc.exe_PATH%'
\r
123 IF DEFINED csc.exe_PATH (
\r
124 GOTO skip_addToPath
\r
127 IF DEFINED FRAMEWORKDIR (
\r
128 REM Use the existing .NET Framework directory...
\r
129 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v2.0.50727" (
\r
130 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework64\v2.0.50727
\r
131 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v3.5" (
\r
132 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework64\v3.5
\r
133 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v4.0.30319" (
\r
134 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework64\v4.0.30319
\r
135 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v2.0.50727" (
\r
136 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework\v2.0.50727
\r
137 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v3.5" (
\r
138 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework\v3.5
\r
139 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v4.0.30319" (
\r
140 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework\v4.0.30319
\r
142 ECHO No suitable version of the .NET Framework appears to be installed.
\r
146 %_VECHO% FrameworkDir = '%FRAMEWORKDIR%'
\r
148 IF NOT EXIST "%FRAMEWORKDIR%\csc.exe" (
\r
149 ECHO The file "%FRAMEWORKDIR%\csc.exe" is missing.
\r
153 CALL :fn_PrependToPath FRAMEWORKDIR
\r
157 IF NOT EXIST "%TEMP%\GetFile.exe" (
\r
158 %__ECHO% csc.exe "/out:%TEMP%\GetFile.exe" /target:exe "%TOOLS%\GetFile.cs"
\r
161 ECHO Compilation of "%TOOLS%\GetFile.cs" failed.
\r
166 FOR %%F IN (%TCLKIT_FILES%) DO (
\r
167 IF NOT EXIST "%TEMP%\%%F" (
\r
168 %__ECHO% "%TEMP%\GetFile.exe" "%TCLKIT_URI%%%F"
\r
171 ECHO Download of "%%F" from "%TCLKIT_URI%" failed.
\r
177 IF DEFINED TCLKIT_NOENV GOTO skip_sdkUnZip
\r
178 IF DEFINED TCLKIT_NOSDK GOTO skip_sdkUnZip
\r
180 IF NOT EXIST "%TEMP%\%TCLKIT_SDK%" (
\r
181 %__ECHO% MKDIR "%TEMP%\%TCLKIT_SDK%"
\r
184 ECHO Could not create directory "%TEMP%\%TCLKIT_SDK%".
\r
189 %__ECHO% "%TEMP%\unzip.exe" -n "%TEMP%\%TCLKIT_SDK_ZIP%" -d "%TEMP%\%TCLKIT_SDK%"
\r
192 ECHO Could not unzip "%TEMP%\%TCLKIT_SDK_ZIP%" to "%TEMP%\%TCLKIT_SDK%".
\r
198 IF DEFINED TCLKIT_NOENV GOTO skip_sdkEnvironment
\r
200 %__ECHO% ECHO SET TCLSH_CMD=%TEMP%\%TCLKIT_EXE%%OVERWRITE%"%ENVDIR%\SetTclKitEnv.bat"
\r
202 IF DEFINED TCLKIT_NOSDK GOTO skip_sdkVariables
\r
204 %__ECHO% ECHO SET TCLINCDIR=%TEMP%\%TCLKIT_SDK%\include%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
\r
205 %__ECHO% ECHO SET TCLLIBDIR=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
\r
206 %__ECHO% ECHO SET LIBTCLPATH=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
\r
207 %__ECHO% ECHO SET LIBTCL=%TCLKIT_LIB%%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
\r
208 %__ECHO% ECHO SET LIBTCLSTUB=%TCLKIT_LIB_STUB%%APPEND%"%ENVDIR%\SetTclKitEnv.bat"
\r
213 ECHO Wrote "%ENVDIR%\SetTclKitEnv.bat".
\r
214 ECHO Please run it to set the necessary Tcl environment variables.
\r
217 :skip_sdkEnvironment
\r
221 :fn_TclKitX86Variables
\r
223 REM NOTE: By default, use latest available version of the TclKit SDK
\r
224 REM for x86. However, the "default" TclKit executable for x86
\r
225 REM is still used here because it is the only one "well-known"
\r
226 REM to be available for download.
\r
228 IF NOT DEFINED TCLKIT_PATCHLEVEL (
\r
229 ECHO The TCLKIT_PATCHLEVEL environment variable must be set first.
\r
230 CALL :fn_SetErrorLevel
\r
233 SET TCLKIT_VERSION=%TCLKIT_PATCHLEVEL:.=%
\r
234 SET TCLKIT_VERSION=%TCLKIT_VERSION:~0,2%
\r
235 IF DEFINED TCLKIT_EXE_PATCHLEVEL (
\r
236 SET TCLKIT_EXE=tclkit-%TCLKIT_EXE_PATCHLEVEL%.exe
\r
238 SET TCLKIT_EXE=tclkit-%TCLKIT_PATCHLEVEL%.exe
\r
240 SET TCLKIT_LIB=libtclkit%TCLKIT_PATCHLEVEL:.=%.lib
\r
241 SET TCLKIT_LIB_STUB=libtclstub%TCLKIT_VERSION:.=%.a
\r
242 SET TCLKIT_SDK=libtclkit-sdk-x86-%TCLKIT_PATCHLEVEL%
\r
243 SET TCLKIT_SDK_ZIP=%TCLKIT_SDK%.zip
\r
244 SET TCLKIT_FILES=%TCLKIT_EXE%
\r
245 IF NOT DEFINED TCLKIT_NOENV IF NOT DEFINED TCLKIT_NOSDK (
\r
246 SET TCLKIT_FILES=%TCLKIT_FILES% unzip.exe %TCLKIT_SDK_ZIP%
\r
250 :fn_TclKitX64Variables
\r
252 REM NOTE: By default, use latest available version of the TclKit SDK
\r
253 REM for x64. However, the "default" TclKit executable for x86
\r
254 REM is still used here because it is the only one "well-known"
\r
255 REM to be available for download.
\r
257 IF NOT DEFINED TCLKIT_PATCHLEVEL (
\r
258 ECHO The TCLKIT_PATCHLEVEL environment variable must be set first.
\r
259 CALL :fn_SetErrorLevel
\r
262 SET TCLKIT_VERSION=%TCLKIT_PATCHLEVEL:.=%
\r
263 SET TCLKIT_VERSION=%TCLKIT_VERSION:~0,2%
\r
264 IF DEFINED TCLKIT_EXE_PATCHLEVEL (
\r
265 SET TCLKIT_EXE=tclkit-%TCLKIT_EXE_PATCHLEVEL%.exe
\r
267 SET TCLKIT_EXE=tclkit-%TCLKIT_PATCHLEVEL%.exe
\r
269 SET TCLKIT_LIB=libtclkit%TCLKIT_PATCHLEVEL:.=%.lib
\r
270 SET TCLKIT_LIB_STUB=libtclstub%TCLKIT_VERSION:.=%.a
\r
271 SET TCLKIT_SDK=libtclkit-sdk-x64-%TCLKIT_PATCHLEVEL%
\r
272 SET TCLKIT_SDK_ZIP=%TCLKIT_SDK%.zip
\r
273 SET TCLKIT_FILES=%TCLKIT_EXE%
\r
274 IF NOT DEFINED TCLKIT_NOENV IF NOT DEFINED TCLKIT_NOSDK (
\r
275 SET TCLKIT_FILES=%TCLKIT_FILES% unzip.exe %TCLKIT_SDK_ZIP%
\r
279 :fn_UnquoteVariable
\r
280 IF NOT DEFINED %1 GOTO :EOF
\r
282 SET __ECHO_CMD=ECHO %%%1%%
\r
283 FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO (
\r
286 SET VALUE=%VALUE:"=%
\r
288 ENDLOCAL && SET %1=%VALUE%
\r
292 IF NOT DEFINED %1 GOTO :EOF
\r
294 SET __ECHO_CMD=ECHO %%%1%%
\r
295 FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO (
\r
298 SET VALUE=%VALUE:"=%
\r
300 ENDLOCAL && SET PATH=%VALUE%;%PATH%
\r
303 :fn_ResetErrorLevel
\r
308 VERIFY MAYBE 2> NUL
\r
313 ECHO Usage: %~nx0 ^<processor^>
\r
315 ECHO The only supported values for processor are "x86" and "x64".
\r
319 CALL :fn_SetErrorLevel
\r
322 ECHO Failure, errors were encountered.
\r
326 CALL :fn_ResetErrorLevel
\r
329 ECHO Success, no errors were encountered.
\r
333 %__ECHO% EXIT /B %ERRORLEVEL%
\r