libcosmic/src/widget/icon/bundle.rs
Kyle Scheuing 80875d5962
fix: compiling on windows requires cosmic-icons in project root
* fix: compiling on windows requires cosmic-icons in project root

crabtime provides crabtime::WORKSPACE_PATH to refer to the
CARGO_MANIFEST_DIR of the top level crate being built, which means when
building libcosmic directly, crabtime::WORKSPACE_PATH will work, but
when building it as a dependency of another crate,
crabtime::WORKSPACE_PATH will no longer refer to the path to libcosmic.

I don't think there's a good workaround, since when in the context of
crabtime, CARGO_MANIFEST_DIR refers to the path to the crate generated
by crabtime rather than to libcosmic.

This replaces crabtime with a simple build.rs script that generates a
file in OUT_DIR.

* fix: do not generate icon bundle for unix targets

---------

Co-authored-by: Michael Aaron Murphy <michael@mmurphy.dev>
2025-12-04 17:31:47 +01:00

21 lines
609 B
Rust

// Copyright 2025 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
//! Embedded icons for platforms which do not support icon themes yet.
/// Icon bundling is not enabled on unix platforms.
#[cfg(unix)]
pub fn get(icon_name: &str) -> Option<super::Data> {
None
}
#[cfg(not(unix))]
/// Get a bundled icon on non-unix platforms.
pub fn get(icon_name: &str) -> Option<super::Data> {
ICONS
.get(icon_name)
.map(|bytes| super::Data::Svg(crate::iced::widget::svg::Handle::from_memory(*bytes)))
}
#[cfg(not(unix))]
include!(concat!(env!("OUT_DIR"), "/bundled_icons.rs"));