meson.build 3.35 KB
Newer Older
1
project('gst-python', 'c', 'cpp',
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
2
  version : '1.15.2',
3
  meson_version : '>= 0.46.0',
4 5 6 7 8 9 10 11 12 13
  default_options : [ 'warning_level=1',
                      'c_std=gnu99',
                      'buildtype=debugoptimized' ])

gst_version = meson.project_version()
version_arr = gst_version.split('.')
gst_version_major = version_arr[0]
gst_version_minor = version_arr[1]
api_version = '@0@.0'.format(gst_version_major)

14 15
add_project_arguments('-DHAVE_CONFIG_H', language: 'c')

16 17 18 19 20 21 22
gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)

gst_dep = dependency('gstreamer-1.0', version : gst_req,
  fallback : ['gstreamer', 'gst_dep'])
gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
  fallback : ['gstreamer', 'gst_base_dep'])
gmodule_dep = dependency('gmodule-2.0')
23
pygobject_dep = dependency('pygobject-3.0', fallback: ['pygobject', 'pygobject_dep'], version : '>= 3.8')
24

25 26 27
pymod = import('python')
python = pymod.find_installation(get_option('python'))
python_dep = python.dependency(required : true)
28

29
python_abi_flags = python.get_variable('ABIFLAGS', '')
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
pylib_loc = get_option('libpython-dir')
if pylib_loc == ''
  check_path_exists = 'import os, sys; assert(os.path.exists(sys.argv[1]))'
  pylib_loc = python.get_variable('LIBPL', '')
  if host_machine.system() != 'windows'
    pylib_ldlibrary = python.get_variable('LDLIBRARY', '')
    if host_machine.system() == 'darwin'
      # OSX is a pain. Python as shipped by apple installs libpython in /usr/lib
      # so we hardcode that. Other systems can use -Dlibpythondir to
      # override this.
      pylib_loc = '/usr/lib'
    else
      if run_command(python, '-c', check_path_exists, join_paths(pylib_loc, pylib_ldlibrary)).returncode() != 0
        # Workaround for Fedora
        pylib_loc = python.get_variable('LIBDIR', '')
        message('pylib_loc = @0@'.format(pylib_loc))
      endif
    endif

    assert(
      run_command(python, '-c', check_path_exists, join_paths(pylib_loc, pylib_ldlibrary)).returncode() == 0,
      'Python dynamic library path could not be determined'
    )
  endif
54
endif
55

56 57
message('python_abi_flags = @0@'.format(python_abi_flags))
message('pylib_loc = @0@'.format(pylib_loc))
58

59
pygi_override_dir = get_option('pygi-overrides-dir')
60

61
if pygi_override_dir == ''
62 63 64
  pygi_override_dir = python.get_install_dir(
    subdir : join_paths('gi', 'overrides')
  )
65
endif
66

67
message('pygobject overrides directory = @0@'.format(pygi_override_dir))
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85

pylib_suffix = 'so'
if host_machine.system() == 'windows'
  pylib_suffix = 'dll'
elif host_machine.system() == 'darwin'
  pylib_suffix = 'dylib'
endif
cdata = configuration_data()
cdata.set('PACKAGE', '"gst-python"')
cdata.set('VERSION', '"@0@"'.format(gst_version))
cdata.set('GST_PACKAGE_NAME', '"GStreamer Python"')
cdata.set('PACKAGE_NAME', '"GStreamer Python"')
cdata.set('GST_API_VERSION', '"@0@"'.format(api_version))
cdata.set('PLUGINDIR', '"@0@/gstreamer-1.0"'.format(get_option('libdir')))
cdata.set('PY_LIB_LOC', '"@0@"'.format(pylib_loc))
cdata.set('PY_ABI_FLAGS', '"@0@"'.format(python_abi_flags))
cdata.set('PY_LIB_SUFFIX', '"@0@"'.format(pylib_suffix))
cdata.set('PYTHON_VERSION', '"@0@"'.format(python_dep.version()))
86
configure_file(output : 'config.h', configuration : cdata)
87 88 89 90
configinc = include_directories('.')

subdir('gi')
subdir('plugin')
Thibault Saunier's avatar
Thibault Saunier committed
91
subdir('testsuite')
92

93
run_command(python, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')