meson: use the version keyword argument for dependencies version
[platform/upstream/gstreamer.git] / meson.build
1 project('gst-python', 'c', 'cpp',
2   version : '1.9.2.1',
3   meson_version : '>= 0.33.0',
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 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
15
16 gst_dep = dependency('gstreamer-1.0', version : gst_req,
17   fallback : ['gstreamer', 'gst_dep'])
18 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
19   fallback : ['gstreamer', 'gst_base_dep'])
20 gmodule_dep = dependency('gmodule-2.0')
21 pygobject_dep = dependency('pygobject-3.0', version : '>= 3.0')
22 python_dep = dependency('python3')
23
24 python = find_program('python3')
25 pythondetector = find_program('pythondetector')
26 py_so_suffix = run_command(pythondetector, '--sosuffix').stdout().strip()
27 pygi_override_dir = run_command(pythondetector, '--pygi-overridedir').stdout().strip()
28 python_abi_flags = run_command(pythondetector, '--abiflags').stdout().strip()
29 pylib_loc = run_command(pythondetector, '--libloc').stdout().strip()
30 assert(pylib_loc != 'None', 'Python dynamic library path could not be determined')
31
32 pylib_suffix = 'so'
33 if host_machine.system() == 'windows'
34   pylib_suffix = 'dll'
35 elif host_machine.system() == 'darwin'
36   pylib_suffix = 'dylib'
37 endif
38
39 cdata = configuration_data()
40 cdata.set('PACKAGE', '"gst-python"')
41 cdata.set('VERSION', '"@0@"'.format(gst_version))
42 cdata.set('GST_PACKAGE_NAME', '"GStreamer Python"')
43 cdata.set('PACKAGE_NAME', '"GStreamer Python"')
44 cdata.set('GST_API_VERSION', '"@0@"'.format(api_version))
45 cdata.set('PLUGINDIR', '"@0@/gstreamer-1.0"'.format(get_option('libdir')))
46 cdata.set('PY_LIB_LOC', '"@0@"'.format(pylib_loc))
47 cdata.set('PY_ABI_FLAGS', '"@0@"'.format(python_abi_flags))
48 cdata.set('PY_LIB_SUFFIX', '"@0@"'.format(pylib_suffix))
49 cdata.set('PYTHON_VERSION', '"@0@"'.format(python_dep.version()))
50 configure_file(input : 'config.h.meson',
51   output : 'config.h',
52   configuration : cdata)
53 configinc = include_directories('.')
54
55 subdir('gi')
56 subdir('plugin')
57
58 python3 = find_program('python3')
59 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')