Skip to content

Commit

Permalink
scripts: add build-vulkan
Browse files Browse the repository at this point in the history
  • Loading branch information
m154k1 committed Oct 12, 2023
1 parent 491f54c commit 40bdc0c
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 33 deletions.
37 changes: 14 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,22 @@ A collection of scripts and patches that helps build [mpv](https://mpv.io) with
```

### Build and install
1. [**MoltenVK**](https://github.com/KhronosGroup/MoltenVK)
:warning: Requires admin password.
1. [**Vulkan Loader**](https://github.com/KhronosGroup/Vulkan-Loader) & [**Vulkan Headers**](https://github.com/KhronosGroup/Vulkan-Headers)

```sh
git -C src clone "https://github.com/KhronosGroup/MoltenVK.git"
./build-MoltenVK
git -C src clone "https://github.com/KhronosGroup/Vulkan-Loader.git"
git -C src clone "https://github.com/KhronosGroup/Vulkan-Headers.git"
./build-vulkan
```

<details>
2. [**MoltenVK**](https://github.com/KhronosGroup/MoltenVK)

<summary>Installed files</summary>

```
/usr/local
├── lib
│   └── libMoltenVK.dylib
└── share
└── vulkan
└── icd.d
└── MoltenVK_icd.json
```sh
git -C src clone "https://github.com/KhronosGroup/MoltenVK.git"
./build-MoltenVK
```

</details>

2. [**FreeType**](https://gitlab.freedesktop.org/freetype/freetype) & [**HarfBuzz**](https://github.com/harfbuzz/harfbuzz)
3. [**FreeType**](https://gitlab.freedesktop.org/freetype/freetype) & [**HarfBuzz**](https://github.com/harfbuzz/harfbuzz)

```sh
git -C src clone "https://gitlab.freedesktop.org/freetype/freetype.git"
Expand All @@ -68,36 +59,36 @@ A collection of scripts and patches that helps build [mpv](https://mpv.io) with
./build-FreeType
```

3. [**libass**](https://github.com/libass/libass)
4. [**libass**](https://github.com/libass/libass)

```sh
git -C src clone "https://github.com/libass/libass.git"
./build-libass
```

4. [**libplacebo**](https://code.videolan.org/videolan/libplacebo)
5. [**libplacebo**](https://code.videolan.org/videolan/libplacebo)

```sh
git -C src clone --recursive "https://code.videolan.org/videolan/libplacebo.git"
./build-libplacebo
```

5. [**FFmpeg**](https://git.ffmpeg.org/ffmpeg.git)
6. [**FFmpeg**](https://git.ffmpeg.org/ffmpeg.git)

```sh
git -C src clone "https://git.ffmpeg.org/ffmpeg.git"
./build-FFmpeg
```

6. [**mpv**](https://github.com/mpv-player/mpv)
7. [**mpv**](https://github.com/mpv-player/mpv)

```sh
git -C src clone "https://github.com/mpv-player/mpv.git"
git -C src/mpv apply "$(pwd)"/patches/mpv/*
./build-mpv
```

7. Add binaries to your `$PATH`:
8. Add binaries to your `$PATH`:

```sh
cd ~/.local/bin
Expand Down
1 change: 1 addition & 0 deletions build-FFmpeg
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import_local_pkg freetype
import_local_pkg harfbuzz
import_local_pkg libass
import_local_pkg libplacebo
import_local_pkg vulkan

cd "${srcdir}"

Expand Down
16 changes: 8 additions & 8 deletions build-MoltenVK
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
cd "$(dirname "$0")"
set -a; source build.env; set +a

prefix="/usr/local"
pkgname="moltenvk"
pkgdir="${PKGPREFIX:-/opt/local}/${pkgname}"
srcdir="src/MoltenVK"
builddir="$(realpath "${srcdir}")/Package/Latest/MoltenVK/dylib/macOS"

cd "${srcdir}"

./fetchDependencies \
--macos \
--v-headers-root "$(brew --prefix vulkan-headers)"
--v-headers-root "${PKGPREFIX:-/opt/local}/vulkan"

make macos MVK_CONFIG_LOG_LEVEL=2

sed -i '' "s/\\.\\/libMoltenVK/${prefix//\//\\\/}\\/lib\\/libMoltenVK/" "${builddir}"/MoltenVK_icd.json
sed -i '' "s/\\.\\/libMoltenVK/${pkgdir//\//\\\/}\\/lib\\/libMoltenVK/" "${builddir}"/MoltenVK_icd.json
cat "${builddir}"/MoltenVK_icd.json

sudo rm -f "${prefix}"/lib/libMoltenVK.dylib
sudo rm -f "${prefix}"/share/vulkan/icd.d/MoltenVK_icd.json
rm -rf "${pkgdir}"

sudo mkdir -p "${prefix}"/lib "${prefix}"/share/vulkan/icd.d
sudo install -vm755 "${builddir}"/libMoltenVK.dylib "${prefix}"/lib
sudo install -vm644 "${builddir}"/MoltenVK_icd.json "${prefix}"/share/vulkan/icd.d
mkdir -p "${pkgdir}"/lib "${pkgdir}"/share/vulkan/icd.d
install -vm755 "${builddir}"/libMoltenVK.dylib "${pkgdir}"/lib
install -vm644 "${builddir}"/MoltenVK_icd.json "${pkgdir}"/share/vulkan/icd.d

rm -rf ~/.swiftpm

Expand Down
5 changes: 4 additions & 1 deletion build-libplacebo
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
#
cd "$(dirname "$0")"
set -a; source build.env; set +a
source utils/pkg-import

pkgname="libplacebo"
pkgdir="${PKGPREFIX:-/opt/local}/${pkgname}"
srcdir="src/libplacebo"
builddir="${TMPDIR:-/tmp}/build.${pkgname}"

import_local_pkg vulkan

rm -rf "${builddir}"

meson setup "${builddir}" "${srcdir}" \
Expand All @@ -19,7 +22,7 @@ meson setup "${builddir}" "${srcdir}" \
-Dbuildtype=release \
-Db_lto=true \
-Db_lto_mode=thin \
-Dvulkan-registry="$(brew --prefix vulkan-headers)/share/vulkan/registry/vk.xml" \
-Dvulkan-registry="${PKGPREFIX:-/opt/local}/vulkan/share/vulkan/registry/vk.xml" \
-Dvulkan=enabled \
-Dshaderc=enabled \
-Dlcms=enabled \
Expand Down
1 change: 1 addition & 0 deletions build-mpv
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import_local_pkg freetype
import_local_pkg harfbuzz
import_local_pkg libass
import_local_pkg libplacebo
import_local_pkg vulkan

import_homebrew_pkg libarchive

Expand Down
50 changes: 50 additions & 0 deletions build-vulkan
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash -e
#
# Vulkan Headers
# https://github.com/KhronosGroup/Vulkan-Headers.git
#
# Vulkan Loader
# https://github.com/KhronosGroup/Vulkan-Loader.git
#
cd "$(dirname "$0")"
set -a; source build.env; set +a

pkgname="vulkan"
pkgdir="${PKGPREFIX:-/opt/local}/${pkgname}"
builddir="${TMPDIR:-/tmp}/build.${pkgname}"
headerssrcdir="src/Vulkan-Headers"
loadersrcdir="src/Vulkan-Loader"
libpath="${pkgdir}/lib/libvulkan.1.dylib"

rm -rf "${builddir}" "${pkgdir}"

cmake \
-B "${builddir}" \
-S "${headerssrcdir}" \
-GNinja \
-DCMAKE_INSTALL_PREFIX="${pkgdir}" \
-DCMAKE_BUILD_TYPE=Release

cmake --build "${builddir}"
cmake --install "${builddir}"

rm -rf "${builddir}"

cmake \
-B "${builddir}" \
-S "${loadersrcdir}" \
-GNinja \
-DCMAKE_INSTALL_PREFIX="${pkgdir}" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DCMAKE_MACOSX_RPATH=OFF \
-DVULKAN_HEADERS_INSTALL_DIR="${pkgdir}" \
-DFALLBACK_DATA_DIRS="${PKGPREFIX:-/opt/local}/moltenvk/share:/usr/local/share"

cmake --build "${builddir}"
cmake --install "${builddir}"
install_name_tool -id "${libpath}" "${libpath}"

rm -rf "${builddir}"

# vi:set ts=2 sw=2 et:
1 change: 0 additions & 1 deletion homebrew/runtime.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ opus
shaderc
svt-av1
uchardet
vulkan-loader
x264
x265
xxhash
Expand Down

0 comments on commit 40bdc0c

Please sign in to comment.