Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 1 | @echo off |
| 2 | setlocal |
| 3 | rem Simple script to fetch source for external libraries |
| 4 | |
Steve Dower | b95a79c | 2019-03-27 16:28:41 -0700 | [diff] [blame] | 5 | if NOT DEFINED PCBUILD (set PCBUILD=%~dp0) |
| 6 | if NOT DEFINED EXTERNALS_DIR (set EXTERNALS_DIR=%PCBUILD%\..\externals) |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 7 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 8 | set DO_FETCH=true |
| 9 | set DO_CLEAN=false |
Paul Monson | 32119e1 | 2019-03-29 16:30:10 -0700 | [diff] [blame] | 10 | set IncludeLibffiSrc=false |
Steve Dower | 68d663c | 2017-07-17 11:15:48 +0200 | [diff] [blame] | 11 | set IncludeTkinterSrc=false |
| 12 | set IncludeSSLSrc=false |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 13 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 14 | :CheckOpts |
| 15 | if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts |
| 16 | if "%~1"=="--no-openssl" (set IncludeSSL=false) & shift & goto CheckOpts |
Paul Monson | 32119e1 | 2019-03-29 16:30:10 -0700 | [diff] [blame] | 17 | if "%~1"=="--no-libffi" (set IncludeLibffi=false) & shift & goto CheckOpts |
Steve Dower | 68d663c | 2017-07-17 11:15:48 +0200 | [diff] [blame] | 18 | if "%~1"=="--tkinter-src" (set IncludeTkinterSrc=true) & shift & goto CheckOpts |
| 19 | if "%~1"=="--openssl-src" (set IncludeSSLSrc=true) & shift & goto CheckOpts |
Paul Monson | 32119e1 | 2019-03-29 16:30:10 -0700 | [diff] [blame] | 20 | if "%~1"=="--libffi-src" (set IncludeLibffiSrc=true) & shift & goto CheckOpts |
Steve Dower | 68d663c | 2017-07-17 11:15:48 +0200 | [diff] [blame] | 21 | if "%~1"=="--python" (set PYTHON=%2) & shift & shift & goto CheckOpts |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 22 | if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts |
| 23 | if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts |
| 24 | if "%~1"=="--clean" (set DO_CLEAN=true) & shift & goto CheckOpts |
| 25 | if "%~1"=="--clean-only" (set DO_FETCH=false) & goto clean |
Steve Dower | 68d663c | 2017-07-17 11:15:48 +0200 | [diff] [blame] | 26 | |
| 27 | rem Include old options for compatibility |
| 28 | if "%~1"=="--no-tkinter" shift & goto CheckOpts |
| 29 | if "%~1"=="--no-openssl" shift & goto CheckOpts |
| 30 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 31 | if "x%~1" NEQ "x" goto usage |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 32 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 33 | if "%DO_CLEAN%"=="false" goto fetch |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 34 | :clean |
| 35 | echo.Cleaning up external libraries. |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 36 | if exist "%EXTERNALS_DIR%" ( |
| 37 | rem Sometimes this fails the first time; try it twice |
| 38 | rmdir /s /q "%EXTERNALS_DIR%" || rmdir /s /q "%EXTERNALS_DIR%" |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 39 | ) |
| 40 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 41 | if "%DO_FETCH%"=="false" goto end |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 42 | :fetch |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 43 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 44 | if "%ORG%"=="" (set ORG=python) |
Zachary Ware | 6c6d3a4 | 2017-12-30 17:17:36 -0600 | [diff] [blame] | 45 | call "%PCBUILD%\find_python.bat" "%PYTHON%" |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 46 | |
Jess | 7ee88bf | 2019-03-21 09:02:59 -0700 | [diff] [blame] | 47 | if NOT DEFINED PYTHON ( |
Steve Dower | efa26bc | 2017-07-17 15:43:55 +0200 | [diff] [blame] | 48 | where /Q git || echo Python 3.6 could not be found or installed, and git.exe is not on your PATH && exit /B 1 |
| 49 | ) |
| 50 | |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 51 | echo.Fetching external libraries... |
| 52 | |
| 53 | set libraries= |
Steve Dower | 68d663c | 2017-07-17 11:15:48 +0200 | [diff] [blame] | 54 | set libraries=%libraries% bzip2-1.0.6 |
Steve Dower | de148f2 | 2019-11-20 09:30:47 -0800 | [diff] [blame] | 55 | if NOT "%IncludeLibffiSrc%"=="false" set libraries=%libraries% libffi |
Steve Dower | afb7144 | 2021-01-05 21:35:01 +0000 | [diff] [blame] | 56 | if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries% openssl-1.1.1i |
Erlend Egeberg Aasland | dd74c01 | 2021-01-05 23:01:56 +0100 | [diff] [blame] | 57 | set libraries=%libraries% sqlite-3.34.0.0 |
Steve Dower | 985f0ab | 2020-10-19 16:55:10 +0100 | [diff] [blame] | 58 | if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tcl-core-8.6.10.0 |
| 59 | if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tk-8.6.10.0 |
Steve Dower | 68d663c | 2017-07-17 11:15:48 +0200 | [diff] [blame] | 60 | if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tix-8.4.3.6 |
| 61 | set libraries=%libraries% xz-5.2.2 |
Zachary Ware | d01db1c | 2017-09-06 17:29:37 -0700 | [diff] [blame] | 62 | set libraries=%libraries% zlib-1.2.11 |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 63 | |
| 64 | for %%e in (%libraries%) do ( |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 65 | if exist "%EXTERNALS_DIR%\%%e" ( |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 66 | echo.%%e already exists, skipping. |
Jess | 7ee88bf | 2019-03-21 09:02:59 -0700 | [diff] [blame] | 67 | ) else if NOT DEFINED PYTHON ( |
Steve Dower | efa26bc | 2017-07-17 15:43:55 +0200 | [diff] [blame] | 68 | echo.Fetching %%e with git... |
| 69 | git clone --depth 1 https://github.com/%ORG%/cpython-source-deps --branch %%e "%EXTERNALS_DIR%\%%e" |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 70 | ) else ( |
| 71 | echo.Fetching %%e... |
Steve Dower | 667b91a | 2018-02-17 19:58:57 -0800 | [diff] [blame] | 72 | %PYTHON% -E "%PCBUILD%\get_external.py" -O %ORG% -e "%EXTERNALS_DIR%" %%e |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 73 | ) |
| 74 | ) |
| 75 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 76 | echo.Fetching external binaries... |
| 77 | |
| 78 | set binaries= |
Paul Monson | 32119e1 | 2019-03-29 16:30:10 -0700 | [diff] [blame] | 79 | if NOT "%IncludeLibffi%"=="false" set binaries=%binaries% libffi |
Steve Dower | afb7144 | 2021-01-05 21:35:01 +0000 | [diff] [blame] | 80 | if NOT "%IncludeSSL%"=="false" set binaries=%binaries% openssl-bin-1.1.1i |
Steve Dower | 985f0ab | 2020-10-19 16:55:10 +0100 | [diff] [blame] | 81 | if NOT "%IncludeTkinter%"=="false" set binaries=%binaries% tcltk-8.6.10.0 |
Steve Dower | 68d663c | 2017-07-17 11:15:48 +0200 | [diff] [blame] | 82 | if NOT "%IncludeSSLSrc%"=="false" set binaries=%binaries% nasm-2.11.06 |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 83 | |
| 84 | for %%b in (%binaries%) do ( |
| 85 | if exist "%EXTERNALS_DIR%\%%b" ( |
| 86 | echo.%%b already exists, skipping. |
Jess | 7ee88bf | 2019-03-21 09:02:59 -0700 | [diff] [blame] | 87 | ) else if NOT DEFINED PYTHON ( |
Steve Dower | efa26bc | 2017-07-17 15:43:55 +0200 | [diff] [blame] | 88 | echo.Fetching %%b with git... |
| 89 | git clone --depth 1 https://github.com/%ORG%/cpython-bin-deps --branch %%b "%EXTERNALS_DIR%\%%b" |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 90 | ) else ( |
| 91 | echo.Fetching %%b... |
Steve Dower | 667b91a | 2018-02-17 19:58:57 -0800 | [diff] [blame] | 92 | %PYTHON% -E "%PCBUILD%\get_external.py" -b -O %ORG% -e "%EXTERNALS_DIR%" %%b |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 93 | ) |
| 94 | ) |
| 95 | |
| 96 | echo Finished. |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 97 | goto end |
| 98 | |
| 99 | :usage |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 100 | echo.Valid options: -c, --clean, --clean-only, --organization, --python, |
| 101 | echo.--no-tkinter, --no-openssl |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 102 | echo. |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 103 | echo.Pull all sources and binaries necessary for compiling optional extension |
| 104 | echo.modules that rely on external libraries. |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 105 | echo. |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 106 | echo.The --organization option determines which github organization to download |
| 107 | echo.from, the --python option determines which Python 3.6+ interpreter to use |
| 108 | echo.with PCbuild\get_external.py. |
| 109 | echo. |
| 110 | echo.Use the -c or --clean option to remove the entire externals directory. |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 111 | echo. |
| 112 | echo.Use the --clean-only option to do the same cleaning, without pulling in |
| 113 | echo.anything new. |
| 114 | echo. |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 115 | exit /b -1 |
| 116 | |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 117 | :end |