Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dynamic linking feature #867

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 25 additions & 44 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,35 @@ categories = ["gui"]

[features]
default = ["wgpu", "default_system_font"]
# Enables the `iced_wgpu` renderer
wgpu = ["iced_wgpu"]
# Enables the `Image` widget
image = ["iced_wgpu/image"]
# Enables the `Svg` widget
svg = ["iced_wgpu/svg"]
# Enables the `Canvas` widget
canvas = ["iced_wgpu/canvas"]
# Enables the `QRCode` widget
qr_code = ["iced_wgpu/qr_code"]
# Enables using system fonts
default_system_font = ["iced_wgpu/default_system_font"]
# Enables the `iced_glow` renderer. Overrides `iced_wgpu`
glow = ["iced_glow", "iced_glutin"]
# Enables the `Canvas` widget for `iced_glow`
glow_canvas = ["iced_glow/canvas"]
# Enables the `QRCode` widget for `iced_glow`
glow_qr_code = ["iced_glow/qr_code"]
# Enables using system fonts for `iced_glow`
glow_default_system_font = ["iced_glow/default_system_font"]
# Enables a debug view in native platforms (press F12)
debug = ["iced_winit/debug"]
# Enables `tokio` as the `executor::Default` on native platforms
tokio = ["iced_futures/tokio"]
# Enables old `tokio` (0.2) as the `executor::Default` on native platforms
tokio_old = ["iced_futures/tokio_old"]
# Enables `async-std` as the `executor::Default` on native platforms
async-std = ["iced_futures/async-std"]
# Enables `smol` as the `executor::Default` on native platforms
smol = ["iced_futures/smol"]
# Enables advanced color conversion via `palette`
palette = ["iced_core/palette"]

# Force dynamic linking, which improves iterative compile times
dynamic = ["iced_dynamic"]

# See ./internal/Cargo.toml for descriptions
wgpu = ["iced_internal/wgpu"]
image = ["iced_internal/image"]
svg = ["iced_internal/svg"]
canvas = ["iced_internal/canvas"]
qr_code = ["iced_internal/qr_code"]
default_system_font = ["iced_internal/default_system_font"]
glow = ["iced_internal/glow"]
glow_canvas = ["iced_internal/canvas"]
glow_qr_code = ["iced_internal/qr_code"]
glow_default_system_font = ["iced_internal/default_system_font"]
debug = ["iced_internal/debug"]
tokio = ["iced_internal/tokio"]
tokio_old = ["iced_internal/tokio_old"]
async-std = ["iced_internal/async-std"]
smol = ["iced_internal/smol"]
palette = ["iced_internal/palette"]

[badges]
maintenance = { status = "actively-developed" }

[workspace]
members = [
"internal",
"dynamic",
"core",
"futures",
"graphics",
Expand Down Expand Up @@ -87,18 +78,8 @@ members = [
]

[dependencies]
iced_core = { version = "0.4", path = "core" }
iced_futures = { version = "0.3", path = "futures" }
thiserror = "1.0"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
iced_winit = { version = "0.3", path = "winit" }
iced_glutin = { version = "0.2", path = "glutin", optional = true }
iced_wgpu = { version = "0.4", path = "wgpu", optional = true }
iced_glow = { version = "0.2", path = "glow", optional = true}

[target.'cfg(target_arch = "wasm32")'.dependencies]
iced_web = { version = "0.4", path = "web" }
iced_dynamic = { version = "0.3.0", path = "dynamic", default-features = false, optional = true }
iced_internal = { version = "0.3.0", path = "internal", default-features = false }

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Inspired by [Elm].
* A [built-in renderer] supporting Vulkan, Metal, DX11, and DX12
* A [windowing shell]
* A [web runtime] leveraging the DOM
* Fast iteration times with dynamic linking (`--features iced/dynamic`)

__Iced is currently experimental software.__ [Take a look at the roadmap],
[check out the issues], and [feel free to contribute!]
Expand Down
18 changes: 18 additions & 0 deletions dynamic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "iced_dynamic"
version = "0.3.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
description = "A cross-platform GUI library inspired by Elm"
license = "MIT"
repository = "https://github.com/hecrj/iced"
documentation = "https://docs.rs/iced"
readme = "README.md"
keywords = ["gui", "ui", "graphics", "interface", "widgets"]
categories = ["gui"]

[lib]
crate-type = ["dylib"]

[dependencies]
iced_internal = { path = "../internal", version = "0.3.0", default-features = false }
12 changes: 12 additions & 0 deletions dynamic/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//! Forces dynamic linking of Iced.
//!
//! Dynamically linking Iced makes the "link" step much faster. This can be achieved by adding
//! `iced_dynamic` as dependency and `#[allow(unused_imports)] use iced_dynamic` to `main.rs`. It is
//! recommended to disable the `iced_dynamic` dependency in release mode by adding
//! `#[cfg(debug_assertions)]` to the `use` statement. Otherwise you will have to ship `libstd.so`
//! and `libiced_dynamic.so` with your game.

// Force linking of the main iced crate
#[allow(unused_imports)]
#[allow(clippy::single_component_path_imports)]
use iced_internal;
60 changes: 60 additions & 0 deletions internal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[package]
name = "iced_internal"
version = "0.3.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
description = "A cross-platform GUI library inspired by Elm"
license = "MIT"
repository = "https://github.com/hecrj/iced"
documentation = "https://docs.rs/iced"
readme = "README.md"
keywords = ["gui", "ui", "graphics", "interface", "widgets"]
categories = ["gui"]

[features]
# Enables the `iced_wgpu` renderer
wgpu = ["iced_wgpu"]
# Enables the `Image` widget
image = ["iced_wgpu/image"]
# Enables the `Svg` widget
svg = ["iced_wgpu/svg"]
# Enables the `Canvas` widget
canvas = ["iced_wgpu/canvas"]
# Enables the `QRCode` widget
qr_code = ["iced_wgpu/qr_code"]
# Enables using system fonts
default_system_font = ["iced_wgpu/default_system_font"]
# Enables the `iced_glow` renderer. Overrides `iced_wgpu`
glow = ["iced_glow", "iced_glutin"]
# Enables the `Canvas` widget for `iced_glow`
glow_canvas = ["iced_glow/canvas"]
# Enables the `QRCode` widget for `iced_glow`
glow_qr_code = ["iced_glow/qr_code"]
# Enables using system fonts for `iced_glow`
glow_default_system_font = ["iced_glow/default_system_font"]
# Enables a debug view in native platforms (press F12)
debug = ["iced_winit/debug"]
# Enables `tokio` as the `executor::Default` on native platforms
tokio = ["iced_futures/tokio"]
# Enables old `tokio` (0.2) as the `executor::Default` on native platforms
tokio_old = ["iced_futures/tokio_old"]
# Enables `async-std` as the `executor::Default` on native platforms
async-std = ["iced_futures/async-std"]
# Enables `smol` as the `executor::Default` on native platforms
smol = ["iced_futures/smol"]
# Enables advanced color conversion via `palette`
palette = ["iced_core/palette"]

[dependencies]
iced_core = { version = "0.4", path = "../core" }
iced_futures = { version = "0.3", path = "../futures" }
thiserror = "1.0"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
iced_winit = { version = "0.3", path = "../winit" }
iced_glutin = { version = "0.2", path = "../glutin", optional = true }
iced_wgpu = { version = "0.4", path = "../wgpu", optional = true }
iced_glow = { version = "0.2", path = "../glow", optional = true}

[target.'cfg(target_arch = "wasm32")'.dependencies]
iced_web = { version = "0.4", path = "../web" }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
75 changes: 75 additions & 0 deletions internal/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
mod application;
mod element;
mod error;
mod result;
mod sandbox;

pub mod executor;
pub mod keyboard;
pub mod mouse;
pub mod settings;
pub mod widget;
pub mod window;

#[cfg(all(
any(
feature = "tokio",
feature = "tokio_old",
feature = "async-std",
feature = "smol"
),
not(target_arch = "wasm32")
))]
#[cfg_attr(
docsrs,
doc(cfg(any(
feature = "tokio",
feature = "tokio_old",
feature = "async-std"
feature = "smol"
)))
)]
pub mod time;

#[cfg(all(
not(target_arch = "wasm32"),
not(feature = "glow"),
feature = "wgpu"
))]
use iced_winit as runtime;

#[cfg(all(not(target_arch = "wasm32"), feature = "glow"))]
use iced_glutin as runtime;

mod renderer {
#[cfg(all(
not(target_arch = "wasm32"),
not(feature = "glow"),
feature = "wgpu"
))]
pub use iced_wgpu::*;

#[cfg(all(not(target_arch = "wasm32"), feature = "glow"))]
pub use iced_glow::*;
}


#[cfg(target_arch = "wasm32")]
use iced_web as runtime;

#[doc(no_inline)]
pub use widget::*;

pub use application::Application;
pub use element::Element;
pub use error::Error;
pub use executor::Executor;
pub use result::Result;
pub use sandbox::Sandbox;
pub use settings::Settings;

pub use runtime::{
futures, Align, Background, Clipboard, Color, Command, Font,
HorizontalAlignment, Length, Point, Rectangle, Size, Subscription, Vector,
VerticalAlignment,
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
77 changes: 6 additions & 71 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,81 +171,16 @@
//!
//! [Elm]: https://elm-lang.org/
//! [The Elm Architecture]: https://guide.elm-lang.org/architecture/

#![deny(missing_docs)]
#![deny(missing_debug_implementations)]
#![deny(unused_results)]
#![forbid(unsafe_code)]
#![forbid(rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg))]
mod application;
mod element;
mod error;
mod result;
mod sandbox;

pub mod executor;
pub mod keyboard;
pub mod mouse;
pub mod settings;
pub mod widget;
pub mod window;

#[cfg(all(
any(
feature = "tokio",
feature = "tokio_old",
feature = "async-std",
feature = "smol"
),
not(target_arch = "wasm32")
))]
#[cfg_attr(
docsrs,
doc(cfg(any(
feature = "tokio",
feature = "tokio_old",
feature = "async-std"
feature = "smol"
)))
)]
pub mod time;

#[cfg(all(
not(target_arch = "wasm32"),
not(feature = "glow"),
feature = "wgpu"
))]
use iced_winit as runtime;

#[cfg(all(not(target_arch = "wasm32"), feature = "glow"))]
use iced_glutin as runtime;

#[cfg(all(
not(target_arch = "wasm32"),
not(feature = "glow"),
feature = "wgpu"
))]
use iced_wgpu as renderer;

#[cfg(all(not(target_arch = "wasm32"), feature = "glow"))]
use iced_glow as renderer;

#[cfg(target_arch = "wasm32")]
use iced_web as runtime;

#[doc(no_inline)]
pub use widget::*;

pub use application::Application;
pub use element::Element;
pub use error::Error;
pub use executor::Executor;
pub use result::Result;
pub use sandbox::Sandbox;
pub use settings::Settings;
pub use iced_internal::*;

pub use runtime::{
futures, Align, Background, Clipboard, Color, Command, Font,
HorizontalAlignment, Length, Point, Rectangle, Size, Subscription, Vector,
VerticalAlignment,
};
#[cfg(feature = "dynamic")]
#[allow(unused_imports)]
#[allow(clippy::single_component_path_imports)]
use iced_dynamic;