209b2d7a94f8c05ac6e19b46a53889483608a967
[platform/upstream/gstreamer.git] / subprojects / gst-python / meson.build
1 project('gst-python', 'c',
2   version : '1.21.2.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   )
62 endif
63
64 message('pygobject overrides directory = @0@'.format(pygi_override_dir))
65
66 # libdir has to be built from pieces.
67 libdir = get_option('prefix')+'/'+get_option('libdir')
68
69
70 pylib_suffix = 'so'
71 if host_machine.system() == 'windows'
72   pylib_suffix = 'dll'
73 elif host_machine.system() == 'darwin'
74   pylib_suffix = 'dylib'
75 endif
76 cdata = configuration_data()
77 cdata.set('PACKAGE', '"gst-python"')
78 cdata.set('VERSION', '"@0@"'.format(gst_version))
79 cdata.set('GST_PACKAGE_NAME', '"GStreamer Python"')
80 cdata.set('PACKAGE_NAME', '"GStreamer Python"')
81 cdata.set('GST_API_VERSION', '"@0@"'.format(api_version))
82 cdata.set('PLUGINDIR', '"@0@/gstreamer-1.0"'.format(libdir))
83 cdata.set('PY_LIB_LOC', '"@0@"'.format(pylib_loc))
84 cdata.set('PY_ABI_FLAGS', '"@0@"'.format(python_abi_flags))
85 cdata.set('PY_LIB_SUFFIX', '"@0@"'.format(pylib_suffix))
86 cdata.set('PYTHON_VERSION', '"@0@"'.format(python_dep.version()))
87 configure_file(output : 'config.h', configuration : cdata)
88 configinc = include_directories('.')
89
90 pkgconfig = import('pkgconfig')
91 plugins_install_dir = join_paths(libdir, 'gstreamer-1.0')
92 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
93 if get_option('default_library') == 'shared'
94   # If we don't build static plugins there is no need to generate pc files
95   plugins_pkgconfig_install_dir = disabler()
96 endif
97
98 subdir('gi')
99 if not get_option('plugin').disabled()
100   if get_option('default_library') != 'static'
101     subdir('plugin')
102   else
103     warning('Python plugin not supported with `static` builds yet.')
104   endif
105 endif
106 if not get_option('tests').disabled()
107   subdir('testsuite')
108 endif