blob: ed9ff759a370f76a64e23ec157a2468c4b36bb31 [file] [log] [blame]
Zachary Ware6b6e6872017-06-10 14:58:42 -05001@echo off
2setlocal
3rem Simple script to fetch source for external libraries
4
Zachary Ware51599e22017-06-15 22:08:51 -05005if "%PCBUILD%"=="" (set PCBUILD=%~dp0)
6if "%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
Steve Dower68d663c2017-07-17 11:15:48 +020010set IncludeTkinterSrc=false
11set IncludeSSLSrc=false
Zachary Ware6b6e6872017-06-10 14:58:42 -050012
Zachary Ware51599e22017-06-15 22:08:51 -050013:CheckOpts
14if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts
15if "%~1"=="--no-openssl" (set IncludeSSL=false) & shift & goto CheckOpts
Steve Dower68d663c2017-07-17 11:15:48 +020016if "%~1"=="--tkinter-src" (set IncludeTkinterSrc=true) & shift & goto CheckOpts
17if "%~1"=="--openssl-src" (set IncludeSSLSrc=true) & shift & goto CheckOpts
18if "%~1"=="--python" (set PYTHON=%2) & shift & shift & goto CheckOpts
Zachary Ware51599e22017-06-15 22:08:51 -050019if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts
20if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts
21if "%~1"=="--clean" (set DO_CLEAN=true) & shift & goto CheckOpts
22if "%~1"=="--clean-only" (set DO_FETCH=false) & goto clean
Steve Dower68d663c2017-07-17 11:15:48 +020023
24rem Include old options for compatibility
25if "%~1"=="--no-tkinter" shift & goto CheckOpts
26if "%~1"=="--no-openssl" shift & goto CheckOpts
27
Zachary Ware51599e22017-06-15 22:08:51 -050028if "x%~1" NEQ "x" goto usage
Zachary Ware6b6e6872017-06-10 14:58:42 -050029
Zachary Ware51599e22017-06-15 22:08:51 -050030if "%DO_CLEAN%"=="false" goto fetch
Zachary Ware6b6e6872017-06-10 14:58:42 -050031:clean
32echo.Cleaning up external libraries.
Zachary Ware51599e22017-06-15 22:08:51 -050033if exist "%EXTERNALS_DIR%" (
34 rem Sometimes this fails the first time; try it twice
35 rmdir /s /q "%EXTERNALS_DIR%" || rmdir /s /q "%EXTERNALS_DIR%"
Zachary Ware6b6e6872017-06-10 14:58:42 -050036)
37
Zachary Ware51599e22017-06-15 22:08:51 -050038if "%DO_FETCH%"=="false" goto end
Zachary Ware6b6e6872017-06-10 14:58:42 -050039:fetch
Zachary Ware6b6e6872017-06-10 14:58:42 -050040
Zachary Ware51599e22017-06-15 22:08:51 -050041if "%ORG%"=="" (set ORG=python)
Zachary Ware6c6d3a42017-12-30 17:17:36 -060042call "%PCBUILD%\find_python.bat" "%PYTHON%"
Zachary Ware6b6e6872017-06-10 14:58:42 -050043
Steve Dowerefa26bc2017-07-17 15:43:55 +020044if "%PYTHON%"=="" (
45 where /Q git || echo Python 3.6 could not be found or installed, and git.exe is not on your PATH && exit /B 1
46)
47
Zachary Ware6b6e6872017-06-10 14:58:42 -050048echo.Fetching external libraries...
49
50set libraries=
Steve Dower68d663c2017-07-17 11:15:48 +020051set libraries=%libraries% bzip2-1.0.6
Steve Dowerb84bcc42017-09-09 06:13:06 -070052if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries% openssl-1.1.0f
Mariatta31af6502017-11-06 19:31:53 -080053set libraries=%libraries% sqlite-3.21.0.0
Steve Dower68d663c2017-07-17 11:15:48 +020054if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tcl-core-8.6.6.0
55if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tk-8.6.6.0
56if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tix-8.4.3.6
57set libraries=%libraries% xz-5.2.2
Zachary Wared01db1c2017-09-06 17:29:37 -070058set libraries=%libraries% zlib-1.2.11
Zachary Ware6b6e6872017-06-10 14:58:42 -050059
60for %%e in (%libraries%) do (
Zachary Ware51599e22017-06-15 22:08:51 -050061 if exist "%EXTERNALS_DIR%\%%e" (
Zachary Ware6b6e6872017-06-10 14:58:42 -050062 echo.%%e already exists, skipping.
Steve Dowerefa26bc2017-07-17 15:43:55 +020063 ) else if "%PYTHON%"=="" (
64 echo.Fetching %%e with git...
65 git clone --depth 1 https://github.com/%ORG%/cpython-source-deps --branch %%e "%EXTERNALS_DIR%\%%e"
Zachary Ware6b6e6872017-06-10 14:58:42 -050066 ) else (
67 echo.Fetching %%e...
Zachary Ware6c6d3a42017-12-30 17:17:36 -060068 %PYTHON% "%PCBUILD%\get_external.py" -O %ORG% %%e
Zachary Ware6b6e6872017-06-10 14:58:42 -050069 )
70)
71
Zachary Ware51599e22017-06-15 22:08:51 -050072echo.Fetching external binaries...
73
74set binaries=
Steve Dowerb84bcc42017-09-09 06:13:06 -070075if NOT "%IncludeSSL%"=="false" set binaries=%binaries% openssl-bin-1.1.0f
Steve Dower68d663c2017-07-17 11:15:48 +020076if NOT "%IncludeTkinter%"=="false" set binaries=%binaries% tcltk-8.6.6.0
77if NOT "%IncludeSSLSrc%"=="false" set binaries=%binaries% nasm-2.11.06
Zachary Ware51599e22017-06-15 22:08:51 -050078
79for %%b in (%binaries%) do (
80 if exist "%EXTERNALS_DIR%\%%b" (
81 echo.%%b already exists, skipping.
Steve Dowerefa26bc2017-07-17 15:43:55 +020082 ) else if "%PYTHON%"=="" (
83 echo.Fetching %%b with git...
84 git clone --depth 1 https://github.com/%ORG%/cpython-bin-deps --branch %%b "%EXTERNALS_DIR%\%%b"
Zachary Ware51599e22017-06-15 22:08:51 -050085 ) else (
86 echo.Fetching %%b...
Zachary Ware6c6d3a42017-12-30 17:17:36 -060087 %PYTHON% "%PCBUILD%\get_external.py" -b -O %ORG% %%b
Zachary Ware51599e22017-06-15 22:08:51 -050088 )
89)
90
91echo Finished.
Zachary Ware6b6e6872017-06-10 14:58:42 -050092goto end
93
94:usage
Zachary Ware51599e22017-06-15 22:08:51 -050095echo.Valid options: -c, --clean, --clean-only, --organization, --python,
96echo.--no-tkinter, --no-openssl
Zachary Ware6b6e6872017-06-10 14:58:42 -050097echo.
Zachary Ware51599e22017-06-15 22:08:51 -050098echo.Pull all sources and binaries necessary for compiling optional extension
99echo.modules that rely on external libraries.
Zachary Ware6b6e6872017-06-10 14:58:42 -0500100echo.
Zachary Ware51599e22017-06-15 22:08:51 -0500101echo.The --organization option determines which github organization to download
102echo.from, the --python option determines which Python 3.6+ interpreter to use
103echo.with PCbuild\get_external.py.
104echo.
105echo.Use the -c or --clean option to remove the entire externals directory.
Zachary Ware6b6e6872017-06-10 14:58:42 -0500106echo.
107echo.Use the --clean-only option to do the same cleaning, without pulling in
108echo.anything new.
109echo.
Zachary Ware6b6e6872017-06-10 14:58:42 -0500110exit /b -1
111
Zachary Ware6b6e6872017-06-10 14:58:42 -0500112:end