flutter.buildFlutterApplication: Supply runtime dependencies
This wraps Flutter programs with an appropriate LD_LIBRARY_PATH. For some reason, the RUNPATH of the executable is not used to load dynamic libraries in dart:ffi with DynamicLibrary.open(). This could alternatively be fixed with patchelf --add-needed, but this would cause all the libraries to be opened immediately, which is not what application authors expect. The name of the runtimeDependencies argument was chosen to match autoPatchelfHook, which has a similar feature.
This commit is contained in:
parent
eefb67036f
commit
bbfc7911d3
@ -1,6 +1,7 @@
|
||||
{ lib
|
||||
, callPackage
|
||||
, stdenvNoCC
|
||||
, makeWrapper
|
||||
, llvmPackages_13
|
||||
, cacert
|
||||
, flutter
|
||||
@ -10,10 +11,12 @@
|
||||
# absolutely no mac support for now
|
||||
|
||||
{ pubGetScript ? "flutter pub get"
|
||||
, flutterBuildFlags ? []
|
||||
, flutterBuildFlags ? [ ]
|
||||
, runtimeDependencies ? [ ]
|
||||
, vendorHash
|
||||
, pubspecLockFile ? null
|
||||
, nativeBuildInputs ? [ ]
|
||||
, postFixup ? ""
|
||||
, ...
|
||||
}@args:
|
||||
let
|
||||
@ -33,6 +36,7 @@ let
|
||||
outputs = [ "out" "debug" ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
deps
|
||||
flutter
|
||||
git
|
||||
@ -87,6 +91,20 @@ let
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
# Add runtime library dependencies to the LD_LIBRARY_PATH.
|
||||
# For some reason, the RUNPATH of the executable is not used to load dynamic libraries in dart:ffi with DynamicLibrary.open().
|
||||
#
|
||||
# This could alternatively be fixed with patchelf --add-needed, but this would cause all the libraries to be opened immediately,
|
||||
# which is not what application authors expect.
|
||||
for f in "$out"/bin/*; do
|
||||
wrapProgram "$f" \
|
||||
--suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath runtimeDependencies}'
|
||||
done
|
||||
|
||||
${postFixup}
|
||||
'';
|
||||
})) self;
|
||||
in
|
||||
self
|
||||
|
Loading…
Reference in New Issue
Block a user