@@ -105,49 +105,9 @@ let make_world = ref false
105
105
let set_make_world () = make_world := true
106
106
107
107
108
+ ;; Bsb_log. setup ()
108
109
109
110
110
- let color_enabled = ref (Unix. isatty Unix. stdin)
111
- let set_color ppf =
112
- Format. pp_set_formatter_tag_functions ppf
113
- ({ (Format. pp_get_formatter_tag_functions ppf () ) with
114
- mark_open_tag = (fun s -> if ! color_enabled then Ext_color. ansi_of_tag s else Ext_string. empty) ;
115
- mark_close_tag = (fun _ -> if ! color_enabled then Ext_color. reset_lit else Ext_string. empty);
116
- })
117
-
118
- let () =
119
- begin
120
- Format. pp_set_mark_tags Format. std_formatter true ;
121
- Format. pp_set_mark_tags Format. err_formatter true ;
122
- Format. pp_set_mark_tags Format. str_formatter true ;
123
- set_color Format. std_formatter ;
124
- set_color Format. err_formatter;
125
- set_color Format. str_formatter
126
- end
127
-
128
-
129
-
130
- let clean_bs_garbage cwd =
131
- Format. fprintf Format. std_formatter " @{<info>Cleaning:@} in %s@." cwd ;
132
- let aux x =
133
- let x = (cwd // x) in
134
- if Sys. file_exists x then
135
- Bsb_unix. remove_dir_recursive x in
136
- try
137
- List. iter aux Bsb_config. all_lib_artifacts
138
- with
139
- e ->
140
- Format. fprintf Format. err_formatter " @{<warning>Failed@} to clean due to %s" (Printexc. to_string e)
141
-
142
-
143
- let clean_bs_deps () =
144
- Bsb_build_util. walk_all_deps cwd (fun { cwd} ->
145
- (* whether top or not always do the cleaning *)
146
- clean_bs_garbage cwd
147
- )
148
-
149
- let clean_self () = clean_bs_garbage cwd
150
-
151
111
152
112
(* * Regenerate ninja file if necessary
153
113
return None if we dont need regenerate
@@ -177,7 +137,7 @@ let regenerate_ninja
177
137
| Other _ ->
178
138
if check_result = Bsb_bsc_version_mismatch then begin
179
139
print_endline " Also clean current repo due to we have detected a different compiler" ;
180
- clean_self () ;
140
+ Bsb_clean. clean_self cwd ;
181
141
end ;
182
142
Bsb_build_util. mkp (cwd // Bsb_config. lib_bs);
183
143
let config =
@@ -206,19 +166,19 @@ let regenerate_ninja
206
166
207
167
let bsb_main_flags : (string * Arg.spec * string) list =
208
168
[
209
- " -color" , Arg. Set color_enabled,
169
+ " -color" , Arg. Set Bsb_log. color_enabled,
210
170
" forced color output"
211
171
;
212
- " -no-color" , Arg. Clear color_enabled,
172
+ " -no-color" , Arg. Clear Bsb_log. color_enabled,
213
173
" forced no color output" ;
214
174
" -w" , Arg. Set watch_mode,
215
175
" Watch mode" ;
216
176
regen, Arg. Set force_regenerate,
217
177
" (internal) Always regenerate build.ninja no matter bsconfig.json is changed or not (for debugging purpose)"
218
178
;
219
- " -clean-world" , Arg. Unit clean_bs_deps,
179
+ " -clean-world" , Arg. Unit ( fun _ -> Bsb_clean. clean_bs_deps cwd) ,
220
180
" Clean all bs dependencies" ;
221
- " -clean" , Arg. Unit clean_self,
181
+ " -clean" , Arg. Unit ( fun _ -> Bsb_clean. clean_self cwd) ,
222
182
" Clean only current project" ;
223
183
" -make-world" , Arg. Unit set_make_world,
224
184
" Build all dependencies and itself " ;
@@ -231,13 +191,6 @@ let bsb_main_flags : (string * Arg.spec * string) list=
231
191
]
232
192
233
193
234
- let print_string_args (args : string array ) =
235
- for i = 0 to Array. length args - 1 do
236
- print_string (Array. unsafe_get args i) ;
237
- print_string Ext_string. single_space;
238
- done ;
239
- print_newline ()
240
-
241
194
242
195
(* Note that [keepdepfile] only makes sense when combined with [deps] for optimization
243
196
It has to be the last command of [bsb]
@@ -257,7 +210,7 @@ let ninja_command_exit vendor_ninja ninja_args =
257
210
(Filename. quote vendor_ninja) " -C" Bsb_config. lib_bs
258
211
else
259
212
let args = [|" ninja.exe" ; " -C" ; Bsb_config. lib_bs |] in
260
- print_string_args args ;
213
+ Bsb_log. print_string_args args ;
261
214
Unix. execvp vendor_ninja args
262
215
else
263
216
let fixed_args_length = 3 in
@@ -279,7 +232,7 @@ let ninja_command_exit vendor_ninja ninja_args =
279
232
| 1 -> " -C"
280
233
| 2 -> Bsb_config. lib_bs
281
234
| _ -> Array. unsafe_get ninja_args (i - fixed_args_length) )) in
282
- print_string_args args ;
235
+ Bsb_log. print_string_args args ;
283
236
Unix. execvp vendor_ninja args
284
237
285
238
0 commit comments