mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-30 08:44:31 +00:00
wgpu-native: init at 22.1.0.5 (#362014)
This commit is contained in:
commit
1306de2eec
88
pkgs/by-name/wg/wgpu-native/examples.nix
Normal file
88
pkgs/by-name/wg/wgpu-native/examples.nix
Normal file
@ -0,0 +1,88 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
cmake,
|
||||
pkg-config,
|
||||
ninja,
|
||||
makeWrapper,
|
||||
wgpu-native,
|
||||
glfw,
|
||||
wayland,
|
||||
xorg,
|
||||
vulkan-loader,
|
||||
|
||||
version,
|
||||
src,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
inherit version src;
|
||||
pname = "wgpu-native-examples";
|
||||
|
||||
sourceRoot = "${src.name}/examples";
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace ./CMakeLists.txt \
|
||||
--replace-fail 'add_subdirectory(vendor/glfw)' 'find_package(glfw3 3.4 REQUIRED)'
|
||||
'';
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
pkg-config
|
||||
ninja
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
buildInputs =
|
||||
[
|
||||
wgpu-native
|
||||
glfw
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
wayland
|
||||
xorg.libX11
|
||||
xorg.libXrandr
|
||||
];
|
||||
|
||||
runtimeInputs = lib.optionals stdenv.hostPlatform.isLinux [
|
||||
# Without wayland in library path, this warning is raised:
|
||||
# "No windowing system present. Using surfaceless platform"
|
||||
wayland
|
||||
# Without vulkan-loader present, wgpu won't find any adapter
|
||||
vulkan-loader
|
||||
];
|
||||
|
||||
makeWrapperArgs = lib.optionals (finalAttrs.runtimeInputs != [ ]) [
|
||||
"--prefix LD_LIBRARY_PATH : ${builtins.toString (lib.makeLibraryPath finalAttrs.runtimeInputs)}"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
concatTo makeWrapperArgsArray makeWrapperArgs
|
||||
|
||||
# find all executables that have the same name as their directory
|
||||
for executable in $(find . -regex '.*\(/[^/]*\)\1' -type f -executable)
|
||||
do
|
||||
target="$(basename "$(dirname "$executable")")"
|
||||
install -Dm755 $executable -t $out/bin
|
||||
mkdir -p $out/share/$target
|
||||
wrapProgram $out/bin/$target --chdir $out/share/$target "''${makeWrapperArgsArray[@]}"
|
||||
|
||||
# The examples expect their shaders in the CWD, so we copy them into the store
|
||||
# and wrap the examples to run in the directory containing the shader.
|
||||
for shader in $(find ../$target -type f -name '*.wgsl'); do
|
||||
install -Dm644 $shader $out/share/$target/
|
||||
done
|
||||
done
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = wgpu-native.meta // {
|
||||
description = "Examples for the native WebGPU implementation based on wgpu-core";
|
||||
mainProgram = "triangle";
|
||||
};
|
||||
})
|
62
pkgs/by-name/wg/wgpu-native/package.nix
Normal file
62
pkgs/by-name/wg/wgpu-native/package.nix
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
rustPlatform,
|
||||
fixDarwinDylibNames,
|
||||
vulkan-loader,
|
||||
nix-update-script,
|
||||
callPackage,
|
||||
}:
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "wgpu-native";
|
||||
version = "22.1.0.5";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "gfx-rs";
|
||||
repo = "wgpu-native";
|
||||
rev = "refs/tags/v${version}";
|
||||
hash = "sha256-lEUHRU7+sFWtEYTOB2F+SmMNG8nrjro3IL7BgYuIGgM=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"dev"
|
||||
];
|
||||
|
||||
useFetchCargoVendor = true;
|
||||
cargoHash = "sha256-frlGlUqyKa3PTRbpLhcnUvu+SX64V/CnZGa6+ADxKCo=";
|
||||
|
||||
nativeBuildInputs = [
|
||||
rustPlatform.bindgenHook
|
||||
] ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
|
||||
|
||||
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
|
||||
vulkan-loader
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
rm $out/lib/libwgpu_native.a
|
||||
install -Dm644 ./ffi/wgpu.h -t $dev/include/webgpu
|
||||
install -Dm644 ./ffi/webgpu-headers/webgpu.h -t $dev/include/webgpu
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
updateScript = nix-update-script { };
|
||||
examples = callPackage ./examples.nix {
|
||||
inherit version src;
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Native WebGPU implementation based on wgpu-core";
|
||||
homepage = "https://github.com/gfx-rs/wgpu-native";
|
||||
license = with lib.licenses; [
|
||||
mit
|
||||
asl20
|
||||
];
|
||||
maintainers = with lib.maintainers; [ niklaskorz ];
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user