Skip to content

Commit

Permalink
fix: apply reviews, fixing names and nsi template
Browse files Browse the repository at this point in the history
  • Loading branch information
pewsheen committed Aug 31, 2023
1 parent 920db86 commit 3d1b95d
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .changes/nsis-set-compressor.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'tauri-bundler': 'patch:enhance'
---

Add `setCompressor` configuration option under `tauri > bundle > windows > nsis`.
Add `compression` configuration option under `tauri > bundle > windows > nsis`.
16 changes: 8 additions & 8 deletions core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1728,11 +1728,11 @@
"default": false,
"type": "boolean"
},
"setCompressor": {
"description": "Set the compression algorithm used to compress files in the installer.",
"compression": {
"description": "Set the compression algorithm used to compress files in the installer.\n\nSee <https://nsis.sourceforge.io/Reference/SetCompressor>",
"anyOf": [
{
"$ref": "#/definitions/NsisCompressor"
"$ref": "#/definitions/NsisCompression"
},
{
"type": "null"
Expand Down Expand Up @@ -1768,25 +1768,25 @@
}
]
},
"NsisCompressor": {
"description": "Compression algorithms used in the NSIS installer.",
"NsisCompression": {
"description": "Compression algorithms used in the NSIS installer.\n\nSee <https://nsis.sourceforge.io/Reference/SetCompressor>",
"oneOf": [
{
"description": "ZLIB compressor",
"description": "ZLIB uses the deflate algorithm, it is a quick and simple method. With the default compression level it uses about 300 KB of memory.",
"type": "string",
"enum": [
"zlib"
]
},
{
"description": "BZIP2 compressor",
"description": "BZIP2 usually gives better compression ratios than ZLIB, but it is a bit slower and uses more memory. With the default compression level it uses about 4 MB of memory.",
"type": "string",
"enum": [
"bzip2"
]
},
{
"description": "LZMA compressor (default)",
"description": "LZMA (default) is a new compression method that gives very good compression ratios. The decompression speed is high (10-20 MB/s on a 2 GHz CPU), the compression speed is lower. The memory size that will be used for decompression is the dictionary size plus a few KBs, the default is 8 MB.",
"type": "string",
"enum": [
"lzma"
Expand Down
4 changes: 2 additions & 2 deletions core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ pub enum NsisCompression {
Zlib,
/// BZIP2 usually gives better compression ratios than ZLIB, but it is a bit slower and uses more memory. With the default compression level it uses about 4 MB of memory.
Bzip2,
/// LZMA (default) is anew compression method that gives very good compression ratios. The decompression speed is high (10-20 MB/s on a 2 GHz CPU), the compression speed is lower. The memory size that will be used for decompression is the dictionary size plus a few KBs, the default is 8 MB.
/// LZMA (default) is a new compression method that gives very good compression ratios. The decompression speed is high (10-20 MB/s on a 2 GHz CPU), the compression speed is lower. The memory size that will be used for decompression is the dictionary size plus a few KBs, the default is 8 MB.
Lzma,
}

Expand Down Expand Up @@ -498,7 +498,7 @@ pub struct NsisConfig {
/// Set the compression algorithm used to compress files in the installer.
///
/// See <https://nsis.sourceforge.io/Reference/SetCompressor>
pub compression: Option<NsisCompressor>,
pub compression: Option<NsisCompression>,
}

/// Install Modes for the NSIS installer.
Expand Down
4 changes: 2 additions & 2 deletions tooling/bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::category::AppCategory;
use crate::bundle::{common, platform::target_triple};
pub use tauri_utils::config::WebviewInstallMode;
use tauri_utils::{
config::{BundleType, FileAssociation, NSISInstallerMode, NsisCompressor},
config::{BundleType, FileAssociation, NSISInstallerMode, NsisCompression},
resources::{external_binaries, ResourcePaths},
};

Expand Down Expand Up @@ -290,7 +290,7 @@ pub struct NsisSettings {
/// By default the OS language is selected, with a fallback to the first language in the `languages` array.
pub display_language_selector: bool,
/// Set compression algorithm used to compress files in the installer.
pub compression: Option<NsisCompressor>,
pub compression: Option<NsisCompression>,
}

/// The Windows bundle settings.
Expand Down
14 changes: 7 additions & 7 deletions tooling/bundler/src/bundle/windows/nsis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use anyhow::Context;
use handlebars::{to_json, Handlebars};
use log::{info, warn};
use tauri_utils::{
config::{NSISInstallerMode, NsisCompressor, WebviewInstallMode},
config::{NSISInstallerMode, NsisCompression, WebviewInstallMode},
resources::resource_relpath,
};

Expand Down Expand Up @@ -243,15 +243,15 @@ fn build_nsis_app_installer(
to_json(dunce::canonicalize(sidebar_image)?),
);
}

data.insert(
"set_compressor",
to_json(match compressor.unwrap_or(NsisCompressor::Lzma) {
NsisCompressor::Zlib => "zlib",
NsisCompressor::Bzip2 => "bzip2",
NsisCompressor::Lzma => "lzma",
"compression",
to_json(match &nsis.compression.unwrap_or(NsisCompression::Lzma) {
NsisCompression::Zlib => "zlib",
NsisCompression::Bzip2 => "bzip2",
NsisCompression::Lzma => "lzma",
}),
);


data.insert(
"display_language_selector",
Expand Down
6 changes: 5 additions & 1 deletion tooling/bundler/src/bundle/windows/templates/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ OutFile "${OUTFILE}"
Unicode true

; Set the compression algorithm. Default is LZMA.
SetCompressor /SOLID "${SETCOMPRESSOR}"
!if "${COMPRESSION}" == ""
SetCompressor /SOLID lzma
!else
SetCompressor /SOLID "${COMPRESSION}"
!endif

VIProductVersion "${VERSIONWITHBUILD}"
VIAddVersionKey "ProductName" "${PRODUCTNAME}"
Expand Down
16 changes: 8 additions & 8 deletions tooling/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1728,11 +1728,11 @@
"default": false,
"type": "boolean"
},
"setCompressor": {
"description": "Set the compression algorithm used to compress files in the installer.",
"compression": {
"description": "Set the compression algorithm used to compress files in the installer.\n\nSee <https://nsis.sourceforge.io/Reference/SetCompressor>",
"anyOf": [
{
"$ref": "#/definitions/NsisCompressor"
"$ref": "#/definitions/NsisCompression"
},
{
"type": "null"
Expand Down Expand Up @@ -1768,25 +1768,25 @@
}
]
},
"NsisCompressor": {
"description": "Compression algorithms used in the NSIS installer.",
"NsisCompression": {
"description": "Compression algorithms used in the NSIS installer.\n\nSee <https://nsis.sourceforge.io/Reference/SetCompressor>",
"oneOf": [
{
"description": "ZLIB compressor",
"description": "ZLIB uses the deflate algorithm, it is a quick and simple method. With the default compression level it uses about 300 KB of memory.",
"type": "string",
"enum": [
"zlib"
]
},
{
"description": "BZIP2 compressor",
"description": "BZIP2 usually gives better compression ratios than ZLIB, but it is a bit slower and uses more memory. With the default compression level it uses about 4 MB of memory.",
"type": "string",
"enum": [
"bzip2"
]
},
{
"description": "LZMA compressor (default)",
"description": "LZMA (default) is a new compression method that gives very good compression ratios. The decompression speed is high (10-20 MB/s on a 2 GHz CPU), the compression speed is lower. The memory size that will be used for decompression is the dictionary size plus a few KBs, the default is 8 MB.",
"type": "string",
"enum": [
"lzma"
Expand Down
2 changes: 1 addition & 1 deletion tooling/cli/src/helpers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn nsis_settings(config: NsisConfig) -> tauri_bundler::NsisSettings {
languages: config.languages,
custom_language_files: config.custom_language_files,
display_language_selector: config.display_language_selector,
set_compressor: config.set_compressor,
compression: config.compression,
}
}

Expand Down

0 comments on commit 3d1b95d

Please sign in to comment.