get_externals.bat 4.29 KB
Newer Older
1 2 3 4
@echo off
setlocal
rem Simple script to fetch source for external libraries

5 6
if NOT DEFINED PCBUILD (set PCBUILD=%~dp0)
if NOT DEFINED EXTERNALS_DIR (set EXTERNALS_DIR=%PCBUILD%\..\externals)
7

8 9
set DO_FETCH=true
set DO_CLEAN=false
10
set IncludeLibffiSrc=false
11 12
set IncludeTkinterSrc=false
set IncludeSSLSrc=false
13

14 15 16
:CheckOpts
if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts
if "%~1"=="--no-openssl" (set IncludeSSL=false) & shift & goto CheckOpts
17
if "%~1"=="--no-libffi" (set IncludeLibffi=false) & shift & goto CheckOpts
18 19
if "%~1"=="--tkinter-src" (set IncludeTkinterSrc=true) & shift & goto CheckOpts
if "%~1"=="--openssl-src" (set IncludeSSLSrc=true) & shift & goto CheckOpts
20
if "%~1"=="--libffi-src" (set IncludeLibffiSrc=true) & shift & goto CheckOpts
21
if "%~1"=="--python" (set PYTHON=%2) & shift & shift & goto CheckOpts
22 23 24 25
if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts
if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts
if "%~1"=="--clean" (set DO_CLEAN=true) & shift & goto CheckOpts
if "%~1"=="--clean-only" (set DO_FETCH=false) & goto clean
26 27 28 29 30

rem Include old options for compatibility
if "%~1"=="--no-tkinter" shift & goto CheckOpts
if "%~1"=="--no-openssl" shift & goto CheckOpts

31
if "x%~1" NEQ "x" goto usage
32

33
if "%DO_CLEAN%"=="false" goto fetch
34 35
:clean
echo.Cleaning up external libraries.
36 37 38
if exist "%EXTERNALS_DIR%" (
    rem Sometimes this fails the first time; try it twice
    rmdir /s /q "%EXTERNALS_DIR%" || rmdir /s /q "%EXTERNALS_DIR%"
39 40
)

41
if "%DO_FETCH%"=="false" goto end
42
:fetch
43 44

if "%ORG%"=="" (set ORG=python)
45
call "%PCBUILD%\find_python.bat" "%PYTHON%"
46

47
if NOT DEFINED PYTHON (
48 49 50
    where /Q git || echo Python 3.6 could not be found or installed, and git.exe is not on your PATH && exit /B 1
)

51 52 53
echo.Fetching external libraries...

set libraries=
54
set libraries=%libraries%                                       bzip2-1.0.6
55
if NOT "%IncludeLibffiSrc%"=="false" set libraries=%libraries%  libffi-3.3.0-rc0-r1
56
if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries%     openssl-1.1.1b
57
set libraries=%libraries%                                       sqlite-3.21.0.0
58 59
if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tcl-core-8.6.9.0
if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tk-8.6.9.0
60 61
if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tix-8.4.3.6
set libraries=%libraries%                                       xz-5.2.2
62
set libraries=%libraries%                                       zlib-1.2.11
63 64

for %%e in (%libraries%) do (
65
    if exist "%EXTERNALS_DIR%\%%e" (
66
        echo.%%e already exists, skipping.
67
    ) else if NOT DEFINED PYTHON (
68 69
        echo.Fetching %%e with git...
        git clone --depth 1 https://github.com/%ORG%/cpython-source-deps --branch %%e "%EXTERNALS_DIR%\%%e"
70 71
    ) else (
        echo.Fetching %%e...
72
        %PYTHON% -E "%PCBUILD%\get_external.py" -O %ORG% -e "%EXTERNALS_DIR%" %%e
73 74 75 76 77 78
    )
)

echo.Fetching external binaries...

set binaries=
79
if NOT "%IncludeLibffi%"=="false"  set binaries=%binaries% libffi
80
if NOT "%IncludeSSL%"=="false"     set binaries=%binaries% openssl-bin-1.1.1b
81
if NOT "%IncludeTkinter%"=="false" set binaries=%binaries% tcltk-8.6.9.0
82
if NOT "%IncludeSSLSrc%"=="false"  set binaries=%binaries% nasm-2.11.06
83 84 85 86

for %%b in (%binaries%) do (
    if exist "%EXTERNALS_DIR%\%%b" (
        echo.%%b already exists, skipping.
87
    ) else if NOT DEFINED PYTHON (
88 89
        echo.Fetching %%b with git...
        git clone --depth 1 https://github.com/%ORG%/cpython-bin-deps --branch %%b "%EXTERNALS_DIR%\%%b"
90 91
    ) else (
        echo.Fetching %%b...
92
        %PYTHON% -E "%PCBUILD%\get_external.py" -b -O %ORG% -e "%EXTERNALS_DIR%" %%b
93 94 95
    )
)

96
echo Finished.
97 98 99
goto end

:usage
100 101
echo.Valid options: -c, --clean, --clean-only, --organization, --python,
echo.--no-tkinter, --no-openssl
102
echo.
103 104
echo.Pull all sources and binaries necessary for compiling optional extension
echo.modules that rely on external libraries.
105
echo.
106 107 108 109 110
echo.The --organization option determines which github organization to download
echo.from, the --python option determines which Python 3.6+ interpreter to use
echo.with PCbuild\get_external.py.
echo.
echo.Use the -c or --clean option to remove the entire externals directory.
111 112 113 114 115 116 117
echo.
echo.Use the --clean-only option to do the same cleaning, without pulling in
echo.anything new.
echo.
exit /b -1

:end