-
Notifications
You must be signed in to change notification settings - Fork 79
feat: Update webview, add linux ARM target #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
95bf030
start updating
sigmaSd 9487335
seems to work
sigmaSd f460844
fixes
sigmaSd cb37071
test build
sigmaSd 47159ac
disable mac for now
sigmaSd 9b6b79d
fixes
sigmaSd 71d47c1
fixes
sigmaSd cdbae39
fixes
sigmaSd 688c9ad
fixes
sigmaSd a008bba
fixes
sigmaSd 2f1de5b
fixes
sigmaSd 60f5bfa
fixes
sigmaSd 65d1137
fixes
sigmaSd 9a9bb53
fixes
sigmaSd 175d6be
fixes
sigmaSd 0b9e255
fixes
sigmaSd 30a532c
fixes
sigmaSd abc4fdc
fixes
sigmaSd 0680711
fixes
sigmaSd 608c3e1
fixes
sigmaSd 867d47d
fixes
sigmaSd e8e65e9
fixes
sigmaSd cd45238
fixes
sigmaSd 6376205
done
sigmaSd 6529899
fix windows artifact name
sigmaSd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,76 +1,29 @@ | ||
| @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" | ||
| if not exist "%vswhere%" ( | ||
| echo ERROR: Failed to find vswhere.exe | ||
| exit /b 1 | ||
| echo ERROR: Failed to find vswhere.exe | ||
| exit /b 1 | ||
| ) | ||
| echo Found %vswhere% | ||
|
|
||
| echo Looking for VC... | ||
| for /f "usebackq tokens=*" %%i in (`"%vswhere%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do ( | ||
| set vc_dir=%%i | ||
| set vc_dir=%%i | ||
| ) | ||
| if not exist "%vc_dir%\Common7\Tools\vsdevcmd.bat" ( | ||
| echo ERROR: Failed to find VC tools x86/x64 | ||
| exit /b 1 | ||
| echo ERROR: Failed to find VC tools x86/x64 | ||
| exit /b 1 | ||
| ) | ||
| echo Found %vc_dir% | ||
|
|
||
| :: 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" | ||
|
|
||
| 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 | ||
| cd %~dp0..\webview | ||
|
|
||
| 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%" | ||
| ) | ||
| cmake -G "Ninja Multi-Config" -B build -S . ^ | ||
| -DWEBVIEW_BUILD_DOCS=OFF ^ | ||
| -DWEBVIEW_USE_CLANG_TIDY=OFF ^ | ||
| -DWEBVIEW_USE_CLANG_FORMAT=OFF | ||
|
|
||
| call "%vc_dir%\Common7\Tools\vsdevcmd.bat" -arch=x64 -host_arch=x64 | ||
| cmake --build build --config Release |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,162 +1,38 @@ | ||
| import { ensureDir } from "jsr:@std/fs@0.218/ensure_dir"; | ||
| import { $ } from "jsr:@david/dax@0.42.0"; | ||
|
|
||
| const decoder = new TextDecoder(); | ||
| const architectures = [["x86_64", "x86_64"], ["aarch64", "arm64"]] as const; | ||
| const { os } = Deno.build; | ||
| $.setPrintCommand(true); | ||
|
|
||
| const ExitType = { | ||
| Exit: "exit", | ||
| Fail: "fail", | ||
| Never: "never", | ||
| } as const; | ||
| type ExitType = typeof ExitType[keyof typeof ExitType]; | ||
|
|
||
| const LogType = { | ||
| Success: "success", | ||
| Always: "always", | ||
| Fail: "fail", | ||
| Never: "never", | ||
| } as const; | ||
| type LogType = typeof LogType[keyof typeof LogType]; | ||
|
|
||
| function indent(source: string, spaces = 2): string { | ||
| return source.split("\n").map((line) => `${" ".repeat(spaces)}${line}\n`) | ||
| .join(""); | ||
| } | ||
|
|
||
| async function command<T extends Deno.CommandOptions>( | ||
| cmd: string, | ||
| { opts, exit, log }: { opts?: T; exit?: ExitType; log?: LogType } = {}, | ||
| ): Promise<{ | ||
| code: number; | ||
| stdout: string; | ||
| stderr: string; | ||
| }> { | ||
| if (opts !== undefined) { | ||
| opts.stdout = "piped"; | ||
| opts.stderr = "piped"; | ||
| } | ||
|
|
||
| exit ??= ExitType.Never; | ||
| log ??= LogType.Always; | ||
|
|
||
| const command = new Deno.Command(cmd, opts); | ||
| const { code, stdout, stderr } = await command.output(); | ||
|
|
||
| const stdoutStr = decoder.decode(stdout); | ||
| const stderrStr = decoder.decode(stderr); | ||
|
|
||
| if (code === 0) { | ||
| if (log !== "never") { | ||
| console.log(`Successfully ran "${cmd} ${(opts?.args ?? []).join(" ")}"`); | ||
| } | ||
|
|
||
| if (log === "success" || log === "always") { | ||
| if (stdoutStr.length !== 0) { | ||
| console.log(`stdout:\n${indent(stdoutStr)}`); | ||
| } | ||
| if (stderrStr.length !== 0) { | ||
| console.log(`stderr:\n${indent(stderrStr)}`); | ||
| } | ||
| } | ||
| } else { | ||
| if (log !== "never") { | ||
| console.log(`Failed run "${cmd}"`); | ||
| } | ||
|
|
||
| if (log === "fail" || log === "always") { | ||
| if (stdoutStr.length !== 0) { | ||
| console.log(`stdout:\n${indent(stdoutStr)}`); | ||
| } | ||
| if (stderrStr.length !== 0) { | ||
| console.log(`stderr:\n${indent(stderrStr)}`); | ||
| } | ||
| console.log(`code: ${code}`); | ||
| } | ||
|
|
||
| if (exit === ExitType.Fail) { | ||
| Deno.exit(code); | ||
| } | ||
| } | ||
|
|
||
| if (exit === ExitType.Exit) { | ||
| Deno.exit(code); | ||
| } | ||
|
|
||
| return { | ||
| code, | ||
| stdout: stdoutStr, | ||
| stderr: stderrStr, | ||
| }; | ||
| } | ||
|
|
||
| await ensureDir("build"); | ||
|
|
||
| switch (Deno.build.os) { | ||
| case "windows": { | ||
| await command("script/build.bat", { | ||
| exit: ExitType.Exit, | ||
| }); | ||
| await $.path("./build").ensureDir(); | ||
| switch (os) { | ||
| case "windows": | ||
| await $`script/build.bat`; | ||
| await $`cp webview/build/core/Release/webview.dll build/webview.dll`; | ||
| break; | ||
| } | ||
|
|
||
| case "darwin": { | ||
| for (const [denoArch, gccArch] of architectures) { | ||
| await command("c++", { | ||
| opts: { | ||
| exit: ExitType.Fail, | ||
| args: [ | ||
| "webview/webview.cc", | ||
| "-dynamiclib", | ||
| "-fpic", | ||
| "-DWEBVIEW_COCOA", | ||
| "-std=c++11", | ||
| "-Wall", | ||
| "-Wextra", | ||
| "-pedantic", | ||
| "-framework", | ||
| "WebKit", | ||
| "-arch", | ||
| gccArch, | ||
| "-o", | ||
| `build/libwebview.${denoArch}.dylib`, | ||
| ], | ||
| }, | ||
| }); | ||
| } | ||
| Deno.exit(0); | ||
| case "linux": | ||
| $.cd("webview"); | ||
| await $`export PATH=/usr/lib/llvm14/bin/:/usr/lib/llvm-14/bin/:/usr/lib64/llvm15/bin/:$PATH`; | ||
| await $`cmake -G Ninja -B build -S . -D CMAKE_BUILD_TYPE=Release -D WEBVIEW_WEBKITGTK_API=6.0 -DWEBVIEW_ENABLE_CHECKS=false -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/host-llvm.cmake -DWEBVIEW_USE_CLANG_TIDY=OFF -DWEBVIEW_BUILD_DOCS=OFF -DWEBVIEW_USE_CLANG_FORMAT=OFF`; | ||
| await $`cmake --build build`; | ||
| await $`cp build/core/libwebview.so ../build/libwebview.${Deno.build.arch}.so`; | ||
| await $`strip ../build/libwebview.${Deno.build.arch}.so`; | ||
| break; | ||
| } | ||
|
|
||
| case "linux": { | ||
| const { stdout } = await command("pkg-config", { | ||
| opts: { | ||
| args: [ | ||
| "--cflags", | ||
| "--libs", | ||
| "gtk+-3.0", | ||
| "webkit2gtk-4.0", | ||
| ], | ||
| }, | ||
| }); | ||
| await command("c++", { | ||
| opts: { | ||
| exit: ExitType.Fail, | ||
| args: [ | ||
| "webview/webview.cc", | ||
| "-DWEBVIEW_GTK", | ||
| "-shared", | ||
| "-std=c++11", | ||
| "-Wall", | ||
| "-Wextra", | ||
| "-pedantic", | ||
| "-fpic", | ||
| ...stdout.trim().split(" "), | ||
| "-o", | ||
| "build/libwebview.so", | ||
| ], | ||
| }, | ||
| }); | ||
| Deno.exit(0); | ||
| case "darwin": | ||
| $.cd("webview"); | ||
| await $`cmake -G "Ninja Multi-Config" -B build -S . \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DWEBVIEW_BUILD_TESTS=OFF \ | ||
| -DWEBVIEW_BUILD_EXAMPLES=OFF \ | ||
| -DWEBVIEW_USE_CLANG_TOOLS=OFF \ | ||
| -DWEBVIEW_ENABLE_CHECKS=OFF \ | ||
| -DWEBVIEW_USE_CLANG_TIDY=OFF \ | ||
| -DWEBVIEW_BUILD_DOCS=OFF \ | ||
| -DWEBVIEW_USE_CLANG_FORMAT=OFF \ | ||
| -DWEBVIEW_CLANG_FORMAT_EXE=${Deno.env.get( | ||
| "WEBVIEW_CLANG_FORMAT_EXE", | ||
| )!}`; | ||
| await $`cmake --build build --config Release`; | ||
| await $`cp build/core/Release/libwebview.dylib ../build/libwebview.${Deno.build.arch}.dylib`; | ||
| await $`strip -x -S ../build/libwebview.${Deno.build.arch}.dylib`; | ||
| break; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.