From dc45b7f8acfd496ea1aff10b80fcb1736b1d791e Mon Sep 17 00:00:00 2001 From: "ahamedsajeer.15" Date: Mon, 3 Jun 2019 16:23:58 +0530 Subject: [PATCH] Add build.rs that provides a version number, release date and other details --- Cargo.toml | 1 + gst-plugin-audiofx/Cargo.toml | 4 ++++ gst-plugin-audiofx/build.rs | 5 ++++ gst-plugin-audiofx/src/lib.rs | 12 +++++----- gst-plugin-cdg/Cargo.toml | 4 ++++ gst-plugin-cdg/build.rs | 5 ++++ gst-plugin-cdg/src/lib.rs | 12 +++++----- gst-plugin-closedcaption/Cargo.toml | 5 ++++ gst-plugin-closedcaption/build.rs | 5 ++++ gst-plugin-closedcaption/src/lib.rs | 12 +++++----- gst-plugin-file/Cargo.toml | 6 ++++- gst-plugin-file/build.rs | 5 ++++ gst-plugin-file/src/lib.rs | 12 +++++----- gst-plugin-flv/Cargo.toml | 4 ++++ gst-plugin-flv/build.rs | 5 ++++ gst-plugin-flv/src/lib.rs | 12 +++++----- gst-plugin-http/Cargo.toml | 4 ++++ gst-plugin-http/build.rs | 5 ++++ gst-plugin-http/src/lib.rs | 12 +++++----- gst-plugin-rav1e/Cargo.toml | 4 ++++ gst-plugin-rav1e/build.rs | 5 ++++ gst-plugin-rav1e/src/lib.rs | 12 +++++----- gst-plugin-s3/Cargo.toml | 4 ++++ gst-plugin-s3/build.rs | 5 ++++ gst-plugin-s3/src/lib.rs | 12 +++++----- gst-plugin-sodium/Cargo.toml | 5 ++++ gst-plugin-sodium/build.rs | 5 ++++ gst-plugin-sodium/src/lib.rs | 14 +++++------- gst-plugin-threadshare/Cargo.toml | 7 +++++- gst-plugin-threadshare/build.rs | 5 ++++ gst-plugin-threadshare/src/lib.rs | 12 +++++----- gst-plugin-togglerecord/Cargo.toml | 5 ++++ gst-plugin-togglerecord/build.rs | 5 ++++ gst-plugin-togglerecord/src/lib.rs | 12 +++++----- gst-plugin-tutorial/Cargo.toml | 4 ++++ gst-plugin-tutorial/build.rs | 5 ++++ gst-plugin-tutorial/src/lib.rs | 12 +++++----- gst-plugin-version-helper/Cargo.toml | 9 ++++++++ gst-plugin-version-helper/src/lib.rs | 34 ++++++++++++++++++++++++++++ 39 files changed, 230 insertions(+), 76 deletions(-) create mode 100644 gst-plugin-audiofx/build.rs create mode 100644 gst-plugin-cdg/build.rs create mode 100644 gst-plugin-closedcaption/build.rs create mode 100644 gst-plugin-file/build.rs create mode 100644 gst-plugin-flv/build.rs create mode 100644 gst-plugin-http/build.rs create mode 100644 gst-plugin-rav1e/build.rs create mode 100644 gst-plugin-s3/build.rs create mode 100644 gst-plugin-sodium/build.rs create mode 100644 gst-plugin-threadshare/build.rs create mode 100644 gst-plugin-togglerecord/build.rs create mode 100644 gst-plugin-tutorial/build.rs create mode 100644 gst-plugin-version-helper/Cargo.toml create mode 100644 gst-plugin-version-helper/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 54d02a3a..eb2e15ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "gst-plugin-threadshare", "gst-plugin-tutorial", "gst-plugin-closedcaption", + "gst-plugin-version-helper", "gst-plugin-sodium", "gst-plugin-cdg", "gst-plugin-rav1e", diff --git a/gst-plugin-audiofx/Cargo.toml b/gst-plugin-audiofx/Cargo.toml index db3cfd68..cdd47b70 100644 --- a/gst-plugin-audiofx/Cargo.toml +++ b/gst-plugin-audiofx/Cargo.toml @@ -4,6 +4,7 @@ version = "0.5.0" authors = ["Sebastian Dröge "] repository = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs" license = "MIT/Apache-2.0" +description = "Rust AudioFx Plugin" [dependencies] glib = { git = "https://github.com/gtk-rs/glib" } @@ -17,3 +18,6 @@ num-traits = "0.2" name = "gstrsaudiofx" crate-type = ["cdylib"] path = "src/lib.rs" + +[build-dependencies] +gst-plugin-version-helper = { path="../gst-plugin-version-helper" } diff --git a/gst-plugin-audiofx/build.rs b/gst-plugin-audiofx/build.rs new file mode 100644 index 00000000..0d1ddb61 --- /dev/null +++ b/gst-plugin-audiofx/build.rs @@ -0,0 +1,5 @@ +extern crate gst_plugin_version_helper; + +fn main() { + gst_plugin_version_helper::get_info() +} diff --git a/gst-plugin-audiofx/src/lib.rs b/gst-plugin-audiofx/src/lib.rs index 56122740..b2ba3319 100644 --- a/gst-plugin-audiofx/src/lib.rs +++ b/gst-plugin-audiofx/src/lib.rs @@ -25,12 +25,12 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { gst_plugin_define!( rsaudiofx, - "Rust AudioFx Plugin", + env!("CARGO_PKG_DESCRIPTION"), plugin_init, - "1.0", + concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")), "MIT/X11", - "rsaudiofx", - "rsaudiofx", - "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs", - "2016-12-08" + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_REPOSITORY"), + env!("BUILD_REL_DATE") ); diff --git a/gst-plugin-cdg/Cargo.toml b/gst-plugin-cdg/Cargo.toml index 0af74cb3..6329b999 100644 --- a/gst-plugin-cdg/Cargo.toml +++ b/gst-plugin-cdg/Cargo.toml @@ -4,6 +4,7 @@ version = "0.5.0" authors = ["Guillaume Desmottes "] repository = "https://gitlab.freedesktop.org/gstreamer/gst-plugin-rs" license = "MIT/Apache-2.0" +description = "CDG Plugin" edition = "2018" [dependencies] @@ -21,3 +22,6 @@ muldiv = "0.2" name = "gstcdg" crate-type = ["cdylib", "rlib"] path = "src/lib.rs" + +[build-dependencies] +gst-plugin-version-helper = { path="../gst-plugin-version-helper" } diff --git a/gst-plugin-cdg/build.rs b/gst-plugin-cdg/build.rs new file mode 100644 index 00000000..0d1ddb61 --- /dev/null +++ b/gst-plugin-cdg/build.rs @@ -0,0 +1,5 @@ +extern crate gst_plugin_version_helper; + +fn main() { + gst_plugin_version_helper::get_info() +} diff --git a/gst-plugin-cdg/src/lib.rs b/gst-plugin-cdg/src/lib.rs index 24970007..7e33cd5b 100644 --- a/gst-plugin-cdg/src/lib.rs +++ b/gst-plugin-cdg/src/lib.rs @@ -21,12 +21,12 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { gst_plugin_define!( cdg, - "CDG Plugin", + env!("CARGO_PKG_DESCRIPTION"), plugin_init, - "1.0", + concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")), "MIT/X11", - "cdg", - "cdg", - "https://gitlab.freedesktop.org/gstreamer/gst-plugin-rs", - "2019-05-01" + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_REPOSITORY"), + env!("BUILD_REL_DATE") ); diff --git a/gst-plugin-closedcaption/Cargo.toml b/gst-plugin-closedcaption/Cargo.toml index 88b61e4e..a4f6c5fa 100644 --- a/gst-plugin-closedcaption/Cargo.toml +++ b/gst-plugin-closedcaption/Cargo.toml @@ -4,6 +4,8 @@ version = "0.5.0" authors = ["Sebastian Dröge ", "Jordan Petridis "] license = "LGPL-2.1+" edition = "2018" +description = "Rust Closed Caption Plugin" +repository = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs" [dependencies] glib = { git = "https://github.com/gtk-rs/glib", features = ["subclassing"] } @@ -40,3 +42,6 @@ package="gstreamer-check" name = "gstrsclosedcaption" crate-type = ["cdylib", "rlib"] path = "src/lib.rs" + +[build-dependencies] +gst-plugin-version-helper = { path="../gst-plugin-version-helper" } diff --git a/gst-plugin-closedcaption/build.rs b/gst-plugin-closedcaption/build.rs new file mode 100644 index 00000000..0d1ddb61 --- /dev/null +++ b/gst-plugin-closedcaption/build.rs @@ -0,0 +1,5 @@ +extern crate gst_plugin_version_helper; + +fn main() { + gst_plugin_version_helper::get_info() +} diff --git a/gst-plugin-closedcaption/src/lib.rs b/gst-plugin-closedcaption/src/lib.rs index 35272b48..ff38aec5 100644 --- a/gst-plugin-closedcaption/src/lib.rs +++ b/gst-plugin-closedcaption/src/lib.rs @@ -52,12 +52,12 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { gst_plugin_define!( rsclosedcaption, - "Rust Closed Caption Plugin", + env!("CARGO_PKG_DESCRIPTION"), plugin_init, - "0.1.0", + concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")), "LGPL", - "rsclosedcaption", - "rsclosedcaption", - "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs", - "2018-12-17" + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_REPOSITORY"), + env!("BUILD_REL_DATE") ); diff --git a/gst-plugin-file/Cargo.toml b/gst-plugin-file/Cargo.toml index 1a49fa0b..423ff6de 100644 --- a/gst-plugin-file/Cargo.toml +++ b/gst-plugin-file/Cargo.toml @@ -4,6 +4,7 @@ version = "0.5.0" authors = ["Sebastian Dröge "] repository = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs" license = "MIT/Apache-2.0" +description = "Rust File Plugin" [dependencies] url = "1.1" @@ -14,4 +15,7 @@ gstreamer-base = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" [lib] name = "gstrsfile" crate-type = ["cdylib"] -path = "src/lib.rs" \ No newline at end of file +path = "src/lib.rs" + +[build-dependencies] +gst-plugin-version-helper = { path="../gst-plugin-version-helper" } diff --git a/gst-plugin-file/build.rs b/gst-plugin-file/build.rs new file mode 100644 index 00000000..0d1ddb61 --- /dev/null +++ b/gst-plugin-file/build.rs @@ -0,0 +1,5 @@ +extern crate gst_plugin_version_helper; + +fn main() { + gst_plugin_version_helper::get_info() +} diff --git a/gst-plugin-file/src/lib.rs b/gst-plugin-file/src/lib.rs index 38aab8f5..8d3c9762 100644 --- a/gst-plugin-file/src/lib.rs +++ b/gst-plugin-file/src/lib.rs @@ -27,12 +27,12 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { gst_plugin_define!( rsfile, - "Rust File Plugin", + env!("CARGO_PKG_DESCRIPTION"), plugin_init, - "1.0", + concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")), "MIT/X11", - "rsfile", - "rsfile", - "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs", - "2016-12-08" + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_REPOSITORY"), + env!("BUILD_REL_DATE") ); diff --git a/gst-plugin-flv/Cargo.toml b/gst-plugin-flv/Cargo.toml index e7cd0cff..bf8b114f 100644 --- a/gst-plugin-flv/Cargo.toml +++ b/gst-plugin-flv/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Sebastian Dröge "] repository = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs" license = "MIT/Apache-2.0" edition = "2018" +description = "Rust FLV Plugin" [dependencies] url = "1.1" @@ -23,3 +24,6 @@ smallvec = "0.6" name = "gstrsflv" crate-type = ["cdylib"] path = "src/lib.rs" + +[build-dependencies] +gst-plugin-version-helper = { path="../gst-plugin-version-helper" } diff --git a/gst-plugin-flv/build.rs b/gst-plugin-flv/build.rs new file mode 100644 index 00000000..0d1ddb61 --- /dev/null +++ b/gst-plugin-flv/build.rs @@ -0,0 +1,5 @@ +extern crate gst_plugin_version_helper; + +fn main() { + gst_plugin_version_helper::get_info() +} diff --git a/gst-plugin-flv/src/lib.rs b/gst-plugin-flv/src/lib.rs index 34882bf7..7cab1829 100644 --- a/gst-plugin-flv/src/lib.rs +++ b/gst-plugin-flv/src/lib.rs @@ -26,12 +26,12 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { gst_plugin_define!( rsflv, - "Rust FLV Plugin", + env!("CARGO_PKG_DESCRIPTION"), plugin_init, - "1.0", + concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")), "MIT/X11", - "rsflv", - "rsflv", - "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs", - "2016-12-08" + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_REPOSITORY"), + env!("BUILD_REL_DATE") ); diff --git a/gst-plugin-http/Cargo.toml b/gst-plugin-http/Cargo.toml index 6e41e679..4bc82ffe 100644 --- a/gst-plugin-http/Cargo.toml +++ b/gst-plugin-http/Cargo.toml @@ -4,6 +4,7 @@ version = "0.5.0" authors = ["Sebastian Dröge "] repository = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs" license = "MIT/Apache-2.0" +description = "Rust HTTP Plugin" [dependencies] url = "1.1" @@ -17,3 +18,6 @@ gstreamer-base = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" name = "gstrshttp" crate-type = ["cdylib"] path = "src/lib.rs" + +[build-dependencies] +gst-plugin-version-helper = { path="../gst-plugin-version-helper" } diff --git a/gst-plugin-http/build.rs b/gst-plugin-http/build.rs new file mode 100644 index 00000000..0d1ddb61 --- /dev/null +++ b/gst-plugin-http/build.rs @@ -0,0 +1,5 @@ +extern crate gst_plugin_version_helper; + +fn main() { + gst_plugin_version_helper::get_info() +} diff --git a/gst-plugin-http/src/lib.rs b/gst-plugin-http/src/lib.rs index e5d17361..4f7eb055 100644 --- a/gst-plugin-http/src/lib.rs +++ b/gst-plugin-http/src/lib.rs @@ -25,12 +25,12 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { gst_plugin_define!( rshttp, - "Rust HTTP Plugin", + env!("CARGO_PKG_DESCRIPTION"), plugin_init, - "1.0", + concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")), "MIT/X11", - "rshttp", - "rshttp", - "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs", - "2016-12-08" + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_REPOSITORY"), + env!("BUILD_REL_DATE") ); diff --git a/gst-plugin-rav1e/Cargo.toml b/gst-plugin-rav1e/Cargo.toml index e9a971d1..310b6453 100644 --- a/gst-plugin-rav1e/Cargo.toml +++ b/gst-plugin-rav1e/Cargo.toml @@ -4,6 +4,7 @@ version = "0.5.0" authors = ["Sebastian Dröge "] repository = "https://gitlab.freedesktop.org/gstreamer/gst-plugin-rs" license = "MIT/Apache-2.0" +description = "rav1e AV1 Encoder Plugin" edition = "2018" [dependencies] @@ -17,3 +18,6 @@ rav1e = { git = "https://github.com/xiph/rav1e.git", default-features=false } name = "gstrav1e" crate-type = ["cdylib", "rlib"] path = "src/lib.rs" + +[build-dependencies] +gst-plugin-version-helper = { path="../gst-plugin-version-helper" } diff --git a/gst-plugin-rav1e/build.rs b/gst-plugin-rav1e/build.rs new file mode 100644 index 00000000..0d1ddb61 --- /dev/null +++ b/gst-plugin-rav1e/build.rs @@ -0,0 +1,5 @@ +extern crate gst_plugin_version_helper; + +fn main() { + gst_plugin_version_helper::get_info() +} diff --git a/gst-plugin-rav1e/src/lib.rs b/gst-plugin-rav1e/src/lib.rs index 86a67681..96a4f232 100644 --- a/gst-plugin-rav1e/src/lib.rs +++ b/gst-plugin-rav1e/src/lib.rs @@ -21,12 +21,12 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { gst_plugin_define!( rav1e, - "rav1e AV1 Encoder Plugin", + env!("CARGO_PKG_DESCRIPTION"), plugin_init, - "1.0", + concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")), "MIT/X11", - "rav1e", - "rav1e", - "https://gitlab.freedesktop.org/gstreamer/gst-plugin-rs", - "2019-05-25" + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_REPOSITORY"), + env!("BUILD_REL_DATE") ); diff --git a/gst-plugin-s3/Cargo.toml b/gst-plugin-s3/Cargo.toml index cf9d4130..92c99049 100644 --- a/gst-plugin-s3/Cargo.toml +++ b/gst-plugin-s3/Cargo.toml @@ -4,6 +4,7 @@ version = "0.5.0" authors = ["Arun Raghavan "] repository = "https://gitlab.freedesktop.org/gstreamer/gst-plugin-rs" license = "MIT/Apache-2.0" +description = "Amazon S3 Plugin" edition = "2018" [dependencies] @@ -21,3 +22,6 @@ tokio = "0.1" name = "gsts3" crate-type = ["cdylib", "rlib"] path = "src/lib.rs" + +[build-dependencies] +gst-plugin-version-helper = { path="../gst-plugin-version-helper" } diff --git a/gst-plugin-s3/build.rs b/gst-plugin-s3/build.rs new file mode 100644 index 00000000..0d1ddb61 --- /dev/null +++ b/gst-plugin-s3/build.rs @@ -0,0 +1,5 @@ +extern crate gst_plugin_version_helper; + +fn main() { + gst_plugin_version_helper::get_info() +} diff --git a/gst-plugin-s3/src/lib.rs b/gst-plugin-s3/src/lib.rs index 6d637f55..0bf0f74d 100644 --- a/gst-plugin-s3/src/lib.rs +++ b/gst-plugin-s3/src/lib.rs @@ -23,12 +23,12 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { gst_plugin_define!( s3, - "Amazon S3 Plugin", + env!("CARGO_PKG_DESCRIPTION"), plugin_init, - "1.0", + concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")), "MIT/X11", - "s3", - "s3", - "https://github.com/ford-prefect/gst-plugin-s3", - "2017-04-17" + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_REPOSITORY"), + env!("BUILD_REL_DATE") ); diff --git a/gst-plugin-sodium/Cargo.toml b/gst-plugin-sodium/Cargo.toml index 003d5b5e..29fddff6 100644 --- a/gst-plugin-sodium/Cargo.toml +++ b/gst-plugin-sodium/Cargo.toml @@ -2,6 +2,8 @@ name = "gst-plugin-sodium" version = "0.1.0" authors = ["Jordan Petridis "] +repository = "https://gitlab.freedesktop.org/gstreamer/gst-plugin-rs" +description = "libsodium-based file encryption and decryption" edition = "2018" [dependencies] @@ -49,3 +51,6 @@ required-features = ["serde", "serde_json", "clap"] name = "decrypt-example" path = "examples/decrypt_example.rs" required-features = ["serde", "serde_json", "clap"] + +[build-dependencies] +gst-plugin-version-helper = { path="../gst-plugin-version-helper" } diff --git a/gst-plugin-sodium/build.rs b/gst-plugin-sodium/build.rs new file mode 100644 index 00000000..0d1ddb61 --- /dev/null +++ b/gst-plugin-sodium/build.rs @@ -0,0 +1,5 @@ +extern crate gst_plugin_version_helper; + +fn main() { + gst_plugin_version_helper::get_info() +} diff --git a/gst-plugin-sodium/src/lib.rs b/gst-plugin-sodium/src/lib.rs index 43b05c6e..01094556 100644 --- a/gst-plugin-sodium/src/lib.rs +++ b/gst-plugin-sodium/src/lib.rs @@ -1,5 +1,3 @@ -// lib.rs -// // Copyright 2019 Jordan Petridis // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -75,12 +73,12 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { gst_plugin_define!( sodium, - "libsodium-based file encryption and decryption", + env!("CARGO_PKG_DESCRIPTION"), plugin_init, - "1.0", + concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")), "MIT/X11", - "sodium", - "sodium", - "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs", - "2019-03-18" + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_REPOSITORY"), + env!("BUILD_REL_DATE") ); diff --git a/gst-plugin-threadshare/Cargo.toml b/gst-plugin-threadshare/Cargo.toml index d9158e51..077531b9 100644 --- a/gst-plugin-threadshare/Cargo.toml +++ b/gst-plugin-threadshare/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "gst-plugin-threadshare" -version = "0.1.0" +version = "0.5.0" authors = ["Sebastian Dröge "] license = "LGPL-2.1+" +description = "Threadshare Plugin" +repository = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs" [dependencies] libc = "0.2" @@ -47,3 +49,6 @@ path = "examples/udpsrc_benchmark_sender.rs" [[example]] name = "tcpclientsrc-benchmark-sender" path = "examples/tcpclientsrc_benchmark_sender.rs" + +[build-dependencies] +gst-plugin-version-helper = { path="../gst-plugin-version-helper" } diff --git a/gst-plugin-threadshare/build.rs b/gst-plugin-threadshare/build.rs new file mode 100644 index 00000000..0d1ddb61 --- /dev/null +++ b/gst-plugin-threadshare/build.rs @@ -0,0 +1,5 @@ +extern crate gst_plugin_version_helper; + +fn main() { + gst_plugin_version_helper::get_info() +} diff --git a/gst-plugin-threadshare/src/lib.rs b/gst-plugin-threadshare/src/lib.rs index cf9fe17c..f6564cc8 100644 --- a/gst-plugin-threadshare/src/lib.rs +++ b/gst-plugin-threadshare/src/lib.rs @@ -73,14 +73,14 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { gst_plugin_define!( threadshare, - "Threadshare Plugin", + env!("CARGO_PKG_DESCRIPTION"), plugin_init, - "0.1.0", + concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")), "LGPL", - "threadshare", - "threadshare", - "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs", - "2018-03-01" + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_REPOSITORY"), + env!("BUILD_REL_DATE") ); pub fn set_element_flags + glib::IsA>( diff --git a/gst-plugin-togglerecord/Cargo.toml b/gst-plugin-togglerecord/Cargo.toml index 039bca82..640fdad6 100644 --- a/gst-plugin-togglerecord/Cargo.toml +++ b/gst-plugin-togglerecord/Cargo.toml @@ -3,6 +3,8 @@ name = "gst-plugin-togglerecord" version = "0.5.0" authors = ["Sebastian Dröge "] license = "LGPL-2.1+" +description = "Toggle Record Plugin" +repository = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs" [dependencies] glib = { git = "https://github.com/gtk-rs/glib", features = ["subclassing"] } @@ -24,3 +26,6 @@ path = "src/lib.rs" name = "gtk-recording" path = "examples/gtk_recording.rs" required-features = ["gtk", "gio"] + +[build-dependencies] +gst-plugin-version-helper = { path="../gst-plugin-version-helper" } diff --git a/gst-plugin-togglerecord/build.rs b/gst-plugin-togglerecord/build.rs new file mode 100644 index 00000000..0d1ddb61 --- /dev/null +++ b/gst-plugin-togglerecord/build.rs @@ -0,0 +1,5 @@ +extern crate gst_plugin_version_helper; + +fn main() { + gst_plugin_version_helper::get_info() +} diff --git a/gst-plugin-togglerecord/src/lib.rs b/gst-plugin-togglerecord/src/lib.rs index e6719dea..140a239a 100644 --- a/gst-plugin-togglerecord/src/lib.rs +++ b/gst-plugin-togglerecord/src/lib.rs @@ -33,12 +33,12 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { gst_plugin_define!( togglerecord, - "Toggle Record Plugin", + env!("CARGO_PKG_DESCRIPTION"), plugin_init, - "0.1.0", + concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")), "LGPL", - "togglerecord", - "togglerecord", - "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs", - "2017-12-04" + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_REPOSITORY"), + env!("BUILD_REL_DATE") ); diff --git a/gst-plugin-tutorial/Cargo.toml b/gst-plugin-tutorial/Cargo.toml index a21e16cc..cc31e555 100644 --- a/gst-plugin-tutorial/Cargo.toml +++ b/gst-plugin-tutorial/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Sebastian Dröge "] repository = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs" license = "MIT/Apache-2.0" edition = "2018" +description = "Rust Tutorial Plugin" [dependencies] glib = { git = "https://github.com/gtk-rs/glib", features = ["subclassing"] } @@ -19,3 +20,6 @@ num-traits = "0.2" name = "gstrstutorial" crate-type = ["cdylib"] path = "src/lib.rs" + +[build-dependencies] +gst-plugin-version-helper = { path="../gst-plugin-version-helper" } diff --git a/gst-plugin-tutorial/build.rs b/gst-plugin-tutorial/build.rs new file mode 100644 index 00000000..0d1ddb61 --- /dev/null +++ b/gst-plugin-tutorial/build.rs @@ -0,0 +1,5 @@ +extern crate gst_plugin_version_helper; + +fn main() { + gst_plugin_version_helper::get_info() +} diff --git a/gst-plugin-tutorial/src/lib.rs b/gst-plugin-tutorial/src/lib.rs index 0dee7179..6fdf73c0 100644 --- a/gst-plugin-tutorial/src/lib.rs +++ b/gst-plugin-tutorial/src/lib.rs @@ -39,12 +39,12 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { // and the date/time of release. gst_plugin_define!( rstutorial, - "Rust Tutorial Plugin", + env!("CARGO_PKG_DESCRIPTION"), plugin_init, - "1.0", + concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")), "MIT/X11", - "rstutorial", - "rstutorial", - "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs", - "2017-12-30" + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_REPOSITORY"), + env!("BUILD_REL_DATE") ); diff --git a/gst-plugin-version-helper/Cargo.toml b/gst-plugin-version-helper/Cargo.toml new file mode 100644 index 00000000..1848ddce --- /dev/null +++ b/gst-plugin-version-helper/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "gst-plugin-version-helper" +version = "0.1.0" +authors = ["Sajeer Ahamed "] +edition = "2018" + +[dependencies] +git2 = "0.8.0" +chrono = "0.4.6" diff --git a/gst-plugin-version-helper/src/lib.rs b/gst-plugin-version-helper/src/lib.rs new file mode 100644 index 00000000..1d37fa96 --- /dev/null +++ b/gst-plugin-version-helper/src/lib.rs @@ -0,0 +1,34 @@ +use chrono::TimeZone; +use git2::{Commit, ObjectType, Repository}; +use std::path; + +pub fn get_info() -> () { + let mut commit_id = "UNKNOWN".to_string(); + let mut commit_date = chrono::Utc::now().format("%Y-%m-%d").to_string(); + + let mut repo_dir = path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); + repo_dir.pop(); + + let repo = Repository::open(&repo_dir); + + if let Ok(repo) = repo { + let commit = find_last_commit(&repo).expect("Couldn't find last commit"); + commit_id = oid_to_short_sha(commit.id()); + let timestamp = commit.time().seconds(); + let dt = chrono::Utc.timestamp(timestamp, 0); + commit_date = dt.format("%Y-%m-%d").to_string() + } + + println!("cargo:rustc-env=COMMIT_ID={}", commit_id); + println!("cargo:rustc-env=BUILD_REL_DATE={}", commit_date); +} + +fn find_last_commit(repo: &Repository) -> Result { + let obj = repo.head()?.resolve()?.peel(ObjectType::Commit)?; + obj.into_commit() + .map_err(|_| git2::Error::from_str("Couldn't find commit")) +} + +fn oid_to_short_sha(oid: git2::Oid) -> String { + oid.to_string()[..8].to_string() +}