Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build

on:
push:
branches:
- main
paths:
- ".github/workflows/**"
- "script/build.*"
- "src/ffi.ts"
- "webview/**"
- ".gitmodules"
- "package.json"

jobs:
build:
name: ${{ matrix.kind }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os:
[
macos-latest,
macos-13,
windows-latest,
ubuntu-latest,
ubuntu-24.04-arm,
]

steps:
- name: Clone repository
uses: actions/checkout@v3
with:
submodules: true

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: install webkit2gtk (Linux)
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y webkitgtk-6.0 libwebkitgtk-6.0-dev cmake ninja-build clang pkg-config libgtk-4-dev

- name: Install ninja (macOS)
if: startsWith(matrix.os, 'macos')
run: |
brew install ninja
brew install llvm
echo "WEBVIEW_CLANG_FORMAT_EXE=$(brew --prefix llvm)/bin/clang-format" >> $GITHUB_ENV

- name: Install ninja (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install ninja

- name: Build dynamic library
run: bun scripts/build.ts

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: build
path: |
build/*.dll
build/*.dylib
build/*.so

# - name: Release Plugin
# uses: softprops/action-gh-release@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: "0.9.1"
# files: |
# build/libwebview.x86_64.dylib
# build/libwebview.aarch64.dylib
# build/libwebview.x86_64.so
# build/libwebview.aarch64.so
# build/webview.dll
# build/Webview2Loader.dll
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
bun.lockb
.vscode
.zed
/webview/**
18 changes: 11 additions & 7 deletions scripts/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@ 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%

call "%vc_dir%\Common7\Tools\vsdevcmd.bat" -arch=x64 -host_arch=x64
cd %~dp0..\webview

cmake -G "Ninja Multi-Config" -B build -S .
cmake --build build --config Release
cmake -G "Ninja Multi-Config" -B build -S . ^
-DWEBVIEW_BUILD_DOCS=OFF ^
-DWEBVIEW_USE_CLANG_TIDY=OFF ^
-DWEBVIEW_USE_CLANG_FORMAT=OFF

cmake --build build --config Release
18 changes: 13 additions & 5 deletions scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { $ } from "bun";
$.nothrow();

const { arch, platform } = process;

Expand All @@ -24,10 +23,19 @@ switch (platform) {
case "darwin":
await $`
cd webview
cmake -G "Ninja Multi-Config" -B build -S . -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/universal-macos-llvm.cmake
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=${process.env.WEBVIEW_CLANG_FORMAT_EXE}
cmake --build build --config Release
cp build/core/Release/libwebview.dylib ../build/libwebview.dylib
strip -x -S ../build/libwebview.dylib
`;
cp build/core/Release/libwebview.dylib ../build/libwebview.${arch}.dylib
strip -x -S ../build/libwebview.${arch}.dylib
`
break;
}