@@ -117,21 +117,17 @@ pub fn initialize_build<'a>(
117
117
let root_config_name = packages:: get_package_name ( & project_root) ;
118
118
let rescript_version = helpers:: get_rescript_version ( & bsc_path) ;
119
119
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 ) ;
125
121
let _ = stdout ( ) . flush ( ) ;
126
122
let timing_package_tree = Instant :: now ( ) ;
127
123
let packages = packages:: make ( & filter, & project_root, & workspace_root) ;
128
124
let timing_package_tree_elapsed = timing_package_tree. elapsed ( ) ;
129
125
130
126
println ! (
131
- "{}\r {} {}Built package tree in {:.2}s" ,
127
+ "{}{} {}Built package tree in {:.2}s" ,
132
128
LINE_CLEAR ,
133
129
style( "[1/7]" ) . bold( ) . dim( ) ,
134
- CHECKMARK ,
130
+ TREE ,
135
131
default_timing
136
132
. unwrap_or( timing_package_tree_elapsed)
137
133
. as_secs_f64( )
@@ -144,7 +140,7 @@ pub fn initialize_build<'a>(
144
140
let timing_source_files = Instant :: now ( ) ;
145
141
146
142
print ! (
147
- "{} {} Finding source files..." ,
143
+ "{} {}Finding source files..." ,
148
144
style( "[2/7]" ) . bold( ) . dim( ) ,
149
145
LOOKING_GLASS
150
146
) ;
@@ -160,67 +156,73 @@ pub fn initialize_build<'a>(
160
156
packages:: parse_packages ( & mut build_state) ;
161
157
let timing_source_files_elapsed = timing_source_files. elapsed ( ) ;
162
158
println ! (
163
- "{}\r {} {}Found source files in {:.2}s" ,
159
+ "{}{} {}Found source files in {:.2}s" ,
164
160
LINE_CLEAR ,
165
161
style( "[2/7]" ) . bold( ) . dim( ) ,
166
- CHECKMARK ,
162
+ LOOKING_GLASS ,
167
163
default_timing
168
164
. unwrap_or( timing_source_files_elapsed)
169
165
. as_secs_f64( )
170
166
) ;
171
167
172
168
print ! (
173
- "{} {} Reading compile state..." ,
169
+ "{} {}Reading compile state..." ,
174
170
style( "[3/7]" ) . bold( ) . dim( ) ,
175
- LOOKING_GLASS
171
+ COMPILE_STATE
176
172
) ;
177
173
let _ = stdout ( ) . flush ( ) ;
178
174
let timing_compile_state = Instant :: now ( ) ;
179
175
let compile_assets_state = read_compile_state:: read ( & mut build_state) ;
180
176
let timing_compile_state_elapsed = timing_compile_state. elapsed ( ) ;
181
177
println ! (
182
- "{}\r {} {}Read compile state {:.2}s" ,
178
+ "{}{} {}Read compile state {:.2}s" ,
183
179
LINE_CLEAR ,
184
180
style( "[3/7]" ) . bold( ) . dim( ) ,
185
- CHECKMARK ,
181
+ COMPILE_STATE ,
186
182
default_timing
187
183
. unwrap_or( timing_compile_state_elapsed)
188
184
. as_secs_f64( )
189
185
) ;
190
186
191
187
print ! (
192
- "{} {} Cleaning up previous build..." ,
188
+ "{} {}Cleaning up previous build..." ,
193
189
style( "[4/7]" ) . bold( ) . dim( ) ,
194
190
SWEEP
195
191
) ;
196
192
let timing_cleanup = Instant :: now ( ) ;
197
193
let ( diff_cleanup, total_cleanup) = clean:: cleanup_previous_build ( & mut build_state, compile_assets_state) ;
198
194
let timing_cleanup_elapsed = timing_cleanup. elapsed ( ) ;
199
195
println ! (
200
- "{}\r {} {}Cleaned {}/{} {:.2}s" ,
196
+ "{}{} {}Cleaned {}/{} {:.2}s" ,
201
197
LINE_CLEAR ,
202
198
style( "[4/7]" ) . bold( ) . dim( ) ,
203
- CHECKMARK ,
199
+ SWEEP ,
204
200
diff_cleanup,
205
201
total_cleanup,
206
202
default_timing. unwrap_or( timing_cleanup_elapsed) . as_secs_f64( )
207
203
) ;
208
204
Ok ( build_state)
209
205
}
210
206
207
+ fn format_step ( current : usize , total : usize ) -> console:: StyledObject < String > {
208
+ style ( format ! ( "[{}/{}]" , current, total) ) . bold ( ) . dim ( )
209
+ }
210
+
211
211
pub fn incremental_build (
212
212
build_state : & mut BuildState ,
213
213
default_timing : Option < Duration > ,
214
214
initial_build : bool ,
215
+ only_incremental : bool ,
215
216
) -> Result < ( ) , ( ) > {
216
217
logs:: initialize ( & build_state. packages ) ;
217
218
let num_dirty_modules = build_state. modules . values ( ) . filter ( |m| is_dirty ( m) ) . count ( ) as u64 ;
218
-
219
219
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 } ;
220
222
pb. set_style (
221
223
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 ) ,
224
226
CODE
225
227
) )
226
228
. unwrap ( ) ,
@@ -233,10 +235,10 @@ pub fn incremental_build(
233
235
match result_asts {
234
236
Ok ( err) => {
235
237
println ! (
236
- "{}\r {} {}Parsed {} source files in {:.2}s" ,
238
+ "{}{} {}Parsed {} source files in {:.2}s" ,
237
239
LINE_CLEAR ,
238
- style ( "[5/7]" ) . bold ( ) . dim ( ) ,
239
- CHECKMARK ,
240
+ format_step ( current_step , total_steps ) ,
241
+ CODE ,
240
242
num_dirty_modules,
241
243
default_timing. unwrap_or( timing_ast_elapsed) . as_secs_f64( )
242
244
) ;
@@ -245,9 +247,9 @@ pub fn incremental_build(
245
247
Err ( err) => {
246
248
logs:: finalize ( & build_state. packages ) ;
247
249
println ! (
248
- "{}\r {} {}Error parsing source files in {:.2}s" ,
250
+ "{}{} {}Error parsing source files in {:.2}s" ,
249
251
LINE_CLEAR ,
250
- style ( "[5/7]" ) . bold ( ) . dim ( ) ,
252
+ format_step ( current_step , total_steps ) ,
251
253
CROSS ,
252
254
default_timing. unwrap_or( timing_ast_elapsed) . as_secs_f64( )
253
255
) ;
@@ -258,12 +260,13 @@ pub fn incremental_build(
258
260
let timing_deps = Instant :: now ( ) ;
259
261
deps:: get_deps ( build_state, & build_state. deleted_modules . to_owned ( ) ) ;
260
262
let timing_deps_elapsed = timing_deps. elapsed ( ) ;
263
+ current_step += 1 ;
261
264
262
265
println ! (
263
- "{}\r {} {}Collected deps in {:.2}s" ,
266
+ "{}{} {}Collected deps in {:.2}s" ,
264
267
LINE_CLEAR ,
265
- style ( "[6/7]" ) . bold ( ) . dim ( ) ,
266
- CHECKMARK ,
268
+ format_step ( current_step , total_steps ) ,
269
+ DEPS ,
267
270
default_timing. unwrap_or( timing_deps_elapsed) . as_secs_f64( )
268
271
) ;
269
272
@@ -279,6 +282,7 @@ pub fn incremental_build(
279
282
mark_modules_with_expired_deps_dirty ( build_state) ;
280
283
}
281
284
mark_modules_with_deleted_deps_dirty ( build_state) ;
285
+ current_step += 1 ;
282
286
283
287
// print all the compile_dirty modules
284
288
// for (module_name, module) in build_state.modules.iter() {
@@ -291,8 +295,8 @@ pub fn incremental_build(
291
295
let pb = ProgressBar :: new ( build_state. modules . len ( ) . try_into ( ) . unwrap ( ) ) ;
292
296
pb. set_style (
293
297
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 ) ,
296
300
SWORDS
297
301
) )
298
302
. unwrap ( ) ,
@@ -308,9 +312,9 @@ pub fn incremental_build(
308
312
println ! ( "{}" , & compile_warnings) ;
309
313
}
310
314
println ! (
311
- "{}\r {} {}Compiled {} modules in {:.2}s" ,
315
+ "{}{} {}Compiled {} modules in {:.2}s" ,
312
316
LINE_CLEAR ,
313
- style ( "[7/7]" ) . bold ( ) . dim ( ) ,
317
+ format_step ( current_step , total_steps ) ,
314
318
CROSS ,
315
319
num_compiled_modules,
316
320
default_timing. unwrap_or( compile_duration) . as_secs_f64( )
@@ -325,10 +329,10 @@ pub fn incremental_build(
325
329
return Err ( ( ) ) ;
326
330
} else {
327
331
println ! (
328
- "{}\r {} {}Compiled {} modules in {:.2}s" ,
332
+ "{}{} {}Compiled {} modules in {:.2}s" ,
329
333
LINE_CLEAR ,
330
- style ( "[7/7]" ) . bold ( ) . dim ( ) ,
331
- CHECKMARK ,
334
+ format_step ( current_step , total_steps ) ,
335
+ SWORDS ,
332
336
num_compiled_modules,
333
337
default_timing. unwrap_or( compile_duration) . as_secs_f64( )
334
338
) ;
@@ -347,13 +351,13 @@ pub fn build(filter: &Option<regex::Regex>, path: &str, no_timing: bool) -> Resu
347
351
} ;
348
352
let timing_total = Instant :: now ( ) ;
349
353
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 ) {
351
355
Ok ( _) => {
352
356
let timing_total_elapsed = timing_total. elapsed ( ) ;
353
357
println ! (
354
- "{} \r {}Finished Compilation in {:.2}s" ,
358
+ "\n {} {}Finished Compilation in {:.2}s" ,
355
359
LINE_CLEAR ,
356
- CHECKMARK ,
360
+ SPARKLES ,
357
361
default_timing. unwrap_or( timing_total_elapsed) . as_secs_f64( )
358
362
) ;
359
363
clean:: cleanup_after_build ( & build_state) ;
0 commit comments