• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1@echo off
2setlocal
3rem Simple script to fetch source for external libraries
4
5if "%PCBUILD%"=="" (set PCBUILD=%~dp0)
6if "%EXTERNALS_DIR%"=="" (set EXTERNALS_DIR=%PCBUILD%\..\externals)
7
8set DO_FETCH=true
9set DO_CLEAN=false
10set IncludeTkinterSrc=false
11set IncludeSSLSrc=false
12
13:CheckOpts
14if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts
15if "%~1"=="--no-openssl" (set IncludeSSL=false) & shift & goto CheckOpts
16if "%~1"=="--tkinter-src" (set IncludeTkinterSrc=true) & shift & goto CheckOpts
17if "%~1"=="--openssl-src" (set IncludeSSLSrc=true) & shift & goto CheckOpts
18if "%~1"=="--python" (set PYTHON=%2) & shift & shift & goto CheckOpts
19if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts
20if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts
21if "%~1"=="--clean" (set DO_CLEAN=true) & shift & goto CheckOpts
22if "%~1"=="--clean-only" (set DO_FETCH=false) & goto clean
23
24rem Include old options for compatibility
25if "%~1"=="--no-tkinter" shift & goto CheckOpts
26if "%~1"=="--no-openssl" shift & goto CheckOpts
27
28if "x%~1" NEQ "x" goto usage
29
30if "%DO_CLEAN%"=="false" goto fetch
31:clean
32echo.Cleaning up external libraries.
33if exist "%EXTERNALS_DIR%" (
34    rem Sometimes this fails the first time; try it twice
35    rmdir /s /q "%EXTERNALS_DIR%" || rmdir /s /q "%EXTERNALS_DIR%"
36)
37
38if "%DO_FETCH%"=="false" goto end
39:fetch
40
41if "%ORG%"=="" (set ORG=python)
42call "%PCBUILD%\find_python.bat" "%PYTHON%"
43
44if "%PYTHON%"=="" (
45    where /Q git || echo Python 3.6 could not be found or installed, and git.exe is not on your PATH && exit /B 1
46)
47
48echo.Fetching external libraries...
49
50set libraries=
51set libraries=%libraries%                                       bzip2-1.0.6
52if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries%     openssl-1.1.0j
53set libraries=%libraries%                                       sqlite-3.21.0.0
54if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tcl-core-8.6.9.0
55if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tk-8.6.9.0
56if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tix-8.4.3.6
57set libraries=%libraries%                                       xz-5.2.2
58set libraries=%libraries%                                       zlib-1.2.11
59
60for %%e in (%libraries%) do (
61    if exist "%EXTERNALS_DIR%\%%e" (
62        echo.%%e already exists, skipping.
63    ) else if "%PYTHON%"=="" (
64        echo.Fetching %%e with git...
65        git clone --depth 1 https://github.com/%ORG%/cpython-source-deps --branch %%e "%EXTERNALS_DIR%\%%e"
66    ) else (
67        echo.Fetching %%e...
68        %PYTHON% -E "%PCBUILD%\get_external.py" -O %ORG% -e "%EXTERNALS_DIR%" %%e
69    )
70)
71
72echo.Fetching external binaries...
73
74set binaries=
75if NOT "%IncludeSSL%"=="false"     set binaries=%binaries% openssl-bin-1.1.0j
76if NOT "%IncludeTkinter%"=="false" set binaries=%binaries% tcltk-8.6.9.0
77if NOT "%IncludeSSLSrc%"=="false"  set binaries=%binaries% nasm-2.11.06
78
79for %%b in (%binaries%) do (
80    if exist "%EXTERNALS_DIR%\%%b" (
81        echo.%%b already exists, skipping.
82    ) else if "%PYTHON%"=="" (
83        echo.Fetching %%b with git...
84        git clone --depth 1 https://github.com/%ORG%/cpython-bin-deps --branch %%b "%EXTERNALS_DIR%\%%b"
85    ) else (
86        echo.Fetching %%b...
87        %PYTHON% -E "%PCBUILD%\get_external.py" -b -O %ORG% -e "%EXTERNALS_DIR%" %%b
88    )
89)
90
91echo Finished.
92goto end
93
94:usage
95echo.Valid options: -c, --clean, --clean-only, --organization, --python,
96echo.--no-tkinter, --no-openssl
97echo.
98echo.Pull all sources and binaries necessary for compiling optional extension
99echo.modules that rely on external libraries.
100echo.
101echo.The --organization option determines which github organization to download
102echo.from, the --python option determines which Python 3.6+ interpreter to use
103echo.with PCbuild\get_external.py.
104echo.
105echo.Use the -c or --clean option to remove the entire externals directory.
106echo.
107echo.Use the --clean-only option to do the same cleaning, without pulling in
108echo.anything new.
109echo.
110exit /b -1
111
112:end
113