From d335fae92cdcbb0ee18aad4e54558914afa3e778 Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Fri, 10 Jun 2022 21:20:37 +0200 Subject: [PATCH] feat(bundler): bundle additional gstreamer files, closes #4092 (#4271) Co-authored-by: Lucas Nogueira --- .changes/appimage-bundle-gstreamer.md | 5 ++++ .changes/bundle-media-framework-config.md | 5 ++++ .changes/cli-bundle-gstreamer.md | 6 ++++ core/tauri-utils/src/config.rs | 17 +++++++++++ .../src/bundle/linux/templates/appimage | 13 +++++++-- tooling/cli/schema.json | 29 +++++++++++++++++++ tooling/cli/src/build.rs | 3 ++ 7 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 .changes/appimage-bundle-gstreamer.md create mode 100644 .changes/bundle-media-framework-config.md create mode 100644 .changes/cli-bundle-gstreamer.md diff --git a/.changes/appimage-bundle-gstreamer.md b/.changes/appimage-bundle-gstreamer.md new file mode 100644 index 000000000..0448ead30 --- /dev/null +++ b/.changes/appimage-bundle-gstreamer.md @@ -0,0 +1,5 @@ +--- +"tauri-bundler": patch +--- + +Bundle additional gstreamer files needed for audio and video playback if the `APPIMAGE_BUNDLE_GSTREAMER` environment variable is set. \ No newline at end of file diff --git a/.changes/bundle-media-framework-config.md b/.changes/bundle-media-framework-config.md new file mode 100644 index 000000000..94ed3b7c1 --- /dev/null +++ b/.changes/bundle-media-framework-config.md @@ -0,0 +1,5 @@ +--- +"tauri-utils": patch +--- + +Added a config flag to bundle the media framework used by webkit2gtk `tauri.conf.json > tauri > bundle > appimage > bundleMediaFramework`. diff --git a/.changes/cli-bundle-gstreamer.md b/.changes/cli-bundle-gstreamer.md new file mode 100644 index 000000000..11f441bb6 --- /dev/null +++ b/.changes/cli-bundle-gstreamer.md @@ -0,0 +1,6 @@ +--- +"cli.rs": patch +"cli.js": patch +--- + +Set the `APPIMAGE_BUNDLE_GSTREAMER` environment variable to make the bundler copy additional gstreamer files to the AppImage. \ No newline at end of file diff --git a/core/tauri-utils/src/config.rs b/core/tauri-utils/src/config.rs index 888f7cea3..6dbc36e18 100644 --- a/core/tauri-utils/src/config.rs +++ b/core/tauri-utils/src/config.rs @@ -87,6 +87,17 @@ impl BundleTarget { } } +/// Configuration for AppImage bundles. +#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)] +#[cfg_attr(feature = "schema", derive(JsonSchema))] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct AppImageConfig { + /// Include additional gstreamer dependencies needed for audio and video playback. + /// This increases the bundle size by ~15-35MB depending on your build system. + #[serde(default)] + pub bundle_media_framework: bool, +} + /// Configuration for Debian (.deb) bundles. #[skip_serializing_none] #[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)] @@ -322,6 +333,9 @@ pub struct BundleConfig { pub short_description: Option, /// A longer, multi-line description of the application. pub long_description: Option, + /// Configuration for the AppImage bundle. + #[serde(default)] + pub appimage: AppImageConfig, /// Configuration for the Debian bundle. #[serde(default)] pub deb: DebConfig, @@ -2728,6 +2742,7 @@ mod build { let category = quote!(None); let short_description = quote!(None); let long_description = quote!(None); + let appimage = quote!(Default::default()); let deb = quote!(Default::default()); let macos = quote!(Default::default()); let external_bin = opt_vec_str_lit(self.external_bin.as_ref()); @@ -2745,6 +2760,7 @@ mod build { category, short_description, long_description, + appimage, deb, macos, external_bin, @@ -3147,6 +3163,7 @@ mod test { category: None, short_description: None, long_description: None, + appimage: Default::default(), deb: Default::default(), macos: Default::default(), external_bin: None, diff --git a/tooling/bundler/src/bundle/linux/templates/appimage b/tooling/bundler/src/bundle/linux/templates/appimage index eca294307..ff621a472 100644 --- a/tooling/bundler/src/bundle/linux/templates/appimage +++ b/tooling/bundler/src/bundle/linux/templates/appimage @@ -7,6 +7,7 @@ set -euxo pipefail export ARCH={{arch}} APPIMAGE_BUNDLE_XDG_OPEN=${APPIMAGE_BUNDLE_XDG_OPEN-0} +APPIMAGE_BUNDLE_GSTREAMER=${APPIMAGE_BUNDLE_GSTREAMER-0} TRAY_LIBRARY_PATH=${TRAY_LIBRARY_PATH-0} if [ "$ARCH" == "i686" ]; then @@ -51,12 +52,20 @@ ln -s "usr/share/applications/{{app_name}}.desktop" "{{app_name}}.desktop" cd .. -wget -q -4 -N -O linuxdeploy-plugin-gtk.sh "https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh" +if [[ "$APPIMAGE_BUNDLE_GSTREAMER" != "0" ]]; then + gst_plugin="--plugin gstreamer" + wget -q -4 -N -O linuxdeploy-plugin-gstreamer.sh "https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gstreamer/master/linuxdeploy-plugin-gstreamer.sh" + chmod +x linuxdeploy-plugin-gstreamer.sh +else + gst_plugin="" +fi + +wget -q -4 -N -O linuxdeploy-plugin-gtk.sh https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh wget -q -4 -N -O linuxdeploy-${ARCH}.AppImage https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-${linuxdeploy_arch}.AppImage chmod +x linuxdeploy-plugin-gtk.sh chmod +x linuxdeploy-${ARCH}.AppImage -OUTPUT="{{appimage_filename}}" ./linuxdeploy-${ARCH}.AppImage --appimage-extract-and-run --appdir "{{app_name}}.AppDir" --plugin gtk --output appimage +OUTPUT="{{appimage_filename}}" ./linuxdeploy-${ARCH}.AppImage --appimage-extract-and-run --appdir "{{app_name}}.AppDir" --plugin gtk ${gst_plugin} --output appimage rm -r "{{app_name}}.AppDir" mv "{{appimage_filename}}" $OUTDIR diff --git a/tooling/cli/schema.json b/tooling/cli/schema.json index 81228dd17..4125a8e1a 100644 --- a/tooling/cli/schema.json +++ b/tooling/cli/schema.json @@ -118,6 +118,9 @@ }, "bundle": { "active": false, + "appimage": { + "bundleMediaFramework": false + }, "deb": { "files": {} }, @@ -245,6 +248,9 @@ "description": "The bundler configuration.", "default": { "active": false, + "appimage": { + "bundleMediaFramework": false + }, "deb": { "files": {} }, @@ -955,6 +961,17 @@ "null" ] }, + "appimage": { + "description": "Configuration for the AppImage bundle.", + "default": { + "bundleMediaFramework": false + }, + "allOf": [ + { + "$ref": "#/definitions/AppImageConfig" + } + ] + }, "deb": { "description": "Configuration for the Debian bundle.", "default": { @@ -1023,6 +1040,18 @@ } ] }, + "AppImageConfig": { + "description": "Configuration for AppImage bundles.", + "type": "object", + "properties": { + "bundleMediaFramework": { + "description": "Include additional gstreamer dependencies needed for audio and video playback. This increases the bundle size by ~15-35MB depending on your build system.", + "default": false, + "type": "boolean" + } + }, + "additionalProperties": false + }, "DebConfig": { "description": "Configuration for Debian (.deb) bundles.", "type": "object", diff --git a/tooling/cli/src/build.rs b/tooling/cli/src/build.rs index ad16e9f29..039be97a7 100644 --- a/tooling/cli/src/build.rs +++ b/tooling/cli/src/build.rs @@ -337,6 +337,9 @@ pub fn command(options: Options) -> Result<()> { } } } + if config_.tauri.bundle.appimage.bundle_media_framework { + std::env::set_var("APPIMAGE_BUNDLE_GSTREAMER", "1"); + } let bundles = bundle_project(settings).with_context(|| "failed to bundle project")?;