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

Fix webkit dependencies on Ubuntu 24+ #1816

Merged
merged 13 commits into from
Jan 30, 2025
42 changes: 26 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,29 @@ jobs:
strategy:
matrix:
include:
- {name: "Linux (amd64 / full)", os: ubuntu-latest, arch: amd64, mode: full, shell: bash}
- {name: "Linux (amd64 / safe)", os: ubuntu-latest, arch: amd64, mode: safe, shell: bash}
- {name: "Linux (amd64 / mini)", os: ubuntu-latest, arch: amd64, mode: mini, shell: bash}
- {name: "Linux (arm64 / mini)", os: ubuntu-latest, arch: arm64, mode: mini, shell: bash}
- {name: "JS (web / mini)", os: ubuntu-latest, arch: amd64, mode: web, shell: bash}
- {name: "Windows (amd64 / full)", os: windows-latest, arch: amd64, mode: full, shell: "msys2 {0}"}
- {name: "Windows (amd64 / mini)", os: windows-latest, arch: amd64, mode: mini, shell: "msys2 {0}"}
- {name: "macOS (amd64 / full)", os: macOS-13, arch: amd64, mode: full, shell: bash}
- {name: "macOS (amd64 / mini)", os: macOS-13, arch: amd64, mode: mini, shell: bash}
- {name: "macOS (arm64 / full)", os: macos-latest, arch: arm64, mode: full, shell: bash}
- {name: "macOS (arm64 / mini)", os: macos-latest, arch: arm64, mode: mini, shell: bash}
- {name: "Linux (amd64 / full / webkit-4.1)", os: ubuntu-latest, arch: amd64, mode: full, shell: bash}
- {name: "Linux (amd64 / full)", os: ubuntu-22.04, arch: amd64, mode: full, shell: bash}
- {name: "Linux (amd64 / safe)", os: ubuntu-22.04, arch: amd64, mode: safe, shell: bash}
- {name: "Linux (amd64 / mini)", os: ubuntu-22.04, arch: amd64, mode: mini, shell: bash}
- {name: "Linux (arm64 / mini)", os: ubuntu-22.04, arch: arm64, mode: mini, shell: bash}
- {name: "JS (web / mini)", os: ubuntu-latest, arch: amd64, mode: web, shell: bash}
- {name: "Windows (amd64 / full)", os: windows-latest, arch: amd64, mode: full, shell: "msys2 {0}"}
- {name: "Windows (amd64 / mini)", os: windows-latest, arch: amd64, mode: mini, shell: "msys2 {0}"}
- {name: "macOS (amd64 / full)", os: macOS-13, arch: amd64, mode: full, shell: bash}
- {name: "macOS (amd64 / mini)", os: macOS-13, arch: amd64, mode: mini, shell: bash}
- {name: "macOS (arm64 / full)", os: macos-latest, arch: arm64, mode: full, shell: bash}
- {name: "macOS (arm64 / mini)", os: macos-latest, arch: arm64, mode: mini, shell: bash}

name: ${{ matrix.name }}
defaults:
run:
shell: ${{ matrix.shell }}
steps:
- name: Check ubuntu version
if: (matrix.os == 'ubuntu-latest')
run: |
lsb_release -a

- name: Install Arturo
uses: arturo-lang/arturo-action@main
with:
Expand All @@ -52,7 +58,7 @@ jobs:
src: ${{ github.ref }}
metadata: ${{ env.BRANCH_NAME }}-${{ github.sha }}

- if: (matrix.mode != 'safe' && matrix.mode != 'web') && (matrix.os != 'ubuntu-latest' || matrix.arch != 'arm64')
- if: (matrix.mode != 'safe' && matrix.mode != 'web') && (runner.os != 'Linux' || matrix.arch != 'arm64')
name: Run tests (Old)
run: |
ls -la arturo
Expand All @@ -62,7 +68,7 @@ jobs:
arturo tools/tester.art
cd ..

- if: matrix.mode == 'full' && (matrix.os != 'ubuntu-latest' || matrix.arch != 'arm64')
- if: matrix.mode == 'full' && (runner.os != 'Linux' || matrix.arch != 'arm64')
name: Run tests (Unitt)
run: |
cd arturo
Expand All @@ -75,29 +81,33 @@ jobs:
binary_path="arturo/bin/arturo"

artifact_os="macos"
artifact_os_extra=""
artifact_arch="${{matrix.arch}}"
artifact_mode="${{matrix.mode}}"

