Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_dylib/src/lib.rs
6596 views
1
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2
#![doc(
3
html_logo_url = "https://bevy.org/assets/icon.png",
4
html_favicon_url = "https://bevy.org/assets/icon.png"
5
)]
6
7
//! Forces dynamic linking of Bevy.
8
//!
9
//! Dynamic linking causes Bevy to be built and linked as a dynamic library. This will make
10
//! incremental builds compile much faster.
11
//!
12
//! # Warning
13
//!
14
//! Do not enable this feature for release builds because this would require you to ship
15
//! `libstd.so` and `libbevy_dylib.so` with your game.
16
//!
17
//! # Enabling dynamic linking
18
//!
19
//! ## The recommended way
20
//!
21
//! The easiest way to enable dynamic linking is to use the `--features bevy/dynamic_linking` flag when
22
//! using the `cargo run` command:
23
//!
24
//! `cargo run --features bevy/dynamic_linking`
25
//!
26
//! ## The unrecommended way
27
//!
28
//! It is also possible to enable the `dynamic_linking` feature inside of the `Cargo.toml` file. This is
29
//! unrecommended because it requires you to remove this feature every time you want to create a
30
//! release build to avoid having to ship additional files with your game.
31
//!
32
//! To enable dynamic linking inside of the `Cargo.toml` file add the `dynamic_linking` feature to the
33
//! bevy dependency:
34
//!
35
//! `features = ["dynamic_linking"]`
36
//!
37
//! ## The manual way
38
//!
39
//! Manually enabling dynamic linking is achieved by adding `bevy_dylib` as a dependency and
40
//! adding the following code to the `main.rs` file:
41
//!
42
//! ```
43
//! #[allow(unused_imports)]
44
//! use bevy_dylib;
45
//! ```
46
//!
47
//! It is recommended to disable the `bevy_dylib` dependency in release mode by adding the
48
//! following code to the `use` statement to avoid having to ship additional files with your game:
49
//!
50
//! ```
51
//! #[allow(unused_imports)]
52
//! #[cfg(debug_assertions)] // new
53
//! use bevy_dylib;
54
//! ```
55
56
// Force linking of the main bevy crate
57
#[expect(
58
unused_imports,
59
clippy::single_component_path_imports,
60
reason = "This links the main bevy crate when using dynamic linking, and as such cannot be removed or changed without affecting dynamic linking."
61
)]
62
use bevy_internal;
63
64