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

Fix headless mode compilation. #347

Merged
merged 1 commit into from
Nov 21, 2022
Merged
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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ jobs:
command: check
args: --all-targets --features atlas

- name: Run cargo check headless
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! 👍

uses: actions-rs/cargo@v1
with:
command: check
args: --all-targets --no-default-features

# test:
# name: Tests
# strategy:
Expand Down
6 changes: 4 additions & 2 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ mod helpers;
fn startup(
mut commands: Commands,
asset_server: Res<AssetServer>,
#[cfg(not(feature = "atlas"))] array_texture_loader: Res<ArrayTextureLoader>,
#[cfg(all(not(feature = "atlas"), feature = "render"))] array_texture_loader: Res<
ArrayTextureLoader,
>,
) {
commands.spawn(Camera2dBundle::default());

Expand Down Expand Up @@ -60,7 +62,7 @@ fn startup(

// Add atlas to array texture loader so it's preprocessed before we need to use it.
// Only used when the atlas feature is off and we are using array textures.
#[cfg(not(feature = "atlas"))]
#[cfg(all(not(feature = "atlas"), feature = "render"))]
{
array_texture_loader.add(TilemapArrayTexture {
texture: TilemapTexture::Single(asset_server.load("tiles.png")),
Expand Down
3 changes: 0 additions & 3 deletions src/array_texture_preload.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(feature = "render")]
use crate::render::{DefaultSampler, TextureArrayCache};
use crate::{
prelude::{TilemapSpacing, TilemapTileSize},
Expand All @@ -8,7 +7,6 @@ use bevy::render::{
render_resource::{FilterMode, TextureFormat},
texture::BevyDefault,
};
#[cfg(feature = "render")]
use bevy::{
prelude::{Assets, Image, Res, ResMut, Resource},
render::Extract,
Expand Down Expand Up @@ -60,7 +58,6 @@ impl ArrayTextureLoader {
}
}

#[cfg(feature = "render")]
pub(crate) fn extract(
images: Extract<Res<Assets<Image>>>,
array_texture_loader: Extract<Res<ArrayTextureLoader>>,
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use tiles::{
use bevy::render::{RenderApp, RenderStage};

/// A module that allows pre-loading of atlases into array textures.
#[cfg(not(feature = "atlas"))]
#[cfg(all(not(feature = "atlas"), feature = "render"))]
mod array_texture_preload;
/// A module which provides helper functions.
pub mod helpers;
Expand Down Expand Up @@ -114,7 +114,7 @@ pub struct TilemapBundle {

/// A module which exports commonly used dependencies.
pub mod prelude {
#[cfg(not(feature = "atlas"))]
#[cfg(all(not(feature = "atlas"), feature = "render"))]
pub use crate::array_texture_preload::*;
pub use crate::helpers::filling::*;
pub use crate::helpers::geometry::*;
Expand Down