diff --git a/config.h.in b/config.h.in deleted file mode 100644 index 6233d30..0000000 --- a/config.h.in +++ /dev/null @@ -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 diff --git a/frida/meson.build b/frida/meson.build index 0b36e11..5e35250 100644 --- a/frida/meson.build +++ b/frida/meson.build @@ -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) diff --git a/meson.build b/meson.build index 30f36bf..a52f13f 100644 --- a/meson.build +++ b/meson.build @@ -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 ' - -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 ', - args: ['-I' + python_incdir]) - - py_minor_v = cc.get_define('PY_MINOR_VERSION', - prefix: '#include ', - 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') diff --git a/meson.options b/meson.options deleted file mode 100644 index 8e3179f..0000000 --- a/meson.options +++ /dev/null @@ -1,5 +0,0 @@ -option('python_incdir', - type: 'string', - value: '', - description: 'Python headers directory to build against' -) diff --git a/src/_frida.c b/src/_frida.c index 5510bb2..ab34500 100644 --- a/src/_frida.c +++ b/src/_frida.c @@ -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 +#ifdef __APPLE__ +# include +# if TARGET_OS_OSX +# include +# endif #endif #define PyUnicode_FromUTF8String(str) PyUnicode_DecodeUTF8 (str, strlen (str), "strict") diff --git a/src/meson.build b/src/meson.build index 54abafc..acb6085 100644 --- a/src/meson.build +++ b/src/meson.build @@ -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, )