From b9563acd4485f19bb54f6d1d2d8bda85fc37daed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Mon, 20 May 2024 22:28:10 +0200 Subject: [PATCH] meson: Fix export of DbgHelp, SymSrv, and vapidir - Install DbgHelp and SymSrv, and move them in the repo to match their installed paths. In this way consumers can use the particular prefix variable and be able to refer to them whether they're installed or uninstalled. - For vapidir we also need to expose two different values for uninstalled vs installed. --- .../{dbghelp-32.dll => 32/dbghelp.dll} | Bin .../{dbghelp-64.dll => 64/dbghelp.dll} | Bin ext/dbghelp/meson.build | 6 ++++- ext/symsrv/{symsrv-32.dll => 32/symsrv.dll} | Bin ext/symsrv/{symsrv-64.dll => 64/symsrv.dll} | Bin ext/symsrv/meson.build | 6 ++++- gum/meson.build | 22 ++++++++++++------ meson.build | 9 +++++++ vapi/meson.build | 2 +- 9 files changed, 35 insertions(+), 10 deletions(-) rename ext/dbghelp/{dbghelp-32.dll => 32/dbghelp.dll} (100%) rename ext/dbghelp/{dbghelp-64.dll => 64/dbghelp.dll} (100%) rename ext/symsrv/{symsrv-32.dll => 32/symsrv.dll} (100%) rename ext/symsrv/{symsrv-64.dll => 64/symsrv.dll} (100%) diff --git a/ext/dbghelp/dbghelp-32.dll b/ext/dbghelp/32/dbghelp.dll similarity index 100% rename from ext/dbghelp/dbghelp-32.dll rename to ext/dbghelp/32/dbghelp.dll diff --git a/ext/dbghelp/dbghelp-64.dll b/ext/dbghelp/64/dbghelp.dll similarity index 100% rename from ext/dbghelp/dbghelp-64.dll rename to ext/dbghelp/64/dbghelp.dll diff --git a/ext/dbghelp/meson.build b/ext/dbghelp/meson.build index 2f3a8e56d..d89f258e5 100644 --- a/ext/dbghelp/meson.build +++ b/ext/dbghelp/meson.build @@ -1,3 +1,7 @@ +dbghelp_prefix = get_option('prefix') / get_option('libdir') / 'frida' +uninstalled_dbghelp_prefix = meson.current_source_dir() + if host_os_family == 'windows' and host_arch in ['x86', 'x86_64'] - dbghelp_dll = files('dbghelp-@0@.dll'.format((host_arch == 'x86_64') ? '64' : '32')) + dbghelp_dll = files(host_cpu_mode / 'dbghelp.dll') + install_data(dbghelp_dll, install_dir: dbghelp_prefix / host_cpu_mode) endif diff --git a/ext/symsrv/symsrv-32.dll b/ext/symsrv/32/symsrv.dll similarity index 100% rename from ext/symsrv/symsrv-32.dll rename to ext/symsrv/32/symsrv.dll diff --git a/ext/symsrv/symsrv-64.dll b/ext/symsrv/64/symsrv.dll similarity index 100% rename from ext/symsrv/symsrv-64.dll rename to ext/symsrv/64/symsrv.dll diff --git a/ext/symsrv/meson.build b/ext/symsrv/meson.build index 686566de2..d950f2739 100644 --- a/ext/symsrv/meson.build +++ b/ext/symsrv/meson.build @@ -1,3 +1,7 @@ +symsrv_prefix = get_option('prefix') / get_option('libdir') / 'frida' +uninstalled_symsrv_prefix = meson.current_source_dir() + if host_os_family == 'windows' and host_arch in ['x86', 'x86_64'] - symsrv_dll = files('symsrv-@0@.dll'.format((host_arch == 'x86_64') ? '64' : '32')) + symsrv_dll = files(host_cpu_mode / 'symsrv.dll') + install_data(symsrv_dll, install_dir: symsrv_prefix / host_cpu_mode) endif diff --git a/gum/meson.build b/gum/meson.build index ddce731f2..827c8998c 100644 --- a/gum/meson.build +++ b/gum/meson.build @@ -361,16 +361,25 @@ if gir.found() ) endif -vapidir = meson.project_source_root() / 'vapi' + +uninstalled_variables = { + 'frida_vapidir': uninstalled_vapidir, + 'frida_dbghelp_prefix': uninstalled_dbghelp_prefix, + 'frida_symsrv_prefix': uninstalled_symsrv_prefix, +} + +installed_variables = { + 'frida_vapidir': vapidir, + 'frida_dbghelp_prefix': dbghelp_prefix, + 'frida_symsrv_prefix': symsrv_prefix, +} gum_dep = declare_dependency(link_with: gum, include_directories: gum_incdirs, compile_args: extra_cflags, link_args: extra_libs_private, dependencies: gum_public_deps, - variables: { - 'frida_vapidir': vapidir, - }, + variables: uninstalled_variables, ) pkg = import('pkgconfig') @@ -384,9 +393,8 @@ pkg.generate(gum, subdirs: install_header_basedir, extra_cflags: extra_cflags, libraries_private: extra_libs_private, - variables: { - 'frida_vapidir': vapidir, - }, + variables: installed_variables, + uninstalled_variables: uninstalled_variables, ) meson.override_dependency('frida-gum-' + api_version, gum_dep) diff --git a/meson.build b/meson.build index 0e8519bdd..80f799686 100644 --- a/meson.build +++ b/meson.build @@ -103,6 +103,12 @@ else have_ptrauth = false endif +if cc.sizeof('void *') == 8 + host_cpu_mode = '64' +else + host_cpu_mode = '32' +endif + if host_os_family == 'windows' host_executable_format = 'pe' elif host_os_family == 'darwin' @@ -741,6 +747,9 @@ endif install_header_basedir = 'frida-' + api_version install_header_subdir = install_header_basedir + '/gum' +vapidir = get_option('prefix') / 'share' / 'vala' / 'vapi' +uninstalled_vapidir = meson.current_source_dir() / 'vapi' + subdir('ext') subdir('gum') if not diet diff --git a/vapi/meson.build b/vapi/meson.build index 205f9107e..cf0c3c1ef 100644 --- a/vapi/meson.build +++ b/vapi/meson.build @@ -22,4 +22,4 @@ if have_gumjs ] endif -install_data(vapis, install_dir: 'share' / 'vala' / 'vapi') +install_data(vapis, install_dir: vapidir)