Skip to content

Commit d335fae

Browse files
feat(bundler): bundle additional gstreamer files, closes #4092 (#4271)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
1 parent f6205af commit d335fae

7 files changed

Lines changed: 76 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-bundler": patch
3+
---
4+
5+
Bundle additional gstreamer files needed for audio and video playback if the `APPIMAGE_BUNDLE_GSTREAMER` environment variable is set.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-utils": patch
3+
---
4+
5+
Added a config flag to bundle the media framework used by webkit2gtk `tauri.conf.json > tauri > bundle > appimage > bundleMediaFramework`.

.changes/cli-bundle-gstreamer.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cli.rs": patch
3+
"cli.js": patch
4+
---
5+
6+
Set the `APPIMAGE_BUNDLE_GSTREAMER` environment variable to make the bundler copy additional gstreamer files to the AppImage.

core/tauri-utils/src/config.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ impl BundleTarget {
8787
}
8888
}
8989

90+
/// Configuration for AppImage bundles.
91+
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
92+
#[cfg_attr(feature = "schema", derive(JsonSchema))]
93+
#[serde(rename_all = "camelCase", deny_unknown_fields)]
94+
pub struct AppImageConfig {
95+
/// Include additional gstreamer dependencies needed for audio and video playback.
96+
/// This increases the bundle size by ~15-35MB depending on your build system.
97+
#[serde(default)]
98+
pub bundle_media_framework: bool,
99+
}
100+
90101
/// Configuration for Debian (.deb) bundles.
91102
#[skip_serializing_none]
92103
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
@@ -322,6 +333,9 @@ pub struct BundleConfig {
322333
pub short_description: Option<String>,
323334
/// A longer, multi-line description of the application.
324335
pub long_description: Option<String>,
336+
/// Configuration for the AppImage bundle.
337+
#[serde(default)]
338+
pub appimage: AppImageConfig,
325339
/// Configuration for the Debian bundle.
326340
#[serde(default)]
327341
pub deb: DebConfig,
@@ -2728,6 +2742,7 @@ mod build {
27282742
let category = quote!(None);
27292743
let short_description = quote!(None);
27302744
let long_description = quote!(None);
2745+
let appimage = quote!(Default::default());
27312746
let deb = quote!(Default::default());
27322747
let macos = quote!(Default::default());
27332748
let external_bin = opt_vec_str_lit(self.external_bin.as_ref());
@@ -2745,6 +2760,7 @@ mod build {
27452760
category,
27462761
short_description,
27472762
long_description,
2763+
appimage,
27482764
deb,
27492765
macos,
27502766
external_bin,
@@ -3147,6 +3163,7 @@ mod test {
31473163
category: None,
31483164
short_description: None,
31493165
long_description: None,
3166+
appimage: Default::default(),
31503167
deb: Default::default(),
31513168
macos: Default::default(),
31523169
external_bin: None,

tooling/bundler/src/bundle/linux/templates/appimage

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set -euxo pipefail
77

88
export ARCH={{arch}}
99
APPIMAGE_BUNDLE_XDG_OPEN=${APPIMAGE_BUNDLE_XDG_OPEN-0}
10+
APPIMAGE_BUNDLE_GSTREAMER=${APPIMAGE_BUNDLE_GSTREAMER-0}
1011
TRAY_LIBRARY_PATH=${TRAY_LIBRARY_PATH-0}
1112

1213
if [ "$ARCH" == "i686" ]; then
@@ -51,12 +52,20 @@ ln -s "usr/share/applications/{{app_name}}.desktop" "{{app_name}}.desktop"
5152

5253
cd ..
5354

54-
wget -q -4 -N -O linuxdeploy-plugin-gtk.sh "https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh"
55+
if [[ "$APPIMAGE_BUNDLE_GSTREAMER" != "0" ]]; then
56+
gst_plugin="--plugin gstreamer"
57+
wget -q -4 -N -O linuxdeploy-plugin-gstreamer.sh "https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gstreamer/master/linuxdeploy-plugin-gstreamer.sh"
58+
chmod +x linuxdeploy-plugin-gstreamer.sh
59+
else
60+
gst_plugin=""
61+
fi
62+
63+
wget -q -4 -N -O linuxdeploy-plugin-gtk.sh https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh
5564
wget -q -4 -N -O linuxdeploy-${ARCH}.AppImage https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-${linuxdeploy_arch}.AppImage
5665

5766
chmod +x linuxdeploy-plugin-gtk.sh
5867
chmod +x linuxdeploy-${ARCH}.AppImage
5968

60-
OUTPUT="{{appimage_filename}}" ./linuxdeploy-${ARCH}.AppImage --appimage-extract-and-run --appdir "{{app_name}}.AppDir" --plugin gtk --output appimage
69+
OUTPUT="{{appimage_filename}}" ./linuxdeploy-${ARCH}.AppImage --appimage-extract-and-run --appdir "{{app_name}}.AppDir" --plugin gtk ${gst_plugin} --output appimage
6170
rm -r "{{app_name}}.AppDir"
6271
mv "{{appimage_filename}}" $OUTDIR

tooling/cli/schema.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@
118118
},
119119
"bundle": {
120120
"active": false,
121+
"appimage": {
122+
"bundleMediaFramework": false
123+
},
121124
"deb": {
122125
"files": {}
123126
},
@@ -245,6 +248,9 @@
245248
"description": "The bundler configuration.",
246249
"default": {
247250
"active": false,
251+
"appimage": {
252+
"bundleMediaFramework": false
253+
},
248254
"deb": {
249255
"files": {}
250256
},
@@ -955,6 +961,17 @@
955961
"null"
956962
]
957963
},
964+
"appimage": {
965+
"description": "Configuration for the AppImage bundle.",
966+
"default": {
967+
"bundleMediaFramework": false
968+
},
969+
"allOf": [
970+
{
971+
"$ref": "#/definitions/AppImageConfig"
972+
}
973+
]
974+
},
958975
"deb": {
959976
"description": "Configuration for the Debian bundle.",
960977
"default": {
@@ -1023,6 +1040,18 @@
10231040
}
10241041
]
10251042
},
1043+
"AppImageConfig": {
1044+
"description": "Configuration for AppImage bundles.",
1045+
"type": "object",
1046+
"properties": {
1047+
"bundleMediaFramework": {
1048+
"description": "Include additional gstreamer dependencies needed for audio and video playback. This increases the bundle size by ~15-35MB depending on your build system.",
1049+
"default": false,
1050+
"type": "boolean"
1051+
}
1052+
},
1053+
"additionalProperties": false
1054+
},
10261055
"DebConfig": {
10271056
"description": "Configuration for Debian (.deb) bundles.",
10281057
"type": "object",

tooling/cli/src/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ pub fn command(options: Options) -> Result<()> {
337337
}
338338
}
339339
}
340+
if config_.tauri.bundle.appimage.bundle_media_framework {
341+
std::env::set_var("APPIMAGE_BUNDLE_GSTREAMER", "1");
342+
}
340343

341344
let bundles = bundle_project(settings).with_context(|| "failed to bundle project")?;
342345

0 commit comments

Comments
 (0)