From 16eef61a7ab8fd674a40803b8e2eaad7b3a4cc8a Mon Sep 17 00:00:00 2001 From: Raffarti Date: Sun, 21 Jan 2018 11:17:15 +0100 Subject: [PATCH] Added script to setup dlls in wine (#19) * Added script to setup dlls in wine * Fix no WINEPREFIX confirmation * move wine_utils outside src --- meson.build | 2 +- src/meson.build | 2 +- wine_utils/dlls_setup.sh.in | 53 +++++++++++++++++++++++++++++++++++++ wine_utils/meson.build | 8 ++++++ 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 wine_utils/dlls_setup.sh.in create mode 100644 wine_utils/meson.build diff --git a/meson.build b/meson.build index fd4bb67b..73a87b82 100644 --- a/meson.build +++ b/meson.build @@ -22,6 +22,6 @@ glsl_generator = generator(glsl_compiler, output : [ '@BASENAME@.h' ], arguments : [ '-V', '--vn', '@BASENAME@', '@INPUT@', '-o', '@OUTPUT@' ]) - subdir('src') subdir('tests') +subdir('wine_utils') diff --git a/src/meson.build b/src/meson.build index c65c8fdd..04645266 100644 --- a/src/meson.build +++ b/src/meson.build @@ -3,4 +3,4 @@ subdir('spirv') subdir('dxvk') subdir('dxgi') subdir('dxbc') -subdir('d3d11') \ No newline at end of file +subdir('d3d11') diff --git a/wine_utils/dlls_setup.sh.in b/wine_utils/dlls_setup.sh.in new file mode 100644 index 00000000..026486e8 --- /dev/null +++ b/wine_utils/dlls_setup.sh.in @@ -0,0 +1,53 @@ +#!/bin/bash + +dlls_dir=@dlldir@ +path_pattern='s|^\s*PATH\s+REG_EXPAND_SZ\s+(.*)\s*$|\1|g' +dlls_windir="Z:$(sed 's|/|\\|g'<<<$dlls_dir)" +dlls_windir_pattern="$(sed 's|\\|\\\\|g'<<<$dlls_windir)" +WINEDEBUG=-all + +if [ -z "$WINEPREFIX" ]; then + echo "WINEPREFIX is not set, continue? (y/N)" + read continue + if [ "$continue" != "y" ] && [ "$continue" != "Y" ]; then + exit 1 + fi +fi + +if [ "$1" == "reset" ]; then + wine reg delete HKEY_CURRENT_USER\\Software\\Wine\\DllRedirects /v d3d11 + wine reg delete HKEY_CURRENT_USER\\Software\\Wine\\DllRedirects /v dxgi + path=$(wine reg query 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' /v PATH | sed -e 's|\r||g') + cleared_path=$(grep REG_EXPAND_SZ <<< $path | sed -E -e $path_pattern -e "s|^(.*;)?$dlls_windir_pattern(;(.*))?$|\\1\\3|") + echo "$path" + echo "new PATH: $cleared_path" + wine reg add 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' /v PATH /d "$cleared_path" /t REG_EXPAND_SZ + exit 0 +fi + +function redirect { + wine reg query HKEY_CURRENT_USER\\Software\\Wine\\DllRedirects /v $2 | grep -E '^\s*'"$2"'\s+REG_SZ\s+'"$2"'_vk.dll\s*$' 1>/dev/null + if [ $? -eq 1 ]; then + echo "redirecting [$2 -> $2_vk]" + wine reg add HKEY_CURRENT_USER\\Software\\Wine\\DllRedirects /v $2 /d $2_vk.dll + else + echo -e "redirection [$2 -> $2_vk] was \\e[0;32mOK\\e[0m" + fi +} + +redirect CHK_REDIRECT_D3D11 d3d11 +redirect CHK_REDIRECT_DXGI dxgi + +path=$(wine reg query 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' /v PATH | sed -e 's|\r||g') +path_val=$(grep REG_EXPAND_SZ<<<$path | sed -E -e $path_pattern) +check=$(sed -E -e "s|^(.*;)?$dlls_windir_pattern(;.*)?$||" <<<$path_val) + +if [ -n "$check" ]; then + echo "adding $dlls_windir to windows PATH" + new_path="$(sed -E -e 's|;?\s*$||' <<<$path_val);$dlls_windir" + echo "$path" + echo "new PATH: $new_path" + wine reg add 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' /v PATH /d "$new_path" /t REG_EXPAND_SZ +else + echo -e "windows PATH was \\e[0;32mOK\\e[0m" +fi diff --git a/wine_utils/meson.build b/wine_utils/meson.build new file mode 100644 index 00000000..31dc5d8f --- /dev/null +++ b/wine_utils/meson.build @@ -0,0 +1,8 @@ +conf = configuration_data() +conf.set('dlldir', get_option('prefix')+'/'+get_option('bindir')) +configure_file( + configuration : conf, + input : 'dlls_setup.sh.in', + output : 'dlls_setup.sh', + install_dir : get_option('bindir') +)