Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 1 | @echo off |
| 2 | setlocal |
| 3 | rem Simple script to fetch source for external libraries |
| 4 | |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 5 | if "%PCBUILD%"=="" (set PCBUILD=%~dp0) |
| 6 | if "%EXTERNALS_DIR%"=="" (set EXTERNALS_DIR=%PCBUILD%\..\externals) |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 7 | |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 8 | set DO_FETCH=true |
| 9 | set DO_CLEAN=false |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 10 | |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 11 | :CheckOpts |
| 12 | if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts |
| 13 | if "%~1"=="--no-openssl" (set IncludeSSL=false) & shift & goto CheckOpts |
| 14 | if "%~1"=="--python" (set PYTHON_FOR_BUILD=%2) & shift & shift & goto CheckOpts |
| 15 | if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts |
| 16 | if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts |
| 17 | if "%~1"=="--clean" (set DO_CLEAN=true) & shift & goto CheckOpts |
| 18 | if "%~1"=="--clean-only" (set DO_FETCH=false) & goto clean |
| 19 | if "x%~1" NEQ "x" goto usage |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 20 | |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 21 | if "%DO_CLEAN%"=="false" goto fetch |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 22 | :clean |
| 23 | echo.Cleaning up external libraries. |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 24 | if exist "%EXTERNALS_DIR%" ( |
| 25 | rem Sometimes this fails the first time; try it twice |
| 26 | rmdir /s /q "%EXTERNALS_DIR%" || rmdir /s /q "%EXTERNALS_DIR%" |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 27 | ) |
| 28 | |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 29 | if "%DO_FETCH%"=="false" goto end |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 30 | :fetch |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 31 | |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 32 | if "%ORG%"=="" (set ORG=python) |
| 33 | call "%PCBUILD%find_python.bat" "%PYTHON%" |
| 34 | |
Zachary Ware | aa23144 | 2017-09-05 09:34:54 -0700 | [diff] [blame^] | 35 | git 2>&1 > nul |
| 36 | if ERRORLEVEL 9009 ( |
| 37 | if "%PYTHON%"=="" ( |
| 38 | echo Python 3.6 could not be found or installed, and git.exe is not on your PATH && exit /B 1 |
| 39 | ) |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 40 | ) |
| 41 | |
| 42 | echo.Fetching external libraries... |
| 43 | |
| 44 | rem When updating these versions, remember to update the relevant property |
| 45 | rem files in both this dir and PC\VS9.0 |
| 46 | |
| 47 | set libraries= |
| 48 | set libraries=%libraries% bzip2-1.0.6 |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 49 | if NOT "%IncludeBsddb%"=="false" set libraries=%libraries% bsddb-4.7.25.0 |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 50 | if NOT "%IncludeSSL%"=="false" set libraries=%libraries% openssl-1.0.2k |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 51 | set libraries=%libraries% sqlite-3.14.2.0 |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 52 | if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tcl-8.5.15.0 |
| 53 | if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tk-8.5.15.0 |
| 54 | if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tix-8.4.3.5 |
| 55 | |
| 56 | for %%e in (%libraries%) do ( |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 57 | if exist "%EXTERNALS_DIR%\%%e" ( |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 58 | echo.%%e already exists, skipping. |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 59 | ) else if "%PYTHON%"=="" ( |
| 60 | echo.Fetching %%e with git... |
| 61 | git clone --depth 1 https://github.com/%ORG%/cpython-source-deps --branch %%e "%EXTERNALS_DIR%\%%e" |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 62 | ) else ( |
| 63 | echo.Fetching %%e... |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 64 | %PYTHON% "%PCBUILD%get_external.py" -O %ORG% %%e |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 65 | ) |
| 66 | ) |
| 67 | |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 68 | echo.Fetching external binaries... |
| 69 | |
| 70 | set binaries= |
| 71 | set binaries=%binaries% |
| 72 | if NOT "%IncludeSSL%"=="false" set binaries=%binaries% nasm-2.11.06 |
| 73 | |
| 74 | for %%b in (%binaries%) do ( |
| 75 | if exist "%EXTERNALS_DIR%\%%b" ( |
| 76 | echo.%%b already exists, skipping. |
| 77 | ) else if "%PYTHON%"=="" ( |
| 78 | echo.Fetching %%b with git... |
| 79 | git clone --depth 1 https://github.com/%ORG%/cpython-bin-deps --branch %%b "%EXTERNALS_DIR%\%%b" |
| 80 | ) else ( |
| 81 | echo.Fetching %%b... |
| 82 | %PYTHON% "%PCBUILD%get_external.py" -b -O %ORG% %%b |
| 83 | ) |
| 84 | ) |
| 85 | |
| 86 | echo Finished. |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 87 | goto end |
| 88 | |
| 89 | :usage |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 90 | echo.Valid options: -c, --clean, --clean-only, --organization, --python, |
| 91 | echo.--no-tkinter, --no-openssl |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 92 | echo. |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 93 | echo.Pull all sources and binaries necessary for compiling optional extension |
| 94 | echo.modules that rely on external libraries. |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 95 | echo. |
Zachary Ware | 986b7ff | 2017-09-04 16:05:33 -0700 | [diff] [blame] | 96 | echo.The --organization option determines which github organization to download |
| 97 | echo.from, the --python option determines which Python 3.6+ interpreter to use |
| 98 | echo.with PCbuild\get_external.py. |
| 99 | echo. |
| 100 | echo.Use the -c or --clean option to remove the entire externals directory. |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 101 | echo. |
| 102 | echo.Use the --clean-only option to do the same cleaning, without pulling in |
| 103 | echo.anything new. |
| 104 | echo. |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 105 | exit /b -1 |
| 106 | |
Zachary Ware | 5fe8ac6 | 2017-06-11 14:19:39 -0500 | [diff] [blame] | 107 | :end |