mirror of
https://github.com/frida/frida-python
synced 2026-06-08 14:16:17 +00:00
meson: Simplify the build system
- Make full use of Meson's Python module. - Drop python_incdir option. It's now possible to use a .pc file to specify the include path. - Drop config.h, as we only needed it for HAVE_MACOS, which we can easily check for in the single location that we need it.
This commit is contained in:
-19
@@ -1,19 +0,0 @@
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if OS is Android based. */
|
||||
#mesondefine HAVE_ANDROID
|
||||
|
||||
/* Define to 1 if OS is Darwin based. */
|
||||
#mesondefine HAVE_DARWIN
|
||||
|
||||
/* Define to 1 if OS is iOS. */
|
||||
#mesondefine HAVE_IOS
|
||||
|
||||
/* Define to 1 if OS is Linux based. */
|
||||
#mesondefine HAVE_LINUX
|
||||
|
||||
/* Define to 1 if OS is macOS. */
|
||||
#mesondefine HAVE_MACOS
|
||||
|
||||
/* Define to 1 if OS is QNX based. */
|
||||
#mesondefine HAVE_QNX
|
||||
+1
-1
@@ -3,4 +3,4 @@ frida_sources = [
|
||||
'core.py',
|
||||
]
|
||||
|
||||
install_data(frida_sources, install_dir: join_paths(python_site_packages, 'frida'))
|
||||
python.install_sources(frida_sources, subdir: 'frida', pure: false)
|
||||
|
||||
+4
-70
@@ -1,11 +1,6 @@
|
||||
project('frida-python', 'c', version: '1.0.0')
|
||||
|
||||
host_os = host_machine.system()
|
||||
if host_os == 'android'
|
||||
host_os_family = 'linux'
|
||||
else
|
||||
host_os_family = host_os
|
||||
endif
|
||||
python = import('python').find_installation()
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
@@ -19,76 +14,15 @@ if ndebug == 'true' or (ndebug == 'if-release' and not get_option('debug'))
|
||||
]
|
||||
endif
|
||||
|
||||
target_conditionals_prefix = '#include <TargetConditionals.h>'
|
||||
|
||||
is_macos_src = target_conditionals_prefix + '''
|
||||
#if !TARGET_OS_OSX
|
||||
# error Not macOS
|
||||
#endif
|
||||
'''
|
||||
if cc.compiles(is_macos_src, name: 'compiling for macOS')
|
||||
host_os = 'macos'
|
||||
endif
|
||||
|
||||
is_ios_src = target_conditionals_prefix + '''
|
||||
#if !TARGET_OS_IOS
|
||||
# error Not iOS
|
||||
#endif
|
||||
'''
|
||||
if cc.compiles(is_ios_src, name: 'compiling for iOS')
|
||||
host_os = 'ios'
|
||||
endif
|
||||
|
||||
if cc.has_header('android/api-level.h')
|
||||
host_os = 'android'
|
||||
endif
|
||||
|
||||
python = import('python').find_installation()
|
||||
|
||||
python_incdir = get_option('python_incdir')
|
||||
if python_incdir == ''
|
||||
result = run_command(python, '-c',
|
||||
'import sys; sys.stdout.write(f"{sys.version_info[0]}.{sys.version_info[1]}")',
|
||||
check: true)
|
||||
python_version = result.stdout()
|
||||
python_name = 'python' + python_version
|
||||
|
||||
result = run_command(python, '-c',
|
||||
'from distutils import sysconfig; import sys; sys.stdout.write(sysconfig.get_python_inc())',
|
||||
check: true)
|
||||
python_incdir = result.stdout()
|
||||
else
|
||||
py_major_v = cc.get_define('PY_MAJOR_VERSION',
|
||||
prefix: '#include <patchlevel.h>',
|
||||
args: ['-I' + python_incdir])
|
||||
|
||||
py_minor_v = cc.get_define('PY_MINOR_VERSION',
|
||||
prefix: '#include <patchlevel.h>',
|
||||
args: ['-I' + python_incdir])
|
||||
|
||||
python_version = py_major_v + '.' + py_minor_v
|
||||
python_name = 'python' + python_version
|
||||
endif
|
||||
|
||||
python_site_packages = join_paths(get_option('libdir'), python_name, 'site-packages')
|
||||
|
||||
cdata = configuration_data()
|
||||
|
||||
cdata.set('HAVE_' + host_os_family.to_upper(), 1)
|
||||
if host_os != host_os_family
|
||||
cdata.set('HAVE_' + host_os.to_upper(), 1)
|
||||
endif
|
||||
|
||||
python_dep = python.dependency()
|
||||
frida_core_dep = dependency('frida-core-1.0')
|
||||
|
||||
os_deps = []
|
||||
host_os_family = host_machine.system()
|
||||
if host_os_family != 'windows'
|
||||
os_deps += dependency('gio-unix-2.0')
|
||||
endif
|
||||
|
||||
configure_file(input: 'config.h.in',
|
||||
output: 'config.h',
|
||||
configuration: cdata)
|
||||
|
||||
subdir('src')
|
||||
subdir('frida')
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
option('python_incdir',
|
||||
type: 'string',
|
||||
value: '',
|
||||
description: 'Python headers directory to build against'
|
||||
)
|
||||
+5
-3
@@ -16,7 +16,6 @@
|
||||
# undef _POSIX_C_SOURCE
|
||||
#endif
|
||||
|
||||
#define Py_LIMITED_API 0x03070000
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
|
||||
/*
|
||||
@@ -39,8 +38,11 @@
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning (pop)
|
||||
#endif
|
||||
#ifdef HAVE_MACOS
|
||||
# include <crt_externs.h>
|
||||
#ifdef __APPLE__
|
||||
# include <TargetConditionals.h>
|
||||
# if TARGET_OS_OSX
|
||||
# include <crt_externs.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define PyUnicode_FromUTF8String(str) PyUnicode_DecodeUTF8 (str, strlen (str), "strict")
|
||||
|
||||
+5
-8
@@ -1,17 +1,14 @@
|
||||
extra_link_args = []
|
||||
if host_os_family == 'darwin'
|
||||
extra_link_args += ['-Wl,-exported_symbol,_PyInit__frida']
|
||||
extra_link_args += '-Wl,-exported_symbol,_PyInit__frida'
|
||||
elif host_os_family != 'windows'
|
||||
extra_link_args += ['-Wl,--version-script,' + join_paths(meson.current_source_dir(), '_frida.version')]
|
||||
extra_link_args += '-Wl,--version-script,' + meson.current_source_dir() / '_frida.version'
|
||||
endif
|
||||
|
||||
extension = shared_module('_frida', '_frida.c',
|
||||
name_prefix: '',
|
||||
name_suffix: 'so',
|
||||
extension = python.extension_module('_frida', '_frida.c',
|
||||
limited_api: '3.7',
|
||||
c_args: frida_component_cflags,
|
||||
include_directories: include_directories(python_incdir),
|
||||
link_args: extra_link_args,
|
||||
dependencies: [frida_core_dep] + os_deps,
|
||||
dependencies: [python_dep, frida_core_dep, os_deps],
|
||||
install: true,
|
||||
install_dir: python_site_packages,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user