@@ -12,7 +12,7 @@ use dfx_core::network::provider::get_network_context;
1212use dfx_core:: util;
1313use fn_error_context:: context;
1414use handlebars:: Handlebars ;
15- use slog:: { trace, Logger } ;
15+ use slog:: { info , trace, Logger } ;
1616use std:: borrow:: Cow ;
1717use std:: collections:: BTreeMap ;
1818use std:: ffi:: OsStr ;
@@ -115,7 +115,7 @@ pub trait CanisterBuilder {
115115 . with_context ( || {
116116 format ! (
117117 "Failed to canonicalize output dir {}." ,
118- generate_output_dir. to_string_lossy ( )
118+ generate_output_dir. display ( )
119119 )
120120 } ) ?;
121121 if !generate_output_dir. starts_with ( info. get_workspace_root ( ) ) {
@@ -125,10 +125,7 @@ pub trait CanisterBuilder {
125125 ) ;
126126 }
127127 std:: fs:: remove_dir_all ( & generate_output_dir) . with_context ( || {
128- format ! (
129- "Failed to remove dir: {}" ,
130- generate_output_dir. to_string_lossy( )
131- )
128+ format ! ( "Failed to remove dir: {}" , generate_output_dir. display( ) )
132129 } ) ?;
133130 }
134131
@@ -139,29 +136,24 @@ pub trait CanisterBuilder {
139136 . context ( "`bindings` must not be None" ) ?;
140137
141138 if bindings. is_empty ( ) {
142- eprintln ! ( "`{}.declarations.bindings` in dfx.json was set to be an empty list, so no type declarations will be generated." , & info. get_name( ) ) ;
139+ info ! ( logger , "`{}.declarations.bindings` in dfx.json was set to be an empty list, so no type declarations will be generated." , & info. get_name( ) ) ;
143140 return Ok ( ( ) ) ;
144141 }
145142
146- trace ! (
147- logger,
148- "Generating type declarations for canister {}" ,
149- & info. get_name( )
150- ) ;
151-
152- std:: fs:: create_dir_all ( generate_output_dir) . with_context ( || {
143+ let spinner = env. new_spinner (
153144 format ! (
154- "Failed to create dir: {}" ,
155- generate_output_dir . to_string_lossy ( )
145+ "Generating type declarations for canister {}" ,
146+ & info . get_name ( )
156147 )
157- } ) ?;
148+ . into ( ) ,
149+ ) ;
150+
151+ std:: fs:: create_dir_all ( generate_output_dir)
152+ . with_context ( || format ! ( "Failed to create dir: {}" , generate_output_dir. display( ) ) ) ?;
158153
159154 let did_from_build = self . get_candid_path ( env, pool, info, config) ?;
160155 if !did_from_build. exists ( ) {
161- bail ! (
162- "Candid file: {} doesn't exist." ,
163- did_from_build. to_string_lossy( )
164- ) ;
156+ bail ! ( "Candid file: {} doesn't exist." , did_from_build. display( ) ) ;
165157 }
166158
167159 let ( env, ty) = CandidSource :: File ( did_from_build. as_path ( ) ) . load ( ) ?;
@@ -192,12 +184,8 @@ pub trait CanisterBuilder {
192184 . with_extension ( "did.js" ) ;
193185 let content =
194186 ensure_trailing_newline ( candid_parser:: bindings:: javascript:: compile ( & env, & ty) ) ;
195- std:: fs:: write ( & output_did_js_path, content) . with_context ( || {
196- format ! (
197- "Failed to write to {}." ,
198- output_did_js_path. to_string_lossy( )
199- )
200- } ) ?;
187+ std:: fs:: write ( & output_did_js_path, content)
188+ . with_context ( || format ! ( "Failed to write to {}." , output_did_js_path. display( ) ) ) ?;
201189 trace ! ( logger, " {}" , & output_did_js_path. display( ) ) ;
202190
203191 compile_handlebars_files ( "js" , info, generate_output_dir) ?;
@@ -210,9 +198,8 @@ pub trait CanisterBuilder {
210198 . with_extension ( "mo" ) ;
211199 let content =
212200 ensure_trailing_newline ( candid_parser:: bindings:: motoko:: compile ( & env, & ty) ) ;
213- std:: fs:: write ( & output_mo_path, content) . with_context ( || {
214- format ! ( "Failed to write to {}." , output_mo_path. to_string_lossy( ) )
215- } ) ?;
201+ std:: fs:: write ( & output_mo_path, content)
202+ . with_context ( || format ! ( "Failed to write to {}." , output_mo_path. display( ) ) ) ?;
216203 trace ! ( logger, " {}" , & output_mo_path. display( ) ) ;
217204 }
218205
@@ -226,6 +213,14 @@ pub trait CanisterBuilder {
226213 trace ! ( logger, " {}" , & output_did_path. display( ) ) ;
227214 }
228215
216+ spinner. finish_and_clear ( ) ;
217+ info ! (
218+ logger,
219+ "Generated type declarations for canister {} to {}" ,
220+ & info. get_name( ) ,
221+ generate_output_dir. display( )
222+ ) ;
223+
229224 Ok ( ( ) )
230225 }
231226
0 commit comments