<commit_before>
REM . 
REM Manages the building of the openssl external on Win32
REM . 

REM FYI: Here's the variables we should have available:
REM PACKAGE_NAME
REM PACKAGE_SRC_NAME
REM PACKAGE_BUILD_DIR
REM PACKAGE_INSTALL_DIR
REM EXTERNALS_INSTALL_DIR

REM Some magic to make sure PACKAGE_INSTALL_DIR has no forward slashes in it
set PACKAGE_INSTALL_DIR=%PACKAGE_INSTALL_DIR:/=\%
set PACKAGE_BUILD_DIR=%PACKAGE_BUILD_DIR:/=\%

REM Now patch the build system to get the Multi-threaded runtime library
REM For now, this is disabled, since I don't think we need it to make
REM condor happy. -stolley

touch zerolength
call :patch %PACKAGE_BUILD_DIR%\renegotiate.patch
if not %ERRORLEVEL%A == 0A goto failure

cd %PACKAGE_SRC_NAME%
rem touch zerolength
rem patch -p1 -i ..\openssl-0.9.8-patch < zerolength
rem if not %ERRORLEVEL%A == 0A goto failure

rem Patch the Makefile builder:
rem The current version of openssl user strcpy, etc. when it should use
rem strncpy (or so say the MS security experts). Anyway, instead of changing
rem openssl code, we simply disable the Visual Studio check by defining:
rem _CRT_SECURE_NO_DEPRECATE at the command line. The VC-32 bla, bla, bla,
rem part removes all the deprecated compiler options openssl passes to VC. 
rem We do this because all warnings are treated as errors in this build. 
if /i A%NEED_MANIFESTS_IN_EXTERNALS%==Atrue ( 
    pushd util
    touch zerolength
    call :patch %PACKAGE_BUILD_DIR%\mk1mf.pl-0.9.8h-patch
    if not %ERRORLEVEL%A == 0A goto failure
    pushd pl
    touch zerolength
    call :patch %PACKAGE_BUILD_DIR%\VC-32.pl-0.9.8h-patch
    if not %ERRORLEVEL%A == 0A goto failure
    popd && popd
)

perl Configure VC-WIN32
if not %ERRORLEVEL%A == 0A goto failure

call ms\do_nt.bat
if not %ERRORLEVEL%A == 0A goto failure

nmake -f ms\ntdll.mak
if not %ERRORLEVEL%A == 0A goto failure

REM ** copy output into install dir
mkdir %PACKAGE_INSTALL_DIR%\out32dll
mkdir %PACKAGE_INSTALL_DIR%\inc32

xcopy out32dll\*.lib %PACKAGE_INSTALL_DIR%\out32dll
if not %ERRORLEVEL%A == 0A goto failure
xcopy out32dll\*.dll %PACKAGE_INSTALL_DIR%\out32dll
if not %ERRORLEVEL%A == 0A goto failure

REM If we are using a modern version of VC, then we need to embed a manifest 
REM into the DLLs we created. This allows them to locate the new CRT libs.
if /i A%NEED_MANIFESTS_IN_EXTERNALS%==Atrue (
    pushd %PACKAGE_INSTALL_DIR%\out32dll
    for %%f in (*.dll) do mt.exe /manifest %PACKAGE_BUILD_DIR%\%%f.manifest /outputresource:%%f;#2
    if not %ERRORLEVEL%A == 0A goto failure
    popd
)

xcopy /s inc32\*.* %PACKAGE_INSTALL_DIR%\inc32
if not %ERRORLEVEL%A == 0A goto failure

:failure
exit %ERRORLEVEL%

rem ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:patch
rem ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
rem function: patch <file_path>
rem  purpose: calls patch.exe in the context of the debugger if patch
rem           fails.  This seems to resolve the errorlevel 3 problem.  
rem           Hurray for mysteriously, magical, nonsensical solutions!
rem ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
patch --verbose -i %1 < zerolength
if ERRORLEVEL 3 ( 
  set ERRORLEVEL=0
  cdb -o -c "g; !gle; kb; q" patch --verbose -p0 -i %1 < zerolength
)
goto :EOF<commit_msg>Fix patch arguments for openssl external on windows. #1043<commit_after>
REM . 
REM Manages the building of the openssl external on Win32
REM . 

