Skip to content

Instantly share code, notes, and snippets.

@shmerl
Last active October 22, 2023 21:53
Show Gist options
  • Save shmerl/3d49bee2ca04c1016f72366dca9438ce to your computer and use it in GitHub Desktop.
Save shmerl/3d49bee2ca04c1016f72366dca9438ce to your computer and use it in GitHub Desktop.
For dxvk and vkd3d-proton building on Debian
#!/bin/bash
# Notes:
#
# For Debian build of dxvk and vkd3d-proton.
#
# 1. To build 64-bit and 32-bit dxvk:
#
# for bitness in 64 32; do project=dxvk bitness=$bitness dxvk_build.sh; done
#
# 2. To build 64-bit and 32-bit vkd3d-proton:
#
# for bitness in 64 32; do project=vkd3d bitness=$bitness dxvk_build.sh; done
#
# 3. To build both:
#
# for project in dxvk vkd3d; do for bitness in 64 32; do project=$project bitness=$bitness dxvk_build.sh; done; done
#
project=${project:-"dxvk"} # dxvk by default
dxvk_repo='https://github.com/doitsujin/dxvk.git'
vkd3d_repo='https://github.com/HansKristian-Work/vkd3d-proton.git'
dxvk_branch=${dxvk_branch:-"master"}
base_dir="${HOME}/build/${project}"
src_dir="${base_dir}/source"
bitness=${bitness:-64}
build_dir="${base_dir}/${project}/build_${bitness}"
dest_dir="${HOME}/mnt/vmshare/${project}"
lib_dir="lib${bitness}"
cpuarch=${cpuarch:-"znver4"} # Ryzen by default. Change to your arch or "native" accordingly.
cross_file="build-win${bitness}.txt"
verbose=${verbose:-false}
if [[ "$project" != "dxvk" ]] && [[ "$project" != "vkd3d" ]]; then
echo "Invalid project ${project} specified! Supported projects: dxvk, vkd3d"
exit 1
fi
project_repo="${project}_repo"
project_repo="${!project_repo}"
if [[ "$bitness" != "64" ]] && [[ "$bitness" != "32" ]]; then
echo "Invalid bitness ${bitness} specified! Supported bitnesses: 64, 32"
exit 2
fi
function prepare() {
sudo apt install meson mingw-w64 mingw-w64-tools glslang-tools
if (($? != 0)); then
echo "Installation of build tools failed! Aborting."
exit 3
fi
}
function update_sources() {
mkdir -p $(dirname "$src_dir")
cd $(dirname "$src_dir")
git clone --recursive "$project_repo" $(basename "$src_dir")
cd "$src_dir"
git reset --hard HEAD
git clean -df
git checkout master
git pull --rebase --prune
git checkout ${dxvk_branch}
if (($? != 0)); then
echo "Invalid branch or tag ${dxvk_branch}! Aborting"
exit 4
fi
git submodule update --rebase
}
function build() {
mkdir -p "$build_dir"
rm -rfv ${build_dir}/*
cd "$src_dir"
export CFLAGS="-march=${cpuarch}"
export CXXFLAGS="-march=${cpuarch}"
meson setup --strip --cross-file "$cross_file" --buildtype release --prefix "$dest_dir" --libdir "$lib_dir" --bindir "$lib_dir" "$build_dir"
cd "$build_dir"
if $verbose; then
ninja -v
else
ninja
fi
if (($? != 0)); then
echo "Build failed!"
exit 5
fi
}
function publish() {
cd "$build_dir"
rm -rfv ${dest_dir}/${lib_dir}
ninja install
}
###################################################
update_sources
prepare
build
publish
@shmerl
Copy link
Author

shmerl commented Jul 27, 2023

Removing d8vk since it's getting into upstream now and can't be built without conflicting with dxvk in the same installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment