diff --git a/meson.build b/meson.build index f5a4f512d..70b0d9511 100644 --- a/meson.build +++ b/meson.build @@ -170,6 +170,7 @@ build_tests = get_option('tests') \ .allowed() cdata = configuration_data() + if cc.get_define('FRIDA_VERSION') == '' version = meson.project_version() tokens = version.split('.') @@ -182,6 +183,10 @@ endif cdata.set_quoted('FRIDA_PREFIX', get_option('prefix')) +foreach name : get_option('backends') + vala_flags += '--define=HAVE_@0@_BACKEND'.format(name.underscorify().to_upper()) +endforeach + exe_suffix = (host_os_family == 'windows') ? '.exe' : '' if host_os_family == 'windows' shlib_suffix = '.dll' diff --git a/meson.options b/meson.options index 6ecb3fada..8aa96312d 100644 --- a/meson.options +++ b/meson.options @@ -1,3 +1,10 @@ +option('backends', + type: 'array', + choices: ['local', 'fruity', 'droidy', 'socket', 'barebone'], + value: ['local', 'fruity', 'droidy', 'socket', 'barebone'], + description: 'Backends to include' +) + option('assets', type: 'combo', choices: ['embedded', 'installed'], diff --git a/src/barebone/meson.build b/src/barebone/meson.build index 33e80122e..38f2bd13f 100644 --- a/src/barebone/meson.build +++ b/src/barebone/meson.build @@ -1,64 +1,59 @@ -barebone_sources = [] +backend_sources += files( + 'barebone-host-session.vala', + 'script.vala', + 'machine.vala', + 'allocator.vala', + 'callback.vala', + 'memory-scanner.vala', + 'interceptor.vala', + 'rust-module.vala', + 'arch-x86' / 'machine.vala', + 'arch-x86_64' / 'machine.vala', + 'arch-arm' / 'machine.vala', + 'arch-arm64' / 'machine.vala', + 'arch-unknown' / 'machine.vala', +) +barebone_script_runtime = custom_target('frida-barebone-script-runtime', + input: [ + 'package.json', + 'package-lock.json', + 'script-runtime' / 'console.ts', + 'script-runtime' / 'entrypoint.ts', + 'script-runtime' / 'gdb.ts', + 'script-runtime' / 'hexdump.ts', + 'script-runtime' / 'message-dispatcher.ts', + 'script-runtime' / 'primitives.ts', + ], + output: [ + 'script-runtime.js', + ], + command: [ + find_program('generate-script-runtime.py'), + meson.current_source_dir(), + meson.current_build_dir(), + ], +) +backend_sources += custom_target('frida-data-barebone', + input: [ + 'barebone.resources', + barebone_script_runtime, + 'helpers/memory-scanner-arm64.elf', + ], + output: [ + 'frida-data-barebone.vapi', + 'frida-data-barebone.h', + 'frida-data-barebone.c', + 'frida-data-barebone-blob' + resource_blob_extension, + ], + command: [ + resource_compiler, + '--toolchain=' + host_toolchain, + '--machine=' + host_arch, + '-c', '@INPUT0@', + '-o', meson.current_build_dir() / 'frida-data-barebone', + '@INPUT1@', + '@INPUT2@', + ], +) -if quickjs_dep.found() - barebone_sources += files( - 'barebone-host-session.vala', - 'script.vala', - 'machine.vala', - 'allocator.vala', - 'callback.vala', - 'memory-scanner.vala', - 'interceptor.vala', - 'rust-module.vala', - 'arch-x86/machine.vala', - 'arch-x86_64/machine.vala', - 'arch-arm/machine.vala', - 'arch-arm64/machine.vala', - 'arch-unknown/machine.vala', - ) - barebone_script_runtime = custom_target('frida-barebone-script-runtime', - input: [ - 'package.json', - 'package-lock.json', - 'script-runtime/console.ts', - 'script-runtime/entrypoint.ts', - 'script-runtime/gdb.ts', - 'script-runtime/hexdump.ts', - 'script-runtime/message-dispatcher.ts', - 'script-runtime/primitives.ts', - ], - output: [ - 'script-runtime.js', - ], - command: [ - find_program('generate-script-runtime.py'), - meson.current_source_dir(), - meson.current_build_dir(), - ], - ) - barebone_data = custom_target('frida-data-barebone', - input: [ - 'barebone.resources', - barebone_script_runtime, - 'helpers/memory-scanner-arm64.elf', - ], - output: [ - 'frida-data-barebone.vapi', - 'frida-data-barebone.h', - 'frida-data-barebone.c', - 'frida-data-barebone-blob' + resource_blob_extension, - ], - command: [ - resource_compiler, - '--toolchain=' + host_toolchain, - '--machine=' + host_arch, - '-c', '@INPUT0@', - '-o', join_paths(meson.current_build_dir(), 'frida-data-barebone'), - '@INPUT1@', - '@INPUT2@', - ], - ) - barebone_sources += barebone_data - - backend_deps += quickjs_dep -endif +backend_deps += quickjs_dep diff --git a/src/compiler/meson.build b/src/compiler/meson.build index 2d166b737..42274d43a 100644 --- a/src/compiler/meson.build +++ b/src/compiler/meson.build @@ -51,7 +51,7 @@ if have_compiler_backend resource_compiler, '--toolchain=' + host_toolchain, '-c', '@INPUT0@', - '-o', join_paths(meson.current_build_dir(), 'frida-data-compiler'), + '-o', meson.current_build_dir() / 'frida-data-compiler', '@INPUT1@', '@INPUT2@', ], diff --git a/src/control-service.vala b/src/control-service.vala index cae1c9f42..02ba0a978 100644 --- a/src/control-service.vala +++ b/src/control-service.vala @@ -44,6 +44,7 @@ namespace Frida { ControlServiceOptions opts = (options != null) ? options : new ControlServiceOptions (); HostSession host_session; +#if HAVE_LOCAL_BACKEND #if WINDOWS var tempdir = new TemporaryDirectory (); host_session = new WindowsHostSession (new WindowsHelperProcess (tempdir), tempdir); @@ -62,6 +63,9 @@ namespace Frida { #if QNX host_session = new QnxHostSession (); #endif +#else + assert_not_reached (); +#endif Object ( host_session: host_session, diff --git a/src/frida.vala b/src/frida.vala index 2f07a8866..eb1e318c0 100644 --- a/src/frida.vala +++ b/src/frida.vala @@ -3229,6 +3229,7 @@ namespace Frida { public signal void uninjected (uint id); public static Injector new () { +#if HAVE_LOCAL_BACKEND #if WINDOWS var tempdir = new TemporaryDirectory (); var helper = new WindowsHelperProcess (tempdir); @@ -3249,10 +3250,14 @@ namespace Frida { #endif #if QNX return new Qinjector (); +#endif +#else + assert_not_reached (); #endif } public static Injector new_inprocess () { +#if HAVE_LOCAL_BACKEND #if WINDOWS var tempdir = new TemporaryDirectory (); var helper = new WindowsHelperBackend (PrivilegeLevel.NORMAL); @@ -3273,6 +3278,9 @@ namespace Frida { #endif #if QNX return new Qinjector (); +#endif +#else + assert_not_reached (); #endif } diff --git a/src/host-session-service.vala b/src/host-session-service.vala index 37c9863b0..224e5a9da 100644 --- a/src/host-session-service.vala +++ b/src/host-session-service.vala @@ -10,11 +10,19 @@ namespace Frida { public HostSessionService.with_default_backends () { add_local_backends (); #if !IOS && !ANDROID && !TVOS +#if HAVE_FRUITY_BACKEND add_backend (new FruityHostSessionBackend ()); +#endif +#if HAVE_DROIDY_BACKEND add_backend (new DroidyHostSessionBackend ()); #endif +#endif +#if HAVE_SOCKET_BACKEND add_backend (new SocketHostSessionBackend ()); +#endif +#if HAVE_BAREBONE_BACKEND add_backend (new BareboneHostSessionBackend ()); +#endif } public HostSessionService.with_local_backend_only () { @@ -22,10 +30,13 @@ namespace Frida { } public HostSessionService.with_socket_backend_only () { +#if HAVE_SOCKET_BACKEND add_backend (new SocketHostSessionBackend ()); +#endif } private void add_local_backends () { +#if HAVE_LOCAL_BACKEND #if WINDOWS add_backend (new WindowsHostSessionBackend ()); #endif @@ -40,6 +51,7 @@ namespace Frida { #endif #if QNX add_backend (new QnxHostSessionBackend ()); +#endif #endif } diff --git a/src/meson.build b/src/meson.build index df1ea9c7d..dc217f082 100644 --- a/src/meson.build +++ b/src/meson.build @@ -11,470 +11,472 @@ base_sources = [ 'async-task.vala', ] -windows_sources = [] -darwin_sources = [] -linux_sources = [] -freebsd_sources = [] -qnx_sources = [] - +backend_sources = [] backend_vala_args = [] backend_libs = [] backend_deps = [] -post_process_helper = post_process + ['executable', 're.frida.Helper'] - -embed_helper = [ - python, - files('embed-helper.py'), - host_os, - host_arch, - host_toolchain, - resource_compiler, - '>>>', lipo, '<<<', - meson.current_build_dir(), - '@INPUT0@', -] - -if host_os_family == 'windows' - windows_sources = [ - 'windows/windows-host-session.vala', - 'windows/windows-host-session-glue.c', - 'windows/winjector.vala', - 'windows/winjector-glue.c', - 'windows/frida-helper-process.vala', - 'windows/frida-helper-process-glue.c', - 'windows/system-windows.c', - 'windows/access-helpers.c', - 'windows/icon-helpers.c', +if 'local' in get_option('backends') + post_process_helper = post_process + ['executable', 're.frida.Helper'] + + embed_helper = [ + python, + files('embed-helper.py'), + host_os, + host_arch, + host_toolchain, + resource_compiler, + '>>>', lipo, '<<<', + meson.current_build_dir(), + '@INPUT0@', ] - helper_backend_sources = [ - 'windows/frida-helper-backend.vala', - 'windows/frida-helper-backend-glue.c', - 'windows/frida-helper-types.vala', - 'windows/wait-handle-source.c', - ] - helper_backend = static_library('frida-helper-backend', helper_backend_sources, - c_args: frida_component_cflags, - dependencies: [gio_dep, gee_dep, gum_dep, base_dep], - ) - backend_libs += helper_backend - - helper_sources = [ - 'windows/frida-helper-service.vala', - 'windows/frida-helper-service-glue.c', - ] - raw_helper = executable('frida-helper-raw', helper_sources, - link_with: helper_backend, - dependencies: [gio_dep, gee_dep, gum_dep, base_dep, pipe_dep], - ) - - helper = custom_target('frida-helper', - input: raw_helper, - output: helper_name, - command: post_process_helper, - build_by_default: true, - install: get_option('assets') == 'installed', - install_dir: asset_dir, - ) + if host_os_family == 'windows' + backend_sources += [ + 'windows' / 'windows-host-session.vala', + 'windows' / 'windows-host-session-glue.c', + 'windows' / 'winjector.vala', + 'windows' / 'winjector-glue.c', + 'windows' / 'frida-helper-process.vala', + 'windows' / 'frida-helper-process-glue.c', + 'windows' / 'system-windows.c', + 'windows' / 'access-helpers.c', + 'windows' / 'icon-helpers.c', + ] - if get_option('assets') == 'embedded' - helper_modern = get_option('helper_modern') - helper_legacy = get_option('helper_legacy') - if host_is_64bit - helper_modern = '' - else - helper_legacy = '' - endif - helper_process_data = custom_target('frida-data-helper-process', - input: 'helper.resources', - output: [ - 'frida-data-helper-process.vapi', - 'frida-data-helper-process.h', - 'frida-data-helper-process.c', - 'frida-data-helper-process-blob' + resource_blob_extension, - ], - command: embed_helper + [helper_modern, helper_legacy], + helper_backend_sources = [ + 'windows' / 'frida-helper-backend.vala', + 'windows' / 'frida-helper-backend-glue.c', + 'windows' / 'frida-helper-types.vala', + 'windows' / 'wait-handle-source.c', + ] + helper_backend = static_library('frida-helper-backend', helper_backend_sources, + c_args: frida_component_cflags, + dependencies: [gio_dep, gee_dep, gum_dep, base_dep], ) - windows_sources += [helper_process_data] - endif -endif + backend_libs += helper_backend -if host_os_family == 'darwin' - darwin_sources = [ - 'darwin/darwin-host-session.vala', - 'darwin/darwin-host-session-glue.m', - 'darwin/fruitjector.vala', - 'darwin/frida-helper-process.vala', - 'darwin/icon-helpers.m', - 'darwin/system-darwin.m', - ] - - darwin_data = custom_target('frida-data-darwin', - input: [ - 'darwin/frida-darwin.resources', - 'darwin/agent/launchd.js', - 'darwin/agent/xpcproxy.js', - 'darwin/agent/reportcrash.js', - 'darwin/agent/osanalytics.js', - ], - output: [ - 'frida-data-darwin.vapi', - 'frida-data-darwin.h', - 'frida-data-darwin.c', - 'frida-data-darwin-blob' + resource_blob_extension, - ], - command: [ - resource_compiler, - '--toolchain=apple', - '-c', '@INPUT0@', - '-o', join_paths(meson.current_build_dir(), 'frida-data-darwin'), - '@INPUT1@', - '@INPUT2@', - '@INPUT3@', - '@INPUT4@', - ], - ) - darwin_sources += [darwin_data] - - helper_backend_sources = [ - 'darwin/frida-helper-types.vala', - 'darwin/policy-softener.vala', - 'darwin/policy-softener-glue.c', - ] - if host_os in ['macos', 'ios', 'tvos'] - helper_backend_sources += [ - 'darwin/frida-helper-backend.vala', - 'darwin/frida-helper-backend-glue.m', - 'darwin/policyd.c', - 'darwin/policyd-client.c', - ] - else - helper_backend_sources += [ - 'darwin/frida-helper-null-backend.vala', - ] - endif - if host_os in ['ios', 'tvos'] - helper_backend_sources += [ - 'darwin/springboard.m', - 'darwin/substituted-client.c', - 'darwin/substituted2-client.c', + helper_sources = [ + 'windows' / 'frida-helper-service.vala', + 'windows' / 'frida-helper-service-glue.c', ] - endif - helper_backend = static_library('frida-helper-backend', helper_backend_sources, - c_args: frida_component_cflags, - vala_args: ['--pkg=frida-gum-darwin-1.0', '--pkg=posix'], - dependencies: [gmodule_dep, gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep, pipe_dep], - ) - backend_libs += [helper_backend] - - helper_sources = [ - 'darwin/frida-helper-service.vala', - 'darwin/frida-helper-service-glue.m', - ] - helper_symlist = 'darwin/frida-helper.symbols' - helper_link_args = ['-Wl,-exported_symbols_list,' + join_paths(meson.current_source_dir(), helper_symlist)] - helper_link_depends = [helper_symlist] - if host_os == 'macos' - helper_plist = 'darwin/frida-helper.plist' - helper_link_args += ['-Wl,-sectcreate,__TEXT,__info_plist,' + join_paths(meson.current_source_dir(), helper_plist)] - helper_link_depends += [helper_plist] - endif - raw_helper = executable('frida-helper-raw', helper_sources, - vala_args: ['--pkg=posix'], - link_args: helper_link_args + backend_libs_private, - link_depends: helper_link_depends, - link_with: helper_backend, - dependencies: [gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep, pipe_dep], - override_options: ['b_asneeded=false'], - ) - - helper = custom_target('frida-helper', - input: [ - raw_helper, - 'darwin/frida-helper.xcent', - ], - output: helper_name, - command: post_process_helper, - build_by_default: true, - install: get_option('assets') == 'installed', - install_dir: asset_dir, - ) + raw_helper = executable('frida-helper-raw', helper_sources, + link_with: helper_backend, + dependencies: [gio_dep, gee_dep, gum_dep, base_dep, pipe_dep], + ) - if get_option('assets') == 'embedded' - helper_modern = get_option('helper_modern') - helper_legacy = get_option('helper_legacy') - helper_inputs = ['helper.resources'] - if helper_modern == '' and helper_legacy == '' + helper = custom_target('frida-helper', + input: raw_helper, + output: helper_name, + command: post_process_helper, + build_by_default: true, + install: get_option('assets') == 'installed', + install_dir: asset_dir, + ) + + if get_option('assets') == 'embedded' + helper_modern = get_option('helper_modern') + helper_legacy = get_option('helper_legacy') if host_is_64bit - helper_modern = helper.full_path() + helper_modern = '' else - helper_legacy = helper.full_path() + helper_legacy = '' endif - helper_inputs += helper + helper_process_data = custom_target('frida-data-helper-process', + input: 'helper.resources', + output: [ + 'frida-data-helper-process.vapi', + 'frida-data-helper-process.h', + 'frida-data-helper-process.c', + 'frida-data-helper-process-blob' + resource_blob_extension, + ], + command: embed_helper + [helper_modern, helper_legacy], + ) + backend_sources += [helper_process_data] endif - helper_process_data = custom_target('frida-data-helper-process', - input: helper_inputs, + endif + + if host_os_family == 'darwin' + backend_sources += [ + 'darwin' / 'darwin-host-session.vala', + 'darwin' / 'darwin-host-session-glue.m', + 'darwin' / 'fruitjector.vala', + 'darwin' / 'frida-helper-process.vala', + 'darwin' / 'icon-helpers.m', + 'darwin' / 'system-darwin.m', + ] + + darwin_data = custom_target('frida-data-darwin', + input: [ + 'darwin' / 'frida-darwin.resources', + 'darwin' / 'agent' / 'launchd.js', + 'darwin' / 'agent' / 'xpcproxy.js', + 'darwin' / 'agent' / 'reportcrash.js', + 'darwin' / 'agent' / 'osanalytics.js', + ], output: [ - 'frida-data-helper-process.vapi', - 'frida-data-helper-process.h', - 'frida-data-helper-process.c', - 'frida-data-helper-process-blob' + resource_blob_extension, + 'frida-data-darwin.vapi', + 'frida-data-darwin.h', + 'frida-data-darwin.c', + 'frida-data-darwin-blob' + resource_blob_extension, + ], + command: [ + resource_compiler, + '--toolchain=apple', + '-c', '@INPUT0@', + '-o', join_paths(meson.current_build_dir(), 'frida-data-darwin'), + '@INPUT1@', + '@INPUT2@', + '@INPUT3@', + '@INPUT4@', ], - command: embed_helper + [helper_modern, helper_legacy], ) - darwin_sources += [helper_process_data] - endif + backend_sources += [darwin_data] - backend_vala_args += ['--pkg=posix'] -endif + helper_backend_sources = [ + 'darwin' / 'frida-helper-types.vala', + 'darwin' / 'policy-softener.vala', + 'darwin' / 'policy-softener-glue.c', + ] + if host_os in ['macos', 'ios', 'tvos'] + helper_backend_sources += [ + 'darwin' / 'frida-helper-backend.vala', + 'darwin' / 'frida-helper-backend-glue.m', + 'darwin' / 'policyd.c', + 'darwin' / 'policyd-client.c', + ] + else + helper_backend_sources += [ + 'darwin' / 'frida-helper-null-backend.vala', + ] + endif + if host_os in ['ios', 'tvos'] + helper_backend_sources += [ + 'darwin' / 'springboard.m', + 'darwin' / 'substituted-client.c', + 'darwin' / 'substituted2-client.c', + ] + endif + helper_backend = static_library('frida-helper-backend', helper_backend_sources, + c_args: frida_component_cflags, + vala_args: ['--pkg=frida-gum-darwin-1.0', '--pkg=posix'], + dependencies: [gmodule_dep, gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep, pipe_dep], + ) + backend_libs += [helper_backend] -if host_os_family == 'linux' - linux_sources = [ - 'linux/linux-host-session.vala', - 'linux/linjector.vala', - 'linux/linjector-glue.c', - 'linux/frida-helper-process.vala', - 'linux/supersu.vala', - 'linux/system-linux.c', - ] + helper_sources = [ + 'darwin' / 'frida-helper-service.vala', + 'darwin' / 'frida-helper-service-glue.m', + ] + helper_symlist = 'darwin/frida-helper.symbols' + helper_link_args = ['-Wl,-exported_symbols_list,' + join_paths(meson.current_source_dir(), helper_symlist)] + helper_link_depends = [helper_symlist] + if host_os == 'macos' + helper_plist = 'darwin/frida-helper.plist' + helper_link_args += ['-Wl,-sectcreate,__TEXT,__info_plist,' + join_paths(meson.current_source_dir(), helper_plist)] + helper_link_depends += [helper_plist] + endif + raw_helper = executable('frida-helper-raw', helper_sources, + vala_args: ['--pkg=posix'], + link_args: helper_link_args + backend_libs_private, + link_depends: helper_link_depends, + link_with: helper_backend, + dependencies: [gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep, pipe_dep], + override_options: ['b_asneeded=false'], + ) - if host_os == 'android' - backend_vala_args += frida_selinux_vala_args - backend_libs += frida_selinux - backend_deps += frida_selinux_dep + helper = custom_target('frida-helper', + input: [ + raw_helper, + 'darwin' / 'frida-helper.xcent', + ], + output: helper_name, + command: post_process_helper, + build_by_default: true, + install: get_option('assets') == 'installed', + install_dir: asset_dir, + ) - android_data = custom_target('frida-data-android', + if get_option('assets') == 'embedded' + helper_modern = get_option('helper_modern') + helper_legacy = get_option('helper_legacy') + helper_inputs = ['helper.resources'] + if helper_modern == '' and helper_legacy == '' + if host_is_64bit + helper_modern = helper.full_path() + else + helper_legacy = helper.full_path() + endif + helper_inputs += helper + endif + helper_process_data = custom_target('frida-data-helper-process', + input: helper_inputs, + output: [ + 'frida-data-helper-process.vapi', + 'frida-data-helper-process.h', + 'frida-data-helper-process.c', + 'frida-data-helper-process-blob' + resource_blob_extension, + ], + command: embed_helper + [helper_modern, helper_legacy], + ) + backend_sources += [helper_process_data] + endif + endif + + if host_os_family == 'linux' + backend_sources += [ + 'linux' / 'linux-host-session.vala', + 'linux' / 'linjector.vala', + 'linux' / 'linjector-glue.c', + 'linux' / 'frida-helper-process.vala', + 'linux' / 'supersu.vala', + 'linux' / 'system-linux.c', + ] + + if host_os == 'android' + backend_vala_args += frida_selinux_vala_args + backend_libs += frida_selinux + backend_deps += frida_selinux_dep + + android_data = custom_target('frida-data-android', + input: [ + 'linux' / 'frida-android.resources', + 'linux' / 'agent' / 'system-server.js', + ], + output: [ + 'frida-data-android.vapi', + 'frida-data-android.h', + 'frida-data-android.c', + 'frida-data-android-blob' + resource_blob_extension, + ], + command: [ + resource_compiler, + '--toolchain=gnu', + '-c', '@INPUT0@', + '-o', join_paths(meson.current_build_dir(), 'frida-data-android'), + '@INPUT1@', + ], + ) + backend_sources += [android_data] + endif + + helper_backend_sources = [ + 'linux' / 'frida-helper-backend.vala', + 'linux' / 'frida-helper-backend-glue.c', + 'linux' / 'frida-helper-backend-types.c', + 'linux' / 'frida-helper-types.vala', + ] + if host_abi == 'armhf' + host_lowlevel_abi = 'arm' + else + host_lowlevel_abi = host_abi + endif + bootstrapper_bin = custom_target('frida-bootstrapper-bin', + input: ['linux' / 'helpers' / f'bootstrapper-@host_lowlevel_abi@.bin'], + output: ['bootstrapper.bin'], + command: ['cp', '@INPUT0@', '@OUTPUT0@'], + ) + loader_bin = custom_target('frida-loader-bin', + input: ['linux' / 'helpers' / f'loader-@host_lowlevel_abi@.bin'], + output: ['loader.bin'], + command: ['cp', '@INPUT0@', '@OUTPUT0@'], + ) + helper_backend_data = custom_target('frida-data-helper-backend', input: [ - 'linux/frida-android.resources', - 'linux/agent/system-server.js', + 'linux' / 'frida-helper-backend.resources', + bootstrapper_bin, + loader_bin, ], output: [ - 'frida-data-android.vapi', - 'frida-data-android.h', - 'frida-data-android.c', - 'frida-data-android-blob' + resource_blob_extension, + 'frida-data-helper-backend.vapi', + 'frida-data-helper-backend.h', + 'frida-data-helper-backend.c', + 'frida-data-helper-backend-blob' + resource_blob_extension, ], command: [ resource_compiler, '--toolchain=gnu', '-c', '@INPUT0@', - '-o', join_paths(meson.current_build_dir(), 'frida-data-android'), + '-o', join_paths(meson.current_build_dir(), 'frida-data-helper-backend'), '@INPUT1@', + '@INPUT2@', + ], + ) + helper_backend_sources += [helper_backend_data] + helper_backend_extra_deps = [] + if host_os == 'android' + helper_backend_extra_deps += [frida_selinux_dep] + endif + helper_backend = static_library('frida-helper-backend', helper_backend_sources, + c_args: frida_component_cflags, + vala_args: [ + '--vapidir=' + (meson.current_source_dir() / 'linux'), + '--pkg=frida-sysapi', + '--pkg=posix', + '--pkg=linux', + '--pkg=frida-gum-linux-1.0', ], + dependencies: [gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep] + helper_backend_extra_deps, ) - linux_sources += [android_data] + backend_libs += [helper_backend] + + helper_sources = [ + 'linux' / 'frida-helper-service.vala', + ] + helper_symscript = 'linux/frida-helper.version' + helper_link_args = ['-Wl,--version-script,' + join_paths(meson.current_source_dir(), helper_symscript)] + helper_link_depends = [helper_symscript] + raw_helper = executable('frida-helper-raw', helper_sources, + vala_args: ['--pkg=posix'], + link_args: helper_link_args, + link_depends: helper_link_depends, + link_with: helper_backend, + dependencies: [gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep], + ) + + helper = custom_target('frida-helper', + input: raw_helper, + output: helper_name, + command: post_process_helper, + build_by_default: true, + install: get_option('assets') == 'installed', + install_dir: asset_dir, + ) + + if get_option('assets') == 'embedded' + helper_modern = get_option('helper_modern') + helper_legacy = get_option('helper_legacy') + if host_is_64bit + helper_modern = '' + else + helper_legacy = '' + endif + helper_process_data = custom_target('frida-data-helper-process', + input: 'helper.resources', + output: [ + 'frida-data-helper-process.vapi', + 'frida-data-helper-process.h', + 'frida-data-helper-process.c', + 'frida-data-helper-process-blob' + resource_blob_extension, + ], + command: embed_helper + [helper_modern, helper_legacy], + ) + backend_sources += [helper_process_data] + endif + + backend_vala_args += '--pkg=frida-gum-linux-1.0' endif - helper_backend_sources = [ - 'linux/frida-helper-backend.vala', - 'linux/frida-helper-backend-glue.c', - 'linux/frida-helper-backend-types.c', - 'linux/frida-helper-types.vala', - ] - if host_abi == 'armhf' - host_lowlevel_abi = 'arm' - else - host_lowlevel_abi = host_abi + if host_os_family == 'freebsd' + backend_sources += [ + 'freebsd' / 'freebsd-host-session.vala', + 'freebsd' / 'binjector.vala', + 'freebsd' / 'binjector-glue.c', + 'freebsd' / 'system-freebsd.c', + ] + backend_vala_args += '--pkg=frida-gum-freebsd-1.0' endif - bootstrapper_bin = custom_target('frida-bootstrapper-bin', - input: ['linux/helpers/bootstrapper-' + host_lowlevel_abi + '.bin'], - output: ['bootstrapper.bin'], - command: ['cp', '@INPUT0@', '@OUTPUT0@'], - ) - loader_bin = custom_target('frida-loader-bin', - input: ['linux/helpers/loader-' + host_lowlevel_abi + '.bin'], - output: ['loader.bin'], - command: ['cp', '@INPUT0@', '@OUTPUT0@'], - ) - helper_backend_data = custom_target('frida-data-helper-backend', - input: [ - 'linux/frida-helper-backend.resources', - bootstrapper_bin, - loader_bin, - ], - output: [ - 'frida-data-helper-backend.vapi', - 'frida-data-helper-backend.h', - 'frida-data-helper-backend.c', - 'frida-data-helper-backend-blob' + resource_blob_extension, - ], - command: [ - resource_compiler, - '--toolchain=gnu', - '-c', '@INPUT0@', - '-o', join_paths(meson.current_build_dir(), 'frida-data-helper-backend'), - '@INPUT1@', - '@INPUT2@', - ], - ) - helper_backend_sources += [helper_backend_data] - helper_backend_extra_deps = [] - if host_os == 'android' - helper_backend_extra_deps += [frida_selinux_dep] + + if host_os_family == 'qnx' + backend_sources += [ + 'qnx' / 'qnx-host-session.vala', + 'qnx' / 'qinjector.vala', + 'qnx' / 'qinjector-glue.c', + 'qnx' / 'system-qnx.c', + ] endif - helper_backend = static_library('frida-helper-backend', helper_backend_sources, - c_args: frida_component_cflags, - vala_args: [ - '--vapidir=' + (meson.current_source_dir() / 'linux'), - '--pkg=frida-sysapi', - '--pkg=posix', - '--pkg=linux', - '--pkg=frida-gum-linux-1.0', - ], - dependencies: [gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep] + helper_backend_extra_deps, - ) - backend_libs += [helper_backend] - - helper_sources = [ - 'linux/frida-helper-service.vala', - ] - helper_symscript = 'linux/frida-helper.version' - helper_link_args = ['-Wl,--version-script,' + join_paths(meson.current_source_dir(), helper_symscript)] - helper_link_depends = [helper_symscript] - raw_helper = executable('frida-helper-raw', helper_sources, - vala_args: ['--pkg=posix'], - link_args: helper_link_args, - link_depends: helper_link_depends, - link_with: helper_backend, - dependencies: [gio_dep, gio_unix_dep, gee_dep, gum_dep, base_dep], - ) - - helper = custom_target('frida-helper', - input: raw_helper, - output: helper_name, - command: post_process_helper, - build_by_default: true, - install: get_option('assets') == 'installed', - install_dir: asset_dir, - ) if get_option('assets') == 'embedded' - helper_modern = get_option('helper_modern') - helper_legacy = get_option('helper_legacy') - if host_is_64bit - helper_modern = '' - else - helper_legacy = '' + agent_modern = get_option('agent_modern') + agent_legacy = get_option('agent_legacy') + agent_inputs = ['agent.resources'] + if agent_modern == '' and agent_legacy == '' + if host_is_64bit + agent_modern = agent.full_path() + else + agent_legacy = agent.full_path() + endif + agent_inputs += agent endif - helper_process_data = custom_target('frida-data-helper-process', - input: 'helper.resources', + backend_sources += custom_target('frida-data-agent', + input: agent_inputs, output: [ - 'frida-data-helper-process.vapi', - 'frida-data-helper-process.h', - 'frida-data-helper-process.c', - 'frida-data-helper-process-blob' + resource_blob_extension, + 'frida-data-agent.vapi', + 'frida-data-agent.h', + 'frida-data-agent.c', + 'frida-data-agent-blob' + resource_blob_extension, + ], + command: [ + python, + files('embed-agent.py'), + host_os, + host_arch, + host_toolchain, + resource_compiler, + '>>>', lipo, '<<<', + meson.current_build_dir(), + '@INPUT0@', + agent_modern, + agent_legacy, + get_option('agent_emulated_modern'), + get_option('agent_emulated_legacy'), + get_option('agent_dbghelp_prefix'), + get_option('agent_symsrv_prefix'), ], - command: embed_helper + [helper_modern, helper_legacy], ) - linux_sources += [helper_process_data] endif - - backend_vala_args += ['--pkg=posix', '--pkg=frida-gum-linux-1.0'] endif -if host_os_family == 'freebsd' - freebsd_sources = [ - 'freebsd/freebsd-host-session.vala', - 'freebsd/binjector.vala', - 'freebsd/binjector-glue.c', - 'freebsd/system-freebsd.c', +if 'fruity' in get_option('backends') + backend_sources += [ + 'fruity' / 'fruity-host-session.vala', + 'fruity' / 'dtx.vala', + 'fruity' / 'lockdown.vala', + 'fruity' / 'installation-proxy.vala', + 'fruity' / 'springboard-services.vala', + 'fruity' / 'lldb.vala', + 'fruity' / 'injector.vala', + 'fruity' / 'usbmux.vala', + 'fruity' / 'keyed-archive.vala', + 'fruity' / 'plist.vala', + 'fruity' / 'plist-service.vala', ] - backend_vala_args += ['--pkg=posix', '--pkg=frida-gum-freebsd-1.0'] + if host_os_family == 'windows' + backend_sources += 'fruity' / 'fruity-host-session-windows.c' + elif host_os_family == 'darwin' + backend_sources += 'fruity' / 'fruity-host-session-darwin.m' + else + backend_sources += 'fruity' / 'fruity-host-session-unix.c' + endif endif -if host_os_family == 'qnx' - qnx_sources = [ - 'qnx/qnx-host-session.vala', - 'qnx/qinjector.vala', - 'qnx/qinjector-glue.c', - 'qnx/system-qnx.c', +if 'droidy' in get_option('backends') + backend_sources += [ + 'droidy' / 'droidy-host-session.vala', + 'droidy' / 'droidy-client.vala', + 'droidy' / 'jdwp.vala', + 'droidy' / 'injector.vala', + 'droidy' / 'axml.vala', ] - backend_vala_args += ['--pkg=posix'] endif -if get_option('assets') == 'embedded' - agent_modern = get_option('agent_modern') - agent_legacy = get_option('agent_legacy') - agent_inputs = ['agent.resources'] - if agent_modern == '' and agent_legacy == '' - if host_is_64bit - agent_modern = agent.full_path() - else - agent_legacy = agent.full_path() - endif - agent_inputs += agent - endif - agent_data = custom_target('frida-data-agent', - input: agent_inputs, - output: [ - 'frida-data-agent.vapi', - 'frida-data-agent.h', - 'frida-data-agent.c', - 'frida-data-agent-blob' + resource_blob_extension, - ], - command: [ - python, - files('embed-agent.py'), - host_os, - host_arch, - host_toolchain, - resource_compiler, - '>>>', lipo, '<<<', - meson.current_build_dir(), - '@INPUT0@', - agent_modern, - agent_legacy, - get_option('agent_emulated_modern'), - get_option('agent_emulated_legacy'), - get_option('agent_dbghelp_prefix'), - get_option('agent_symsrv_prefix'), - ], - ) -else - agent_data = [] +if 'socket' in get_option('backends') + backend_sources += [ + 'socket' / 'socket-host-session.vala', + ] endif -socket_sources = [ - 'socket/socket-host-session.vala', -] - -fruity_sources = [ - 'fruity/fruity-host-session.vala', - 'fruity/dtx.vala', - 'fruity/lockdown.vala', - 'fruity/installation-proxy.vala', - 'fruity/springboard-services.vala', - 'fruity/lldb.vala', - 'fruity/injector.vala', - 'fruity/usbmux.vala', - 'fruity/keyed-archive.vala', - 'fruity/plist.vala', - 'fruity/plist-service.vala', -] -if host_os_family == 'windows' - fruity_sources += ['fruity/fruity-host-session-windows.c'] -elif host_os_family == 'darwin' - fruity_sources += ['fruity/fruity-host-session-darwin.m'] -else - fruity_sources += ['fruity/fruity-host-session-unix.c'] +if 'barebone' in get_option('backends') and quickjs_dep.found() + subdir('barebone') endif -droidy_sources = [ - 'droidy/droidy-host-session.vala', - 'droidy/droidy-client.vala', - 'droidy/jdwp.vala', - 'droidy/injector.vala', - 'droidy/axml.vala', -] +if host_os_family != 'windows' + backend_vala_args += ['--pkg=posix'] +endif -subdir('barebone') subdir('compiler') -local_sources = windows_sources + darwin_sources + linux_sources + freebsd_sources + qnx_sources + [agent_data] -remote_sources = socket_sources + fruity_sources + droidy_sources + barebone_sources - -core_sources = base_sources + local_sources + remote_sources + compiler_sources +core_sources = base_sources + backend_sources + compiler_sources internal_libs = [base, pipe] + backend_libs internal_deps = [base_dep, pipe_dep]