python: Add an option to set where to install pygi overrides
[platform/upstream/gstreamer.git] / meson.build
1 project('gst-python', 'c', 'cpp',
2   version : '1.11.1.1',
3   meson_version : '>= 0.36.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 python_abi_flags = run_command(pythondetector, '--abiflags').stdout().strip()
28 pylib_loc = run_command(pythondetector, '--libloc').stdout().strip()
29 assert(pylib_loc != 'None', 'Python dynamic library path could not be determined')
30 pygi_override_dir = get_option('pygi-overrides-dir')
31 if pygi_override_dir == ''
32     pygi_override_dir = run_command(pythondetector, '--pygi-overridedir').stdout().strip()
33 endif
34 message('pygobject overrides directory ' + pygi_override_dir)
35
36 pylib_suffix = 'so'
37 if host_machine.system() == 'windows'
38   pylib_suffix = 'dll'
39 elif host_machine.system() == 'darwin'
40   pylib_suffix = 'dylib'
41 endif
42
43 cdata = configuration_data()
44 cdata.set('PACKAGE', '"gst-python"')
45 cdata.set('VERSION', '"@0@"'.format(gst_version))
46 cdata.set('GST_PACKAGE_NAME', '"GStreamer Python"')
47 cdata.set('PACKAGE_NAME', '"GStreamer Python"')
48 cdata.set('GST_API_VERSION', '"@0@"'.format(api_version))
49 cdata.set('PLUGINDIR', '"@0@/gstreamer-1.0"'.format(get_option('libdir')))
50 cdata.set('PY_LIB_LOC', '"@0@"'.format(pylib_loc))
51 cdata.set('PY_ABI_FLAGS', '"@0@"'.format(python_abi_flags))
52 cdata.set('PY_LIB_SUFFIX', '"@0@"'.format(pylib_suffix))
53 cdata.set('PYTHON_VERSION', '"@0@"'.format(python_dep.version()))
54 configure_file(input : 'config.h.meson',
55   output : 'config.h',
56   configuration : cdata)
57 configinc = include_directories('.')
58
59 subdir('gi')
60 subdir('plugin')
61 subdir('testsuite')
62
63 python3 = find_program('python3')
64 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')