if [ "${{matrix.os}}" = "windows-latest" ]; then
if [ "${{runner.os}}" = "Windows" ]; then
artifact_os="windows"
binary_path="${binary_path}.exe"
fi
if [ "${{matrix.os}}" = "ubuntu-latest" ]; then
if [ "${{runner.os}}" = "Linux" ]; then
artifact_os="linux"
if [ "${{matrix.mode}}" = "web" ]; then
artifact_os="js"
artifact_arch="web"
artifact_mode="mini"
binary_path="${binary_path}.js"
fi
if [ "${{matrix.name}}" = "Linux (amd64 / full / webkit-4.1)" ]; then
artifact_os_extra=".webkit41"
fi
fi

cd arturo
git_hash=$(git rev-parse --short "$GITHUB_SHA")
git_stamp="${{ env.BRANCH_NAME}}.${git_hash}"
cd ..

artifact_name="arturo-${git_stamp}-${artifact_arch}-${artifact_os}-${artifact_mode}"
artifact_name="arturo-${git_stamp}-${artifact_arch}-${artifact_os}${artifact_os_extra}-${artifact_mode}"

echo "BINARY_PATH=$binary_path" >> "$GITHUB_OUTPUT"
echo "ARTIFACT_NAME=$artifact_name" >> "$GITHUB_OUTPUT"
Expand Down
16 changes: 16 additions & 0 deletions config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ proc configWinPCRE() =
proc configMacosPCRE() =
--dynlibOverride:pcre

proc configWebkit() =
const webkitVersions = ["4.1", "4.0"]

proc getWebkitVersion(): string =
for version in webkitVersions:
let ret = gorgeEx("pkg-config --exists webkit2gtk-" & version)
if ret.exitCode == 0:
return version

return ""

switch "define", "webkitVersion=" & getWebkitVersion()

proc configWinSSL() =
--define:"noOpenSSLHacks"
--define:"sslVersion:("
Expand All @@ -81,6 +94,9 @@ proc main() =
# configGMPOnWindows()
configMimalloc()

if defined(linux):
configWebkit()

if defined(windows):
configWinPCRE()

Expand Down
6 changes: 4 additions & 2 deletions src/extras/webview.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ import extras/window
{.passC: "-I" & parentDir(currentSourcePath()) .}

when defined(linux):
const
webkitVersion {.strdefine.} = "empty"
{.compile("webview/webview-unix.cc","-std=c++11").}
{.passC: "-DWEBVIEW_GTK=1 -DWEBVIEW_STATIC=1 " &
staticExec"pkg-config --cflags gtk+-3.0 webkit2gtk-4.0".}
staticExec("pkg-config --cflags gtk+-3.0 webkit2gtk-" & webkitVersion) .}
{.passL: "-lstdc++ " &
staticExec"pkg-config --libs gtk+-3.0 webkit2gtk-4.0".}
staticExec("pkg-config --libs gtk+-3.0 webkit2gtk-" & webkitVersion) .}
elif defined(freebsd) or defined(netbsd) or defined(openbsd):
{.compile("webview/webview-unix.cc","-std=c++11").}
{.passC: "-DWEBVIEW_GTK=1 " &
Expand Down
8 changes: 5 additions & 3 deletions src/extras/window.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ import os
{.passC: "-I" & parentDir(currentSourcePath()) .}

when defined(linux):
{.compile("window/window.cc", staticExec"pkg-config --cflags gtk+-3.0 webkit2gtk-4.0").}
{.passC: staticExec"pkg-config --cflags gtk+-3.0 webkit2gtk-4.0".}
{.passL: staticExec"pkg-config --libs gtk+-3.0 webkit2gtk-4.0".}
const
webkitVersion {.strdefine.} = "empty"
{.compile("window/window.cc", staticExec("pkg-config --cflags gtk+-3.0 webkit2gtk-" & webkitVersion)).}
{.passC: staticExec("pkg-config --cflags gtk+-3.0 webkit2gtk-" & webkitVersion) .}
{.passL: staticExec("pkg-config --libs gtk+-3.0 webkit2gtk-" & webkitVersion) .}
elif defined(freebsd) or defined(netbsd) or defined(openbsd):
{.compile("window/window.cc", staticExec"pkg-config --cflags gtk3 webkit2-gtk3").}
{.passC: staticExec"pkg-config --cflags gtk3 webkit2-gtk3".}
Expand Down