blob: b82b6e6588e621039f87f512f5ca79abcada6417 [file] [log] [blame]
Zachary Ware6b6e6872017-06-10 14:58:42 -05001@echo off
2setlocal
3rem Simple script to fetch source for external libraries
4
Steve Dowerb95a79c2019-03-27 16:28:41 -07005if NOT DEFINED PCBUILD (set PCBUILD=%~dp0)
6if NOT DEFINED EXTERNALS_DIR (set EXTERNALS_DIR=%PCBUILD%\..\externals)
Zachary Ware6b6e6872017-06-10 14:58:42 -05007
Zachary Ware51599e22017-06-15 22:08:51 -05008set DO_FETCH=true
9set DO_CLEAN=false
Paul Monson32119e12019-03-29 16:30:10 -070010set IncludeLibffiSrc=false
Steve Dower68d663c2017-07-17 11:15:48 +020011set IncludeTkinterSrc=false
12set IncludeSSLSrc=false
Zachary Ware6b6e6872017-06-10 14:58:42 -050013
Zachary Ware51599e22017-06-15 22:08:51 -050014:CheckOpts
15if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts
16if "%~1"=="--no-openssl" (set IncludeSSL=false) & shift & goto CheckOpts
Paul Monson32119e12019-03-29 16:30:10 -070017if "%~1"=="--no-libffi" (set IncludeLibffi=false) & shift & goto CheckOpts
Steve Dower68d663c2017-07-17 11:15:48 +020018if "%~1"=="--tkinter-src" (set IncludeTkinterSrc=true) & shift & goto CheckOpts
19if "%~1"=="--openssl-src" (set IncludeSSLSrc=true) & shift & goto CheckOpts
Paul Monson32119e12019-03-29 16:30:10 -070020if "%~1"=="--libffi-src" (set IncludeLibffiSrc=true) & shift & goto CheckOpts
Steve Dower68d663c2017-07-17 11:15:48 +020021if "%~1"=="--python" (set PYTHON=%2) & shift & shift & goto CheckOpts
Zachary Ware51599e22017-06-15 22:08:51 -050022if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts
23if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts
24if "%~1"=="--clean" (set DO_CLEAN=true) & shift & goto CheckOpts
25if "%~1"=="--clean-only" (set DO_FETCH=false) & goto clean
Steve Dower68d663c2017-07-17 11:15:48 +020026
27rem Include old options for compatibility
28if "%~1"=="--no-tkinter" shift & goto CheckOpts
29if "%~1"=="--no-openssl" shift & goto CheckOpts
30
Zachary Ware51599e22017-06-15 22:08:51 -050031if "x%~1" NEQ "x" goto usage
Zachary Ware6b6e6872017-06-10 14:58:42 -050032
Zachary Ware51599e22017-06-15 22:08:51 -050033if "%DO_CLEAN%"=="false" goto fetch
Zachary Ware6b6e6872017-06-10 14:58:42 -050034:clean
35echo.Cleaning up external libraries.
Zachary Ware51599e22017-06-15 22:08:51 -050036if exist "%EXTERNALS_DIR%" (
37 rem Sometimes this fails the first time; try it twice
38 rmdir /s /q "%EXTERNALS_DIR%" || rmdir /s /q "%EXTERNALS_DIR%"
Zachary Ware6b6e6872017-06-10 14:58:42 -050039)
40
Zachary Ware51599e22017-06-15 22:08:51 -050041if "%DO_FETCH%"=="false" goto end
Zachary Ware6b6e6872017-06-10 14:58:42 -050042:fetch
Zachary Ware6b6e6872017-06-10 14:58:42 -050043
Zachary Ware51599e22017-06-15 22:08:51 -050044if "%ORG%"=="" (set ORG=python)
Zachary Ware6c6d3a42017-12-30 17:17:36 -060045call "%PCBUILD%\find_python.bat" "%PYTHON%"
Zachary Ware6b6e6872017-06-10 14:58:42 -050046
Jess7ee88bf2019-03-21 09:02:59 -070047if NOT DEFINED PYTHON (
Steve Dowerefa26bc2017-07-17 15:43:55 +020048 where /Q git || echo Python 3.6 could not be found or installed, and git.exe is not on your PATH && exit /B 1
49)
50
Zachary Ware6b6e6872017-06-10 14:58:42 -050051echo.Fetching external libraries...
52
53set libraries=
Steve Dower68d663c2017-07-17 11:15:48 +020054set libraries=%libraries% bzip2-1.0.6
Paul Monson32119e12019-03-29 16:30:10 -070055if NOT "%IncludeLibffiSrc%"=="false" set libraries=%libraries% libffi-3.3.0-rc0-r1
Steve Dower48243852018-12-10 19:52:36 -080056if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries% openssl-1.1.0j
Mariatta31af6502017-11-06 19:31:53 -080057set libraries=%libraries% sqlite-3.21.0.0
Steve Dowerf8e9bd52018-12-14 09:13:15 -080058if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tcl-core-8.6.9.0
59if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tk-8.6.9.0
Steve Dower68d663c2017-07-17 11:15:48 +020060if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tix-8.4.3.6
61set libraries=%libraries% xz-5.2.2
Zachary Wared01db1c2017-09-06 17:29:37 -070062set libraries=%libraries% zlib-1.2.11
Zachary Ware6b6e6872017-06-10 14:58:42 -050063
64for %%e in (%libraries%) do (
Zachary Ware51599e22017-06-15 22:08:51 -050065 if exist "%EXTERNALS_DIR%\%%e" (
Zachary Ware6b6e6872017-06-10 14:58:42 -050066 echo.%%e already exists, skipping.
Jess7ee88bf2019-03-21 09:02:59 -070067 ) else if NOT DEFINED PYTHON (
Steve Dowerefa26bc2017-07-17 15:43:55 +020068 echo.Fetching %%e with git...
69 git clone --depth 1 https://github.com/%ORG%/cpython-source-deps --branch %%e "%EXTERNALS_DIR%\%%e"
Zachary Ware6b6e6872017-06-10 14:58:42 -050070 ) else (
71 echo.Fetching %%e...
Steve Dower667b91a2018-02-17 19:58:57 -080072 %PYTHON% -E "%PCBUILD%\get_external.py" -O %ORG% -e "%EXTERNALS_DIR%" %%e
Zachary Ware6b6e6872017-06-10 14:58:42 -050073 )
74)
75
Zachary Ware51599e22017-06-15 22:08:51 -050076echo.Fetching external binaries...
77
78set binaries=
Paul Monson32119e12019-03-29 16:30:10 -070079if NOT "%IncludeLibffi%"=="false" set binaries=%binaries% libffi
Steve Dower48243852018-12-10 19:52:36 -080080if NOT "%IncludeSSL%"=="false" set binaries=%binaries% openssl-bin-1.1.0j
Steve Dowerf8e9bd52018-12-14 09:13:15 -080081if NOT "%IncludeTkinter%"=="false" set binaries=%binaries% tcltk-8.6.9.0
Steve Dower68d663c2017-07-17 11:15:48 +020082if NOT "%IncludeSSLSrc%"=="false" set binaries=%binaries% nasm-2.11.06
Zachary Ware51599e22017-06-15 22:08:51 -050083
84for %%b in (%binaries%) do (
85 if exist "%EXTERNALS_DIR%\%%b" (
86 echo.%%b already exists, skipping.
Jess7ee88bf2019-03-21 09:02:59 -070087 ) else if NOT DEFINED PYTHON (
Steve Dowerefa26bc2017-07-17 15:43:55 +020088 echo.Fetching %%b with git...
89 git clone --depth 1 https://github.com/%ORG%/cpython-bin-deps --branch %%b "%EXTERNALS_DIR%\%%b"
Zachary Ware51599e22017-06-15 22:08:51 -050090 ) else (
91 echo.Fetching %%b...
Steve Dower667b91a2018-02-17 19:58:57 -080092 %PYTHON% -E "%PCBUILD%\get_external.py" -b -O %ORG% -e "%EXTERNALS_DIR%" %%b
Zachary Ware51599e22017-06-15 22:08:51 -050093 )
94)
95
96echo Finished.
Zachary Ware6b6e6872017-06-10 14:58:42 -050097goto end
98
99:usage
Zachary Ware51599e22017-06-15 22:08:51 -0500100echo.Valid options: -c, --clean, --clean-only, --organization, --python,
101echo.--no-tkinter, --no-openssl
Zachary Ware6b6e6872017-06-10 14:58:42 -0500102echo.
Zachary Ware51599e22017-06-15 22:08:51 -0500103echo.Pull all sources and binaries necessary for compiling optional extension
104echo.modules that rely on external libraries.
Zachary Ware6b6e6872017-06-10 14:58:42 -0500105echo.
Zachary Ware51599e22017-06-15 22:08:51 -0500106echo.The --organization option determines which github organization to download
107echo.from, the --python option determines which Python 3.6+ interpreter to use
108echo.with PCbuild\get_external.py.
109echo.
110echo.Use the -c or --clean option to remove the entire externals directory.
Zachary Ware6b6e6872017-06-10 14:58:42 -0500111echo.
112echo.Use the --clean-only option to do the same cleaning, without pulling in
113echo.anything new.
114echo.
Zachary Ware6b6e6872017-06-10 14:58:42 -0500115exit /b -1
116
Zachary Ware6b6e6872017-06-10 14:58:42 -0500117:end