@@ -117,21 +117,17 @@ pub fn initialize_build<'a>(
117117 let root_config_name = packages:: get_package_name ( & project_root) ;
118118 let rescript_version = helpers:: get_rescript_version ( & bsc_path) ;
119119
120- print ! (
121- "{} {} Building package tree..." ,
122- style( "[1/7]" ) . bold( ) . dim( ) ,
123- TREE
124- ) ;
120+ print ! ( "{}{}Building package tree..." , style( "[1/7]" ) . bold( ) . dim( ) , TREE ) ;
125121 let _ = stdout ( ) . flush ( ) ;
126122 let timing_package_tree = Instant :: now ( ) ;
127123 let packages = packages:: make ( & filter, & project_root, & workspace_root) ;
128124 let timing_package_tree_elapsed = timing_package_tree. elapsed ( ) ;
129125
130126 println ! (
131- "{}\r {} {}Built package tree in {:.2}s" ,
127+ "{}{} {}Built package tree in {:.2}s" ,
132128 LINE_CLEAR ,
133129 style( "[1/7]" ) . bold( ) . dim( ) ,
134- CHECKMARK ,
130+ TREE ,
135131 default_timing
136132 . unwrap_or( timing_package_tree_elapsed)
137133 . as_secs_f64( )
@@ -144,7 +140,7 @@ pub fn initialize_build<'a>(
144140 let timing_source_files = Instant :: now ( ) ;
145141
146142 print ! (
147- "{} {} Finding source files..." ,
143+ "{} {}Finding source files..." ,
148144 style( "[2/7]" ) . bold( ) . dim( ) ,
149145 LOOKING_GLASS
150146 ) ;
@@ -160,67 +156,73 @@ pub fn initialize_build<'a>(
160156 packages:: parse_packages ( & mut build_state) ;
161157 let timing_source_files_elapsed = timing_source_files. elapsed ( ) ;
162158 println ! (
163- "{}\r {} {}Found source files in {:.2}s" ,
159+ "{}{} {}Found source files in {:.2}s" ,
164160 LINE_CLEAR ,
165161 style( "[2/7]" ) . bold( ) . dim( ) ,
166- CHECKMARK ,
162+ LOOKING_GLASS ,
167163 default_timing
168164 . unwrap_or( timing_source_files_elapsed)
169165 . as_secs_f64( )
170166 ) ;
171167
172168 print ! (
173- "{} {} Reading compile state..." ,
169+ "{} {}Reading compile state..." ,
174170 style( "[3/7]" ) . bold( ) . dim( ) ,
175- LOOKING_GLASS
171+ COMPILE_STATE
176172 ) ;
177173 let _ = stdout ( ) . flush ( ) ;
178174 let timing_compile_state = Instant :: now ( ) ;
179175 let compile_assets_state = read_compile_state:: read ( & mut build_state) ;
180176 let timing_compile_state_elapsed = timing_compile_state. elapsed ( ) ;
181177 println ! (
182- "{}\r {} {}Read compile state {:.2}s" ,
178+ "{}{} {}Read compile state {:.2}s" ,
183179 LINE_CLEAR ,
184180 style( "[3/7]" ) . bold( ) . dim( ) ,
185- CHECKMARK ,
181+ COMPILE_STATE ,
186182 default_timing
187183 . unwrap_or( timing_compile_state_elapsed)
188184 . as_secs_f64( )
189185 ) ;
190186
191187 print ! (
192- "{} {} Cleaning up previous build..." ,
188+ "{} {}Cleaning up previous build..." ,
193189 style( "[4/7]" ) . bold( ) . dim( ) ,
194190 SWEEP
195191 ) ;
196192 let timing_cleanup = Instant :: now ( ) ;
197193 let ( diff_cleanup, total_cleanup) = clean:: cleanup_previous_build ( & mut build_state, compile_assets_state) ;
198194 let timing_cleanup_elapsed = timing_cleanup. elapsed ( ) ;
199195 println ! (
200- "{}\r {} {}Cleaned {}/{} {:.2}s" ,
196+ "{}{} {}Cleaned {}/{} {:.2}s" ,
201197 LINE_CLEAR ,
202198 style( "[4/7]" ) . bold( ) . dim( ) ,
203- CHECKMARK ,
199+ SWEEP ,
204200 diff_cleanup,
205201 total_cleanup,
206202 default_timing. unwrap_or( timing_cleanup_elapsed) . as_secs_f64( )
207203 ) ;
208204 Ok ( build_state)
209205}
210206
207+ fn format_step ( current : usize , total : usize ) -> console:: StyledObject < String > {
208+ style ( format ! ( "[{}/{}]" , current, total) ) . bold ( ) . dim ( )
209+ }
210+
211211pub fn incremental_build (
212212 build_state : & mut BuildState ,
213213 default_timing : Option < Duration > ,
214214 initial_build : bool ,
215+ only_incremental : bool ,
215216) -> Result < ( ) , ( ) > {
216217 logs:: initialize ( & build_state. packages ) ;
217218 let num_dirty_modules = build_state. modules . values ( ) . filter ( |m| is_dirty ( m) ) . count ( ) as u64 ;
218-
219219 let pb = ProgressBar :: new ( num_dirty_modules) ;
220+ let mut current_step = if only_incremental { 1 } else { 5 } ;
221+ let total_steps = if only_incremental { 3 } else { 7 } ;
220222 pb. set_style (
221223 ProgressStyle :: with_template ( & format ! (
222- "{} {} Parsing... {{spinner}} {{pos}}/{{len}} {{msg}}" ,
223- style ( "[5/7]" ) . bold ( ) . dim ( ) ,
224+ "{} {}Parsing... {{spinner}} {{pos}}/{{len}} {{msg}}" ,
225+ format_step ( current_step , total_steps ) ,
224226 CODE
225227 ) )
226228 . unwrap ( ) ,
@@ -233,10 +235,10 @@ pub fn incremental_build(
233235 match result_asts {
234236 Ok ( err) => {
235237 println ! (
236- "{}\r {} {}Parsed {} source files in {:.2}s" ,
238+ "{}{} {}Parsed {} source files in {:.2}s" ,
237239 LINE_CLEAR ,
238- style ( "[5/7]" ) . bold ( ) . dim ( ) ,
239- CHECKMARK ,
240+ format_step ( current_step , total_steps ) ,
241+ CODE ,
240242 num_dirty_modules,
241243 default_timing. unwrap_or( timing_ast_elapsed) . as_secs_f64( )
242244 ) ;
@@ -245,9 +247,9 @@ pub fn incremental_build(
245247 Err ( err) => {
246248 logs:: finalize ( & build_state. packages ) ;
247249 println ! (
248- "{}\r {} {}Error parsing source files in {:.2}s" ,
250+ "{}{} {}Error parsing source files in {:.2}s" ,
249251 LINE_CLEAR ,
250- style ( "[5/7]" ) . bold ( ) . dim ( ) ,
252+ format_step ( current_step , total_steps ) ,
251253 CROSS ,
252254 default_timing. unwrap_or( timing_ast_elapsed) . as_secs_f64( )
253255 ) ;
@@ -258,12 +260,13 @@ pub fn incremental_build(
258260 let timing_deps = Instant :: now ( ) ;
259261 deps:: get_deps ( build_state, & build_state. deleted_modules . to_owned ( ) ) ;
260262 let timing_deps_elapsed = timing_deps. elapsed ( ) ;
263+ current_step += 1 ;
261264
262265 println ! (
263- "{}\r {} {}Collected deps in {:.2}s" ,
266+ "{}{} {}Collected deps in {:.2}s" ,
264267 LINE_CLEAR ,
265- style ( "[6/7]" ) . bold ( ) . dim ( ) ,
266- CHECKMARK ,
268+ format_step ( current_step , total_steps ) ,
269+ DEPS ,
267270 default_timing. unwrap_or( timing_deps_elapsed) . as_secs_f64( )
268271 ) ;
269272
@@ -279,6 +282,7 @@ pub fn incremental_build(
279282 mark_modules_with_expired_deps_dirty ( build_state) ;
280283 }
281284 mark_modules_with_deleted_deps_dirty ( build_state) ;
285+ current_step += 1 ;
282286
283287 // print all the compile_dirty modules
284288 // for (module_name, module) in build_state.modules.iter() {
@@ -291,8 +295,8 @@ pub fn incremental_build(
291295 let pb = ProgressBar :: new ( build_state. modules . len ( ) . try_into ( ) . unwrap ( ) ) ;
292296 pb. set_style (
293297 ProgressStyle :: with_template ( & format ! (
294- "{} {} Compiling... {{spinner}} {{pos}}/{{len}} {{msg}}" ,
295- style ( "[7/7]" ) . bold ( ) . dim ( ) ,
298+ "{} {}Compiling... {{spinner}} {{pos}}/{{len}} {{msg}}" ,
299+ format_step ( current_step , total_steps ) ,
296300 SWORDS
297301 ) )
298302 . unwrap ( ) ,
@@ -308,9 +312,9 @@ pub fn incremental_build(
308312 println ! ( "{}" , & compile_warnings) ;
309313 }
310314 println ! (
311- "{}\r {} {}Compiled {} modules in {:.2}s" ,
315+ "{}{} {}Compiled {} modules in {:.2}s" ,
312316 LINE_CLEAR ,
313- style ( "[7/7]" ) . bold ( ) . dim ( ) ,
317+ format_step ( current_step , total_steps ) ,
314318 CROSS ,
315319 num_compiled_modules,
316320 default_timing. unwrap_or( compile_duration) . as_secs_f64( )
@@ -325,10 +329,10 @@ pub fn incremental_build(
325329 return Err ( ( ) ) ;
326330 } else {
327331 println ! (
328- "{}\r {} {}Compiled {} modules in {:.2}s" ,
332+ "{}{} {}Compiled {} modules in {:.2}s" ,
329333 LINE_CLEAR ,
330- style ( "[7/7]" ) . bold ( ) . dim ( ) ,
331- CHECKMARK ,
334+ format_step ( current_step , total_steps ) ,
335+ SWORDS ,
332336 num_compiled_modules,
333337 default_timing. unwrap_or( compile_duration) . as_secs_f64( )
334338 ) ;
@@ -347,13 +351,13 @@ pub fn build(filter: &Option<regex::Regex>, path: &str, no_timing: bool) -> Resu
347351 } ;
348352 let timing_total = Instant :: now ( ) ;
349353 let mut build_state = initialize_build ( default_timing, filter, path) ?;
350- match incremental_build ( & mut build_state, default_timing, true ) {
354+ match incremental_build ( & mut build_state, default_timing, true , false ) {
351355 Ok ( _) => {
352356 let timing_total_elapsed = timing_total. elapsed ( ) ;
353357 println ! (
354- "{} \r {}Finished Compilation in {:.2}s" ,
358+ "\n {} {}Finished Compilation in {:.2}s" ,
355359 LINE_CLEAR ,
356- CHECKMARK ,
360+ SPARKLES ,
357361 default_timing. unwrap_or( timing_total_elapsed) . as_secs_f64( )
358362 ) ;
359363 clean:: cleanup_after_build ( & build_state) ;
0 commit comments