Add production build pipeline (#46)
## Summary - split development dynamic linking from production builds - add headless processed-asset generation - add a separate production CI cache and static Bevy/Rust linkage verification - keep custom debug features enabled for production builds behind a feature gate Reviewed-on: #46 Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #46.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
use bevy::{
|
||||
app::ScheduleRunnerPlugin,
|
||||
asset::{AssetMode, AssetPlugin, processor::AssetProcessor, processor::ProcessorState},
|
||||
prelude::*,
|
||||
tasks::block_on,
|
||||
};
|
||||
use shinespark::AssetProcessingPlugin;
|
||||
use std::{process::ExitCode, time::Duration};
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let mut app = App::new();
|
||||
app.add_plugins(MinimalPlugins.set(ScheduleRunnerPlugin::run_loop(Duration::from_millis(50))))
|
||||
.add_plugins(AssetPlugin {
|
||||
mode: AssetMode::Processed,
|
||||
use_asset_processor_override: Some(true),
|
||||
..default()
|
||||
})
|
||||
.add_plugins(AssetProcessingPlugin)
|
||||
.add_systems(Update, finish_when_processed);
|
||||
|
||||
app.run();
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
|
||||
fn finish_when_processed(processor: Option<Res<AssetProcessor>>, mut exit: MessageWriter<AppExit>) {
|
||||
if processor
|
||||
.is_some_and(|processor| block_on(processor.get_state()) == ProcessorState::Finished)
|
||||
{
|
||||
exit.write(AppExit::Success);
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,10 @@ type FighterBakeProcessor = LoadTransformAndSave<
|
||||
>;
|
||||
|
||||
pub struct BakedAnimationPlugin;
|
||||
impl Plugin for BakedAnimationPlugin {
|
||||
|
||||
pub struct BakedAnimationAssetProcessingPlugin;
|
||||
|
||||
impl Plugin for BakedAnimationAssetProcessingPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_asset::<BakedFighterAnimations>()
|
||||
.register_asset_loader(FighterBakeSourceLoader)
|
||||
@@ -160,7 +163,13 @@ impl Plugin for BakedAnimationPlugin {
|
||||
FighterBakeTransformer,
|
||||
BakedFighterAnimationsSaver,
|
||||
))
|
||||
.set_default_asset_processor::<FighterBakeProcessor>("fighterbake")
|
||||
.set_default_asset_processor::<FighterBakeProcessor>("fighterbake");
|
||||
}
|
||||
}
|
||||
|
||||
impl Plugin for BakedAnimationPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_plugins(BakedAnimationAssetProcessingPlugin)
|
||||
.add_systems(
|
||||
bevy_ggrs::prelude::GgrsSchedule,
|
||||
super::runtime::update_fighter_bone_matrices
|
||||
|
||||
@@ -4,7 +4,7 @@ mod asset_baking;
|
||||
mod runtime;
|
||||
mod visual_binding;
|
||||
|
||||
pub use asset_baking::BakedAnimationPlugin;
|
||||
pub use asset_baking::{BakedAnimationAssetProcessingPlugin, BakedAnimationPlugin};
|
||||
pub use crate::math::fixed_transform::FixedMat4;
|
||||
pub use runtime::{
|
||||
BakedAnimationClip, BakedFighterAnimations, FighterBoneIndexMap, FighterBoneMatrices,
|
||||
|
||||
+16
-1
@@ -155,11 +155,26 @@ impl Plugin for GamePlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/// Registers only the custom asset processors used by CI and release builds.
|
||||
/// The processing binary adds this plugin without starting the game.
|
||||
pub struct AssetProcessingPlugin;
|
||||
|
||||
impl Plugin for AssetProcessingPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_plugins((
|
||||
scripting::importer::FighterScriptImportPlugin,
|
||||
fighter::baked_animation::BakedAnimationAssetProcessingPlugin,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
fn wait_for_asset_processor(
|
||||
processor: Option<Res<AssetProcessor>>,
|
||||
mut next_state: ResMut<NextState<AppState>>,
|
||||
) {
|
||||
if processor.is_none_or(|processor| block_on(processor.get_state()) == ProcessorState::Finished)
|
||||
if !cfg!(feature = "development")
|
||||
|| processor
|
||||
.is_none_or(|processor| block_on(processor.get_state()) == ProcessorState::Finished)
|
||||
{
|
||||
next_state.set(AppState::LoadCommonAssets);
|
||||
}
|
||||
|
||||
+16
-7
@@ -1,8 +1,11 @@
|
||||
use bevy::asset::AssetMode::Processed;
|
||||
#[cfg(feature = "debug_features")]
|
||||
use bevy::camera_controller::free_camera::FreeCameraPlugin;
|
||||
use bevy::image::{ImageAddressMode, ImagePlugin, ImageSamplerDescriptor};
|
||||
use bevy::prelude::*;
|
||||
#[cfg(feature = "debug_features")]
|
||||
use bevy_egui::EguiPlugin;
|
||||
#[cfg(feature = "debug_features")]
|
||||
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
||||
|
||||
fn main() -> AppExit {
|
||||
@@ -20,16 +23,22 @@ fn main() -> AppExit {
|
||||
})
|
||||
.set(AssetPlugin {
|
||||
mode: Processed,
|
||||
use_asset_processor_override: Some(cfg!(feature = "development")),
|
||||
..default()
|
||||
});
|
||||
|
||||
App::new()
|
||||
.add_plugins(default_plugins)
|
||||
let mut app = App::new();
|
||||
app.add_plugins(default_plugins)
|
||||
.add_plugins(avian3d::prelude::PhysicsPlugins::default())
|
||||
.add_plugins(shinespark::GamePlugin)
|
||||
.add_plugins(FreeCameraPlugin)
|
||||
.add_plugins(EguiPlugin::default())
|
||||
.add_plugins(WorldInspectorPlugin::default()) // adds default options and `InspectorEguiImpl`s
|
||||
.insert_resource(Time::<Fixed>::from_hz(60.0))
|
||||
.run()
|
||||
.insert_resource(Time::<Fixed>::from_hz(60.0));
|
||||
|
||||
#[cfg(feature = "debug_features")]
|
||||
app.add_plugins((
|
||||
FreeCameraPlugin,
|
||||
EguiPlugin::default(),
|
||||
WorldInspectorPlugin::default(),
|
||||
));
|
||||
|
||||
app.run()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user