blob: 92fc9441727f80b9fa9d5a89a46e4c5702782674 [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
Zachary Wareaa231442017-09-05 09:34:54 -070035git 2>&1 > nul
36if 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 Ware5fe8ac62017-06-11 14:19:39 -050040)
41
42echo.Fetching external libraries...
43
44rem When updating these versions, remember to update the relevant property
45rem files in both this dir and PC\VS9.0
46
47set libraries=
48set libraries=%libraries% bzip2-1.0.6
Zachary Ware986b7ff2017-09-04 16:05:33 -070049if NOT "%IncludeBsddb%"=="false" set libraries=%libraries% bsddb-4.7.25.0
Zachary Ware5fe8ac62017-06-11 14:19:39 -050050if NOT "%IncludeSSL%"=="false" set libraries=%libraries% openssl-1.0.2k
Zachary Ware986b7ff2017-09-04 16:05:33 -070051set libraries=%libraries% sqlite-3.14.2.0
Zachary Ware5fe8ac62017-06-11 14:19:39 -050052if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tcl-8.5.15.0
53if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tk-8.5.15.0
54if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tix-8.4.3.5
55
56for %%e in (%libraries%) do (
Zachary Ware986b7ff2017-09-04 16:05:33 -070057 if exist "%EXTERNALS_DIR%\%%e" (
Zachary Ware5fe8ac62017-06-11 14:19:39 -050058 echo.%%e already exists, skipping.
Zachary Ware986b7ff2017-09-04 16:05:33 -070059 ) 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 Ware5fe8ac62017-06-11 14:19:39 -050062 ) else (
63 echo.Fetching %%e...
Zachary Ware986b7ff2017-09-04 16:05:33 -070064 %PYTHON% "%PCBUILD%get_external.py" -O %ORG% %%e
Zachary Ware5fe8ac62017-06-11 14:19:39 -050065 )
66)
67
Zachary Ware986b7ff2017-09-04 16:05:33 -070068echo.Fetching external binaries...
69
70set binaries=
71set binaries=%binaries%
72if NOT "%IncludeSSL%"=="false" set binaries=%binaries% nasm-2.11.06
73
74for %%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
86echo Finished.
Zachary Ware5fe8ac62017-06-11 14:19:39 -050087goto end
88
89:usage
Zachary Ware986b7ff2017-09-04 16:05:33 -070090echo.Valid options: -c, --clean, --clean-only, --organization, --python,
91echo.--no-tkinter, --no-openssl
Zachary Ware5fe8ac62017-06-11 14:19:39 -050092echo.
Zachary Ware986b7ff2017-09-04 16:05:33 -070093echo.Pull all sources and binaries necessary for compiling optional extension
94echo.modules that rely on external libraries.
Zachary Ware5fe8ac62017-06-11 14:19:39 -050095echo.
Zachary Ware986b7ff2017-09-04 16:05:33 -070096echo.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.
Zachary Ware5fe8ac62017-06-11 14:19:39 -0500101echo.
102echo.Use the --clean-only option to do the same cleaning, without pulling in
103echo.anything new.
104echo.
Zachary Ware5fe8ac62017-06-11 14:19:39 -0500105exit /b -1
106
Zachary Ware5fe8ac62017-06-11 14:19:39 -0500107:end