diff --git a/crates/engine-core/src/cmd.rs b/crates/engine-core/src/cmd.rs index dce170f22a..ac05cf2ad8 100644 --- a/crates/engine-core/src/cmd.rs +++ b/crates/engine-core/src/cmd.rs @@ -19,17 +19,12 @@ pub mod actions_cmds; pub mod actions_edit_cmds; pub mod adjust_cmds; mod adjust_params; -pub mod adjustment_brush_cmds; -#[cfg(test)] -mod adjustment_brush_cmds_tests; pub mod align_cmds; pub mod analysis_cmds; pub mod artboard_cmds; pub mod atn_cmds; pub mod automate_cmds; pub mod background_cmds; -pub mod brush_cmds; -pub mod brush_key_cmds; pub mod brush_preset_cmds; pub mod channel_cmds; pub mod color_cmds; @@ -50,22 +45,16 @@ pub mod document_preset_cmds; pub mod edit_cmds; pub mod edit_menu_cmds; mod enabled; -pub mod eraser_cmds; pub mod export_preset_cmds; pub mod exr_cmds; pub mod extra_cmds; -pub mod face_cmds; pub mod file_cmds; -pub mod fill_cmds; -pub mod fill_key_cmds; pub mod float_cmds; pub mod font_library_cmds; pub mod frame_cmds; pub mod fx_view_cmds; pub mod fx_visibility_cmds; pub mod gallery_cmds; -#[cfg(test)] -mod gradient_alpha_method_tests; pub mod gradient_fill_cmds; pub mod group_view_cmds; pub mod history_cmds; @@ -99,7 +88,6 @@ pub mod notes_cmds; #[cfg(test)] mod notes_stored_values_tests; mod ops; -pub mod paint_cmds; mod params; pub mod path_edit_cmds; pub mod pattern_cmds; @@ -108,14 +96,11 @@ pub mod perspective_crop_cmds; #[cfg(test)] mod perspective_crop_refuse_tests; pub mod photo_cmds; -pub mod pick_cmds; pub mod plugin_cmds; pub mod preset_import_cmds; pub mod print_cmds; pub mod rasterize_style_cmds; -pub mod redeye_cmds; pub mod render_cmds; -pub mod retouch_cmds; #[cfg(test)] mod rotate_canvas_bitmap_tests; @@ -124,7 +109,6 @@ mod rotate_canvas_guides_tests; pub mod sample_cmds; #[cfg(test)] mod sample_zoom_box_tests; -pub mod sampler_cmds; pub mod select_extra_cmds; pub mod selection_cmds; pub mod slice_cmds; @@ -132,7 +116,6 @@ pub mod smart_cmds; pub mod smart_svg_cmds; pub mod smartselect_cmds; pub mod solid_fill_cmds; -pub mod stamp_cmds; pub mod style_asl_cmds; pub mod swatch_cmds; pub mod symmetry_cmds; diff --git a/crates/engine-core/src/cmd/table.rs b/crates/engine-core/src/cmd/table.rs index f3fac7fc3a..9a70334125 100644 --- a/crates/engine-core/src/cmd/table.rs +++ b/crates/engine-core/src/cmd/table.rs @@ -4,5 +4,4 @@ pub mod core; pub mod image; pub mod model; -pub mod paint; pub mod store; diff --git a/crates/engine-core/src/lib.rs b/crates/engine-core/src/lib.rs index 4f29b25461..2da881b44c 100644 --- a/crates/engine-core/src/lib.rs +++ b/crates/engine-core/src/lib.rs @@ -78,15 +78,12 @@ pub use cmd as commands; pub use cmd::actions_cmds; pub use cmd::actions_edit_cmds; pub use cmd::adjust_cmds; -pub use cmd::adjustment_brush_cmds; pub use cmd::align_cmds; pub use cmd::analysis_cmds; pub use cmd::artboard_cmds; pub use cmd::atn_cmds; pub use cmd::automate_cmds; pub use cmd::background_cmds; -pub use cmd::brush_cmds; -pub use cmd::brush_key_cmds; pub use cmd::brush_preset_cmds; pub use cmd::channel_cmds; pub use cmd::color_cmds; @@ -98,14 +95,10 @@ pub use cmd::distort_cmds; pub use cmd::document_preset_cmds; pub use cmd::edit_cmds; pub use cmd::edit_menu_cmds; -pub use cmd::eraser_cmds; pub use cmd::export_preset_cmds; pub use cmd::exr_cmds; pub use cmd::extra_cmds; -pub use cmd::face_cmds; pub use cmd::file_cmds; -pub use cmd::fill_cmds; -pub use cmd::fill_key_cmds; pub use cmd::float_cmds; pub use cmd::font_library_cmds; pub use cmd::frame_cmds; @@ -136,22 +129,17 @@ pub use cmd::migrate_cmds; pub use cmd::mode_cmds; pub use cmd::multichannel_cmds; pub use cmd::notes_cmds; -pub use cmd::paint_cmds; pub use cmd::path_edit_cmds; pub use cmd::pattern_cmds; pub use cmd::pattern_fill_cmds; pub use cmd::perspective_crop_cmds; pub use cmd::photo_cmds; -pub use cmd::pick_cmds; pub use cmd::plugin_cmds; pub use cmd::preset_import_cmds; pub use cmd::print_cmds; pub use cmd::rasterize_style_cmds; -pub use cmd::redeye_cmds; pub use cmd::render_cmds; -pub use cmd::retouch_cmds; pub use cmd::sample_cmds; -pub use cmd::sampler_cmds; pub use cmd::select_extra_cmds; pub use cmd::selection_cmds; pub use cmd::slice_cmds; @@ -159,7 +147,6 @@ pub use cmd::smart_cmds; pub use cmd::smart_svg_cmds; pub use cmd::smartselect_cmds; pub use cmd::solid_fill_cmds; -pub use cmd::stamp_cmds; pub use cmd::style_asl_cmds; pub use cmd::swatch_cmds; pub use cmd::symmetry_cmds; @@ -346,19 +333,11 @@ pub struct Session { pub whole_redraws: usize, } -#[cfg(test)] -mod brush_pressure_size_default_tests; #[cfg(test)] mod embed_all_linked_tests; #[cfg(test)] -mod eraser_gray_background_tests; -#[cfg(test)] mod fill_layer_mode_tests; -#[cfg(test)] -mod mixer_indexed_bitmap_tests; -#[cfg(test)] -mod mixer_toggle_commands_tests; #[cfg(test)] mod pattern_mode_tests; #[cfg(test)] @@ -372,8 +351,4 @@ mod fx_mode_tests; #[cfg(test)] mod dense_budget_tests; -#[cfg(test)] -mod brush_clear_background_tests; pub mod command_hints; -#[cfg(test)] -mod pencil_auto_erase_exact_tests; diff --git a/crates/engine-core/src/brush_clear_background_tests.rs b/crates/engine-paint/src/brush_clear_background_tests.rs similarity index 100% rename from crates/engine-core/src/brush_clear_background_tests.rs rename to crates/engine-paint/src/brush_clear_background_tests.rs diff --git a/crates/engine-core/src/brush_pressure_size_default_tests.rs b/crates/engine-paint/src/brush_pressure_size_default_tests.rs similarity index 100% rename from crates/engine-core/src/brush_pressure_size_default_tests.rs rename to crates/engine-paint/src/brush_pressure_size_default_tests.rs diff --git a/crates/engine-core/src/cmd/adjustment_brush_cmds.rs b/crates/engine-paint/src/cmd/adjustment_brush_cmds.rs similarity index 98% rename from crates/engine-core/src/cmd/adjustment_brush_cmds.rs rename to crates/engine-paint/src/cmd/adjustment_brush_cmds.rs index 28c271e7c5..71c364d886 100644 --- a/crates/engine-core/src/cmd/adjustment_brush_cmds.rs +++ b/crates/engine-paint/src/cmd/adjustment_brush_cmds.rs @@ -6,8 +6,8 @@ use photocraft_doc::{Adjustment, ColorMode, Layer, LayerContent, LayerMask, SampleType}; use serde_json::{Value, json}; -use super::adjust_params::adjustment_kind; -use super::layer_params::{mask_at_depth, selection_mask}; +use crate::commands::adjust_params::adjustment_kind; +use crate::commands::layer_params::{mask_at_depth, selection_mask}; use crate::commands::CommandSpec; use crate::{EngineError, Result, Session}; @@ -234,7 +234,7 @@ fn run(s: &mut Session, p: &Value) -> Result { json!({"layer": id.0, "created": true, "damage": [damage.x0, damage.y0, damage.width(), damage.height()]}) }; // The new layer's mask is the target, and the colours are the stroke's. - super::channel_cmds::target_layer_mask(s); + crate::commands::channel_cmds::target_layer_mask(s); s.tools.foreground = fg; s.tools.background = bg; Ok(result) diff --git a/crates/engine-core/src/cmd/adjustment_brush_cmds_tests.rs b/crates/engine-paint/src/cmd/adjustment_brush_cmds_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/adjustment_brush_cmds_tests.rs rename to crates/engine-paint/src/cmd/adjustment_brush_cmds_tests.rs diff --git a/crates/engine-core/src/cmd/background_eraser_channel_target_tests.rs b/crates/engine-paint/src/cmd/background_eraser_channel_target_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/background_eraser_channel_target_tests.rs rename to crates/engine-paint/src/cmd/background_eraser_channel_target_tests.rs diff --git a/crates/engine-core/src/cmd/background_eraser_transparency_lock_tests.rs b/crates/engine-paint/src/cmd/background_eraser_transparency_lock_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/background_eraser_transparency_lock_tests.rs rename to crates/engine-paint/src/cmd/background_eraser_transparency_lock_tests.rs diff --git a/crates/engine-core/src/cmd/brush_cmds.rs b/crates/engine-paint/src/cmd/brush_cmds.rs similarity index 100% rename from crates/engine-core/src/cmd/brush_cmds.rs rename to crates/engine-paint/src/cmd/brush_cmds.rs diff --git a/crates/engine-core/src/cmd/brush_cmds/define_brush_color_density_tests.rs b/crates/engine-paint/src/cmd/brush_cmds/define_brush_color_density_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/brush_cmds/define_brush_color_density_tests.rs rename to crates/engine-paint/src/cmd/brush_cmds/define_brush_color_density_tests.rs diff --git a/crates/engine-core/src/cmd/brush_cmds/define_brush_merged_source_tests.rs b/crates/engine-paint/src/cmd/brush_cmds/define_brush_merged_source_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/brush_cmds/define_brush_merged_source_tests.rs rename to crates/engine-paint/src/cmd/brush_cmds/define_brush_merged_source_tests.rs diff --git a/crates/engine-core/src/cmd/brush_cmds/define_brush_no_selection_tests.rs b/crates/engine-paint/src/cmd/brush_cmds/define_brush_no_selection_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/brush_cmds/define_brush_no_selection_tests.rs rename to crates/engine-paint/src/cmd/brush_cmds/define_brush_no_selection_tests.rs diff --git a/crates/engine-core/src/cmd/brush_cmds/filter_mask_stroke_tests.rs b/crates/engine-paint/src/cmd/brush_cmds/filter_mask_stroke_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/brush_cmds/filter_mask_stroke_tests.rs rename to crates/engine-paint/src/cmd/brush_cmds/filter_mask_stroke_tests.rs diff --git a/crates/engine-core/src/cmd/brush_cmds/mixer_live.rs b/crates/engine-paint/src/cmd/brush_cmds/mixer_live.rs similarity index 100% rename from crates/engine-core/src/cmd/brush_cmds/mixer_live.rs rename to crates/engine-paint/src/cmd/brush_cmds/mixer_live.rs diff --git a/crates/engine-core/src/cmd/brush_cmds/mixer_live_tests.rs b/crates/engine-paint/src/cmd/brush_cmds/mixer_live_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/brush_cmds/mixer_live_tests.rs rename to crates/engine-paint/src/cmd/brush_cmds/mixer_live_tests.rs diff --git a/crates/engine-core/src/cmd/brush_cmds/tests.rs b/crates/engine-paint/src/cmd/brush_cmds/tests.rs similarity index 99% rename from crates/engine-core/src/cmd/brush_cmds/tests.rs rename to crates/engine-paint/src/cmd/brush_cmds/tests.rs index 037e7aa49b..02e577a24a 100644 --- a/crates/engine-core/src/cmd/brush_cmds/tests.rs +++ b/crates/engine-paint/src/cmd/brush_cmds/tests.rs @@ -1,3 +1,4 @@ +use crate::brush_cmds::LiveStrokeExt; use super::*; fn session(w: u32, h: u32) -> Session { diff --git a/crates/engine-core/src/cmd/brush_key_cmds.rs b/crates/engine-paint/src/cmd/brush_key_cmds.rs similarity index 100% rename from crates/engine-core/src/cmd/brush_key_cmds.rs rename to crates/engine-paint/src/cmd/brush_key_cmds.rs diff --git a/crates/engine-core/src/cmd/brush_key_cmds/bracket_steps_tests.rs b/crates/engine-paint/src/cmd/brush_key_cmds/bracket_steps_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/brush_key_cmds/bracket_steps_tests.rs rename to crates/engine-paint/src/cmd/brush_key_cmds/bracket_steps_tests.rs diff --git a/crates/engine-core/src/cmd/color_replacement_history_name_tests.rs b/crates/engine-paint/src/cmd/color_replacement_history_name_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/color_replacement_history_name_tests.rs rename to crates/engine-paint/src/cmd/color_replacement_history_name_tests.rs diff --git a/crates/engine-core/src/cmd/color_replacement_modes_tests.rs b/crates/engine-paint/src/cmd/color_replacement_modes_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/color_replacement_modes_tests.rs rename to crates/engine-paint/src/cmd/color_replacement_modes_tests.rs diff --git a/crates/engine-core/src/cmd/eraser_cmds.rs b/crates/engine-paint/src/cmd/eraser_cmds.rs similarity index 100% rename from crates/engine-core/src/cmd/eraser_cmds.rs rename to crates/engine-paint/src/cmd/eraser_cmds.rs diff --git a/crates/engine-core/src/cmd/eraser_cmds/magic_eraser_mode_refusal_tests.rs b/crates/engine-paint/src/cmd/eraser_cmds/magic_eraser_mode_refusal_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/eraser_cmds/magic_eraser_mode_refusal_tests.rs rename to crates/engine-paint/src/cmd/eraser_cmds/magic_eraser_mode_refusal_tests.rs diff --git a/crates/engine-core/src/cmd/eraser_cmds/magic_eraser_tolerance_tests.rs b/crates/engine-paint/src/cmd/eraser_cmds/magic_eraser_tolerance_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/eraser_cmds/magic_eraser_tolerance_tests.rs rename to crates/engine-paint/src/cmd/eraser_cmds/magic_eraser_tolerance_tests.rs diff --git a/crates/engine-core/src/cmd/eraser_cmds/tests.rs b/crates/engine-paint/src/cmd/eraser_cmds/tests.rs similarity index 100% rename from crates/engine-core/src/cmd/eraser_cmds/tests.rs rename to crates/engine-paint/src/cmd/eraser_cmds/tests.rs diff --git a/crates/engine-core/src/cmd/face_cmds.rs b/crates/engine-paint/src/cmd/face_cmds.rs similarity index 100% rename from crates/engine-core/src/cmd/face_cmds.rs rename to crates/engine-paint/src/cmd/face_cmds.rs diff --git a/crates/engine-core/src/cmd/fill_cmds.rs b/crates/engine-paint/src/cmd/fill_cmds.rs similarity index 100% rename from crates/engine-core/src/cmd/fill_cmds.rs rename to crates/engine-paint/src/cmd/fill_cmds.rs diff --git a/crates/engine-core/src/cmd/fill_cmds/tests.rs b/crates/engine-paint/src/cmd/fill_cmds/tests.rs similarity index 100% rename from crates/engine-core/src/cmd/fill_cmds/tests.rs rename to crates/engine-paint/src/cmd/fill_cmds/tests.rs diff --git a/crates/engine-core/src/cmd/fill_key_cmds.rs b/crates/engine-paint/src/cmd/fill_key_cmds.rs similarity index 100% rename from crates/engine-core/src/cmd/fill_key_cmds.rs rename to crates/engine-paint/src/cmd/fill_key_cmds.rs diff --git a/crates/engine-core/src/cmd/gradient_alpha_method_tests.rs b/crates/engine-paint/src/cmd/gradient_alpha_method_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/gradient_alpha_method_tests.rs rename to crates/engine-paint/src/cmd/gradient_alpha_method_tests.rs diff --git a/crates/engine-core/src/cmd/paint_cmds.rs b/crates/engine-paint/src/cmd/paint_cmds.rs similarity index 100% rename from crates/engine-core/src/cmd/paint_cmds.rs rename to crates/engine-paint/src/cmd/paint_cmds.rs diff --git a/crates/engine-core/src/cmd/paint_cmds/bucket_bitmap_tests.rs b/crates/engine-paint/src/cmd/paint_cmds/bucket_bitmap_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/paint_cmds/bucket_bitmap_tests.rs rename to crates/engine-paint/src/cmd/paint_cmds/bucket_bitmap_tests.rs diff --git a/crates/engine-core/src/cmd/paint_cmds/bucket_no_op_history_tests.rs b/crates/engine-paint/src/cmd/paint_cmds/bucket_no_op_history_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/paint_cmds/bucket_no_op_history_tests.rs rename to crates/engine-paint/src/cmd/paint_cmds/bucket_no_op_history_tests.rs diff --git a/crates/engine-core/src/cmd/paint_cmds/tests.rs b/crates/engine-paint/src/cmd/paint_cmds/tests.rs similarity index 100% rename from crates/engine-core/src/cmd/paint_cmds/tests.rs rename to crates/engine-paint/src/cmd/paint_cmds/tests.rs diff --git a/crates/engine-core/src/cmd/pick_cmds.rs b/crates/engine-paint/src/cmd/pick_cmds.rs similarity index 100% rename from crates/engine-core/src/cmd/pick_cmds.rs rename to crates/engine-paint/src/cmd/pick_cmds.rs diff --git a/crates/engine-core/src/cmd/redeye_cmds.rs b/crates/engine-paint/src/cmd/redeye_cmds.rs similarity index 100% rename from crates/engine-core/src/cmd/redeye_cmds.rs rename to crates/engine-paint/src/cmd/redeye_cmds.rs diff --git a/crates/engine-core/src/cmd/redeye_color_mode_tests.rs b/crates/engine-paint/src/cmd/redeye_color_mode_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/redeye_color_mode_tests.rs rename to crates/engine-paint/src/cmd/redeye_color_mode_tests.rs diff --git a/crates/engine-core/src/cmd/redeye_history_state_tests.rs b/crates/engine-paint/src/cmd/redeye_history_state_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/redeye_history_state_tests.rs rename to crates/engine-paint/src/cmd/redeye_history_state_tests.rs diff --git a/crates/engine-core/src/cmd/redeye_outside_selection_tests.rs b/crates/engine-paint/src/cmd/redeye_outside_selection_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/redeye_outside_selection_tests.rs rename to crates/engine-paint/src/cmd/redeye_outside_selection_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds.rs b/crates/engine-paint/src/cmd/retouch_cmds.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds.rs rename to crates/engine-paint/src/cmd/retouch_cmds.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/art_history.rs b/crates/engine-paint/src/cmd/retouch_cmds/art_history.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/art_history.rs rename to crates/engine-paint/src/cmd/retouch_cmds/art_history.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/art_history_depth_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/art_history_depth_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/art_history_depth_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/art_history_depth_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/art_history_mode_mismatch_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/art_history_mode_mismatch_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/art_history_mode_mismatch_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/art_history_mode_mismatch_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/art_history_noop_state_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/art_history_noop_state_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/art_history_noop_state_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/art_history_noop_state_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/art_history_refusal_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/art_history_refusal_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/art_history_refusal_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/art_history_refusal_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/blur_refuses_indexed_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/blur_refuses_indexed_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/blur_refuses_indexed_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/blur_refuses_indexed_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/burn_refuses_indexed_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/burn_refuses_indexed_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/burn_refuses_indexed_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/burn_refuses_indexed_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/clone.rs b/crates/engine-paint/src/cmd/retouch_cmds/clone.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/clone.rs rename to crates/engine-paint/src/cmd/retouch_cmds/clone.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/clone_sampling.rs b/crates/engine-paint/src/cmd/retouch_cmds/clone_sampling.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/clone_sampling.rs rename to crates/engine-paint/src/cmd/retouch_cmds/clone_sampling.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/clone_source_layer_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/clone_source_layer_tests.rs similarity index 99% rename from crates/engine-core/src/cmd/retouch_cmds/clone_source_layer_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/clone_source_layer_tests.rs index 7332cc59bf..ddeb63aaed 100644 --- a/crates/engine-core/src/cmd/retouch_cmds/clone_source_layer_tests.rs +++ b/crates/engine-paint/src/cmd/retouch_cmds/clone_source_layer_tests.rs @@ -1,3 +1,4 @@ +use crate::retouch_cmds::LiveRetouchExt; use super::*; use crate::color_cmds::ColorExt; use crate::presets::PresetsExt; diff --git a/crates/engine-core/src/cmd/retouch_cmds/content_aware_move.rs b/crates/engine-paint/src/cmd/retouch_cmds/content_aware_move.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/content_aware_move.rs rename to crates/engine-paint/src/cmd/retouch_cmds/content_aware_move.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/content_aware_move_color_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/content_aware_move_color_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/content_aware_move_color_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/content_aware_move_color_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/dab.rs b/crates/engine-paint/src/cmd/retouch_cmds/dab.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/dab.rs rename to crates/engine-paint/src/cmd/retouch_cmds/dab.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/dodge_refuses_indexed_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/dodge_refuses_indexed_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/dodge_refuses_indexed_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/dodge_refuses_indexed_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/heal.rs b/crates/engine-paint/src/cmd/retouch_cmds/heal.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/heal.rs rename to crates/engine-paint/src/cmd/retouch_cmds/heal.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/heal_indexed_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/heal_indexed_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/heal_indexed_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/heal_indexed_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/patch.rs b/crates/engine-paint/src/cmd/retouch_cmds/patch.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/patch.rs rename to crates/engine-paint/src/cmd/retouch_cmds/patch.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/patch_destination_selection_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/patch_destination_selection_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/patch_destination_selection_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/patch_destination_selection_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/patch_history_names_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/patch_history_names_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/patch_history_names_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/patch_history_names_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/pattern_stamp.rs b/crates/engine-paint/src/cmd/retouch_cmds/pattern_stamp.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/pattern_stamp.rs rename to crates/engine-paint/src/cmd/retouch_cmds/pattern_stamp.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/pattern_stamp_behind_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/pattern_stamp_behind_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/pattern_stamp_behind_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/pattern_stamp_behind_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/pattern_stamp_indexed_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/pattern_stamp_indexed_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/pattern_stamp_indexed_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/pattern_stamp_indexed_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/pattern_stamp_origin_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/pattern_stamp_origin_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/pattern_stamp_origin_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/pattern_stamp_origin_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/periodic.rs b/crates/engine-paint/src/cmd/retouch_cmds/periodic.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/periodic.rs rename to crates/engine-paint/src/cmd/retouch_cmds/periodic.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/remove.rs b/crates/engine-paint/src/cmd/retouch_cmds/remove.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/remove.rs rename to crates/engine-paint/src/cmd/retouch_cmds/remove.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/remove_history_name_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/remove_history_name_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/remove_history_name_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/remove_history_name_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/remove_new_layer_name_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/remove_new_layer_name_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/remove_new_layer_name_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/remove_new_layer_name_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/sampling.rs b/crates/engine-paint/src/cmd/retouch_cmds/sampling.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/sampling.rs rename to crates/engine-paint/src/cmd/retouch_cmds/sampling.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/sharpen_refuses_indexed_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/sharpen_refuses_indexed_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/sharpen_refuses_indexed_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/sharpen_refuses_indexed_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/smudge_mode_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/smudge_mode_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/smudge_mode_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/smudge_mode_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/smudge_refuses_indexed_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/smudge_refuses_indexed_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/smudge_refuses_indexed_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/smudge_refuses_indexed_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/sponge_refuses_indexed_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/sponge_refuses_indexed_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/retouch_cmds/sponge_refuses_indexed_tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/sponge_refuses_indexed_tests.rs diff --git a/crates/engine-core/src/cmd/retouch_cmds/tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/tests.rs similarity index 99% rename from crates/engine-core/src/cmd/retouch_cmds/tests.rs rename to crates/engine-paint/src/cmd/retouch_cmds/tests.rs index e92c265917..2ed1d6b579 100644 --- a/crates/engine-core/src/cmd/retouch_cmds/tests.rs +++ b/crates/engine-paint/src/cmd/retouch_cmds/tests.rs @@ -1,3 +1,4 @@ +use crate::retouch_cmds::LiveRetouchExt; use super::*; use crate::presets::PresetsExt; use photocraft_color::ColorMode; diff --git a/crates/engine-core/src/cmd/sampler_cmds.rs b/crates/engine-paint/src/cmd/sampler_cmds.rs similarity index 100% rename from crates/engine-core/src/cmd/sampler_cmds.rs rename to crates/engine-paint/src/cmd/sampler_cmds.rs diff --git a/crates/engine-core/src/cmd/sampler_cmds/pixel_centre_tests.rs b/crates/engine-paint/src/cmd/sampler_cmds/pixel_centre_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/sampler_cmds/pixel_centre_tests.rs rename to crates/engine-paint/src/cmd/sampler_cmds/pixel_centre_tests.rs diff --git a/crates/engine-core/src/cmd/sampler_cmds/sample_size_tests.rs b/crates/engine-paint/src/cmd/sampler_cmds/sample_size_tests.rs similarity index 100% rename from crates/engine-core/src/cmd/sampler_cmds/sample_size_tests.rs rename to crates/engine-paint/src/cmd/sampler_cmds/sample_size_tests.rs diff --git a/crates/engine-core/src/cmd/sampler_cmds/tests.rs b/crates/engine-paint/src/cmd/sampler_cmds/tests.rs similarity index 100% rename from crates/engine-core/src/cmd/sampler_cmds/tests.rs rename to crates/engine-paint/src/cmd/sampler_cmds/tests.rs diff --git a/crates/engine-core/src/cmd/stamp_cmds.rs b/crates/engine-paint/src/cmd/stamp_cmds.rs similarity index 100% rename from crates/engine-core/src/cmd/stamp_cmds.rs rename to crates/engine-paint/src/cmd/stamp_cmds.rs diff --git a/crates/engine-core/src/cmd/table/paint.rs b/crates/engine-paint/src/cmd/table/paint.rs similarity index 100% rename from crates/engine-core/src/cmd/table/paint.rs rename to crates/engine-paint/src/cmd/table/paint.rs diff --git a/crates/engine-core/src/cmd/table/paint/edit_menu.rs b/crates/engine-paint/src/cmd/table/paint/edit_menu.rs similarity index 94% rename from crates/engine-core/src/cmd/table/paint/edit_menu.rs rename to crates/engine-paint/src/cmd/table/paint/edit_menu.rs index 483a0b1943..f4ad7f1ce6 100644 --- a/crates/engine-core/src/cmd/table/paint/edit_menu.rs +++ b/crates/engine-paint/src/cmd/table/paint/edit_menu.rs @@ -1,4 +1,4 @@ -use crate::cmd::{CommandSpec, has_pixel_or_channel}; +use crate::commands::{CommandSpec, has_pixel_or_channel}; /// Edit menu: Fill. pub fn specs() -> Vec { diff --git a/crates/engine-core/src/cmd/table/paint/stroke.rs b/crates/engine-paint/src/cmd/table/paint/stroke.rs similarity index 94% rename from crates/engine-core/src/cmd/table/paint/stroke.rs rename to crates/engine-paint/src/cmd/table/paint/stroke.rs index 06b0e7fccd..0cb5b18c1e 100644 --- a/crates/engine-core/src/cmd/table/paint/stroke.rs +++ b/crates/engine-paint/src/cmd/table/paint/stroke.rs @@ -1,4 +1,4 @@ -use crate::cmd::{CommandSpec, has_paintable}; +use crate::commands::{CommandSpec, has_paintable}; /// Painting: the stroke command. pub fn specs() -> Vec { diff --git a/crates/engine-core/src/eraser_gray_background_tests.rs b/crates/engine-paint/src/eraser_gray_background_tests.rs similarity index 99% rename from crates/engine-core/src/eraser_gray_background_tests.rs rename to crates/engine-paint/src/eraser_gray_background_tests.rs index b8bed101bc..0c09ac2c4f 100644 --- a/crates/engine-core/src/eraser_gray_background_tests.rs +++ b/crates/engine-paint/src/eraser_gray_background_tests.rs @@ -3,6 +3,7 @@ //! luminance (#11940). The swatch goes through the sRGB tone curve (sGray), not the document's Dot //! Gain curve, which would give 153. +use crate::brush_cmds::LiveStrokeExt; use crate::Session; use serde_json::json; diff --git a/crates/engine-core/src/mixer_indexed_bitmap_tests.rs b/crates/engine-paint/src/mixer_indexed_bitmap_tests.rs similarity index 100% rename from crates/engine-core/src/mixer_indexed_bitmap_tests.rs rename to crates/engine-paint/src/mixer_indexed_bitmap_tests.rs diff --git a/crates/engine-core/src/mixer_toggle_commands_tests.rs b/crates/engine-paint/src/mixer_toggle_commands_tests.rs similarity index 100% rename from crates/engine-core/src/mixer_toggle_commands_tests.rs rename to crates/engine-paint/src/mixer_toggle_commands_tests.rs diff --git a/crates/engine-core/src/pencil_auto_erase_exact_tests.rs b/crates/engine-paint/src/pencil_auto_erase_exact_tests.rs similarity index 100% rename from crates/engine-core/src/pencil_auto_erase_exact_tests.rs rename to crates/engine-paint/src/pencil_auto_erase_exact_tests.rs diff --git a/crates/engine/examples/bench_brush_mips.rs b/crates/engine/examples/bench_brush_mips.rs index de7798dd29..46a5edd408 100644 --- a/crates/engine/examples/bench_brush_mips.rs +++ b/crates/engine/examples/bench_brush_mips.rs @@ -1,6 +1,7 @@ //! Sampled-tip preparation and live strokes on a materialized 24 MP layer. This harness also //! builds against the pre-cache revision for alternating before/after runs on the same runner. //! `cargo run --release -p photocraft-engine --example bench_brush_mips` +use photocraft_engine::brush_cmds::LiveStrokeExt; use std::hint::black_box; use std::time::Instant; diff --git a/crates/engine/examples/bench_live_dab.rs b/crates/engine/examples/bench_live_dab.rs index 3e98a44789..2ce4484161 100644 --- a/crates/engine/examples/bench_live_dab.rs +++ b/crates/engine/examples/bench_live_dab.rs @@ -1,6 +1,7 @@ //! Live retouch latency on a materialized 24 MP layer. Run the same example at base and head //! in release mode on one machine. Setup, Undo and the full output fingerprint are not timed. //! This measures engine stroke work; canvas compositing/upload and presentation are excluded. +use photocraft_engine::retouch_cmds::LiveRetouchExt; use std::time::Instant; use photocraft_engine::{EngineError, Session, paint::StrokePoint, retouch_cmds::LiveDab}; diff --git a/crates/engine/examples/bench_live_dab_release.rs b/crates/engine/examples/bench_live_dab_release.rs index f6935d3210..e87caea028 100644 --- a/crates/engine/examples/bench_live_dab_release.rs +++ b/crates/engine/examples/bench_live_dab_release.rs @@ -1,6 +1,7 @@ //! Release cost of a live sequential-dab stroke on a 24 MP layer, in release mode: the commit //! rendering the stroke again (no offer) against taking the live pixels (`offer_live_dab`, which //! runs the finishing dabs, plus the commit). Also the live stroke's per-frame cost while drawn. +use photocraft_engine::retouch_cmds::LiveRetouchExt; use std::time::Instant; use photocraft_engine::{EngineError, Session, paint::StrokePoint, retouch_cmds::LiveDab}; diff --git a/crates/engine/tests/it/live_dab_matches_replay.rs b/crates/engine/tests/it/live_dab_matches_replay.rs index 42242cd010..7569d9b31d 100644 --- a/crates/engine/tests/it/live_dab_matches_replay.rs +++ b/crates/engine/tests/it/live_dab_matches_replay.rs @@ -1,3 +1,4 @@ +use photocraft_engine::retouch_cmds::LiveRetouchExt; use photocraft_engine::{Session, retouch_cmds::LiveDab}; use photocraft_paint::StrokePoint; use serde_json::json; diff --git a/crates/engine/tests/it/multi_channel_editing.rs b/crates/engine/tests/it/multi_channel_editing.rs index 3290897f28..99ccbad088 100644 --- a/crates/engine/tests/it/multi_channel_editing.rs +++ b/crates/engine/tests/it/multi_channel_editing.rs @@ -1,3 +1,5 @@ +use photocraft_engine::brush_cmds::LiveStrokeExt; +use photocraft_engine::retouch_cmds::LiveRetouchExt; use photocraft_color::SampleType; use photocraft_engine::{Session, brush_cmds::LiveStroke, channel_cmds::ChannelTarget, color_channels}; use photocraft_geom::Rect; diff --git a/crates/ui-egui/examples/perf_scenarios.rs b/crates/ui-egui/examples/perf_scenarios.rs index fb5a9fded3..789ddc8777 100644 --- a/crates/ui-egui/examples/perf_scenarios.rs +++ b/crates/ui-egui/examples/perf_scenarios.rs @@ -18,6 +18,7 @@ //! what the refreshes did (`refresh_kinds`: `Refresh::kind` counts, also "rect" / "full" without //! an adapter; `fallbacks`: `CpuReason::kind` of any refresh the wgpu compositor didn't draw). +use photocraft_engine::brush_cmds::LiveStrokeExt; use photocraft_engine::color_cmds::ColorExt; use std::time::Instant; diff --git a/crates/ui-egui/src/canvas/strokes.rs b/crates/ui-egui/src/canvas/strokes.rs index eba49821fb..8f0a74ba3d 100644 --- a/crates/ui-egui/src/canvas/strokes.rs +++ b/crates/ui-egui/src/canvas/strokes.rs @@ -1,3 +1,5 @@ +use photocraft_engine::retouch_cmds::LiveRetouchExt; +use photocraft_engine::brush_cmds::LiveStrokeExt; use photocraft_engine::presets::PresetsExt; use std::sync::Arc; diff --git a/scripts/engine_split/crates.tsv b/scripts/engine_split/crates.tsv new file mode 100644 index 0000000000..ef160e354f --- /dev/null +++ b/scripts/engine_split/crates.tsv @@ -0,0 +1,180 @@ +# Engine split (photocraft#15710): the crate each engine module goes to. A unit is a module of +# crates/engine-core/src: `cmd/` for one declared in cmd.rs, `` for one declared in lib.rs. +# Its files are the module's file and every file its `mod` declarations reach. scripts/engine_split/engine_cut.py reads it. A module not listed stays in core. +unit crate +actions_record core +adjust_params model +allocation core +build_info core +canvas_geom model +channel_clip model +clip_group core +cmd/actions_cmds files +cmd/actions_edit_cmds files +cmd/adjust_cmds image +cmd/adjust_params model +cmd/adjustment_brush_cmds paint +cmd/adjustment_brush_cmds_tests paint +cmd/align_cmds vector +cmd/analysis_cmds image +cmd/artboard_cmds model +cmd/atn_cmds files +cmd/automate_cmds files +cmd/background_cmds model +cmd/brush_cmds paint +cmd/brush_key_cmds paint +cmd/brush_preset_cmds store +cmd/channel_cmds model +cmd/color_cmds model +cmd/color_to_alpha_cmds image +cmd/comps_cmds vector +cmd/contour_lib_cmds store +cmd/cutout_cmds image +cmd/distort_cmds image +cmd/document_preset_cmds store +cmd/edit_cmds model +cmd/edit_menu_cmds image +cmd/enabled core +cmd/eraser_cmds paint +cmd/export_preset_cmds store +cmd/exr_cmds files +cmd/extra_cmds image +cmd/face_cmds paint +cmd/file_cmds files +cmd/fill_cmds paint +cmd/fill_key_cmds paint +cmd/float_cmds vector +cmd/font_library_cmds store +cmd/frame_cmds vector +cmd/fx_view_cmds store +cmd/fx_visibility_cmds store +cmd/gallery_cmds image +cmd/gradient_fill_cmds store +cmd/group_view_cmds image +cmd/history_cmds model +cmd/history_menu_cmds model +cmd/history_options_cmds model +cmd/history_select_cmds model +cmd/history_source_cmds model +cmd/image_cmds image +cmd/layer_copy_cmds model +cmd/layer_css_cmds vector +cmd/layer_label_cmds image +cmd/layer_list_cmds image +cmd/layer_mask_props_cmds image +cmd/layer_menu_cmds image +cmd/layer_multi_cmds model +cmd/layer_nav_cmds image +cmd/layer_params core +cmd/layer_references core +cmd/layer_xmp_cmds vector +cmd/lens_cmds image +cmd/magnetic_cmds image +cmd/mask_view_cmds model +cmd/migrate_cmds store +cmd/mode_cmds image +cmd/multichannel_cmds image +cmd/notes_cmds vector +cmd/ops core +cmd/paint_cmds paint +cmd/params core +cmd/path_edit_cmds vector +cmd/pattern_cmds store +cmd/pattern_fill_cmds store +cmd/perspective_crop_cmds image +cmd/photo_cmds image +cmd/pick_cmds paint +cmd/plugin_cmds image +cmd/preset_import_cmds store +cmd/print_cmds files +cmd/rasterize_style_cmds vector +cmd/redeye_cmds paint +cmd/render_cmds image +cmd/retouch_cmds paint +cmd/sample_cmds model +cmd/sampler_cmds paint +cmd/select_extra_cmds image +cmd/selection_cmds image +cmd/slice_cmds vector +cmd/smart_cmds vector +cmd/smart_svg_cmds vector +cmd/smartselect_cmds image +cmd/solid_fill_cmds store +cmd/stamp_cmds paint +cmd/style_asl_cmds store +cmd/swatch_cmds store +cmd/symmetry_cmds vector +cmd/timeline_cmds files +cmd/transform_cmds vector +cmd/trap_cmds vector +cmd/type_area_cmds vector +cmd/type_caret_cmds vector +cmd/type_cmds vector +cmd/type_extra_cmds vector +cmd/type_mask_cmds vector +cmd/type_spell_cmds vector +cmd/type_styles_cmds vector +cmd/variables_cmds files +cmd/vector_clipboard model +cmd/vector_cmds vector +cmd/video_cmds files +cmd/vp_cmds image +cmd/warp_cmds vector +cmd/web_cmds files +cmd/wia_cmds files +color_channels model +command_hints core +crop_fill image +display_color model +doc_path core +doc_state core +error core +filters image +filters_ext image +group_options core +guide_layout core +hidden_target core +inspect core +installed_profiles core +jobs core +keymap_defs store +layer_place core +layer_style store +link_watch model +malloc_tuning core +memory core +memory_gate core +new_layer core +param_check core +pixels core +prefs store +preset_store store +presets store +proof_sim model +scratch core +select_mask_edits image +session core +shell_commands core +shortcut_sets store +snap core +cmd/table/paint paint +cmd/table/image image +cmd/table/model model +cmd/table/store store +pixel_fill core +content_sampling model +brush_defs store +brush_clear_background_tests paint +brush_pressure_size_default_tests paint +eraser_gray_background_tests paint +pencil_auto_erase_exact_tests paint +mixer_indexed_bitmap_tests paint +mixer_toggle_commands_tests paint +cmd/gradient_alpha_method_tests paint +action_history core +damage core +slots core +state core +install core +registry core +hooks core diff --git a/scripts/engine_split/engine_cut.py b/scripts/engine_split/engine_cut.py new file mode 100755 index 0000000000..b98f0f147a --- /dev/null +++ b/scripts/engine_split/engine_cut.py @@ -0,0 +1,533 @@ +#!/usr/bin/env python3 +"""Engine split, steps 7-12: cut one engine crate out of `photocraft-engine-core`. + +`scripts/engine_split/crates.tsv` names the crate of each engine module. A cut moves the modules of +one crate, with every file their `mod` declarations reach, from `crates/engine-core/src` to the same +paths under `crates/engine-/src`, so git's rename detection carries edits to them. + + python3 scripts/engine_split/engine_cut.py split + On the day's main: `git mv` the crate's files, drop their declarations from core's `lib.rs`, + `cmd.rs` and `cmd/table.rs`, and in the moved files point `crate::cmd::` at + `crate::commands::` (the crate's own `cmd` module holds only its modules). Calls of + `Session` methods that became the crate's traits get the trait's import (TRAITS). The + hand-written part of the step (the crate's Cargo.toml, lib.rs, cmd.rs, install.rs, the + install lists, tooling) is its own commit, cherry-picked after this one. + + python3 scripts/engine_split/engine_cut.py imports + Prints the import block the crate's root needs: every name its code reaches as `crate::x` + that the crate doesn't define, so moved code compiles without path edits. + + python3 scripts/engine_split/engine_cut.py branch --base --head + On a branch rebased onto the cut (`--head` is the branch from before the rebase, `ORIG_HEAD` + right after it): + - moves files the branch added under core that belong to the crate's modules (new files in + a directory that still exists in core, such as `cmd/`, stay where git put them); + - moves `mod` lines the branch added to core's `cmd.rs`/`lib.rs` for the crate's modules, + and `TABLES` entries it added to core's `install.rs` naming them, into the crate's files; + - adds the import-block names the branch's moved code needs; + - adds trait imports for the trait methods it calls; + - lists, as NOT DONE, tests the branch added or edited in core that run one of the + crate's command ids: core installs only its own commands, so they fail at run time + with `UnknownCommand` and belong in the top crate's `tests/it`. + + cargo check --message-format json ... | python3 scripts/engine_split/engine_cut.py fix + Widens to `pub` each core item the compiler reports as private where another engine crate + uses it (E0603, E0624, and E0616 when the note names the field). + +Running split or branch twice gives the same result. What it cannot do is printed at the end. +""" +import argparse, json, os, re, sys + +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +from rust_source import MOD_DECL, compiled_files, git, git_show, inline_mods, mask, module_file # noqa: E402 + +CORE = "crates/engine-core/src" +MAP = os.path.join(os.path.dirname(os.path.abspath(__file__)), "crates.tsv") +ROOTS = ["crates", "apps"] + +# Session methods that became a crate's extension traits at its cut: method -> (module, trait). +TRAITS = { + "paint": { + "offer_live_stroke": ("brush_cmds", "LiveStrokeExt"), + "offer_live_retouch": ("retouch_cmds", "LiveRetouchExt"), + "offer_live_dab": ("retouch_cmds", "LiveRetouchExt"), + }, +} + +# Names a crate's root defines itself, which its import block must not bring from core. +OWN = {"cmd", "install", "session", "command_tables", "register"} + + +def crate_src(crate): + return f"crates/engine-{crate}/src" + + +def units(crate): + out = [] + with open(MAP) as f: + for line in f: + if line.startswith("#") or line.startswith("unit\t") or not line.strip(): + continue + u, c = line.rstrip("\n").split("\t") + if c == crate: + out.append(u) + return out + + +def unit_root(u, src=CORE): + for f in (f"{src}/{u}.rs", f"{src}/{u}/mod.rs"): + if os.path.isfile(f): + return f + return None + + +def reach(root): + """`root` and every file its `mod` declarations reach.""" + seen, todo = [], [root] + while todo: + f = todo.pop() + if f in seen: + continue + seen.append(f) + src = open(f).read() + m = mask(src) + for d in MOD_DECL.finditer(m): + child = module_file(f, d.group(2), src[d.start(1) : d.end(1)], [dir_ for dir_, _ in inline_mods(src, m, d.start())]) + if child: + todo.append(os.path.normpath(child)) + return seen + + +def crate_files(crate, src=CORE): + files = [] + for u in units(crate): + r = unit_root(u, src) + if r: + files += [f for f in reach(r) if f not in files] + return files + + +def read(path): + with open(path, encoding="utf-8") as f: + return f.read() + + +def write(path, text): + with open(path, "w", encoding="utf-8") as f: + f.write(text) + + +def decl_re(name): + """A declaration line of module `name` with its attributes, or a `pub use cmd::name;` line.""" + return re.compile(r"^(?:[ \t]*#\[[^\n]*\]\n)*[ \t]*(?:pub(?:\([a-z]+\))?\s+)?(?:mod\s+" + name + r"\s*;|use\s+cmd::" + name + r"\s*;)[ \t]*\n", re.M) + + +def drop_decls(crate): + """Removes the crate's module declarations from core's lib.rs, cmd.rs and cmd/table.rs.""" + changed = [] + for u in units(crate): + parts = u.split("/") + parent = {1: [f"{CORE}/lib.rs"], 2: [f"{CORE}/cmd.rs", f"{CORE}/lib.rs"], 3: [f"{CORE}/cmd/table.rs"]}[len(parts)] + for p in parent: + text = read(p) + new = decl_re(parts[-1]).sub("", text) + if new != text: + write(p, new) + changed.append(p) + return changed + + +def own_cmd_names(crate): + return {u.split("/")[1] for u in units(crate) if u.startswith("cmd/")} | {"table"} + + +CMD_PATH = re.compile(r"\bcrate::cmd::(\w+)") +CMD_USE = re.compile(r"\buse crate::cmd::\{") + + +SUPER_PATH = re.compile(r"(?.rs`), whose parent was core's `cmd`.""" + own = own_cmd_names(crate) + masked = mask(text) + edits = [(m.start(), m.end(), f"crate::commands::{m.group(1)}") for m in CMD_PATH.finditer(masked) if m.group(1) not in own] + if path in {f"{crate_src(crate)}/{u}.rs" for u in units(crate) if u.startswith("cmd/") and u.count("/") == 1}: + edits += [(m.start(), m.end(), f"crate::commands::{m.group(1)}") for m in SUPER_PATH.finditer(masked) if m.group(1) not in own and m.group(1) != "super"] + edits += [(m.start(), m.end(), "use crate::commands::{") for m in CMD_USE.finditer(masked)] + for s, e, r in sorted(edits, reverse=True): + text = text[:s] + r + text[e:] + return text + + +def rust_files(roots): + """The .rs files under `roots` that some crate target compiles: a file no module reaches never + builds, and CI's unreached-rs guard flags any edit to it.""" + return sorted(compiled_files(roots)) + + +def tree_files(src): + """Every .rs file under a crate's `src` (a crate cut by this script may not have its + Cargo.toml yet, so `compiled_files` can't reach it).""" + return sorted(os.path.join(d, n) for d, _, fs in os.walk(src) for n in fs if n.endswith(".rs")) + + +def trait_root(path, crate): + if path.startswith(crate_src(crate) + "/"): + return "crate" + if path.startswith(CORE + "/"): + return None # core can't name an upper crate's trait + return f"photocraft_engine_{crate}" if path.startswith(f"crates/engine-{crate}/") else "photocraft_engine" + + +def add_trait_imports(path, crate): + """Adds `use ::::;` for each trait method the file calls.""" + methods = TRAITS.get(crate, {}) + if not methods: + return False + text = read(path) + masked = mask(text) + root = trait_root(path, crate) + needed = {} + for m in re.finditer(r"\.(" + "|".join(methods) + r")\s*\(", masked): + module, trait = methods[m.group(1)] + if re.search(r"\b(?:use|trait)\b[^;{]*\b" + trait + r"\b", masked): + continue + needed.setdefault(trait, (module, m.start())) + if not needed or root is None: + return False + for trait, (module, pos) in sorted(needed.items(), key=lambda x: -x[1][1]): + body = enclosing_mod(mask(text), pos) + line = f"use {root}::{module}::{trait};\n" + if body is not None: + nl = text.index("\n", body) + 1 + indent = re.match(r"[ \t]*", text[nl:]).group(0) + text = text[:nl] + indent + line + text[nl:] + else: + um = re.search(r"^use ", mask(text), re.M) + at = um.start() if um else 0 + text = text[:at] + line + text[at:] + write(path, text) + return True + + +def enclosing_mod(masked, pos): + from rust_source import block_end + + best = None + for m in re.finditer(r"\bmod\s+\w+\s*\{", masked[:pos]): + if block_end(masked, m.start()) > pos: + best = m.end() + return best + + +def split(crate): + files = crate_files(crate) + if not files: + print(f"nothing of `{crate}` left in {CORE}") + for f in files: + dst = crate_src(crate) + f[len(CORE) :] + os.makedirs(os.path.dirname(dst), exist_ok=True) + git("mv", f, dst) + print(f"moved {len(files)} files to {crate_src(crate)}") + print("declarations dropped in:", ", ".join(sorted(set(drop_decls(crate)))) or "none") + finish(crate, tree_files(crate_src(crate))) + + +def finish(crate, moved): + n = 0 + for f in moved: + text = read(f) + new = point_cmd_at_core(text, crate, f) + if new != text: + write(f, new) + n += 1 + print(f"crate::cmd paths pointed at core's commands in {n} files") + t = sum(add_trait_imports(f, crate) for f in sorted(set(rust_files(ROOTS)) | set(moved))) + print(f"trait imports added in {t} files") + + +def import_names(crate, files=None): + """(names the crate's code reaches as `crate::x` that it doesn't define, the subset only its + tests reach).""" + from rust_source import in_test, test_regions + + lib = f"{crate_src(crate)}/lib.rs" + regions = test_regions(lib) if os.path.exists(lib) else {} + files = files if files is not None else tree_files(crate_src(crate)) + own = OWN | {u.split("/")[-1] for u in units(crate)} + used, in_code = set(), set() + for f in files: + masked = mask(read(f)) + ranges = regions.get(f, []) + hits = [(m.start(), m.group(1)) for m in re.finditer(r"\bcrate::([A-Za-z_][A-Za-z0-9_]*)", masked)] + for m in re.finditer(r"\buse crate::\{([^}]*)\}", masked): + hits += [(m.start(), n) for n in re.findall(r"(?:^|,)\s*([A-Za-z_][A-Za-z0-9_]*)", m.group(1))] + for pos, n in hits: + if n in own or n == "self": + continue + used.add(n) + if not in_test(ranges, pos): + in_code.add(n) + return sorted(in_code), sorted(used - in_code) + + +def import_block(crate): + code, tests = import_names(crate) + out = "use photocraft_engine_core::{" + ", ".join(code) + "};" + if tests: + out += "\n#[cfg(test)]\nuse photocraft_engine_core::{" + ", ".join(tests) + "};" + return out + + +def imports(crate): + print("// The core items this crate's code names as `crate::x` (photocraft#15710).") + print(import_block(crate)) + + +def crate_ids(crate): + ids = set() + for f in tree_files(crate_src(crate)): + ids |= set(re.findall(r'(?:\b\w+!\(\s*|\bid:\s*)"([a-z][A-Za-z0-9_]*\.[A-Za-z0-9_.]+)"', read(f))) + return ids + + +def branch(crate, base, head): + not_done = [] + changed = git("diff", "--name-status", "-M", base, head).splitlines() + added = [l.split("\t")[-1] for l in changed if l.startswith("A")] + # Files git left in core that the crate's modules declare. + roots = [unit_root(u) for u in units(crate)] + left = [f for r in roots if r for f in reach(r)] + for f in left: + dst = crate_src(crate) + f[len(CORE) :] + os.makedirs(os.path.dirname(dst), exist_ok=True) + git("mv", f, dst) + # Declarations and table entries the branch added in core for the crate's modules. + own = {u.split("/")[-1] for u in units(crate)} + for core_file, crate_file in ((f"{CORE}/cmd.rs", f"{crate_src(crate)}/cmd.rs"), (f"{CORE}/lib.rs", f"{crate_src(crate)}/lib.rs")): + text = read(core_file) + for name in own: + m = decl_re(name).search(text) + if m: + text = text[: m.start()] + text[m.end() :] + ct = read(crate_file) + if not decl_re(name).search(ct): + write(crate_file, ct.rstrip("\n") + "\n" + m.group(0)) + write(core_file, text) + inst = f"{CORE}/install.rs" + text = read(inst) + entry = re.compile(r'^[ \t]*\("[^"]+",\s*crate::(?:cmd::)?(' + "|".join(sorted(own)) + r')::specs\),[ \t]*\n', re.M) + for m in list(entry.finditer(text))[::-1]: + text = text[: m.start()] + text[m.end() :] + not_done.append(f"{crate_src(crate)}/install.rs: add the table entry `{m.group(0).strip()}` to TABLES") + write(inst, text) + finish(crate, left + [f for f in added if f.startswith(crate_src(crate) + "/") and os.path.exists(f)]) + # Import block names the moved code now needs. + lib = f"{crate_src(crate)}/lib.rs" + lt = read(lib) + m = re.search(r"use photocraft_engine_core::\{[^}]*\};(?:\n#\[cfg\(test\)\]\nuse photocraft_engine_core::\{[^}]*\};)?", lt) + if m: + write(lib, lt[: m.start()] + import_block(crate) + lt[m.end() :]) + # Tests in core that run the crate's commands. + ids = crate_ids(crate) + pat = re.compile(r'"(' + "|".join(re.escape(i) for i in sorted(ids)) + r')"') if ids else None + for l in changed: + f = l.split("\t")[-1] + if pat and f.startswith(CORE + "/") and f.endswith(".rs") and os.path.exists(f): + diff = git("diff", base, head, "--", f) + hits = sorted({m.group(1) for m in pat.finditer("\n".join(x for x in diff.splitlines() if x.startswith("+")))}) + if hits: + not_done.append(f"{f}: the branch's lines run {', '.join(hits)}; a test doing that moves to crates/engine/tests/it") + report(not_done) + + +USE_STMT = re.compile(r"^([ \t]*)(?:pub(?:\([^)]*\))?\s+)?use\s+", re.M) + + +def widen(text, pos, end): + """`text` with the item named at `pos`..`end` made `pub`: its definition line, or for a name in + a `use` list, its own `pub use` line beside the list.""" + masked = mask(text) + stmt = None + for m in USE_STMT.finditer(masked, 0, pos): + stmt = m + if stmt is not None: + semi = masked.find(";", stmt.start()) + if stmt.start() < pos < semi and ";" not in masked[stmt.end() : pos]: + body = text[stmt.end() : semi] + name = text[pos:end] + if "{" not in body: + head = text[stmt.start() : stmt.end()] + return text[: stmt.start()] + stmt.group(1) + "pub use " + text[stmt.end() :] if not head.lstrip().startswith("pub use") else text + if "{" in body[body.index("{") + 1 : body.rindex("}")]: + return None + prefix = body[: body.index("{")] + # Edit only at and after `pos`, so the offsets of earlier names stay valid. + after = re.match(r"\s*,\s*", text[end:semi]) + if after: + text = text[:pos] + text[end + after.end() :] + else: + before = re.search(r",\s*$", text[stmt.end() : pos]) + if not before: + return None + text = text[: stmt.end() + before.start()] + text[end:] + masked = mask(text) + semi = masked.find(";", stmt.start()) + line_end = text.index("\n", semi) + 1 + if re.fullmatch(r"\{\s*\}", text[stmt.end() + len(prefix) : semi].strip() or "{}"): + return text[: stmt.start()] + f"{stmt.group(1)}pub use {prefix}{name};\n" + text[line_end:] + return text[:line_end] + f"{stmt.group(1)}pub use {prefix}{name};\n" + text[line_end:] + ls = text.rfind("\n", 0, pos) + 1 + le = text.find("\n", pos) + line = text[ls:le] + new = re.sub(r"^(\s*)(?:pub\((?:crate|super|in [^)]*)\)\s+)?(?!pub\b)", r"\1pub ", line, count=1) + return text[:ls] + new + text[le:] + + +def child_module(f, name): + src = read(f) + for d in MOD_DECL.finditer(mask(src)): + if d.group(2) == name: + return module_file(f, name, src[d.start(1) : d.end(1)]) + return None + + +def reexported(d): + """(file, ("chars", start, end)) of the definition a refused `pub use` names.""" + m = re.search(r"`([A-Za-z_][A-Za-z0-9_]*)`", d["message"]) + spans = [s for c in d.get("children", []) for s in c.get("spans", [])] + [s for s in d.get("spans", []) if s.get("is_primary")] + spans = [s for s in spans if s["file_name"].startswith(CORE + "/")] + if not m or not spans: + return None + name, f = m.group(1), spans[0]["file_name"] + text = read(f) + line = text.split("\n")[spans[0]["line_start"] - 1] + um = re.search(r"use\s+((?:[a-z_][a-z0-9_]*::)+)(?:\{[^}]*\b" + name + r"\b|" + name + r"\b)", line) + if not um: + return None + segs = [x for x in um.group(1).split("::") if x] + cur = f + for seg in segs: + if seg == "crate": + cur = f"{CORE}/lib.rs" + elif seg == "super": + return None + else: + cur = child_module(cur, seg) + if cur is None: + return None + src = read(cur) + dm = re.search(r"^[ \t]*(?:pub\([a-z]+\)\s+)?(?:const\s+|async\s+)*(?:fn|struct|enum|const|static|type|trait|mod)\s+(" + name + r")\b", src, re.M) + if not dm: + um2 = re.search(r"^[ \t]*(?:pub\([a-z]+\)\s+)?use\s[^;]*\b(" + name + r")\b[^;]*;", mask(src), re.M) + if not um2: + return None + return cur, ("chars", um2.start(1), um2.end(1)) + return cur, ("chars", dm.start(1), dm.end(1)) + + +def fix(stream): + defs_by_file = {} + left = [] + for line in stream: + line = line.strip() + if not line.startswith("{"): + continue + try: + msg = json.loads(line) + except ValueError: + continue + if msg.get("reason") != "compiler-message": + continue + d = msg["message"] + code = (d.get("code") or {}).get("code") + if code in ("E0364", "E0365"): + # A `pub use` of an item that is only `pub(crate)` where it is defined. + target = reexported(d) + if target: + defs_by_file.setdefault(target[0], set()).add(target[1]) + else: + left.append(d.get("rendered", d["message"]).splitlines()[0]) + continue + if code not in ("E0603", "E0624", "E0616"): + continue + defs = [s for c in d.get("children", []) for s in c.get("spans", []) if "defined here" in (c.get("message") or "") or "private" in (c.get("message") or "")] + defs += [s for s in d.get("spans", []) if not s.get("is_primary")] + defs = [s for s in defs if s["file_name"].startswith(CORE + "/")] + if not defs: + left.append(d.get("rendered", d["message"]).splitlines()[0]) + continue + sp = defs[0] + defs_by_file.setdefault(sp["file_name"], set()).add(("bytes", sp["byte_start"], sp["byte_end"])) + n = 0 + for f, spans in defs_by_file.items(): + text = read(f) + raw = text.encode("utf-8") + for kind, b0, b1 in sorted(spans, key=lambda x: x[1] if x[0] == "bytes" else len(text[: x[1]].encode("utf-8")), reverse=True): + if kind == "bytes": + c0, c1 = len(raw[:b0].decode("utf-8", "ignore")), len(raw[:b1].decode("utf-8", "ignore")) + else: + c0, c1 = b0, b1 + new = widen(text, c0, c1) + if new is not None and new != text: + print(f"WIDENED: {f}: {text[c0:c1]}") + if new is None: + left.append(f"{f}: `{text[c0:c1]}` in a nested use list") + elif new != text: + text = new + n += 1 + write(f, text) + print(f"widened {n} items in {len(defs_by_file)} files") + for l in sorted(set(left)): + print("BY HAND:", l) + report([]) + + +CANNOT_DO = """ +What this script cannot do: + - items that core-crate code uses from the cut crate: they move down by hand (each cut's PR + lists where they went), or become a hook or a trait of the crate; + - core tests that run the cut crate's commands: they fail at run time with `UnknownCommand` + and move to crates/engine/tests/it, against the public API; + - the crate's own install list and `command_ids.txt` (crates/engine/src/install/) for a new + command or table: add them by hand; + - core items that only a test of the crate uses under `#[cfg(test)]`: core is then an ordinary + dependency, so the item doesn't exist there. +""" + + +def report(not_done): + for n in not_done: + print("NOT DONE:", n) + print(CANNOT_DO) + + +def main(): + ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + sub = ap.add_subparsers(dest="mode", required=True) + for name in ("split", "imports"): + p = sub.add_parser(name) + p.add_argument("crate") + p = sub.add_parser("branch") + p.add_argument("crate") + p.add_argument("--base", required=True) + p.add_argument("--head", required=True) + sub.add_parser("fix") + a = ap.parse_args() + os.chdir(git("rev-parse", "--show-toplevel").strip()) + if a.mode == "split": + split(a.crate) + report([]) + elif a.mode == "imports": + imports(a.crate) + elif a.mode == "branch": + branch(a.crate, a.base, a.head) + else: + fix(sys.stdin) + + +if __name__ == "__main__": + main()