@@ -205,8 +205,8 @@ let run
205205 if Option. is_some source_map && Parse_bytecode.Debug. is_empty one.debug
206206 then
207207 warn
208- " Warning: '--source-map' is enabled but the program was compiled with \
209- no debugging information.\n \
208+ " Warning: '--source-map' is enabled but the program was compiled with no \
209+ debugging information.\n \
210210 %!"
211211 in
212212 let pseudo_fs_instr prim debug cmis =
@@ -290,7 +290,7 @@ let run
290290 sm
291291 in
292292 let output_partial
293- ({name = _ ; info = uinfo ; contents } : Parse_bytecode.compilation_unit )
293+ ({ name = _ ; info = uinfo ; contents } : Parse_bytecode.compilation_unit )
294294 ~standalone
295295 ~source_map
296296 ((_ , fmt ) as output_file ) =
@@ -364,81 +364,82 @@ let run
364364 ~link: `All
365365 output_file
366366 |> sourcemap_of_info ~base: source_map_base)
367- | `Filename filename ->
367+ | `Filename filename -> (
368368 match
369369 Parse_bytecode. load
370370 ~filename
371371 ~include_dirs
372372 ~include_cmis
373373 ~debug: need_debug
374- ~log_times: (times() )
374+ ~log_times: (times () )
375375 with
376376 | `Cmj cmj ->
377- output_gen
378- ~standalone: false
379- ~custom_header
380- ~build_info: (Build_info. create `Cmj )
381- ~source_map
382- (fst output_file)
383- (fun ~standalone ~source_map output ->
384- if include_runtime then
385- (let sm1 = output_partial_runtime ~standalone ~source_map output in
386- let sm2 = output_partial cmj ~standalone ~source_map output in
387- sourcemap_of_infos ~base: source_map_base [sm1; sm2])
388- else
389- output_partial cmj ~standalone ~source_map output
390- |> sourcemap_of_info ~base: source_map_base)
377+ output_gen
378+ ~standalone: false
379+ ~custom_header
380+ ~build_info: (Build_info. create `Cmj )
381+ ~source_map
382+ (fst output_file)
383+ (fun ~standalone ~source_map output ->
384+ if include_runtime
385+ then
386+ let sm1 = output_partial_runtime ~standalone ~source_map output in
387+ let sm2 = output_partial cmj ~standalone ~source_map output in
388+ sourcemap_of_infos ~base: source_map_base [ sm1; sm2 ]
389+ else
390+ output_partial cmj ~standalone ~source_map output
391+ |> sourcemap_of_info ~base: source_map_base)
391392 | `Cmja units ->
392- if keep_unit_names then (
393- let output_dir =
394- match output_file with
395- | `Stdout , false -> Filename. current_dir_name
396- | `Name x , false -> Filename. dirname x
397- | `Name x , true when String. ends_with x ~suffix: " /" -> x
398- | `Stdout , true | `Name _ , true ->
399- failwith " use [-o dirname/] or remove [--keep-unit-names]"
400- in
401- if include_runtime then (
402- output_gen
403- ~standalone: false
404- ~custom_header
405- ~build_info: (Build_info. create `Runtime )
406- ~source_map
407- (`Name (Filename. concat output_dir " runtime.js" ))
408- (fun ~standalone ~source_map output ->
409- output_partial_runtime ~standalone ~source_map output
410- |> sourcemap_of_info ~base: source_map_base));
411- List. iter units ~f: (fun (cmj : Parse_bytecode.compilation_unit ) ->
393+ if keep_unit_names
394+ then (
395+ let output_dir =
396+ match output_file with
397+ | `Stdout , false -> Filename. current_dir_name
398+ | `Name x , false -> Filename. dirname x
399+ | `Name x , true when String. ends_with x ~suffix: " /" -> x
400+ | `Stdout , true | `Name _ , true ->
401+ failwith " use [-o dirname/] or remove [--keep-unit-names]"
402+ in
403+ if include_runtime
404+ then
405+ output_gen
406+ ~standalone: false
407+ ~custom_header
408+ ~build_info: (Build_info. create `Runtime )
409+ ~source_map
410+ (`Name (Filename. concat output_dir " runtime.js" ))
411+ (fun ~standalone ~source_map output ->
412+ output_partial_runtime ~standalone ~source_map output
413+ |> sourcemap_of_info ~base: source_map_base);
414+ List. iter units ~f: (fun (cmj : Parse_bytecode.compilation_unit ) ->
415+ output_gen
416+ ~standalone: false
417+ ~custom_header
418+ ~build_info: (Build_info. create `Cmja )
419+ ~source_map
420+ (`Name (Filename. concat output_dir (cmj.name ^ " .js" )))
421+ (fun ~standalone ~source_map output ->
422+ output_partial ~standalone ~source_map cmj output
423+ |> sourcemap_of_info ~base: source_map_base)))
424+ else
412425 output_gen
413426 ~standalone: false
414427 ~custom_header
415428 ~build_info: (Build_info. create `Cmja )
416429 ~source_map
417- (`Name ( Filename. concat output_dir (cmj.name ^ " .js " )) )
430+ (fst output_file )
418431 (fun ~standalone ~source_map output ->
419- output_partial ~standalone ~source_map cmj output
420- |> sourcemap_of_info ~base: source_map_base))
421- ) else (
422- output_gen
423- ~standalone: false
424- ~custom_header
425- ~build_info: (Build_info. create `Cmja )
426- ~source_map
427- (fst output_file)
428- (fun ~standalone ~source_map output ->
429- let source_map_runtime =
430- if not include_runtime
431- then []
432- else [ output_partial_runtime ~standalone ~source_map output ]
433- in
434- let source_map_units =
435- List. map units ~f: (fun cmj ->
436- output_partial cmj ~standalone ~source_map output)
437- in
438- let source_maps = source_map_runtime @ source_map_units in
439- sourcemap_of_infos ~base: source_map_base source_maps)
440- )
441- );
432+ let source_map_runtime =
433+ if not include_runtime
434+ then []
435+ else [ output_partial_runtime ~standalone ~source_map output ]
436+ in
437+ let source_map_units =
438+ List. map units ~f: (fun cmj ->
439+ output_partial cmj ~standalone ~source_map output)
440+ in
441+ let source_maps = source_map_runtime @ source_map_units in
442+ sourcemap_of_infos ~base: source_map_base source_maps)));
442443 Debug. stop_profiling ()
443444
444445let info name =
0 commit comments