From 04aba3636b251af149fc6020d8c9a16dc8801c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Wed, 17 Apr 2024 23:29:28 +0200 Subject: [PATCH] meson: Revise the Frida version logic - Add frida_version option, replacing the old way of looking for a FRIDA_VERSION preprocessor define. This allows a parent project to pass this option to us when we're a subproject. - Propagate the option to Gum in case we end up building it. --- meson.build | 37 +++++++++++++++++++++++++++---------- meson.options | 6 ++++++ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index 74fee9dc1..793d7ff93 100644 --- a/meson.build +++ b/meson.build @@ -13,6 +13,22 @@ Vala compiler from: https://github.com/frida/vala''') endif +frida_version = get_option('frida_version') +if frida_version == '' + frida_version = meson.project_version() +endif +tokens = frida_version.split('.') +frida_major_version = tokens[0].to_int() +frida_minor_version = tokens[1].to_int() +if tokens.length() == 4 + frida_micro_version = tokens[2].split('-')[0].to_int() - 1 + frida_nano_version = tokens[3].to_int() + 1 +else + assert(tokens.length() == 3) + frida_micro_version = tokens[2].to_int() + frida_nano_version = 0 +endif + api_version = '1.0' header_install_dir = get_option('includedir') / f'frida-@api_version@' @@ -162,17 +178,17 @@ endif cdata = configuration_data() -if cc.get_define('FRIDA_VERSION') == '' - version = meson.project_version() - tokens = version.split('.') - cdata.set_quoted('FRIDA_VERSION', version) - cdata.set('FRIDA_MAJOR_VERSION', tokens[0].to_int()) - cdata.set('FRIDA_MINOR_VERSION', tokens[1].to_int()) - cdata.set('FRIDA_MICRO_VERSION', tokens[2].to_int()) - cdata.set('FRIDA_NANO_VERSION', 0) -endif +cdata.set_quoted('FRIDA_VERSION', frida_version) +cdata.set('FRIDA_MAJOR_VERSION', frida_major_version) +cdata.set('FRIDA_MINOR_VERSION', frida_minor_version) +cdata.set('FRIDA_MICRO_VERSION', frida_micro_version) +cdata.set('FRIDA_NANO_VERSION', frida_nano_version) -cdata.set_quoted('FRIDA_PREFIX', get_option('prefix')) +escaped_prefix = get_option('prefix') +if host_os_family == 'windows' + escaped_prefix = escaped_prefix.replace('\\', '\\\\') +endif +cdata.set_quoted('FRIDA_PREFIX', escaped_prefix) exe_suffix = (host_os_family == 'windows') ? '.exe' : '' if host_os_family == 'windows' @@ -269,6 +285,7 @@ if get_option('b_sanitize') == 'address' endif gum_dep = dependency('frida-gum-1.0', default_options: [ + f'frida_version=@frida_version@', 'gumjs=enabled', ]) gumjs_dep = dependency('frida-gumjs-1.0') diff --git a/meson.options b/meson.options index c53cbd7fd..6eb50add3 100644 --- a/meson.options +++ b/meson.options @@ -1,3 +1,9 @@ +option('frida_version', + type: 'string', + value: '', + description: 'Frida version, such as 16.2.1 (stable) or 16.2.2-dev.27 (snapshot)', +) + option('local_backend', type: 'feature', value: 'auto',