Skip to content

Commit

Permalink
Discard changes to script/build.bat
Browse files Browse the repository at this point in the history
  • Loading branch information
eliassjogreen authored Oct 23, 2024
1 parent d11d31e commit 3165073
Showing 1 changed file with 55 additions and 4 deletions.
59 changes: 55 additions & 4 deletions script/build.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
@echo off

echo Prepare directories...
set script_dir=%~dp0
set src_dir=%script_dir%..\webview
set build_dir=%script_dir%..\build
mkdir "%build_dir%"

echo Webview directory: %src_dir%
echo Build directory: %build_dir%

:: If you update the nuget package, change its version here
set nuget_version=1.0.1150.38
echo Using Nuget Package microsoft.web.webview2.%nuget_version%
if not exist "%script_dir%\microsoft.web.webview2.%nuget_version%" (
curl -sSLO https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
nuget.exe install Microsoft.Web.Webview2 -Version %nuget_version% -OutputDirectory %script_dir%
echo Nuget package installed
)

echo Looking for vswhere.exe...
set "vswhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "%vswhere%" set "vswhere=%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
Expand All @@ -18,8 +37,40 @@ if not exist "%vc_dir%\Common7\Tools\vsdevcmd.bat" (
)
echo Found %vc_dir%

call "%vc_dir%\Common7\Tools\vsdevcmd.bat" -arch=x64 -host_arch=x64
cd %~dp0..\webview
:: 4100: unreferenced formal parameter
set warning_params=/W4 /wd4100

:: build dlls if not found
if not exist "%src_dir%\dll\x64\webview.dll" (
mkdir "%src_dir%\dll\x86"
mkdir "%src_dir%\dll\x64"
copy "%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\x64\WebView2Loader.dll" "%src_dir%\dll\x64"
copy "%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\x86\WebView2Loader.dll" "%src_dir%\dll\x86"

cmake -G "Ninja Multi-Config" -B build -S .
cmake --build build --config Release
call "%vc_dir%\Common7\Tools\vsdevcmd.bat" -arch=x86 -host_arch=x64

echo "Building webview.dll (x86)"
cl %warning_params% ^
/D "WEBVIEW_API=__declspec(dllexport)" ^
/I "%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\include" ^
"%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\x86\WebView2Loader.dll.lib" ^
/std:c++17 /EHsc "/Fo%build_dir%"\ ^
"%src_dir%\webview.cc" /link /DLL "/OUT:%src_dir%\dll\x86\webview.dll" || exit \b

call "%vc_dir%\Common7\Tools\vsdevcmd.bat" -arch=x64 -host_arch=x64
echo "Building webview.dll (x64)"
cl %warning_params% ^
/D "WEBVIEW_API=__declspec(dllexport)" ^
/I "%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\include" ^
"%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\x64\WebView2Loader.dll.lib" ^
/std:c++17 /EHsc "/Fo%build_dir%"\ ^
"%src_dir%\webview.cc" /link /DLL "/OUT:%src_dir%\dll\x64\webview.dll" || exit \b
)
if not exist "%build_dir%\webview.dll" (
copy "%src_dir%\dll\x64\webview.dll" %build_dir%
)
if not exist "%build_dir%\WebView2Loader.dll" (
copy "%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\x64\WebView2Loader.dll" "%build_dir%"
)

call "%vc_dir%\Common7\Tools\vsdevcmd.bat" -arch=x64 -host_arch=x64

0 comments on commit 3165073

Please sign in to comment.