Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 1 | @echo off |
| 2 | setlocal |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame^] | 3 | rem Simple script to fetch source for external libraries |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 4 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame^] | 5 | set HERE=%~dp0 |
| 6 | if "%PCBUILD%"=="" (set PCBUILD=%HERE%..\..\PCbuild\) |
| 7 | if "%EXTERNALS_DIR%"=="" (set EXTERNALS_DIR=%HERE%..\..\externals\windows-installer) |
| 8 | if "%NUGET%"=="" (set NUGET=%EXTERNALS_DIR%\..\nuget.exe) |
| 9 | if "%NUGET_URL%"=="" (set NUGET_URL=https://aka.ms/nugetclidl) |
| 10 | |
| 11 | set DO_FETCH=true |
| 12 | set DO_CLEAN=false |
| 13 | |
| 14 | :CheckOpts |
| 15 | if "%~1"=="--python" (set PYTHON_FOR_BUILD=%2) & shift & shift & goto CheckOpts |
| 16 | if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts |
| 17 | if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts |
| 18 | if "%~1"=="--clean" (set DO_CLEAN=true) & shift & goto CheckOpts |
| 19 | if "%~1"=="--clean-only" (set DO_FETCH=false) & goto clean |
| 20 | if "x%~1" NEQ "x" goto usage |
| 21 | |
| 22 | if "%DO_CLEAN%"=="false" goto fetch |
| 23 | :clean |
| 24 | echo.Cleaning up external libraries. |
| 25 | if exist "%EXTERNALS_DIR%" ( |
| 26 | rem Sometimes this fails the first time; try it twice |
| 27 | rmdir /s /q "%EXTERNALS_DIR%" || rmdir /s /q "%EXTERNALS_DIR%" |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 28 | ) |
| 29 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame^] | 30 | if "%DO_FETCH%"=="false" goto end |
| 31 | :fetch |
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 "%ORG%"=="" (set ORG=python) |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 34 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame^] | 35 | if "%PYTHON_FOR_BUILD%"=="" ( |
| 36 | echo Checking for installed python... |
| 37 | py -3.6 -V >nul 2>&1 && (set PYTHON_FOR_BUILD=py -3.6) |
| 38 | ) |
| 39 | if "%PYTHON_FOR_BUILD%"=="" ( |
| 40 | if NOT exist "%EXTERNALS_DIR%" mkdir "%EXTERNALS_DIR%" |
| 41 | if NOT exist "%NUGET%" ( |
| 42 | echo Downloading nuget... |
| 43 | rem NB: Must use single quotes around NUGET here, NOT double! |
| 44 | rem Otherwise, a space in the path would break things |
| 45 | powershell.exe -Command Invoke-WebRequest %NUGET_URL% -OutFile '%NUGET%' |
| 46 | ) |
| 47 | echo Installing Python via nuget... |
| 48 | "%NUGET%" install pythonx86 -ExcludeVersion -OutputDirectory "%EXTERNALS_DIR%" |
| 49 | rem Quote it here; it's not quoted later because "py -3.6" wouldn't work |
| 50 | set PYTHON_FOR_BUILD="%EXTERNALS_DIR%\pythonx86\tools\python.exe" |
Zachary Ware | 6b6e687 | 2017-06-10 14:58:42 -0500 | [diff] [blame] | 51 | ) |
| 52 | |
Zachary Ware | 51599e2 | 2017-06-15 22:08:51 -0500 | [diff] [blame^] | 53 | echo.Fetching external libraries... |
| 54 | |
| 55 | set libraries= |
| 56 | |
| 57 | for %%e in (%libraries%) do ( |
| 58 | if exist "%EXTERNALS_DIR%\%%e" ( |
| 59 | echo.%%e already exists, skipping. |
| 60 | ) else ( |
| 61 | echo.Fetching %%e... |
| 62 | %PYTHON_FOR_BUILD% "%PCBUILD%get_external.py" -e "%EXTERNALS_DIR%" -O %ORG% %%e |
| 63 | ) |
| 64 | ) |
| 65 | |
| 66 | echo.Fetching external tools... |
| 67 | |
| 68 | set binaries= |
| 69 | rem We always use whatever's latest in the repo for these |
| 70 | set binaries=%binaries% binutils |
| 71 | set binaries=%binaries% gpg |
| 72 | set binaries=%binaries% htmlhelp |
| 73 | set binaries=%binaries% nuget |
| 74 | set binaries=%binaries% redist |
| 75 | set binaries=%binaries% wix |
| 76 | |
| 77 | for %%b in (%binaries%) do ( |
| 78 | if exist "%EXTERNALS_DIR%\%%b" ( |
| 79 | echo.%%b already exists, skipping. |
| 80 | ) else ( |
| 81 | echo.Fetching %%b... |
| 82 | %PYTHON_FOR_BUILD% "%PCBUILD%get_external.py" -e "%EXTERNALS_DIR%" -b -O %ORG% %%b |
| 83 | ) |
| 84 | ) |
| 85 | |
| 86 | echo Finished. |
| 87 | goto end |
| 88 | |
| 89 | :usage |
| 90 | echo.Valid options: -c, --clean, --clean-only, --organization, --python, |
| 91 | echo.--no-tkinter, --no-openssl |
| 92 | echo. |
| 93 | echo.Pull all sources and binaries necessary for compiling optional extension |
| 94 | echo.modules that rely on external libraries. |
| 95 | echo. |
| 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. |
| 101 | echo. |
| 102 | echo.Use the --clean-only option to do the same cleaning, without pulling in |
| 103 | echo.anything new. |
| 104 | echo. |
| 105 | exit /b -1 |
| 106 | |
| 107 | :end |