From cd227556895b03b505b07923f2914cd8ac477026 Mon Sep 17 00:00:00 2001
From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
Date: Fri, 22 Jun 2018 16:54:00 -0400
Subject: [PATCH] project: fixes for native windows contrib patching

Change-Id: I6d477f20579640ebf7a050f3fe2edd6930892ed3
---
 contrib/src/argon2/argon2-uwp.patch       | 27 +++++++++++++++++++++--
 contrib/src/pcre/fetch_and_patch.bat      |  3 +++
 contrib/src/pjproject/fetch_and_patch.bat | 11 ++++++++-
 contrib/src/yaml-cpp/fetch_and_patch.bat  |  3 +++
 4 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/contrib/src/argon2/argon2-uwp.patch b/contrib/src/argon2/argon2-uwp.patch
index 546ef0244c..fd2fc6135e 100644
--- a/contrib/src/argon2/argon2-uwp.patch
+++ b/contrib/src/argon2/argon2-uwp.patch
@@ -62,7 +62,31 @@
      <WholeProgramOptimization>true</WholeProgramOptimization>
      <CharacterSet>MultiByte</CharacterSet>
    </PropertyGroup>
-@@ -179,6 +179,7 @@
+@@ -132,6 +132,7 @@
+       <Optimization>Disabled</Optimization>
+       <SDLCheck>true</SDLCheck>
+       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
++      <AdditionalIncludeDirectories>$(ProjectDir)..\..\include</AdditionalIncludeDirectories>
+     </ClCompile>
+   </ItemDefinitionGroup>
+   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+@@ -140,6 +141,7 @@
+       <Optimization>Disabled</Optimization>
+       <SDLCheck>true</SDLCheck>
+       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
++      <AdditionalIncludeDirectories>$(ProjectDir)..\..\include</AdditionalIncludeDirectories>
+     </ClCompile>
+   </ItemDefinitionGroup>
+   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+@@ -150,6 +152,7 @@
+       <IntrinsicFunctions>true</IntrinsicFunctions>
+       <SDLCheck>true</SDLCheck>
+       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
++      <AdditionalIncludeDirectories>$(ProjectDir)..\..\include</AdditionalIncludeDirectories>
+     </ClCompile>
+     <Link>
+       <EnableCOMDATFolding>true</EnableCOMDATFolding>
+@@ -179,6 +182,7 @@
        <IntrinsicFunctions>true</IntrinsicFunctions>
        <SDLCheck>true</SDLCheck>
        <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -70,7 +94,6 @@
      </ClCompile>
      <Link>
        <EnableCOMDATFolding>true</EnableCOMDATFolding>
-\ No newline at end of file
 -- 
 2.10.2.windows.1
 
diff --git a/contrib/src/pcre/fetch_and_patch.bat b/contrib/src/pcre/fetch_and_patch.bat
index df896cd5da..b717311700 100644
--- a/contrib/src/pcre/fetch_and_patch.bat
+++ b/contrib/src/pcre/fetch_and_patch.bat
@@ -19,6 +19,9 @@ rename %BUILD%\%PCRE_NAME%-%PCRE_VERSION% %PCRE_NAME%
 cd %BUILD%\%PCRE_NAME%
 
 mkdir msvc && cd msvc
+setlocal
+set PATH=C:\\Program Files\\CMake\\bin\\;%PATH%
 cmake .. -G "Visual Studio 15 2017 Win64"
+endlocal
 
 cd %SRC%
\ No newline at end of file
diff --git a/contrib/src/pjproject/fetch_and_patch.bat b/contrib/src/pjproject/fetch_and_patch.bat
index f072408b70..b0f3159a46 100644
--- a/contrib/src/pjproject/fetch_and_patch.bat
+++ b/contrib/src/pjproject/fetch_and_patch.bat
@@ -17,8 +17,17 @@ rename %BUILD%\pjproject-%PJPROJECT_VERSION% pjproject
 
 cd %BUILD%\pjproject
 
+echo off
+for /F "tokens=* usebackq" %%F in (`bash -c "pwd | grep /mnt/c/"`) do (
+    set NO_AUTO=%%F
+)
+if "%NO_AUTO%"=="" (
+    set ROOTPATH=/c/
+) else (
+    set ROOTPATH=/mnt/c/
+)
 set UNIXPATH=%SRC:\=/%
-set UNIXPATH=%UNIXPATH:C:=/mnt/c%
+set UNIXPATH=%ROOTPATH%%UNIXPATH:C:/=%
 bash -c "%PATCH_CMD% %UNIXPATH%pjproject/gnutls.patch"
 bash -c "%PATCH_CMD% %UNIXPATH%pjproject/ipv6.patch"
 bash -c "%PATCH_CMD% %UNIXPATH%pjproject/ice_config.patch"
diff --git a/contrib/src/yaml-cpp/fetch_and_patch.bat b/contrib/src/yaml-cpp/fetch_and_patch.bat
index d31425737f..5b5aff8f6c 100644
--- a/contrib/src/yaml-cpp/fetch_and_patch.bat
+++ b/contrib/src/yaml-cpp/fetch_and_patch.bat
@@ -18,6 +18,9 @@ rename %BUILD%\yaml-cpp-%YAMLCPP_VERSION% yaml-cpp
 cd %BUILD%\yaml-cpp
 
 mkdir msvc && cd msvc
+setlocal
+set PATH=C:\\Program Files\\CMake\\bin\\;%PATH%
 cmake .. -G "Visual Studio 15 2017 Win64"
+endlocal
 
 cd %SRC%
\ No newline at end of file
-- 
GitLab