From dc5e50c5b144d782b79a38a44060e7f3524b7fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Tue, 5 Mar 2024 16:00:42 +0100 Subject: [PATCH] meson: Add support for building devkits --- meson.build | 32 ++++++++++++++++++++++++++++++++ meson.options | 7 +++++++ src/devkit/meson.build | 26 ++++++++++++++++++++++++++ src/meson.build | 3 +++ 4 files changed, 68 insertions(+) create mode 100644 src/devkit/meson.build diff --git a/meson.build b/meson.build index 5b124bd3d..ee1ecf0f2 100644 --- a/meson.build +++ b/meson.build @@ -412,6 +412,38 @@ else codesign = '' endif +if get_option('devkits').length() != 0 + if get_option('default_library') != 'static' + error('Devkits can only be generated from static libraries') + endif + mkdevkit = find_program('./releng/mkdevkit.py') + uninstalled_dir = meson.global_build_root() / 'meson-uninstalled' + devkit_options = [ + '--cc=' + '!'.join(cc.cmd_array()), + '--c-args=' + '!'.join(get_option('c_args')), + '--pkg-config-path=' + '!'.join([uninstalled_dir] + get_option('pkg_config_path')), + ] + if host_toolchain == 'microsoft' + static_lib_prefix = '' + static_lib_suffix = '.lib' + devkit_options += ['--lib=' + lib.full_path()] + else + static_lib_prefix = 'lib' + static_lib_suffix = '.a' + devkit_options += [ + '--ar=' + ar.full_path(), + '--nm=' + nm.full_path(), + ] + objcopy = find_program('objcopy', required: false) + if objcopy.found() + devkit_options += '--objcopy=' + objcopy.full_path() + endif + endif + if host_os_family == 'darwin' + devkit_options += ['--libtool=' + libtool.full_path()] + endif +endif + modulate = [ python, files('tools/modulate.py'), diff --git a/meson.options b/meson.options index 6afcbbfbb..6ecb3fada 100644 --- a/meson.options +++ b/meson.options @@ -98,6 +98,13 @@ option('compiler_snapshot', description: 'Speed up compiler startup by using a snapshot' ) +option('devkits', + type: 'array', + choices: ['core'], + value: [], + description: 'Devkits to build' +) + option('tests', type: 'feature', value: 'auto', diff --git a/src/devkit/meson.build b/src/devkit/meson.build new file mode 100644 index 000000000..6950ed82d --- /dev/null +++ b/src/devkit/meson.build @@ -0,0 +1,26 @@ +devkit_outputs = [ + 'frida-core.h', + static_lib_prefix + 'frida-core' + static_lib_suffix, + 'frida-core-example.c', +] + +if host_toolchain == 'microsoft' + devkit_outputs += [ + 'frida-core-example.sln', + 'frida-core-example.vcxproj', + 'frida-core-example.vcxproj.filters', + ] +endif + +custom_target('core-devkit', + input: core_public, + output: devkit_outputs, + command: [ + mkdevkit, + 'frida-core', + f'@host_os@-@host_arch@', + meson.current_build_dir(), + ] + devkit_options, + install: true, + install_dir: get_option('libdir') / 'frida' / 'devkits' / 'core' +) diff --git a/src/meson.build b/src/meson.build index 172895bc6..df1ea9c7d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -518,3 +518,6 @@ core_dep = declare_dependency( core_build_dir = meson.current_build_dir() subdir('api') +if 'core' in get_option('devkits') + subdir('devkit') +endif