Skip to content

Commit

Permalink
feat(bundler): bundle additional gstreamer files, closes #4092 (#4271)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
  • Loading branch information
FabianLars and lucasfernog committed Jun 10, 2022
1 parent f6205af commit d335fae
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/appimage-bundle-gstreamer.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions .changes/bundle-media-framework-config.md
Original file line number Diff line number Diff line change
@@ -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`.
6 changes: 6 additions & 0 deletions .changes/cli-bundle-gstreamer.md
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 17 additions & 0 deletions core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -322,6 +333,9 @@ pub struct BundleConfig {
pub short_description: Option<String>,
/// A longer, multi-line description of the application.
pub long_description: Option<String>,
/// Configuration for the AppImage bundle.
#[serde(default)]
pub appimage: AppImageConfig,
/// Configuration for the Debian bundle.
#[serde(default)]
pub deb: DebConfig,
Expand Down Expand Up @@ -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());
Expand All @@ -2745,6 +2760,7 @@ mod build {
category,
short_description,
long_description,
appimage,
deb,
macos,
external_bin,
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 11 additions & 2 deletions tooling/bundler/src/bundle/linux/templates/appimage
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
29 changes: 29 additions & 0 deletions tooling/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
},
"bundle": {
"active": false,
"appimage": {
"bundleMediaFramework": false
},
"deb": {
"files": {}
},
Expand Down Expand Up @@ -245,6 +248,9 @@
"description": "The bundler configuration.",
"default": {
"active": false,
"appimage": {
"bundleMediaFramework": false
},
"deb": {
"files": {}
},
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions tooling/cli/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")?;

Expand Down

0 comments on commit d335fae

Please sign in to comment.