Skip to content
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

chore: Bump to 0.9.0, neater build script, update workflows #190

Merged
merged 1 commit into from
Jan 29, 2025
Merged
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
6 changes: 2 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ jobs:

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

- name: Install deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x
uses: denoland/setup-deno@v2

- name: install webkit2gtk (Linux)
if: startsWith(matrix.os, 'ubuntu')
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install stable deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x
uses: denoland/setup-deno@v2

- name: Run check
run: deno task check
run: deno check mod.ts

# TODO: Re-enable these tests
# - name: Run test:doc
# run: deno task test:doc

- name: Run fmt
run: deno task fmt:check
run: deno fmt --check

- name: Run lint
run: deno task lint
run: deno lint
11 changes: 8 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ jobs:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
- run: deno publish
- name: Clone repository
uses: actions/checkout@v4

- name: Install deno
uses: denoland/setup-deno@v2

- name: Publish to JSR
run: deno publish
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2022 the webview team
Copyright (c) 2020-2025 the webview team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
9 changes: 2 additions & 7 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
{
"name": "@webview/webview",
"version": "0.8.1",
"version": "0.9.0",
"exports": "./mod.ts",
"lock": false,
"tasks": {
"check": "deno check mod.ts",
"fmt": "deno fmt",
"fmt:check": "deno fmt --check",
"lint": "deno lint",
"test:doc": "deno test -A --unstable-ffi --doc --import-map test_import_map.json",
"build": "deno run -A script/build.ts",
"run": "deno task build && export PLUGIN_URL=\"./build/\" && deno run -A --unstable-ffi",
"run:fast": "export PLUGIN_URL=\"./build/\" && deno run -A --unstable-ffi"
Expand All @@ -17,5 +12,5 @@
"fmt": {
"exclude": ["webview/"]
},
"imports": { "@denosaurs/plug": "jsr:@denosaurs/plug@^1.0.6" }
"imports": { "@denosaurs/plug": "jsr:@denosaurs/plug@^1.0" }
}
48 changes: 39 additions & 9 deletions script/build.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,54 @@
import { $ } from "jsr:@david/[email protected]";

const { os } = Deno.build;
async function findClangFormat() {
let WEBVIEW_CLANG_FORMAT_EXE = Deno.env.get("WEBVIEW_CLANG_FORMAT_EXE");
if (WEBVIEW_CLANG_FORMAT_EXE) {
return WEBVIEW_CLANG_FORMAT_EXE;
}

WEBVIEW_CLANG_FORMAT_EXE = await $.which("clang-format");
if (WEBVIEW_CLANG_FORMAT_EXE) {
return WEBVIEW_CLANG_FORMAT_EXE;
}

if (await $.commandExists("brew")) {
const llvm = await $`brew --prefix llvm`.text();
return `${llvm}/bin/clang-format"`;
}

$.logError(
"error",
"clang-format not found. Please install clang-format using brew or set the WEBVIEW_CLANG_FORMAT_EXE environment variable.",
);
Deno.exit(1);
}

$.setPrintCommand(true);

await $.path("./build").ensureDir();
switch (os) {
case "windows":
switch (Deno.build.os) {
case "windows": {
await $`script/build.bat`;
await $`cp webview/build/core/Release/webview.dll build/webview.dll`;
break;
case "linux":
}
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 -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 "darwin":
}
case "darwin": {
$.cd("webview");
await $`cmake -G "Ninja Multi-Config" -B build -S . \
-DCMAKE_BUILD_TYPE=Release \
Expand All @@ -28,11 +59,10 @@ switch (os) {
-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",
)!}`;
-DWEBVIEW_CLANG_FORMAT_EXE=${await findClangFormat()}`;
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;
}
}
2 changes: 1 addition & 1 deletion test_import_map.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"imports": {
"@webview/webview": "./mod.ts",
"@denosaurs/plug": "jsr:@denosaurs/plug@^1.0.5"
"@denosaurs/plug": "jsr:@denosaurs/plug@^1.0"
}
}