Rename embed-resources parameters fro the Slint compiler

This commit is contained in:
Tobias Hunger 2023-03-09 14:35:33 +01:00 committed by Tobias Hunger
parent bad588e1e4
commit c5ecade881
3 changed files with 17 additions and 18 deletions

View file

@ -2,10 +2,10 @@
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
# Set up machinery to handle SLINT_EMBED_RESOURCES target property
set(DEFAULT_SLINT_EMBED_RESOURCES as-paths CACHE STRING
set(DEFAULT_SLINT_EMBED_RESOURCES as-absolute-path CACHE STRING
"The default resource embedding option to pass to the Slint compiler")
set_property(CACHE DEFAULT_SLINT_EMBED_RESOURCES PROPERTY STRINGS
"as-paths" "as-contents" "as-textures")
"as-absolute-path" "embed-files" "embed-for-software-renderer")
define_property(TARGET PROPERTY SLINT_EMBED_RESOURCES
INITIALIZE_FROM_VARIABLE DEFAULT_SLINT_EMBED_RESOURCES)

View file

@ -68,18 +68,18 @@ CMake project, install it into a prefix directory of your choice and use `find_p
### Resource Embedding
You may change the default resource embedding the Slint compiler will use via
the `SLINT_EMBED_RESOURCES` target property, which accepts `as-paths`,
`as-contents` and `as-textures`. The latter optimizes for the Slint
software-renderer and falls back to `as-contents` if that isn't used.
the `SLINT_EMBED_RESOURCES` target property, which accepts `as-absolute-path`,
`embed-files` and `embed-for-software-renderer`. The latter optimizes for the
Slint software-renderer and falls back to `embed-files` if that isn't used.
Typically you will want to effect resource embedding for all targets in a
CMake project. This is done with the `DEFAULT_SLINT_EMBED_RESOURCES` option,
which initializes the `SLINT_EMBED_RESOURCES` target property.
Typically you will want to set `DEFAULT_SLINT_EMBED_RESOURCES` to `as-paths`
for debug builds as this reduces build times. When doing a release, you will
want to switch to `as-contents` to create self-contained binary that will work
on all systems.
Typically you will want to set `DEFAULT_SLINT_EMBED_RESOURCES` to
`as-absolute-path` for debug builds as this reduces build times. When doing a
release, you will want to switch to `embed-files` to create self-contained
binary that will work on all systems.
### Features

View file

@ -9,16 +9,15 @@ use std::io::Write;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
enum Embedding {
/// Embed resources using absolute paths on the build system (alias: false)
#[value(alias = "false", name = "as-paths")]
#[value(alias = "false")]
AsAbsolutePath,
/// Embed contents of resource files (alias: true)
#[value(alias = "true", name = "as-contents")]
AsFiles,
#[value(alias = "true")]
EmbedFiles,
/// Embed in a format optimized for the software renderer. This
/// option falls back to as-contents when the software-renderer is not
/// option falls back to `embed-files` if the software-renderer is not
/// used
#[value(name = "as-textures")]
SoftwareRenderer,
EmbedForSoftwareRenderer,
}
#[derive(Parser)]
@ -69,11 +68,11 @@ fn main() -> std::io::Result<()> {
if let Some(embed) = args.embed_resources {
compiler_config.embed_resources = match embed {
Embedding::AsAbsolutePath => EmbedResourcesKind::OnlyBuiltinResources,
Embedding::AsFiles => EmbedResourcesKind::EmbedAllResources,
Embedding::EmbedFiles => EmbedResourcesKind::EmbedAllResources,
#[cfg(feature = "software-renderer")]
Embedding::SoftwareRenderer => EmbedResourcesKind::EmbedTextures,
Embedding::EmbedForSoftwareRenderer => EmbedResourcesKind::EmbedTextures,
#[cfg(not(feature = "software-renderer"))]
Embedding::SoftwareRenderer => EmbedResourcesKind::EmbedAllResources,
Embedding::EmbedForSoftwareRenderer => EmbedResourcesKind::EmbedAllResources,
};
}