mesa: make more things optional (#87438)

osmesa & gallium-nine are not needed for all systems. So this adds a
flag to disable them if you don’t want them.
This commit is contained in:
Matthew Bauer 2020-05-29 22:29:32 -05:00 committed by GitHub
parent 01377fc6ef
commit c2039e1901
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,8 @@
, eglPlatforms ? [ "x11" "surfaceless" ] ++ lib.optionals stdenv.isLinux [ "wayland" "drm" ]
, OpenGL, Xplugin
, withValgrind ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAarch32, valgrind-light
, enableGalliumNine ? stdenv.isLinux
, enableOSMesa ? stdenv.isLinux
}:
/** Packaging design:
@ -79,7 +81,7 @@ stdenv.mkDerivation {
"find_program('${buildPackages.pkg-config.targetPrefix}pkg-config')"
'';
outputs = [ "out" "dev" "drivers" "osmesa" ];
outputs = [ "out" "dev" "drivers" ] ++ lib.optional enableOSMesa "osmesa";
# TODO: Figure out how to enable opencl without having a runtime dependency on clang
mesonFlags = [
@ -103,10 +105,10 @@ stdenv.mkDerivation {
"-Domx-libs-path=${placeholder "drivers"}/lib/bellagio"
"-Dva-libs-path=${placeholder "drivers"}/lib/dri"
"-Dd3d-drivers-path=${placeholder "drivers"}/lib/d3d"
"-Dgallium-nine=${if enableGalliumNine then "true" else "false"}" # Direct3D in Wine
"-Dosmesa=${if enableOSMesa then "gallium" else "none"}" # used by wine
] ++ optionals stdenv.isLinux [
"-Dglvnd=true"
"-Dosmesa=gallium" # used by wine
"-Dgallium-nine=true" # Direct3D in Wine
];
buildInputs = with xorg; [
@ -142,17 +144,17 @@ stdenv.mkDerivation {
'' + optionalString stdenv.isLinux ''
mkdir -p $drivers/lib
# move gallium-related stuff to $drivers, so $out doesn't depend on LLVM
mv -t $drivers/lib \
$out/lib/libxatracker* \
$out/lib/libvulkan_*
if [ -n "$(shopt -s nullglob; echo "$out/lib/libxatracker"*)" -o -n "$(shopt -s nullglob; echo "$out/lib/libvulkan_"*)" ]; then
# move gallium-related stuff to $drivers, so $out doesn't depend on LLVM
mv -t $drivers/lib \
$out/lib/libxatracker* \
$out/lib/libvulkan_*
fi
# Move other drivers to a separate output
mv $out/lib/lib*_mesa* $drivers/lib
# move libOSMesa to $osmesa, as it's relatively big
mkdir -p $osmesa/lib
mv -t $osmesa/lib/ $out/lib/libOSMesa*
if [ -n "$(shopt -s nullglob; echo "$out"/lib/lib*_mesa*)" ]; then
# Move other drivers to a separate output
mv $out/lib/lib*_mesa* $drivers/lib
fi
# move vendor files
mv $out/share/ $drivers/
@ -167,6 +169,10 @@ stdenv.mkDerivation {
for js in $drivers/share/vulkan/icd.d/*.json; do
substituteInPlace "$js" --replace "$out" "$drivers"
done
'' + lib.optionalString enableOSMesa ''
# move libOSMesa to $osmesa, as it's relatively big
mkdir -p $osmesa/lib
mv -t $osmesa/lib/ $out/lib/libOSMesa*
'';
# TODO:
@ -181,7 +187,9 @@ stdenv.mkDerivation {
# Update search path used by pkg-config
for pc in $dev/lib/pkgconfig/{d3d,dri,xatracker}.pc; do
substituteInPlace "$pc" --replace $out $drivers
if [ -f "$pc" ]; then
substituteInPlace "$pc" --replace $out $drivers
fi
done
# add RPATH so the drivers can find the moved libgallium and libdricore9