rutabaga_gfx: fix build on Darwin (#298441)
* gfxstream: fix build on Darwin - Add patch from upstream to remove libdrm dependency; - Modify `meson.build` to support Objective-C; - Add required Darwin frameworks; and - Ensure everything that’s required is linked on Darwin. * rutabaga_gfx: fix build on Darwin
This commit is contained in:
parent
90f6939439
commit
03adc266bf
|
@ -1,5 +1,5 @@
|
||||||
{ lib, stdenv, fetchFromGitiles, meson, ninja, pkg-config, python3
|
{ lib, stdenv, fetchFromGitiles, fetchpatch, meson, ninja, pkg-config, python3
|
||||||
, aemu, libdrm, libglvnd, vulkan-headers, vulkan-loader, xorg
|
, aemu, darwin, libdrm, libglvnd, vulkan-headers, vulkan-loader, xorg
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
|
@ -12,14 +12,45 @@ stdenv.mkDerivation {
|
||||||
hash = "sha256-IYXkaHZPEYIE9KW731GN6x6yRS+FYtP1zyHcaSofhIM=";
|
hash = "sha256-IYXkaHZPEYIE9KW731GN6x6yRS+FYtP1zyHcaSofhIM=";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
# Make libdrm an optional dependency, which is required to build on Darwin.
|
||||||
|
(fetchpatch {
|
||||||
|
url = "https://android.googlesource.com/platform/hardware/google/gfxstream/+/a8df2a3eb099b419a7b3638e68ea30b4cffb751b%5E%21/?format=TEXT";
|
||||||
|
decode = "base64 -d";
|
||||||
|
hash = "sha256-shjeNuxtQokscCGBKEUbOPKOWRELBAnHFNj3Y5w87Nw=";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
# Ensure that meson can find an Objective-C compiler on Darwin.
|
||||||
|
postPatch = lib.optionalString stdenv.isDarwin ''
|
||||||
|
substituteInPlace meson.build \
|
||||||
|
--replace-fail "project('gfxstream_backend', 'cpp', 'c'" "project('gfxstream_backend', 'cpp', 'c', 'objc'"
|
||||||
|
'';
|
||||||
|
|
||||||
nativeBuildInputs = [ meson ninja pkg-config python3 ];
|
nativeBuildInputs = [ meson ninja pkg-config python3 ];
|
||||||
buildInputs = [ aemu libglvnd vulkan-headers vulkan-loader xorg.libX11 ]
|
buildInputs = [ aemu libglvnd vulkan-headers vulkan-loader xorg.libX11 ]
|
||||||
++ lib.optional (lib.meta.availableOn stdenv.hostPlatform libdrm) libdrm;
|
++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform libdrm) [ libdrm ]
|
||||||
|
++ lib.optionals stdenv.isDarwin [
|
||||||
|
darwin.apple_sdk.frameworks.Cocoa
|
||||||
|
darwin.apple_sdk.frameworks.CoreGraphics
|
||||||
|
darwin.apple_sdk.frameworks.IOKit
|
||||||
|
darwin.apple_sdk.frameworks.IOSurface
|
||||||
|
darwin.apple_sdk.frameworks.OpenGL
|
||||||
|
darwin.apple_sdk.frameworks.QuartzCore
|
||||||
|
];
|
||||||
|
|
||||||
|
env = lib.optionalAttrs stdenv.isDarwin {
|
||||||
|
NIX_LDFLAGS = toString [
|
||||||
|
"-framework Cocoa"
|
||||||
|
"-framework IOKit"
|
||||||
|
"-framework IOSurface"
|
||||||
|
"-framework OpenGL"
|
||||||
|
"-framework QuartzCore"
|
||||||
|
"-needed-lvulkan"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# dlopens libvulkan.
|
# dlopens libvulkan.
|
||||||
#
|
|
||||||
# XXX: Unsure if this is required on Darwin. If it is, it probably
|
|
||||||
# needs to be done using install_name_tool.
|
|
||||||
preConfigure = lib.optionalString (!stdenv.isDarwin) ''
|
preConfigure = lib.optionalString (!stdenv.isDarwin) ''
|
||||||
mesonFlagsArray=(-Dcpp_link_args="-Wl,--push-state -Wl,--no-as-needed -lvulkan -Wl,--pop-state")
|
mesonFlagsArray=(-Dcpp_link_args="-Wl,--push-state -Wl,--no-as-needed -lvulkan -Wl,--pop-state")
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
diff --git a/rutabaga_gfx/ffi/Makefile b/rutabaga_gfx/ffi/Makefile
|
||||||
|
index f8c7820bf..e88a6c308 100644
|
||||||
|
--- a/rutabaga_gfx/ffi/Makefile
|
||||||
|
+++ b/rutabaga_gfx/ffi/Makefile
|
||||||
|
@@ -47,24 +47,16 @@ build:
|
||||||
|
cargo build $(gfxstream_feature) $(release)
|
||||||
|
|
||||||
|
install: build
|
||||||
|
-ifeq ($(UNAME), Linux)
|
||||||
|
install -D -m 755 $(OUT)/$(LIB_NAME) $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION)
|
||||||
|
-endif
|
||||||
|
ifeq ($(UNAME), Darwin)
|
||||||
|
- install_name_tool -id $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION) $(DESTDIR)$(libdir)/$(LIB_NAME)
|
||||||
|
+ install_name_tool -id $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION) $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ln -sf $(LIB_NAME).$(RUTABAGA_VERSION) $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION_MAJOR)
|
||||||
|
ln -sf $(LIB_NAME).$(RUTABAGA_VERSION) $(DESTDIR)$(libdir)/$(LIB_NAME)
|
||||||
|
|
||||||
|
-ifeq ($(UNAME), Linux)
|
||||||
|
install -D -m 0644 $(SRC)/share/rutabaga_gfx_ffi.pc $(DESTDIR)$(libdir)/pkgconfig/rutabaga_gfx_ffi.pc
|
||||||
|
install -D -m 0644 $(SRC)/include/rutabaga_gfx_ffi.h $(DESTDIR)$(includedir)/rutabaga_gfx_ffi.h
|
||||||
|
-endif
|
||||||
|
-ifeq ($(UNAME), Darwin)
|
||||||
|
- install -m 0644 $(SRC)/share/rutabaga_gfx_ffi.pc $(DESTDIR)$(libdir)/pkgconfig/rutabaga_gfx_ffi.pc
|
||||||
|
- install -m 0644 $(SRC)/include/rutabaga_gfx_ffi.h $(DESTDIR)$(includedir)/rutabaga_gfx_ffi.h
|
||||||
|
-endif
|
||||||
|
|
||||||
|
clean:
|
||||||
|
cargo clean $(release)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
, aemu
|
, aemu
|
||||||
, gfxstream
|
, gfxstream
|
||||||
, libdrm
|
, libdrm
|
||||||
|
, libiconv
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
|
@ -29,10 +30,19 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
decode = "base64 -d";
|
decode = "base64 -d";
|
||||||
hash = "sha256-Ji1bK7jnRlg0OpDfCLcTHfPSiz3zYcdgsWL4n3EoIYI=";
|
hash = "sha256-Ji1bK7jnRlg0OpDfCLcTHfPSiz3zYcdgsWL4n3EoIYI=";
|
||||||
})
|
})
|
||||||
|
# Fix error in Makefile where it uses eight spaces instead of a tab
|
||||||
|
# https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4863380
|
||||||
|
(fetchpatch {
|
||||||
|
url = "https://chromium.googlesource.com/crosvm/crosvm/+/fc415bccc43d36f63a2fd4c28878591bb1053450%5E%21/?format=TEXT";
|
||||||
|
decode = "base64 -d";
|
||||||
|
hash = "sha256-SLzlZ4o1+R2bGTPvA0a5emq97hOIIIHrubFhcQjqYwg=";
|
||||||
|
})
|
||||||
|
# Install the dylib on Darwin.
|
||||||
|
./darwin-install.patch
|
||||||
];
|
];
|
||||||
|
|
||||||
nativeBuildInputs = [ cargo pkg-config rustPlatform.cargoSetupHook ];
|
nativeBuildInputs = [ cargo pkg-config rustPlatform.cargoSetupHook ];
|
||||||
buildInputs = lib.optionals (lib.meta.availableOn stdenv.hostPlatform gfxstream) ([
|
buildInputs = [ libiconv ] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform gfxstream) ([
|
||||||
aemu
|
aemu
|
||||||
gfxstream
|
gfxstream
|
||||||
] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform libdrm) [
|
] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform libdrm) [
|
||||||
|
|
Loading…
Reference in New Issue