@@ -24,7 +24,7 @@ use log::log_enabled;
2424use serde:: Serialize ;
2525use std:: fmt;
2626use std:: fs:: File ;
27- use std:: io:: { Write , stdout } ;
27+ use std:: io:: Write ;
2828use std:: path:: { Path , PathBuf } ;
2929use std:: time:: { Duration , Instant } ;
3030
@@ -137,118 +137,47 @@ pub fn initialize_build(
137137 let project_context = ProjectContext :: new ( path) ?;
138138 let compiler = get_compiler_info ( & project_context) ?;
139139
140- if !plain_output && show_progress {
141- print ! ( "{} {}Building package tree..." , style( "[1/7]" ) . bold( ) . dim( ) , TREE ) ;
142- let _ = stdout ( ) . flush ( ) ;
143- }
144-
145- let timing_package_tree = Instant :: now ( ) ;
140+ let timing_clean_start = Instant :: now ( ) ;
146141 let packages = packages:: make ( filter, & project_context, show_progress) ?;
147- let timing_package_tree_elapsed = timing_package_tree. elapsed ( ) ;
148142
149143 let compiler_check = verify_compiler_info ( & packages, & compiler) ;
150144
145+ if !packages:: validate_packages_dependencies ( & packages) {
146+ return Err ( anyhow ! ( "Failed to validate package dependencies" ) ) ;
147+ }
148+
149+ let mut build_state = BuildCommandState :: new ( project_context, packages, compiler, warn_error) ;
150+ packages:: parse_packages ( & mut build_state) ;
151+
152+ let compile_assets_state = read_compile_state:: read ( & mut build_state) ?;
153+
154+ let ( diff_cleanup, total_cleanup) = clean:: cleanup_previous_build ( & mut build_state, compile_assets_state) ;
155+ let timing_clean_total = timing_clean_start. elapsed ( ) ;
156+
151157 if show_progress {
152158 if plain_output {
153159 if let CompilerCheckResult :: CleanedPackagesDueToCompiler = compiler_check {
154160 // Snapshot-friendly output (no progress prefixes or emojis)
155161 println ! ( "Cleaned previous build due to compiler update" ) ;
156162 }
163+ println ! ( "Cleaned {diff_cleanup}/{total_cleanup}" )
157164 } else {
158- println ! (
159- "{}{} {}Built package tree in {:.2}s" ,
160- LINE_CLEAR ,
161- style( "[1/7]" ) . bold( ) . dim( ) ,
162- TREE ,
163- default_timing
164- . unwrap_or( timing_package_tree_elapsed)
165- . as_secs_f64( )
166- ) ;
167165 if let CompilerCheckResult :: CleanedPackagesDueToCompiler = compiler_check {
168166 println ! (
169167 "{}{} {}Cleaned previous build due to compiler update" ,
170168 LINE_CLEAR ,
171- style( "[1/7 ]" ) . bold( ) . dim( ) ,
169+ style( "[1/3 ]" ) . bold( ) . dim( ) ,
172170 SWEEP
173171 ) ;
174172 }
175- }
176- }
177-
178- if !packages:: validate_packages_dependencies ( & packages) {
179- return Err ( anyhow ! ( "Failed to validate package dependencies" ) ) ;
180- }
181-
182- let timing_source_files = Instant :: now ( ) ;
183-
184- if !plain_output && show_progress {
185- print ! (
186- "{} {}Finding source files..." ,
187- style( "[2/7]" ) . bold( ) . dim( ) ,
188- LOOKING_GLASS
189- ) ;
190- let _ = stdout ( ) . flush ( ) ;
191- }
192-
193- let mut build_state = BuildCommandState :: new ( project_context, packages, compiler, warn_error) ;
194- packages:: parse_packages ( & mut build_state) ;
195- let timing_source_files_elapsed = timing_source_files. elapsed ( ) ;
196-
197- if !plain_output && show_progress {
198- println ! (
199- "{}{} {}Found source files in {:.2}s" ,
200- LINE_CLEAR ,
201- style( "[2/7]" ) . bold( ) . dim( ) ,
202- LOOKING_GLASS ,
203- default_timing
204- . unwrap_or( timing_source_files_elapsed)
205- . as_secs_f64( )
206- ) ;
207-
208- print ! (
209- "{} {}Reading compile state..." ,
210- style( "[3/7]" ) . bold( ) . dim( ) ,
211- COMPILE_STATE
212- ) ;
213- let _ = stdout ( ) . flush ( ) ;
214- }
215- let timing_compile_state = Instant :: now ( ) ;
216- let compile_assets_state = read_compile_state:: read ( & mut build_state) ?;
217- let timing_compile_state_elapsed = timing_compile_state. elapsed ( ) ;
218-
219- if !plain_output && show_progress {
220- println ! (
221- "{}{} {}Read compile state {:.2}s" ,
222- LINE_CLEAR ,
223- style( "[3/7]" ) . bold( ) . dim( ) ,
224- COMPILE_STATE ,
225- default_timing
226- . unwrap_or( timing_compile_state_elapsed)
227- . as_secs_f64( )
228- ) ;
229-
230- print ! (
231- "{} {}Cleaning up previous build..." ,
232- style( "[4/7]" ) . bold( ) . dim( ) ,
233- SWEEP
234- ) ;
235- }
236- let timing_cleanup = Instant :: now ( ) ;
237- let ( diff_cleanup, total_cleanup) = clean:: cleanup_previous_build ( & mut build_state, compile_assets_state) ;
238- let timing_cleanup_elapsed = timing_cleanup. elapsed ( ) ;
239-
240- if show_progress {
241- if plain_output {
242- println ! ( "Cleaned {diff_cleanup}/{total_cleanup}" )
243- } else {
244173 println ! (
245- "{}{} {}Cleaned {}/{} {:.2}s" ,
174+ "{}{} {}Cleaned {}/{} in {:.2}s" ,
246175 LINE_CLEAR ,
247- style( "[4/7 ]" ) . bold( ) . dim( ) ,
176+ style( "[1/3 ]" ) . bold( ) . dim( ) ,
248177 SWEEP ,
249178 diff_cleanup,
250179 total_cleanup,
251- default_timing. unwrap_or( timing_cleanup_elapsed ) . as_secs_f64( )
180+ default_timing. unwrap_or( timing_clean_total ) . as_secs_f64( )
252181 ) ;
253182 }
254183 }
@@ -316,8 +245,8 @@ pub fn incremental_build(
316245 } else {
317246 ProgressBar :: hidden ( )
318247 } ;
319- let mut current_step = if only_incremental { 1 } else { 5 } ;
320- let total_steps = if only_incremental { 3 } else { 7 } ;
248+ let mut current_step = if only_incremental { 1 } else { 2 } ;
249+ let total_steps = if only_incremental { 2 } else { 3 } ;
321250 pb. set_style (
322251 ProgressStyle :: with_template ( & format ! (
323252 "{} {}Parsing... {{spinner}} {{pos}}/{{len}} {{msg}}" ,
@@ -327,27 +256,14 @@ pub fn incremental_build(
327256 . unwrap ( ) ,
328257 ) ;
329258
259+ let timing_parse_start = Instant :: now ( ) ;
330260 let timing_ast = Instant :: now ( ) ;
331261 let result_asts = parse:: generate_asts ( build_state, || pb. inc ( 1 ) ) ;
332262 let timing_ast_elapsed = timing_ast. elapsed ( ) ;
333263
334264 match result_asts {
335265 Ok ( _ast) => {
336- if show_progress {
337- if plain_output {
338- println ! ( "Parsed {num_dirty_modules} source files" )
339- } else {
340- println ! (
341- "{}{} {}Parsed {} source files in {:.2}s" ,
342- LINE_CLEAR ,
343- format_step( current_step, total_steps) ,
344- CODE ,
345- num_dirty_modules,
346- default_timing. unwrap_or( timing_ast_elapsed) . as_secs_f64( )
347- ) ;
348- pb. finish ( ) ;
349- }
350- }
266+ pb. finish ( ) ;
351267 }
352268 Err ( err) => {
353269 logs:: finalize ( & build_state. packages ) ;
@@ -370,20 +286,23 @@ pub fn incremental_build(
370286 } ) ;
371287 }
372288 }
373- let timing_deps = Instant :: now ( ) ;
374289 let deleted_modules = build_state. deleted_modules . clone ( ) ;
375290 deps:: get_deps ( build_state, & deleted_modules) ;
376- let timing_deps_elapsed = timing_deps. elapsed ( ) ;
377- current_step += 1 ;
291+ let timing_parse_total = timing_parse_start. elapsed ( ) ;
378292
379- if !plain_output && show_progress {
380- println ! (
381- "{}{} {}Collected deps in {:.2}s" ,
382- LINE_CLEAR ,
383- format_step( current_step, total_steps) ,
384- DEPS ,
385- default_timing. unwrap_or( timing_deps_elapsed) . as_secs_f64( )
386- ) ;
293+ if show_progress {
294+ if plain_output {
295+ println ! ( "Parsed {num_dirty_modules} source files" )
296+ } else {
297+ println ! (
298+ "{}{} {}Parsed {} source files in {:.2}s" ,
299+ LINE_CLEAR ,
300+ format_step( current_step, total_steps) ,
301+ CODE ,
302+ num_dirty_modules,
303+ default_timing. unwrap_or( timing_parse_total) . as_secs_f64( )
304+ ) ;
305+ }
387306 }
388307
389308 mark_modules_with_expired_deps_dirty ( build_state) ;
0 commit comments