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 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 5 | if "%PCBUILD%"=="" (set PCBUILD=%~dp0) |
| 6 | if "%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 |
Steve Dower | 68d663c | 2017-07-17 11:15:48 +0200 | [diff] [blame] | 10 | set IncludeTkinterSrc=false |
| 11 | set IncludeSSLSrc=false |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 12 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 13 | :CheckOpts |
| 14 | if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts |
| 15 | if "%~1"=="--no-openssl" (set IncludeSSL=false) & shift & goto CheckOpts |
Steve Dower | 68d663c | 2017-07-17 11:15:48 +0200 | [diff] [blame] | 16 | if "%~1"=="--tkinter-src" (set IncludeTkinterSrc=true) & shift & goto CheckOpts |
| 17 | if "%~1"=="--openssl-src" (set IncludeSSLSrc=true) & shift & goto CheckOpts |
| 18 | if "%~1"=="--python" (set PYTHON=%2) & shift & shift & goto CheckOpts |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 19 | if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts |
| 20 | if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts |
| 21 | if "%~1"=="--clean" (set DO_CLEAN=true) & shift & goto CheckOpts |
| 22 | if "%~1"=="--clean-only" (set DO_FETCH=false) & goto clean |
Steve Dower | 68d663c | 2017-07-17 11:15:48 +0200 | [diff] [blame] | 23 | |
| 24 | rem Include old options for compatibility |
| 25 | if "%~1"=="--no-tkinter" shift & goto CheckOpts |
| 26 | if "%~1"=="--no-openssl" shift & goto CheckOpts |
| 27 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 28 | if "x%~1" NEQ "x" goto usage |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 29 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 30 | if "%DO_CLEAN%"=="false" goto fetch |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 31 | :clean |
| 32 | echo.Cleaning up external libraries. |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 33 | if 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%" |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 36 | ) |
| 37 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 38 | if "%DO_FETCH%"=="false" goto end |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 39 | :fetch |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 40 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 41 | if "%ORG%"=="" (set ORG=python) |
Zachary Ware | 6c6d3a4 | 2017-12-30 17:17:36 -0600 | [diff] [blame] | 42 | call "%PCBUILD%\find_python.bat" "%PYTHON%" |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 43 | |
Steve Dower | efa26bc | 2017-07-17 15:43:55 +0200 | [diff] [blame] | 44 | if "%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 | |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 48 | echo.Fetching external libraries... |
| 49 | |
| 50 | set libraries= |
Steve Dower | 68d663c | 2017-07-17 11:15:48 +0200 | [diff] [blame] | 51 | set libraries=%libraries% bzip2-1.0.6 |
Steve Dower | b84bcc4 | 2017-09-09 06:13:06 -0700 | [diff] [blame] | 52 | if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries% openssl-1.1.0f |
Mariatta | 31af650 | 2017-11-06 19:31:53 -0800 | [diff] [blame] | 53 | set libraries=%libraries% sqlite-3.21.0.0 |
Steve Dower | 68d663c | 2017-07-17 11:15:48 +0200 | [diff] [blame] | 54 | if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tcl-core-8.6.6.0 |
| 55 | if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tk-8.6.6.0 |
| 56 | if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tix-8.4.3.6 |
| 57 | set libraries=%libraries% xz-5.2.2 |
Zachary Ware | d01db1c | 2017-09-06 17:29:37 -0700 | [diff] [blame] | 58 | set libraries=%libraries% zlib-1.2.11 |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 59 | |
| 60 | for %%e in (%libraries%) do ( |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 61 | if exist "%EXTERNALS_DIR%\%%e" ( |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 62 | echo.%%e already exists, skipping. |
Steve Dower | efa26bc | 2017-07-17 15:43:55 +0200 | [diff] [blame] | 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" |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 66 | ) else ( |
| 67 | echo.Fetching %%e... |
Zachary Ware | 6c6d3a4 | 2017-12-30 17:17:36 -0600 | [diff] [blame] | 68 | %PYTHON% "%PCBUILD%\get_external.py" -O %ORG% %%e |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 69 | ) |
| 70 | ) |
| 71 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 72 | echo.Fetching external binaries... |
| 73 | |
| 74 | set binaries= |
Steve Dower | b84bcc4 | 2017-09-09 06:13:06 -0700 | [diff] [blame] | 75 | if NOT "%IncludeSSL%"=="false" set binaries=%binaries% openssl-bin-1.1.0f |
Steve Dower | 68d663c | 2017-07-17 11:15:48 +0200 | [diff] [blame] | 76 | if NOT "%IncludeTkinter%"=="false" set binaries=%binaries% tcltk-8.6.6.0 |
| 77 | if NOT "%IncludeSSLSrc%"=="false" set binaries=%binaries% nasm-2.11.06 |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 78 | |
| 79 | for %%b in (%binaries%) do ( |
| 80 | if exist "%EXTERNALS_DIR%\%%b" ( |
| 81 | echo.%%b already exists, skipping. |
Steve Dower | efa26bc | 2017-07-17 15:43:55 +0200 | [diff] [blame] | 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" |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 85 | ) else ( |
| 86 | echo.Fetching %%b... |
Zachary Ware | 6c6d3a4 | 2017-12-30 17:17:36 -0600 | [diff] [blame] | 87 | %PYTHON% "%PCBUILD%\get_external.py" -b -O %ORG% %%b |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 88 | ) |
| 89 | ) |
| 90 | |
| 91 | echo Finished. |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 92 | goto end |
| 93 | |
| 94 | :usage |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 95 | echo.Valid options: -c, --clean, --clean-only, --organization, --python, |
| 96 | echo.--no-tkinter, --no-openssl |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 97 | echo. |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 98 | echo.Pull all sources and binaries necessary for compiling optional extension |
| 99 | echo.modules that rely on external libraries. |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 100 | echo. |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame] | 101 | echo.The --organization option determines which github organization to download |
| 102 | echo.from, the --python option determines which Python 3.6+ interpreter to use |
| 103 | echo.with PCbuild\get_external.py. |
| 104 | echo. |
| 105 | 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] | 106 | echo. |
| 107 | echo.Use the --clean-only option to do the same cleaning, without pulling in |
| 108 | echo.anything new. |
| 109 | echo. |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 110 | exit /b -1 |
| 111 | |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 112 | :end |