summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Wiberg <troglobit@gmail.com>2022-12-30 16:47:35 +0100
committerJoachim Wiberg <troglobit@gmail.com>2022-12-31 19:49:57 +0100
commita5a09aa0eeabb6219fab503958f6bc0e9eabb4f4 (patch)
treed4b5e694f8ad4d479b34a66d16d94945e3ea11ae
parentc8f8446d23ced6d409c53622ecbca24f3649902c (diff)
downloadlibnet-a5a09aa0eeabb6219fab503958f6bc0e9eabb4f4.tar.gz
win32: search for path to VC Tools
- convert to Visual Studio 2017 using vswhere Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
-rw-r--r--win32/msvcbuild.bat30
1 files changed, 19 insertions, 11 deletions
diff --git a/win32/msvcbuild.bat b/win32/msvcbuild.bat
index 97c6cb8..6171703 100644
--- a/win32/msvcbuild.bat
+++ b/win32/msvcbuild.bat
@@ -6,8 +6,18 @@
@rem We assume WpdPack\ and libnet-master\ to have the same path,
@rem and that this script is executed from either a VS2015 Developer Command Prompt
@rem or an elevated Command Prompt.
+@rem
+@rem Helpful links for non-Windows users:
+@rem https://github.com/microsoft/vswhere/wiki/Find-VC#batch
+@rem https://renenyffenegger.ch/notes/Windows/dirs/Program-Files-x86/Microsoft-Visual-Studio/version/edition/Common7/Tools/VsDevCmd_bat
+@rem https://renenyffenegger.ch/notes/Windows/development/Visual-Studio/environment-variables/index
:start
+for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -nologo`) do (
+ set InstallDir=%%i
+)
+if not exist "%InstallDir%\Common7\Tools\VsDevCmd.bat" (goto fail)
+
@if "%1" == "" goto x86
@setlocal
@set userinput=%1
@@ -18,18 +28,15 @@
@endlocal
:x86
-if not exist "%VCINSTALLDIR%bin\vcvars32.bat" goto path
-call "%VCINSTALLDIR%bin\vcvars32.bat"
+call "%InstallDir%\Common7\Tools\VsDevCmd.bat" -arch=x86
goto msvcbuild32
:x64
-if not exist "%VCINSTALLDIR%bin\amd64\vcvars64.bat" goto path
-call "%VCINSTALLDIR%bin\amd64\vcvars64.bat"
+call "%InstallDir%\Common7\Tools\VsDevCmd.bat" -arch=x64
goto msvcbuild64
:x86_x64
-if not exist "%VCINSTALLDIR%vcvarsall.bat" goto path
-call "%VCINSTALLDIR%vcvarsall.bat" x86_amd64
+call "%InstallDir%\Common7\Tools\VsDevCmd.bat" -arch=x86_amd64
goto msvcbuild64
:msvcbuild32
@@ -82,6 +89,12 @@ copy win32\config.h include\
copy win32\getopt.h include\
cd src
+dir ..\..\
+dir ..\..\WpdPack
+dir ..\..\WpdPack\Include
+type ..\..\WpdPack\Include\Packet32.h
+@echo "Foo"
+dir "%WINPCAP%\Include\"
%MYCOMPILE% /I..\include /I%WINPCAP%\Include libnet_a*.c libnet_build_*.c libnet_c*.c libnet_dll.c libnet_error.c libnet_i*.c libnet_link_win32.c libnet_p*.c libnet_raw.c libnet_resolve.c libnet_version.c libnet_write.c
%MYLINK% /DLL /libpath:%WINPCAP%\Lib\x64 /out:..\lib\x64\libnet%VERSION%.dll win64\*.obj Advapi32.lib
if exist libnet.dll.manifest^
@@ -112,11 +125,6 @@ echo and that this script is executed from a Developer Command Prompt.
echo :
goto end
-:path
-call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"
-if not exist "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat" goto fail
-goto start
-
:fail
echo Visual Studio or the C++ Build SKU do not seem to be installed.
echo Please Install either of them or try to executed this script