Skip to content

Commit a9caa08

Browse files
Discard changes to script/build.bat
1 parent d11d31e commit a9caa08

File tree

1 file changed

+55
-4
lines changed

1 file changed

+55
-4
lines changed

script/build.bat

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
@echo off
2+
3+
echo Prepare directories...
4+
set script_dir=%~dp0
5+
set src_dir=%script_dir%..\webview
6+
set build_dir=%script_dir%..\build
7+
mkdir "%build_dir%"
8+
9+
echo Webview directory: %src_dir%
10+
echo Build directory: %build_dir%
11+
12+
:: If you update the nuget package, change its version here
13+
set nuget_version=1.0.1150.38
14+
echo Using Nuget Package microsoft.web.webview2.%nuget_version%
15+
if not exist "%script_dir%\microsoft.web.webview2.%nuget_version%" (
16+
curl -sSLO https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
17+
nuget.exe install Microsoft.Web.Webview2 -Version %nuget_version% -OutputDirectory %script_dir%
18+
echo Nuget package installed
19+
)
20+
221
echo Looking for vswhere.exe...
322
set "vswhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
423
if not exist "%vswhere%" set "vswhere=%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
@@ -18,8 +37,40 @@ if not exist "%vc_dir%\Common7\Tools\vsdevcmd.bat" (
1837
)
1938
echo Found %vc_dir%
2039

21-
call "%vc_dir%\Common7\Tools\vsdevcmd.bat" -arch=x64 -host_arch=x64
22-
cd %~dp0..\webview
40+
:: 4100: unreferenced formal parameter
41+
set warning_params=/W4 /wd4100
42+
43+
:: build dlls if not found
44+
if not exist "%src_dir%\dll\x64\webview.dll" (
45+
mkdir "%src_dir%\dll\x86"
46+
mkdir "%src_dir%\dll\x64"
47+
copy "%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\x64\WebView2Loader.dll" "%src_dir%\dll\x64"
48+
copy "%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\x86\WebView2Loader.dll" "%src_dir%\dll\x86"
2349

24-
cmake -G "Ninja Multi-Config" -B build -S .
25-
cmake --build build --config Release
50+
call "%vc_dir%\Common7\Tools\vsdevcmd.bat" -arch=x86 -host_arch=x64
51+
52+
echo "Building webview.dll (x86)"
53+
cl %warning_params% ^
54+
/D "WEBVIEW_API=__declspec(dllexport)" ^
55+
/I "%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\include" ^
56+
"%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\x86\WebView2Loader.dll.lib" ^
57+
/std:c++17 /EHsc "/Fo%build_dir%"\ ^
58+
"%src_dir%\webview.cc" /link /DLL "/OUT:%src_dir%\dll\x86\webview.dll" || exit \b
59+
60+
call "%vc_dir%\Common7\Tools\vsdevcmd.bat" -arch=x64 -host_arch=x64
61+
echo "Building webview.dll (x64)"
62+
cl %warning_params% ^
63+
/D "WEBVIEW_API=__declspec(dllexport)" ^
64+
/I "%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\include" ^
65+
"%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\x64\WebView2Loader.dll.lib" ^
66+
/std:c++17 /EHsc "/Fo%build_dir%"\ ^
67+
"%src_dir%\webview.cc" /link /DLL "/OUT:%src_dir%\dll\x64\webview.dll" || exit \b
68+
)
69+
if not exist "%build_dir%\webview.dll" (
70+
copy "%src_dir%\dll\x64\webview.dll" %build_dir%
71+
)
72+
if not exist "%build_dir%\WebView2Loader.dll" (
73+
copy "%script_dir%\microsoft.web.webview2.%nuget_version%\build\native\x64\WebView2Loader.dll" "%build_dir%"
74+
)
75+
76+
call "%vc_dir%\Common7\Tools\vsdevcmd.bat" -arch=x64 -host_arch=x64

0 commit comments

Comments
 (0)