mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 00:36:51 +00:00
ptp-helper: Add a feature option for the PTP support
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4410>
This commit is contained in:
parent
2e84603b02
commit
6378ebbdcd
2 changed files with 102 additions and 97 deletions
|
@ -1,114 +1,118 @@
|
|||
# Check PTP support
|
||||
have_ptp = true
|
||||
ptp_helper_option = get_option('ptp-helper')
|
||||
|
||||
if ptp_helper_option.disabled()
|
||||
subdir_done()
|
||||
endif
|
||||
|
||||
if host_system not in ['linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly', 'darwin', 'sunos', 'solaris', 'illumos', 'windows']
|
||||
have_ptp = false
|
||||
message('PTP not supported on this OS')
|
||||
if ptp_helper_option.enabled()
|
||||
error('PTP not supported on this OS')
|
||||
endif
|
||||
subdir_done()
|
||||
endif
|
||||
|
||||
if have_ptp
|
||||
have_rust = add_languages('rust', native : false, required : false)
|
||||
if not have_rust
|
||||
have_ptp = false
|
||||
warning('PTP not supported without Rust compiler')
|
||||
have_rust = add_languages('rust', native : false, required : false)
|
||||
if not have_rust
|
||||
if ptp_helper_option.enabled()
|
||||
error('PTP not supported without Rust compiler')
|
||||
endif
|
||||
subdir_done()
|
||||
endif
|
||||
|
||||
if have_ptp
|
||||
rustc = meson.get_compiler('rust')
|
||||
rustc = meson.get_compiler('rust')
|
||||
|
||||
if rustc.get_id() not in ['rustc', 'clippy-driver rustc']
|
||||
warning('PTP support is only tested with rustc, found different compiler @0@ @1@'.format(rustc.get_id(), rustc.version()))
|
||||
endif
|
||||
|
||||
# We currently need at least Rust 1.48 on all platforms but Windows.
|
||||
# On Windows some 1.54 API is used that would otherwise complicate things
|
||||
# unncecessarily.
|
||||
rust_req = '1.48'
|
||||
if host_system == 'windows'
|
||||
rust_req = '1.54'
|
||||
endif
|
||||
|
||||
if rustc.get_id() in ['rustc', 'clippy-driver rustc'] and not rustc.version().version_compare('>=' + rust_req)
|
||||
have_ptp = false
|
||||
warning('PTP support requires at least Rust @0@ on this platform, found @1@'.format(rust_req, rustc.version()))
|
||||
endif
|
||||
if rustc.get_id() not in ['rustc', 'clippy-driver rustc']
|
||||
warning('PTP support is only tested with rustc, found different compiler @0@ @1@'.format(rustc.get_id(), rustc.version()))
|
||||
endif
|
||||
|
||||
if have_ptp
|
||||
cdata.set('HAVE_PTP', 1, description : 'PTP support available')
|
||||
# We currently need at least Rust 1.48 on all platforms but Windows.
|
||||
# On Windows some 1.54 API is used that would otherwise complicate things
|
||||
# unncecessarily.
|
||||
rust_req = '1.48'
|
||||
if host_system == 'windows'
|
||||
rust_req = '1.54'
|
||||
endif
|
||||
|
||||
ptp_helper_conf_data = configuration_data()
|
||||
rust_args = []
|
||||
if rustc.get_id() in ['rustc', 'clippy-driver rustc'] and not rustc.version().version_compare('>=' + rust_req)
|
||||
if ptp_helper_option.enabled()
|
||||
error('PTP support requires at least Rust @0@ on this platform, found @1@'.format(rust_req, rustc.version()))
|
||||
endif
|
||||
subdir_done()
|
||||
endif
|
||||
|
||||
setcap_prog = find_program('setcap', '/usr/sbin/setcap', '/sbin/setcap', required : false)
|
||||
cap_dep = dependency('libcap', required: false)
|
||||
cdata.set('HAVE_PTP', 1, description : 'PTP support available')
|
||||
|
||||
# user/group to change to in gst-ptp-helper
|
||||
ptp_helper_setuid_user = get_option('ptp-helper-setuid-user')
|
||||
if ptp_helper_setuid_user != ''
|
||||
ptp_helper_conf_data.set('PTP_HELPER_SETUID_USER', 'Some("@0@")'.format(ptp_helper_setuid_user))
|
||||
ptp_helper_conf_data = configuration_data()
|
||||
rust_args = []
|
||||
|
||||
setcap_prog = find_program('setcap', '/usr/sbin/setcap', '/sbin/setcap', required : false)
|
||||
cap_dep = dependency('libcap', required: false)
|
||||
|
||||
# user/group to change to in gst-ptp-helper
|
||||
ptp_helper_setuid_user = get_option('ptp-helper-setuid-user')
|
||||
if ptp_helper_setuid_user != ''
|
||||
ptp_helper_conf_data.set('PTP_HELPER_SETUID_USER', 'Some("@0@")'.format(ptp_helper_setuid_user))
|
||||
else
|
||||
ptp_helper_conf_data.set('PTP_HELPER_SETUID_USER', 'None')
|
||||
endif
|
||||
ptp_helper_setuid_group = get_option('ptp-helper-setuid-group')
|
||||
if ptp_helper_setuid_group != ''
|
||||
ptp_helper_conf_data.set('PTP_HELPER_SETUID_GROUP', 'Some("@0@")'.format(ptp_helper_setuid_group))
|
||||
else
|
||||
ptp_helper_conf_data.set('PTP_HELPER_SETUID_GROUP', 'None')
|
||||
endif
|
||||
|
||||
# how to install gst-ptp-helper
|
||||
with_ptp_helper_permissions = get_option('ptp-helper-permissions')
|
||||
if with_ptp_helper_permissions == 'auto'
|
||||
if setcap_prog.found() and cap_dep.found()
|
||||
with_ptp_helper_permissions = 'capabilities'
|
||||
elif host_system == 'windows'
|
||||
with_ptp_helper_permissions = 'none'
|
||||
else
|
||||
ptp_helper_conf_data.set('PTP_HELPER_SETUID_USER', 'None')
|
||||
with_ptp_helper_permissions = 'setuid-root'
|
||||
endif
|
||||
ptp_helper_setuid_group = get_option('ptp-helper-setuid-group')
|
||||
if ptp_helper_setuid_group != ''
|
||||
ptp_helper_conf_data.set('PTP_HELPER_SETUID_GROUP', 'Some("@0@")'.format(ptp_helper_setuid_group))
|
||||
else
|
||||
ptp_helper_conf_data.set('PTP_HELPER_SETUID_GROUP', 'None')
|
||||
endif
|
||||
|
||||
# how to install gst-ptp-helper
|
||||
with_ptp_helper_permissions = get_option('ptp-helper-permissions')
|
||||
if with_ptp_helper_permissions == 'auto'
|
||||
if setcap_prog.found() and cap_dep.found()
|
||||
with_ptp_helper_permissions = 'capabilities'
|
||||
elif host_system == 'windows'
|
||||
with_ptp_helper_permissions = 'none'
|
||||
else
|
||||
with_ptp_helper_permissions = 'setuid-root'
|
||||
endif
|
||||
endif
|
||||
message('How to install gst-ptp-helper: ' + with_ptp_helper_permissions)
|
||||
|
||||
if with_ptp_helper_permissions == 'none'
|
||||
rust_args += ['--cfg', 'ptp_helper_permissions="none"']
|
||||
# nothing to do
|
||||
elif with_ptp_helper_permissions == 'setuid-root'
|
||||
rust_args += ['--cfg', 'ptp_helper_permissions="setuid-root"']
|
||||
elif with_ptp_helper_permissions == 'capabilities'
|
||||
if not setcap_prog.found()
|
||||
error('capabilities-based ptp-helper-permissions requested, but could not find setcap tool.')
|
||||
elif not cap_dep.found()
|
||||
error('capabilities-based ptp-helper-permissions requested, but could not find libcap.')
|
||||
endif
|
||||
rust_args += ['--cfg', 'ptp_helper_permissions="setcap"']
|
||||
else
|
||||
error('Unexpected ptp helper permissions value: ' + with_ptp_helper_permissions)
|
||||
endif
|
||||
|
||||
conf_lib_rs = configure_file(input : 'conf_lib.rs.in',
|
||||
output : 'conf_lib.rs',
|
||||
configuration: ptp_helper_conf_data)
|
||||
|
||||
conf = static_library('gst_ptp_helper_conf', conf_lib_rs,
|
||||
override_options : ['rust_std=2018'],
|
||||
rust_args : ['-Cpanic=abort'],
|
||||
rust_crate_type : 'rlib')
|
||||
|
||||
exe = executable('gst-ptp-helper', 'main.rs',
|
||||
override_options : ['rust_std=2018'],
|
||||
rust_args : ['-Cpanic=abort', rust_args],
|
||||
dependencies : [cap_dep],
|
||||
link_with : conf,
|
||||
install_dir : helpers_install_dir,
|
||||
install : true)
|
||||
|
||||
if host_system != 'windows'
|
||||
meson.add_install_script('ptp_helper_post_install.sh',
|
||||
helpers_install_dir, with_ptp_helper_permissions,
|
||||
setcap_prog.found() ? setcap_prog.full_path() : '')
|
||||
endif
|
||||
|
||||
meson.add_devenv({'GST_PTP_HELPER': exe.full_path()})
|
||||
endif
|
||||
message('How to install gst-ptp-helper: ' + with_ptp_helper_permissions)
|
||||
|
||||
if with_ptp_helper_permissions == 'none'
|
||||
rust_args += ['--cfg', 'ptp_helper_permissions="none"']
|
||||
# nothing to do
|
||||
elif with_ptp_helper_permissions == 'setuid-root'
|
||||
rust_args += ['--cfg', 'ptp_helper_permissions="setuid-root"']
|
||||
elif with_ptp_helper_permissions == 'capabilities'
|
||||
if not setcap_prog.found()
|
||||
error('capabilities-based ptp-helper-permissions requested, but could not find setcap tool.')
|
||||
elif not cap_dep.found()
|
||||
error('capabilities-based ptp-helper-permissions requested, but could not find libcap.')
|
||||
endif
|
||||
rust_args += ['--cfg', 'ptp_helper_permissions="setcap"']
|
||||
else
|
||||
error('Unexpected ptp helper permissions value: ' + with_ptp_helper_permissions)
|
||||
endif
|
||||
|
||||
conf_lib_rs = configure_file(input : 'conf_lib.rs.in',
|
||||
output : 'conf_lib.rs',
|
||||
configuration: ptp_helper_conf_data)
|
||||
|
||||
conf = static_library('gst_ptp_helper_conf', conf_lib_rs,
|
||||
override_options : ['rust_std=2018'],
|
||||
rust_args : ['-Cpanic=abort'],
|
||||
rust_crate_type : 'rlib')
|
||||
|
||||
exe = executable('gst-ptp-helper', 'main.rs',
|
||||
override_options : ['rust_std=2018'],
|
||||
rust_args : ['-Cpanic=abort', rust_args],
|
||||
dependencies : [cap_dep],
|
||||
link_with : conf,
|
||||
install_dir : helpers_install_dir,
|
||||
install : true)
|
||||
|
||||
if host_system != 'windows'
|
||||
meson.add_install_script('ptp_helper_post_install.sh',
|
||||
helpers_install_dir, with_ptp_helper_permissions,
|
||||
setcap_prog.found() ? setcap_prog.full_path() : '')
|
||||
endif
|
||||
|
||||
meson.add_devenv({'GST_PTP_HELPER': exe.full_path()})
|
||||
|
|
|
@ -3,6 +3,7 @@ option('gst_parse', type : 'boolean', value : true,
|
|||
description: 'Enable pipeline string parser')
|
||||
option('registry', type : 'boolean', value : true)
|
||||
option('tracer_hooks', type : 'boolean', value : true, description: 'Enable tracer usage')
|
||||
option('ptp-helper', type: 'feature', description: 'Build gst-ptp-helper')
|
||||
option('ptp-helper-setuid-user', type : 'string',
|
||||
description : 'User to switch to when installing gst-ptp-helper setuid root')
|
||||
option('ptp-helper-setuid-group', type : 'string',
|
||||
|
|
Loading…
Reference in a new issue