Back to development
[platform/upstream/gstreamer.git] / subprojects / gst-python / meson.build
1 project('gst-python', 'c',
2   version : '1.22.7.1',
3   meson_version : '>= 0.62',
4   default_options : [ 'warning_level=1',
5                       'c_std=gnu99',
6                       'buildtype=debugoptimized' ])
7
8 gst_version = meson.project_version()
9 version_arr = gst_version.split('.')
10 gst_version_major = version_arr[0]
11 gst_version_minor = version_arr[1]
12 api_version = '@0@.0'.format(gst_version_major)
13
14 add_project_arguments('-DHAVE_CONFIG_H', language: 'c')
15
16 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
17
18 gst_dep = dependency('gstreamer-1.0', version : gst_req,
19   fallback : ['gstreamer', 'gst_dep'])
20 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
21   fallback : ['gstreamer', 'gst_base_dep'])
22 gmodule_dep = dependency('gmodule-no-export-2.0')
23 pygobject_dep = dependency('pygobject-3.0', fallback: ['pygobject', 'pygobject_dep'], version : '>= 3.8')
24
25 pymod = import('python')
26 python = pymod.find_installation(get_option('python'))
27 pythonver = python.language_version()
28 if pythonver.version_compare('<3.0')
29   error('Python2 is not supported anymore, please port your code to python3 (@0@ specified)'.format(python.language_version()))
30 endif
31
32 python_dep = python.dependency(embed:true, required : true)
33
34 python_abi_flags = python.get_variable('ABIFLAGS', '')
35 pylib_loc = get_option('libpython-dir')
36 if pylib_loc == ''
37   fsmod = import('fs')
38   pylib_loc = python.get_variable('LIBPL', '')
39   if host_machine.system() != 'windows' and host_machine.system() != 'darwin'
40     pylib_ldlibrary = python.get_variable('LDLIBRARY', '')
41     if not fsmod.exists(pylib_loc / pylib_ldlibrary)
42       # Workaround for Fedora
43       pylib_loc = python.get_variable('LIBDIR', '')
44       message('pylib_loc = @0@'.format(pylib_loc))
45     endif
46
47     if not fsmod.exists(pylib_loc / pylib_ldlibrary)
48       error('Python dynamic library path could not be determined')
49     endif
50   endif
51 endif
52
53 message('python_abi_flags = @0@'.format(python_abi_flags))
54 message('pylib_loc = @0@'.format(pylib_loc))
55
56 pygi_override_dir = get_option('pygi-overrides-dir')
57
58 if pygi_override_dir == ''
59   pygi_override_dir = python.get_install_dir(
60     subdir : join_paths('gi', 'overrides'),
61     pure: false
62   )
63 endif
64
65 message('pygobject overrides directory = @0@'.format(pygi_override_dir))
66
67 # libdir has to be built from pieces.
68 libdir = get_option('prefix')+'/'+get_option('libdir')
69
70
71 pylib_suffix = 'so'
72 if host_machine.system() == 'windows'
73   pylib_suffix = 'dll'
74 elif host_machine.system() == 'darwin'
75   pylib_suffix = 'dylib'
76 endif
77 cdata = configuration_data()
78 cdata.set('PACKAGE', '"gst-python"')
79 cdata.set('VERSION', '"@0@"'.format(gst_version))
80 cdata.set('GST_PACKAGE_NAME', '"GStreamer Python"')
81 cdata.set('PACKAGE_NAME', '"GStreamer Python"')
82 cdata.set('GST_API_VERSION', '"@0@"'.format(api_version))
83 cdata.set('PLUGINDIR', '"@0@/gstreamer-1.0"'.format(libdir))
84 cdata.set('PY_LIB_LOC', '"@0@"'.format(pylib_loc))
85 cdata.set('PY_ABI_FLAGS', '"@0@"'.format(python_abi_flags))
86 cdata.set('PY_LIB_SUFFIX', '"@0@"'.format(pylib_suffix))
87 cdata.set('PYTHON_VERSION', '"@0@"'.format(python_dep.version()))
88 configure_file(output : 'config.h', configuration : cdata)
89 configinc = include_directories('.')
90
91 meson.add_dist_script('scripts/gen-changelog.py', meson.project_name(), '1.20.0', meson.project_version())
92
93 pkgconfig = import('pkgconfig')
94 plugins_install_dir = join_paths(libdir, 'gstreamer-1.0')
95 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
96 if get_option('default_library') == 'shared'
97   # If we don't build static plugins there is no need to generate pc files
98   plugins_pkgconfig_install_dir = disabler()
99 endif
100
101 subdir('gi')
102 if not get_option('plugin').disabled()
103   if get_option('default_library') != 'static'
104     subdir('plugin')
105   else
106     warning('Python plugin not supported with `static` builds yet.')
107   endif
108 endif
109 if not get_option('tests').disabled()
110   subdir('testsuite')
111 endif