blob: aece81fbb1cf3e162fc3b2d7bde3c29480aebec2 [file] [log] [blame]
Zachary Ware6b6e6872017-06-10 14:58:42 -05001@echo off
2setlocal
Zachary Ware51599e22017-06-15 22:08:51 -05003rem Simple script to fetch source for external libraries
Zachary Ware6b6e6872017-06-10 14:58:42 -05004
Zachary Ware51599e22017-06-15 22:08:51 -05005set HERE=%~dp0
6if "%PCBUILD%"=="" (set PCBUILD=%HERE%..\..\PCbuild\)
7if "%EXTERNALS_DIR%"=="" (set EXTERNALS_DIR=%HERE%..\..\externals\windows-installer)
8if "%NUGET%"=="" (set NUGET=%EXTERNALS_DIR%\..\nuget.exe)
9if "%NUGET_URL%"=="" (set NUGET_URL=https://aka.ms/nugetclidl)
10
11set DO_FETCH=true
12set DO_CLEAN=false
13
14:CheckOpts
15if "%~1"=="--python" (set PYTHON_FOR_BUILD=%2) & shift & shift & goto CheckOpts
16if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts
17if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts
18if "%~1"=="--clean" (set DO_CLEAN=true) & shift & goto CheckOpts
19if "%~1"=="--clean-only" (set DO_FETCH=false) & goto clean
20if "x%~1" NEQ "x" goto usage
21
22if "%DO_CLEAN%"=="false" goto fetch
23:clean
24echo.Cleaning up external libraries.
25if 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 Ware6b6e6872017-06-10 14:58:42 -050028)
29
Zachary Ware51599e22017-06-15 22:08:51 -050030if "%DO_FETCH%"=="false" goto end
31:fetch
Zachary Ware6b6e6872017-06-10 14:58:42 -050032
Zachary Ware51599e22017-06-15 22:08:51 -050033if "%ORG%"=="" (set ORG=python)
Zachary Ware6b6e6872017-06-10 14:58:42 -050034
Zachary Ware51599e22017-06-15 22:08:51 -050035if "%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)
39if "%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 Ware6b6e6872017-06-10 14:58:42 -050051)
52
Zachary Ware51599e22017-06-15 22:08:51 -050053echo.Fetching external libraries...
54
55set libraries=
56
57for %%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
66echo.Fetching external tools...
67
68set binaries=
69rem We always use whatever's latest in the repo for these
70set binaries=%binaries% binutils
71set binaries=%binaries% gpg
72set binaries=%binaries% htmlhelp
73set binaries=%binaries% nuget
74set binaries=%binaries% redist
75set binaries=%binaries% wix
76
77for %%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
86echo Finished.
87goto end
88
89:usage
90echo.Valid options: -c, --clean, --clean-only, --organization, --python,
91echo.--no-tkinter, --no-openssl
92echo.
93echo.Pull all sources and binaries necessary for compiling optional extension
94echo.modules that rely on external libraries.
95echo.
96echo.The --organization option determines which github organization to download
97echo.from, the --python option determines which Python 3.6+ interpreter to use
98echo.with PCbuild\get_external.py.
99echo.
100echo.Use the -c or --clean option to remove the entire externals directory.
101echo.
102echo.Use the --clean-only option to do the same cleaning, without pulling in
103echo.anything new.
104echo.
105exit /b -1
106
107:end