REM FYI: Here's the variables we should have available:
REM PACKAGE_NAME
REM PACKAGE_SRC_NAME
REM PACKAGE_BUILD_DIR
REM PACKAGE_INSTALL_DIR
REM EXTERNALS_INSTALL_DIR

REM Some magic to make sure PACKAGE_INSTALL_DIR has no forward slashes in it
set PACKAGE_INSTALL_DIR=%PACKAGE_INSTALL_DIR:/=\%
set PACKAGE_BUILD_DIR=%PACKAGE_BUILD_DIR:/=\%

REM Now patch the build system to get the Multi-threaded runtime library
REM For now, this is disabled, since I don't think we need it to make
REM condor happy. -stolley

touch zerolength
call :patch %PACKAGE_BUILD_DIR%\renegotiate.patch
if not %ERRORLEVEL%A == 0A goto failure

cd %PACKAGE_SRC_NAME%
rem touch zerolength
rem patch -p1 -i ..\openssl-0.9.8-patch < zerolength
rem if not %ERRORLEVEL%A == 0A goto failure

rem Patch the Makefile builder:
rem The current version of openssl user strcpy, etc. when it should use
rem strncpy (or so say the MS security experts). Anyway, instead of changing
rem openssl code, we simply disable the Visual Studio check by defining:
rem _CRT_SECURE_NO_DEPRECATE at the command line. The VC-32 bla, bla, bla,
rem part removes all the deprecated compiler options openssl passes to VC. 
rem We do this because all warnings are treated as errors in this build. 
if /i A%NEED_MANIFESTS_IN_EXTERNALS%==Atrue ( 
    pushd util
    touch zerolength
    call :patch %PACKAGE_BUILD_DIR%\mk1mf.pl-0.9.8h-patch
    if not %ERRORLEVEL%A == 0A goto failure
    pushd pl
    touch zerolength
    call :patch %PACKAGE_BUILD_DIR%\VC-32.pl-0.9.8h-patch
    if not %ERRORLEVEL%A == 0A goto failure
    popd && popd
)

perl Configure VC-WIN32
if not %ERRORLEVEL%A == 0A goto failure

call ms\do_nt.bat
if not %ERRORLEVEL%A == 0A goto failure

nmake -f ms\ntdll.mak
if not %ERRORLEVEL%A == 0A goto failure

REM ** copy output into install dir
mkdir %PACKAGE_INSTALL_DIR%\out32dll
mkdir %PACKAGE_INSTALL_DIR%\inc32

xcopy out32dll\*.lib %PACKAGE_INSTALL_DIR%\out32dll
if not %ERRORLEVEL%A == 0A goto failure
xcopy out32dll\*.dll %PACKAGE_INSTALL_DIR%\out32dll
if not %ERRORLEVEL%A == 0A goto failure

REM If we are using a modern version of VC, then we need to embed a manifest 
REM into the DLLs we created. This allows them to locate the new CRT libs.
if /i A%NEED_MANIFESTS_IN_EXTERNALS%==Atrue (
    pushd %PACKAGE_INSTALL_DIR%\out32dll
    for %%f in (*.dll) do mt.exe /manifest %PACKAGE_BUILD_DIR%\%%f.manifest /outputresource:%%f;#2
    if not %ERRORLEVEL%A == 0A goto failure
    popd
)

xcopy /s inc32\*.* %PACKAGE_INSTALL_DIR%\inc32
if not %ERRORLEVEL%A == 0A goto failure

:failure
exit %ERRORLEVEL%

rem ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:patch
rem ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
rem function: patch <file_path>
rem  purpose: calls patch.exe in the context of the debugger if patch
rem           fails.  This seems to resolve the errorlevel 3 problem.  
rem           Hurray for mysteriously, magical, nonsensical solutions!
rem ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
patch --verbose -p 0 -i %1 < zerolength
if ERRORLEVEL 3 ( 
  set ERRORLEVEL=0
  cdb -o -c "g; !gle; kb; q" patch --verbose -p 0 -i %1 < zerolength
)
goto :EOF
{'fraction_non_alphanumeric': 0.1316543507766551, 'fraction_numerical': 0.017342783893832002, 'mean_word_length': 4.374392220421393, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3955311', 'n_tokens_mistral': 2312, 'n_tokens_neox': 2111, 'n_words': 814}