simplify cross arch preloading

This commit does a couple of things. In the mangohud launch script, the library will be found using $LIB with ld, so the correct path is selected depending on the cpu arch. The same is done for mangohud.json (vulkan layer). In addition some now unused files have been deleted.

Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
sdf
Stephan Lachnit 4 years ago committed by jackun
parent 6ee225ed66
commit d712d35aaf
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -1,10 +1,5 @@
#!/bin/sh
MANGOHUD_LIB_NAME="libMangoHud.so"
if [ "$MANGOHUD_DLSYM" = "1" ]; then
MANGOHUD_LIB_NAME="libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}"
fi
if [ "$#" -eq 0 ]; then
programname=`basename "$0"`
echo "ERROR: No program supplied"
@ -13,13 +8,16 @@ if [ "$#" -eq 0 ]; then
exit 1
fi
# Execute the program under a clean environment
# pass through the overriden LD_PRELOAD environment variables
LD_PRELOAD="${LD_PRELOAD}:${MANGOHUD_LIB_NAME}"
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:@libdir_mangohud@"
MANGOHUD_LIB_NAME="libMangoHud.so"
if hash @mangohud_sh@ 2>/dev/null; then
exec env MANGOHUD=1 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" LD_PRELOAD="${LD_PRELOAD}" @mangohud_sh@ "$@"
else
exec env MANGOHUD=1 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" LD_PRELOAD="${LD_PRELOAD}" "$@"
if [ "$MANGOHUD_DLSYM" = "1" ]; then
MANGOHUD_LIB_NAME="libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}"
fi
# Preload using the plain filesnames of the libs, the dynamic linker will
# figure out whether the 32 or 64 bit version should be used, and will search
# for it in the correct directory
LD_PRELOAD="${LD_PRELOAD}:${MANGOHUD_LIB_NAME}"
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:@ld_libdir_mangohud@"
exec env MANGOHUD=1 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" LD_PRELOAD="${LD_PRELOAD}" "$@"

@ -1,2 +0,0 @@
/usr/lib/mangohud/lib32
/usr/lib/mangohud/lib64

@ -1 +0,0 @@
@libdir_mangohud@

@ -1,22 +0,0 @@
{
"file_format_version" : "1.0.0",
"layer" : {
"name": "MangoHud",
"type": "GLOBAL",
"api_version": "1.1.125",
"library_path": "libMangoHud.so",
"implementation_version": "1",
"description": "Vulkan Hud Overlay",
"functions": {
"vkGetInstanceProcAddr": "overlay_GetInstanceProcAddr",
"vkGetDeviceProcAddr": "overlay_GetDeviceProcAddr"
},
"enable_environment": {
"MANGOHUD": "1"
},
"disable_environment": {
"DISABLE_MANGOHUD": "1"
}
}
}

@ -1,10 +1,10 @@
{
"file_format_version" : "1.0.0",
"layer" : {
"name": "@PROJECT_NAME@@LAYER_SUFFIX@",
"name": "VK_LAYER_@PROJECT_NAME@_overlay",
"type": "GLOBAL",
"api_version": "1.2.135",
"library_path": "@libdir_mangohud@libMangoHud.so",
"library_path": "@ld_libdir_mangohud@libMangoHud.so",
"implementation_version": "1",
"description": "Vulkan Hud Overlay",
"functions": {
@ -19,4 +19,3 @@
}
}
}

@ -2,9 +2,11 @@ glslang = find_program('glslangValidator')
# Needs prefix for configure_file()
if get_option('append_libdir_mangohud')
libdir_mangohud = join_paths(get_option('prefix'), get_option('libdir'), 'mangohud')
libdir_mangohud = join_paths(get_option('libdir'), 'mangohud')
ld_libdir_mangohud = get_option('prefix') + '/\$LIB/mangohud/'
else
libdir_mangohud = join_paths(get_option('prefix'), get_option('libdir'))
libdir_mangohud = get_option('libdir')
ld_libdir_mangohud = get_option('prefix') + '/\$LIB/'
endif
overlay_shaders = [
@ -163,26 +165,16 @@ mangohud_dlsym = shared_library(
)
configure_file(input : 'mangohud.json.in',
output : '@0@.@1@.json'.format(meson.project_name(), target_machine.cpu_family()),
configuration : {'libdir_mangohud' : libdir_mangohud + '/',
'PROJECT_NAME' : meson.project_name() + ' ',
'LAYER_SUFFIX' : target_machine.cpu_family()},
output : '@0@.json'.format(meson.project_name()),
configuration : {'ld_libdir_mangohud' : ld_libdir_mangohud,
'PROJECT_NAME' : meson.project_name()},
install : true,
install_dir : join_paths(get_option('datadir'), 'vulkan', 'implicit_layer.d'),
)
if target_machine.cpu_family() == 'x86_64'
mangohud_cpu_family = ''
mangohud_opposite_bin = 'mangohud.x86'
else
mangohud_cpu_family = '.@0@'.format(target_machine.cpu_family())
#this is probably dumb but works for now
mangohud_opposite_bin = 'intentionally_borked'
endif
configure_file(input : '../bin/mangohud.in',
output : 'mangohud@0@'.format(mangohud_cpu_family),
configuration : {'libdir_mangohud' : libdir_mangohud, 'mangohud_sh' : mangohud_opposite_bin},
output : 'mangohud',
configuration : {'ld_libdir_mangohud' : ld_libdir_mangohud},
install_dir : get_option('bindir'),
)

Loading…
Cancel
Save