* Create a crate for constant serialization of config structs for manganis * use SerializeConst for the image asset builder * switch to a declarative macro for assets * add serializable options for each asset type * implement the new manganis macro * optimize assets in the CLI * Fix assets with dioxus formattable * reduce fuzzing test limits * use the new syntax in examples * fix avif support * Fix manganis doc tests * cache asset optimization * Split out asset and bundled asset * make hash pointer width independent * Fix manganis macro docs * add constvec::is_empty method to fix clippy lint * remove nasm feature * simplify test_rsplit_once test so typos passes * revert example change from clippy fix * always accept unix paths * fix windows path seperator * fix folder asset hash * Optimize assets in a blocking task * Fix asset options docs * Document Asset and BundledAsset * simplify the linker macro a bit * add more docs to AssetParser expansion * add image format helpers * Split by both unix and windows path separators and take the smallest one
72 lines
2.1 KiB
Rust
72 lines
2.1 KiB
Rust
//! Utilities for working with Manganis assets in the linker. This module defines [`LinkSection`] which has information about what section manganis assets are stored in on each platform.
|
|
|
|
/// Information about the manganis link section for a given platform
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub struct LinkSection {
|
|
/// The link section we pass to the static
|
|
pub link_section: &'static str,
|
|
/// The name of the section we find in the binary
|
|
pub name: &'static str,
|
|
}
|
|
|
|
impl LinkSection {
|
|
/// The list of link sections for all supported platforms
|
|
pub const ALL: &'static [&'static LinkSection] =
|
|
&[Self::WASM, Self::MACOS, Self::WINDOWS, Self::ILLUMOS];
|
|
|
|
/// Returns the link section used in linux, android, fuchsia, psp, freebsd, and wasm32
|
|
pub const WASM: &'static LinkSection = &LinkSection {
|
|
link_section: "manganis",
|
|
name: "manganis",
|
|
};
|
|
|
|
/// Returns the link section used in macOS, iOS, tvOS
|
|
pub const MACOS: &'static LinkSection = &LinkSection {
|
|
link_section: "__DATA,manganis,regular,no_dead_strip",
|
|
name: "manganis",
|
|
};
|
|
|
|
/// Returns the link section used in windows
|
|
pub const WINDOWS: &'static LinkSection = &LinkSection {
|
|
link_section: "mg",
|
|
name: "mg",
|
|
};
|
|
|
|
/// Returns the link section used in illumos
|
|
pub const ILLUMOS: &'static LinkSection = &LinkSection {
|
|
link_section: "set_manganis",
|
|
name: "set_manganis",
|
|
};
|
|
|
|
/// The link section used on the current platform
|
|
pub const CURRENT: &'static LinkSection = {
|
|
#[cfg(any(
|
|
target_os = "none",
|
|
target_os = "linux",
|
|
target_os = "android",
|
|
target_os = "fuchsia",
|
|
target_os = "psp",
|
|
target_os = "freebsd",
|
|
target_arch = "wasm32"
|
|
))]
|
|
{
|
|
Self::WASM
|
|
}
|
|
|
|
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos"))]
|
|
{
|
|
Self::MACOS
|
|
}
|
|
|
|
#[cfg(target_os = "windows")]
|
|
{
|
|
Self::WINDOWS
|
|
}
|
|
|
|
#[cfg(target_os = "illumos")]
|
|
{
|
|
Self::ILLUMOS
|
|
}
|
|
};
|
|
}
|