Make plugin date-time optional

It is described as optional in
https://gstreamer.freedesktop.org/documentation/gstreamer/gstplugin.html?gi-language=c#GstPluginDesc
and is also pretty difficult to provide for Rust plugins, I feel. For C
stuff the expectation is that build system would set something like
GST_PACKAGE_RELEASE_DATETIME=`date -u "+%Y-%m-%dT%H:%MZ"` which is
terrible.
This commit is contained in:
Simonas Kazlauskas 2021-08-10 17:38:55 +03:00
parent f84fc0dc59
commit 3ad9d3340b
2 changed files with 48 additions and 4 deletions

View file

@ -13,7 +13,7 @@ pub const MINOR_VERSION: i32 = 12;
macro_rules! plugin_define(
($name:ident, $description:expr, $plugin_init:ident,
$version:expr, $license:expr, $source:expr,
$package:expr, $origin:expr, $release_datetime:expr) => {
$package:expr, $origin:expr $(, $release_datetime:expr)?) => {
pub mod plugin_desc {
#[repr(transparent)]
pub struct GstPluginDesc($crate::ffi::GstPluginDesc);
@ -33,7 +33,29 @@ macro_rules! plugin_define(
source: concat!($source, "\0") as *const str as *const _,
package: concat!($package, "\0") as *const str as *const _,
origin: concat!($origin, "\0") as *const str as *const _,
release_datetime: concat!($release_datetime, "\0") as *const str as *const _,
release_datetime: {
// NB: if this looks a lot like `Option`, it is not a coincidence. Alas,
// Option::or is not `const` and neither is `unwrap_or` so we have to roll our
// own oli-obk-ified enum instead.
enum OptionalPtr<T>{
Null,
Some(*const T),
}
impl<T: Sized> OptionalPtr<T> {
const fn with(self, value: *const T) -> Self {
Self::Some(value)
}
const fn ptr(self) -> *const T {
match self {
Self::Null => std::ptr::null(),
Self::Some(ptr) => ptr
}
}
}
OptionalPtr::Null
$(.with(concat!($release_datetime, "\0").as_ptr() as _))?
.ptr()
},
_gst_reserved: [0 as $crate::glib::ffi::gpointer; 4],
});

View file

@ -18,7 +18,7 @@ cfg_if::cfg_if! {
macro_rules! plugin_define(
($name:ident, $description:expr, $plugin_init:ident,
$version:expr, $license:expr, $source:expr,
$package:expr, $origin:expr, $release_datetime:expr) => {
$package:expr, $origin:expr $(, $release_datetime:expr)?) => {
pub mod plugin_desc {
#[repr(transparent)]
pub struct GstPluginDesc($crate::ffi::GstPluginDesc);
@ -36,7 +36,29 @@ macro_rules! plugin_define(
source: concat!($source, "\0") as *const str as *const _,
package: concat!($package, "\0") as *const str as *const _,
origin: concat!($origin, "\0") as *const str as *const _,
release_datetime: concat!($release_datetime, "\0") as *const str as *const _,
release_datetime: {
// NB: if this looks a lot like `Option`, it is not a coincidence. Alas,
// Option::or is not `const` and neither is `unwrap_or` so we have to roll our
// own oli-obk-ified enum instead.
enum OptionalPtr<T>{
Null,
Some(*const T),
}
impl<T: Sized> OptionalPtr<T> {
const fn with(self, value: *const T) -> Self {
Self::Some(value)
}
const fn ptr(self) -> *const T {
match self {
Self::Null => std::ptr::null(),
Self::Some(ptr) => ptr
}
}
}
OptionalPtr::Null
$(.with(concat!($release_datetime, "\0").as_ptr() as _))?
.ptr()
},
_gst_reserved: [0 as $crate::glib::ffi::gpointer; 4],
});