52 {master: (Path.T * SHA1.digest), (*master dependencies for thy file*) |
52 {master: (Path.T * SHA1.digest), (*master dependencies for thy file*) |
53 imports: (string * Position.T) list}; (*source specification of imports (partially qualified)*) |
53 imports: (string * Position.T) list}; (*source specification of imports (partially qualified)*) |
54 |
54 |
55 fun make_deps master imports : deps = {master = master, imports = imports}; |
55 fun make_deps master imports : deps = {master = master, imports = imports}; |
56 |
56 |
57 fun master_dir (d: deps option) = |
57 fun master_dir_deps (d: deps option) = |
58 the_default Path.current (Option.map (Path.dir o #1 o #master) d); |
58 the_default Path.current (Option.map (Path.dir o #1 o #master) d); |
59 |
59 |
60 local |
60 local |
61 val global_thys = |
61 val global_thys = |
62 Synchronized.var "Thy_Info.thys" |
62 Synchronized.var "Thy_Info.thys" |
285 in |
285 in |
286 |
286 |
287 fun require_thys document symbols last_timing initiators qualifier dir strs tasks = |
287 fun require_thys document symbols last_timing initiators qualifier dir strs tasks = |
288 fold_map (require_thy document symbols last_timing initiators qualifier dir) strs tasks |
288 fold_map (require_thy document symbols last_timing initiators qualifier dir) strs tasks |
289 |>> forall I |
289 |>> forall I |
290 and require_thy document symbols last_timing initiators qualifier dir (str, require_pos) tasks = |
290 and require_thy document symbols last_timing initiators qualifier dir (s, require_pos) tasks = |
291 let |
291 let |
292 val path = Path.expand (Path.explode str); |
292 val {node_name, master_dir, theory_name} = Resources.import_name qualifier dir s; |
293 val {node_name, theory_name} = Resources.import_name qualifier dir path; |
|
294 fun check_entry (Task (node_name', _, _)) = |
293 fun check_entry (Task (node_name', _, _)) = |
295 if op = (apply2 File.platform_path (node_name, node_name')) |
294 if op = (apply2 File.platform_path (node_name, node_name')) |
296 then () |
295 then () |
297 else |
296 else |
298 error ("Incoherent imports for theory " ^ quote theory_name ^ |
297 error ("Incoherent imports for theory " ^ quote theory_name ^ |
303 in |
302 in |
304 (case try (String_Graph.get_node tasks) theory_name of |
303 (case try (String_Graph.get_node tasks) theory_name of |
305 SOME task => (check_entry task; (task_finished task, tasks)) |
304 SOME task => (check_entry task; (task_finished task, tasks)) |
306 | NONE => |
305 | NONE => |
307 let |
306 let |
308 val dir' = Path.append dir (Path.dir path); |
|
309 val _ = member (op =) initiators theory_name andalso error (cycle_msg initiators); |
307 val _ = member (op =) initiators theory_name andalso error (cycle_msg initiators); |
310 |
308 |
311 val (current, deps, theory_pos, imports, keywords) = check_deps dir' theory_name |
309 val (current, deps, theory_pos, imports, keywords) = check_deps master_dir theory_name |
312 handle ERROR msg => |
310 handle ERROR msg => |
313 cat_error msg |
311 cat_error msg |
314 ("The error(s) above occurred for theory " ^ quote theory_name ^ |
312 ("The error(s) above occurred for theory " ^ quote theory_name ^ |
315 Position.here require_pos ^ required_by "\n" initiators); |
313 Position.here require_pos ^ required_by "\n" initiators); |
316 |
314 |
317 val parents = map (Thy_Header.import_name o #1) imports; |
315 val parents = map (Thy_Header.import_name o #1) imports; |
318 val (parents_current, tasks') = |
316 val (parents_current, tasks') = |
319 require_thys document symbols last_timing (theory_name :: initiators) |
317 require_thys document symbols last_timing (theory_name :: initiators) |
320 (Resources.theory_qualifier theory_name) |
318 (Resources.theory_qualifier theory_name) |
321 (Path.append dir (master_dir (Option.map #1 deps))) imports tasks; |
319 (Path.append dir (master_dir_deps (Option.map #1 deps))) imports tasks; |
322 |
320 |
323 val all_current = current andalso parents_current; |
321 val all_current = current andalso parents_current; |
324 val task = |
322 val task = |
325 if all_current then Finished (get_theory theory_name) |
323 if all_current then Finished (get_theory theory_name) |
326 else |
324 else |