blob: e83e1d4c9ad4fa75021593e35a2fc3ab6085ea83 [file] [log] [blame]
Zachary Ware5fe8ac62017-06-11 14:19:39 -05001@echo off
2setlocal
3rem Simple script to fetch source for external libraries
4
Zachary Ware986b7ff2017-09-04 16:05:33 -07005if "%PCBUILD%"=="" (set PCBUILD=%~dp0)
6if "%EXTERNALS_DIR%"=="" (set EXTERNALS_DIR=%PCBUILD%\..\externals)
Zachary Ware5fe8ac62017-06-11 14:19:39 -05007
Zachary Ware986b7ff2017-09-04 16:05:33 -07008set DO_FETCH=true
9set DO_CLEAN=false
Zachary Ware5fe8ac62017-06-11 14:19:39 -050010
Zachary Ware986b7ff2017-09-04 16:05:33 -070011:CheckOpts
12if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts
13if "%~1"=="--no-openssl" (set IncludeSSL=false) & shift & goto CheckOpts
14if "%~1"=="--python" (set PYTHON_FOR_BUILD=%2) & shift & shift & goto CheckOpts
15if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts
16if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts
17if "%~1"=="--clean" (set DO_CLEAN=true) & shift & goto CheckOpts
18if "%~1"=="--clean-only" (set DO_FETCH=false) & goto clean
19if "x%~1" NEQ "x" goto usage
Zachary Ware5fe8ac62017-06-11 14:19:39 -050020
Zachary Ware986b7ff2017-09-04 16:05:33 -070021if "%DO_CLEAN%"=="false" goto fetch
Zachary Ware5fe8ac62017-06-11 14:19:39 -050022:clean
23echo.Cleaning up external libraries.
Zachary Ware986b7ff2017-09-04 16:05:33 -070024if 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 Ware5fe8ac62017-06-11 14:19:39 -050027)
28
Zachary Ware986b7ff2017-09-04 16:05:33 -070029if "%DO_FETCH%"=="false" goto end
Zachary Ware5fe8ac62017-06-11 14:19:39 -050030:fetch
Zachary Ware5fe8ac62017-06-11 14:19:39 -050031
Zachary Ware986b7ff2017-09-04 16:05:33 -070032if "%ORG%"=="" (set ORG=python)
33call "%PCBUILD%find_python.bat" "%PYTHON%"
34
35if "%PYTHON%"=="" (
36 where /Q git || echo Python 3.6 could not be found or installed, and git.exe is not on your PATH && exit /B 1
Zachary Ware5fe8ac62017-06-11 14:19:39 -050037)
38
39echo.Fetching external libraries...
40
41rem When updating these versions, remember to update the relevant property
42rem files in both this dir and PC\VS9.0
43
44set libraries=
45set libraries=%libraries% bzip2-1.0.6
Zachary Ware986b7ff2017-09-04 16:05:33 -070046if NOT "%IncludeBsddb%"=="false" set libraries=%libraries% bsddb-4.7.25.0
Zachary Ware5fe8ac62017-06-11 14:19:39 -050047if NOT "%IncludeSSL%"=="false" set libraries=%libraries% openssl-1.0.2k
Zachary Ware986b7ff2017-09-04 16:05:33 -070048set libraries=%libraries% sqlite-3.14.2.0
Zachary Ware5fe8ac62017-06-11 14:19:39 -050049if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tcl-8.5.15.0
50if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tk-8.5.15.0
51if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tix-8.4.3.5
52
53for %%e in (%libraries%) do (
Zachary Ware986b7ff2017-09-04 16:05:33 -070054 if exist "%EXTERNALS_DIR%\%%e" (
Zachary Ware5fe8ac62017-06-11 14:19:39 -050055 echo.%%e already exists, skipping.
Zachary Ware986b7ff2017-09-04 16:05:33 -070056 ) else if "%PYTHON%"=="" (
57 echo.Fetching %%e with git...
58 git clone --depth 1 https://github.com/%ORG%/cpython-source-deps --branch %%e "%EXTERNALS_DIR%\%%e"
Zachary Ware5fe8ac62017-06-11 14:19:39 -050059 ) else (
60 echo.Fetching %%e...
Zachary Ware986b7ff2017-09-04 16:05:33 -070061 %PYTHON% "%PCBUILD%get_external.py" -O %ORG% %%e
Zachary Ware5fe8ac62017-06-11 14:19:39 -050062 )
63)
64
Zachary Ware986b7ff2017-09-04 16:05:33 -070065echo.Fetching external binaries...
66
67set binaries=
68set binaries=%binaries%
69if NOT "%IncludeSSL%"=="false" set binaries=%binaries% nasm-2.11.06
70
71for %%b in (%binaries%) do (
72 if exist "%EXTERNALS_DIR%\%%b" (
73 echo.%%b already exists, skipping.
74 ) else if "%PYTHON%"=="" (
75 echo.Fetching %%b with git...
76 git clone --depth 1 https://github.com/%ORG%/cpython-bin-deps --branch %%b "%EXTERNALS_DIR%\%%b"
77 ) else (
78 echo.Fetching %%b...
79 %PYTHON% "%PCBUILD%get_external.py" -b -O %ORG% %%b
80 )
81)
82
83echo Finished.
Zachary Ware5fe8ac62017-06-11 14:19:39 -050084goto end
85
86:usage
Zachary Ware986b7ff2017-09-04 16:05:33 -070087echo.Valid options: -c, --clean, --clean-only, --organization, --python,
88echo.--no-tkinter, --no-openssl
Zachary Ware5fe8ac62017-06-11 14:19:39 -050089echo.
Zachary Ware986b7ff2017-09-04 16:05:33 -070090echo.Pull all sources and binaries necessary for compiling optional extension
91echo.modules that rely on external libraries.
Zachary Ware5fe8ac62017-06-11 14:19:39 -050092echo.
Zachary Ware986b7ff2017-09-04 16:05:33 -070093echo.The --organization option determines which github organization to download
94echo.from, the --python option determines which Python 3.6+ interpreter to use
95echo.with PCbuild\get_external.py.
96echo.
97echo.Use the -c or --clean option to remove the entire externals directory.
Zachary Ware5fe8ac62017-06-11 14:19:39 -050098echo.
99echo.Use the --clean-only option to do the same cleaning, without pulling in
100echo.anything new.
101echo.
Zachary Ware5fe8ac62017-06-11 14:19:39 -0500102exit /b -1
103
Zachary Ware5fe8ac62017-06-11 14:19:39 -0500104:end