summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3f6376fcda5f07bed912ffec06554bf0eba3ba66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Maintainer: Ali Mohammad Pur <totally@fakegmail.ch>
# Contributor: Tim Schumacher <timschumi@gmx.de>
# Contributor: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Brian <brain@derelict.garden>

pkgname=ladybird-git
pkgver=r79948.f4d31df69ae
pkgrel=1
pkgdesc='Truly independent web browser'
arch=(x86_64)
url='https://github.com/LadybirdBrowser/ladybird'
license=(BSD-2-Clause)
conflicts=(ladybird)
provides=(ladybird)
depends=(
  curl
  fast_float
  ffmpeg
  fmt
  harfbuzz
  icu
  libavif
  libedit
  libgl
  libjpeg-turbo
  libjxl
  libtiff
  libtommath
  libwebp
  qt6-base
  qt6-multimedia
  qt6-tools
  qt6-wayland
  sdl3
  simdjson
  sqlite
  ttf-liberation
  woff2
  mimalloc
  
  angle # AUR
  simdutf-git # 'simdutf' is v6, we need v7.
  cpptrace # AUR
  libpng-apng # AUR, extra/libpng doesn't provide APNG.
  vulkan-memory-allocator-git
  wuffs-lib-git
)
makedepends=(autoconf-archive automake cargo cmake git nasm ninja patchelf skia-static tar unzip zip)
options=('!lto' '!debug' '!buildflags' '!staticlibs' '!emptydirs')
source=(
  "git+$url"
)
sha256sums=(
  'SKIP'
)

pkgver() {
  cd ladybird
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  sed -e '/march=/d' -i ladybird/Meta/CMake/compile_options.cmake
  sed -e 's/78\.3 EXACT/78.3/' -i ladybird/Meta/CMake/check_for_dependencies.cmake
  sed -e 's#wuffs/wuffs#wuffs#' -i ladybird/Meta/CMake/check_for_dependencies.cmake
  sed -e 's#wuffs/wuffs#wuffs#' -i ladybird/Libraries/LibGfx/ImageFormats/GIFLoader.cpp
  sed -e 's/mi_heap_get_default/mi_heap_main/' -i ladybird/AK/kmalloc.cpp
}

build() {
  cd "${srcdir}"

  export PKG_CONFIG_PATH="$(realpath .)"
  unset CARGO_TARGET_DIR
  export RUSTUP_TOOLCHAIN=stable

  cmake \
    -B build \
    -S ladybird \
    -DENABLE_RUST=YES \
    -DBUILD_SHARED_LIBS=OFF \
    -DLADYBIRD_CACHE_DIR=Build/caches \
    -DCMAKE_BUILD_TYPE=Release \
    -DENABLE_LTO_FOR_RELEASE=OFF \
    -DCMAKE_INSTALL_PREFIX='/opt/ladybird/usr' \
    -DENABLE_INSTALL_HEADERS=OFF \
    -DCMAKE_INSTALL_LIBEXECDIR="lib/${pkgname%-git}" \
    -GNinja \
    -Wno-dev
  cmake --build build
}

package() {
  cd "${srcdir}"

  DESTDIR="${pkgdir}" cmake --install build

  find "$pkgdir" -name '*.a' -delete
  find "$pkgdir" -name '*.cmake' -delete

  find "$pkgdir" -type f -executable -exec sh -c '
    for exe; do
      r=$(patchelf --print-rpath "$exe" 2>/dev/null)
      [ "${r%%/opt/angle/lib*}" = "$r" ] && patchelf --set-rpath "/opt/angle/lib${r:+:$r}" "$exe"
    done
  ' sh {} +

  # Make the desktop file point to the file in /opt
  RELATIVE_DESKTOP_FILE_PATH='usr/share/applications/org.ladybird.Ladybird.desktop'
  sed -i -e 's#Exec=Ladybird #Exec=/opt/ladybird/usr/bin/Ladybird #' "${pkgdir}/opt/ladybird/${RELATIVE_DESKTOP_FILE_PATH}"


  install -Dm644 ladybird/LICENSE -t "${pkgdir}/opt/ladybird/usr/share/licenses/${pkgname}/"
  install -Dm644 "${pkgdir}/opt/ladybird/${RELATIVE_DESKTOP_FILE_PATH}" "${pkgdir}/${RELATIVE_DESKTOP_FILE_PATH}"

  # Links
  mkdir -p "${pkgdir}/usr/bin" "${pkgdir}/usr/share/licenses" "${pkgdir}/usr/share/metainfo" "${pkgdir}/usr/share/icons/hicolor/scalable/apps" "${pkgdir}/usr/share/icons/hicolor/128x128/apps" "${pkgdir}/usr/share/icons/hicolor/48x48/apps"
  ln -s /opt/ladybird/usr/bin/Ladybird "${pkgdir}/usr/bin/Ladybird"
  ln -s /opt/ladybird/usr/share/licenses/ladybird-git "${pkgdir}/usr/share/licenses/ladybird-git"
  ln -s /opt/ladybird/usr/share/metainfo/org.ladybird.Ladybird.metainfo.xml "${pkgdir}/usr/share/metainfo/org.ladybird.Ladybird.metainfo.xml"
  ln -s /opt/ladybird/usr/share/icons/hicolor/scalable/apps/org.ladybird.Ladybird.svg "${pkgdir}/usr/share/icons/hicolor/scalable/apps/org.ladybird.Ladybird.svg"
  ln -s /opt/ladybird/usr/share/Lagom/icons/128x128/app-browser.png "${pkgdir}/usr/share/icons/hicolor/128x128/apps/org.ladybird.Ladybird.png"
  ln -s /opt/ladybird/usr/share/Lagom/icons/48x48/app-browser.png "${pkgdir}/usr/share/icons/hicolor/48x48/apps/org.ladybird.Ladybird.png"
}