Merging gst-build
[platform/upstream/gstreamer.git] / subprojects / gst-python / meson.build
1 project('gst-python', 'c', 'cpp',
2   version : '1.19.2',
3   meson_version : '>= 0.54',
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-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   check_path_exists = 'import os, sys; assert(os.path.exists(sys.argv[1]))'
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 run_command(python, '-c', check_path_exists, join_paths(pylib_loc, pylib_ldlibrary)).returncode() != 0
42       # Workaround for Fedora
43       pylib_loc = python.get_variable('LIBDIR', '')
44       message('pylib_loc = @0@'.format(pylib_loc))
45     endif
46
47     assert(
48       run_command(python, '-c', check_path_exists, join_paths(pylib_loc, pylib_ldlibrary)).returncode() == 0,
49       'Python dynamic library path could not be determined'
50     )
51   endif
52 endif
53
54 message('python_abi_flags = @0@'.format(python_abi_flags))
55 message('pylib_loc = @0@'.format(pylib_loc))
56
57 pygi_override_dir = get_option('pygi-overrides-dir')
58
59 if pygi_override_dir == ''
60   pygi_override_dir = python.get_install_dir(
61     subdir : join_paths('gi', 'overrides')
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 pkgconfig = import('pkgconfig')
92 plugins_install_dir = join_paths(libdir, 'gstreamer-1.0')
93 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
94 if get_option('default_library') == 'shared'
95   # If we don't build static plugins there is no need to generate pc files
96   plugins_pkgconfig_install_dir = disabler()
97 endif
98
99 subdir('gi')
100 subdir('plugin')
101 subdir('testsuite')
102  
103 run_command(python, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')