@@ -318,23 +318,31 @@ let run_in_program ?(program = current_program ()) ?(st_setup=fun x -> x) (loc,
318318 str" is unknown; please add a directive like 'From .. Extra Dependency .. as " ++
319319 Names.Id. print id ++ str" '." )) in
320320 try
321- let new_src_ast = List. map (fun fname ->
322- File {
323- fname;
324- fast = P. unit_from_file ~elpi fname;
325- }) s in
321+ let new_src_ast = List. map (fun fname -> P. unit_from_file ~elpi fname) s in
322+ if P. db_exists program then
323+ P. accumulate_to_db program new_src_ast [] ~scope: Coq_elpi_utils. Regular
324+ else
325+ let new_src_ast = List. map2 (fun fname funit ->
326+ File {
327+ fname;
328+ fast = funit;
329+ }) s new_src_ast in
326330 P. accumulate program new_src_ast
327331 with Failure s -> CErrors. user_err Pp. (str s)
328332 let accumulate_extra_deps ~atts :(only ,ph ) ?program ids = skip ~only ~ph (accumulate_extra_deps ?program) ids
329333
330334 let accumulate_files ?(program =current_program() ) s =
331335 let elpi = P. ensure_initialized () in
332336 try
333- let new_src_ast = List. map (fun fname ->
334- File {
335- fname;
336- fast = P. unit_from_file ~elpi fname;
337- }) s in
337+ let new_src_ast = List. map (fun fname -> P. unit_from_file ~elpi fname) s in
338+ if P. db_exists program then
339+ P. accumulate_to_db program new_src_ast [] ~scope: Coq_elpi_utils. Regular
340+ else
341+ let new_src_ast = List. map2 (fun fname funit ->
342+ File {
343+ fname;
344+ fast = funit;
345+ }) s new_src_ast in
338346 P. accumulate program new_src_ast
339347 with Failure s -> CErrors. user_err Pp. (str s)
340348 let accumulate_files ~atts :(only ,ph ) ?program s = skip ~only ~ph (accumulate_files ?program) s
0 commit comments