• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SPDX-License-Identifier: GPL-2.0
2#
3# Copyright (c) 2023 Daniel Wagner, SUSE LLC
4
5want_python = get_option('python')
6if want_python != 'false'
7    python3 = import('python').find_installation('python3')
8    py3_dep = python3.dependency(required: want_python == 'true')
9    swig = find_program('swig', required: want_python == 'true')
10    header_found = cc.has_header('Python.h', dependencies: py3_dep)
11    have_python_support = py3_dep.found() and swig.found() and header_found
12else
13    have_python_support = false
14endif
15
16if have_python_support
17    pymod_swig = custom_target(
18        'ctracecmd.py',
19        input:   ['ctracecmd.i'],
20        output:  ['ctracecmd.py', 'ctracecmd_wrap.c'],
21        command: [
22            swig,
23            '-python',
24            '-I' + meson.current_source_dir() + '/../include/trace-cmd',
25            '-I' + meson.current_source_dir() + '/../lib/trace-cmd/include/private',
26            '-I' + libtraceevent_dep.get_pkgconfig_variable('prefix') + '/include/traceevent',
27            '-o', '@OUTPUT1@',
28            '@INPUT0@'],
29        install: true,
30        install_dir: [ python3.get_install_dir(pure: false, subdir: 'trace-cmd'), false])
31
32    incdir_py = include_directories(['.', '../include/trace-cmd', '../lib/trace-cmd/include/private'])
33
34    pyctracecmd_clib = python3.extension_module(
35        '_ctracecmd',
36        pymod_swig[1],
37        dependencies : [libtraceevent_dep, libtracefs_dep, py3_dep],
38        include_directories: [incdir, incdir_py],
39        install: true,
40        subdir: 'trace-cmd')
41endif
42