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
43 SET ROOT=%ROOT:\\=\%
\r
45 %_VECHO% Root = '%ROOT%'
\r
48 SET TOOLS=%TOOLS:~0,-1%
\r
50 %_VECHO% Tools = '%TOOLS%'
\r
52 IF NOT DEFINED windir (
\r
53 ECHO The windir environment variable must be set first.
\r
57 %_VECHO% WinDir = '%windir%'
\r
59 IF NOT DEFINED TEMP (
\r
60 ECHO The TEMP environment variable must be set first.
\r
64 %_VECHO% Temp = '%TEMP%'
\r
66 IF NOT DEFINED TCLKIT_URI (
\r
67 SET TCLKIT_URI=https://tclsh.com/
\r
70 %_VECHO% TclKitUri = '%TCLKIT_URI%'
\r
72 IF /I "%PROCESSOR%" == "x86" (
\r
73 CALL :fn_TclKitX86Variables
\r
74 ) ELSE IF /I "%PROCESSOR%" == "x64" (
\r
75 CALL :fn_TclKitX64Variables
\r
80 %_VECHO% TclKitVersion = '%TCLKIT_VERSION%'
\r
81 %_VECHO% TclKitPatchLevel = '%TCLKIT_PATCHLEVEL%'
\r
82 %_VECHO% TclKitNoEnv = '%TCLKIT_NOENV%'
\r
83 %_VECHO% TclKitNoSdk = '%TCLKIT_NOSDK%'
\r
84 %_VECHO% TclKitExe = '%TCLKIT_EXE%'
\r
85 %_VECHO% TclKitLib = '%TCLKIT_LIB%'
\r
86 %_VECHO% TclKitLibStub = '%TCLKIT_LIB_STUB%'
\r
87 %_VECHO% TclKitSdk = '%TCLKIT_SDK%'
\r
88 %_VECHO% TclKitSdkZip = '%TCLKIT_SDK_ZIP%'
\r
89 %_VECHO% TclKitFiles = '%TCLKIT_FILES%'
\r
91 CALL :fn_ResetErrorLevel
\r
93 FOR %%T IN (csc.exe) DO (
\r
94 SET %%T_PATH=%%~dp$PATH:T
\r
97 %_VECHO% Csc.exe_PATH = '%csc.exe_PATH%'
\r
99 IF DEFINED csc.exe_PATH (
\r
100 GOTO skip_addToPath
\r
103 IF DEFINED FRAMEWORKDIR (
\r
104 REM Use the existing .NET Framework directory...
\r
105 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v2.0.50727" (
\r
106 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework64\v2.0.50727
\r
107 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v3.5" (
\r
108 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework64\v3.5
\r
109 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework64\v4.0.30319" (
\r
110 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework64\v4.0.30319
\r
111 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v2.0.50727" (
\r
112 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework\v2.0.50727
\r
113 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v3.5" (
\r
114 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework\v3.5
\r
115 ) ELSE IF EXIST "%windir%\Microsoft.NET\Framework\v4.0.30319" (
\r
116 SET FRAMEWORKDIR=%windir%\Microsoft.NET\Framework\v4.0.30319
\r
118 ECHO No suitable version of the .NET Framework appears to be installed.
\r
122 %_VECHO% FrameworkDir = '%FRAMEWORKDIR%'
\r
124 IF NOT EXIST "%FRAMEWORKDIR%\csc.exe" (
\r
125 ECHO The file "%FRAMEWORKDIR%\csc.exe" is missing.
\r
129 CALL :fn_PrependToPath FRAMEWORKDIR
\r
133 IF NOT EXIST "%TEMP%\GetFile.exe" (
\r
134 %__ECHO% csc.exe "/out:%TEMP%\GetFile.exe" /target:exe "%TOOLS%\GetFile.cs"
\r
137 ECHO Compilation of "%TOOLS%\GetFile.cs" failed.
\r
142 FOR %%F IN (%TCLKIT_FILES%) DO (
\r
143 IF NOT EXIST "%TEMP%\%%F" (
\r
144 %__ECHO% "%TEMP%\GetFile.exe" "%TCLKIT_URI%%%F"
\r
147 ECHO Download of "%%F" from "%TCLKIT_URI%" failed.
\r
153 IF DEFINED TCLKIT_NOENV GOTO skip_sdkUnZip
\r
154 IF DEFINED TCLKIT_NOSDK GOTO skip_sdkUnZip
\r
156 IF NOT EXIST "%TEMP%\%TCLKIT_SDK%" (
\r
157 %__ECHO% MKDIR "%TEMP%\%TCLKIT_SDK%"
\r
160 ECHO Could not create directory "%TEMP%\%TCLKIT_SDK%".
\r
165 %__ECHO% "%TEMP%\unzip.exe" -n "%TEMP%\%TCLKIT_SDK_ZIP%" -d "%TEMP%\%TCLKIT_SDK%"
\r
168 ECHO Could not unzip "%TEMP%\%TCLKIT_SDK_ZIP%" to "%TEMP%\%TCLKIT_SDK%".
\r
174 IF DEFINED TCLKIT_NOENV GOTO skip_sdkEnvironment
\r
176 %__ECHO% ECHO SET TCLSH_CMD=%TEMP%\%TCLKIT_EXE%%OVERWRITE%"%ROOT%\SetTclKitEnv.bat"
\r
178 IF DEFINED TCLKIT_NOSDK GOTO skip_sdkVariables
\r
180 %__ECHO% ECHO SET TCLINCDIR=%TEMP%\%TCLKIT_SDK%\include%APPEND%"%ROOT%\SetTclKitEnv.bat"
\r
181 %__ECHO% ECHO SET TCLLIBDIR=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ROOT%\SetTclKitEnv.bat"
\r
182 %__ECHO% ECHO SET LIBTCLPATH=%TEMP%\%TCLKIT_SDK%\lib%APPEND%"%ROOT%\SetTclKitEnv.bat"
\r
183 %__ECHO% ECHO SET LIBTCL=%TCLKIT_LIB%%APPEND%"%ROOT%\SetTclKitEnv.bat"
\r
184 %__ECHO% ECHO SET LIBTCLSTUB=%TCLKIT_LIB_STUB%%APPEND%"%ROOT%\SetTclKitEnv.bat"
\r
189 ECHO Wrote "%ROOT%\SetTclKitEnv.bat".
\r
190 ECHO Please run it to set the necessary Tcl environment variables.
\r
193 :skip_sdkEnvironment
\r
197 :fn_TclKitX86Variables
\r
199 REM NOTE: By default, use latest available version of the TclKit SDK
\r
200 REM for x86. However, the "default" TclKit executable for x86
\r
201 REM is still used here because it is the only one "well-known"
\r
202 REM to be available for download.
\r
204 IF NOT DEFINED TCLKIT_PATCHLEVEL (
\r
205 SET TCLKIT_PATCHLEVEL=8.6.6
\r
207 SET TCLKIT_VERSION=%TCLKIT_PATCHLEVEL:.=%
\r
208 SET TCLKIT_VERSION=%TCLKIT_VERSION:~0,2%
\r
209 REM SET TCLKIT_EXE=tclkit-%TCLKIT_PATCHLEVEL%.exe
\r
210 SET TCLKIT_EXE=tclkit-8.6.4.exe
\r
211 SET TCLKIT_LIB=libtclkit%TCLKIT_PATCHLEVEL:.=%.lib
\r
212 SET TCLKIT_LIB_STUB=libtclstub%TCLKIT_VERSION:.=%.a
\r
213 SET TCLKIT_SDK=libtclkit-sdk-x86-%TCLKIT_PATCHLEVEL%
\r
214 SET TCLKIT_SDK_ZIP=%TCLKIT_SDK%.zip
\r
215 SET TCLKIT_FILES=%TCLKIT_EXE%
\r
216 IF NOT DEFINED TCLKIT_NOENV IF NOT DEFINED TCLKIT_NOSDK (
\r
217 SET TCLKIT_FILES=%TCLKIT_FILES% unzip.exe %TCLKIT_SDK_ZIP%
\r
221 :fn_TclKitX64Variables
\r
223 REM NOTE: By default, use latest available version of the TclKit SDK
\r
224 REM for x64. 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 SET TCLKIT_PATCHLEVEL=8.6.6
\r
231 SET TCLKIT_VERSION=%TCLKIT_PATCHLEVEL:.=%
\r
232 SET TCLKIT_VERSION=%TCLKIT_VERSION:~0,2%
\r
233 REM SET TCLKIT_EXE=tclkit-%TCLKIT_PATCHLEVEL%.exe
\r
234 SET TCLKIT_EXE=tclkit-8.6.4.exe
\r
235 SET TCLKIT_LIB=libtclkit%TCLKIT_PATCHLEVEL:.=%.lib
\r
236 SET TCLKIT_LIB_STUB=libtclstub%TCLKIT_VERSION:.=%.a
\r
237 SET TCLKIT_SDK=libtclkit-sdk-x64-%TCLKIT_PATCHLEVEL%
\r
238 SET TCLKIT_SDK_ZIP=%TCLKIT_SDK%.zip
\r
239 SET TCLKIT_FILES=%TCLKIT_EXE%
\r
240 IF NOT DEFINED TCLKIT_NOENV IF NOT DEFINED TCLKIT_NOSDK (
\r
241 SET TCLKIT_FILES=%TCLKIT_FILES% unzip.exe %TCLKIT_SDK_ZIP%
\r
245 :fn_UnquoteVariable
\r
246 IF NOT DEFINED %1 GOTO :EOF
\r
248 SET __ECHO_CMD=ECHO %%%1%%
\r
249 FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO (
\r
252 SET VALUE=%VALUE:"=%
\r
254 ENDLOCAL && SET %1=%VALUE%
\r
258 IF NOT DEFINED %1 GOTO :EOF
\r
260 SET __ECHO_CMD=ECHO %%%1%%
\r
261 FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO (
\r
264 SET VALUE=%VALUE:"=%
\r
266 ENDLOCAL && SET PATH=%VALUE%;%PATH%
\r
269 :fn_ResetErrorLevel
\r
274 VERIFY MAYBE 2> NUL
\r
279 ECHO Usage: %~nx0 ^<processor^>
\r
281 ECHO The only supported values for processor are "x86" and "x64".
\r
285 CALL :fn_SetErrorLevel
\r
288 ECHO Failure, errors were encountered.
\r
292 CALL :fn_ResetErrorLevel
\r
295 ECHO Success, no errors were encountered.
\r
299 %__ECHO% EXIT /B %ERRORLEVEL%
\r