# HG changeset patch # User wenzelm # Date 1554389229 -7200 # Node ID a884b2967dd7f53bb55db41b13c63a8c23604591 # Parent 997f256c98e323691a47d8c8251aa5fc0176d43e clarified export_files: Isabelle_System.copy_file_base preserves given directory sub-structure; tuned concrete syntax; diff -r 997f256c98e3 -r a884b2967dd7 src/Pure/Pure.thy --- a/src/Pure/Pure.thy Thu Apr 04 15:26:18 2019 +0200 +++ b/src/Pure/Pure.thy Thu Apr 04 16:47:09 2019 +0200 @@ -130,20 +130,24 @@ val files_in = (Parse.underscore >> K [] || Scan.repeat1 Parse.path_binding) -- - Scan.option (\<^keyword>\in\ |-- Parse.!!! Parse.theory_name); + Scan.option (\<^keyword>\(\ |-- Parse.!!! (\<^keyword>\in\ |-- Parse.theory_name --| \<^keyword>\)\)); val _ = Outer_Syntax.command \<^command_keyword>\export_generated_files\ "export generated files from given theories" (Parse.and_list1 files_in >> (fn args => Toplevel.keep (fn st => - Generated_Files.export_generated_files_cmd (Toplevel.context_of st) args))) + Generated_Files.export_generated_files_cmd (Toplevel.context_of st) args))); + + val base_dir = + Scan.optional (\<^keyword>\(\ |-- + Parse.!!! (\<^keyword>\in\ |-- Parse.position Parse.path --| \<^keyword>\)\)) ("", Position.none); + + val external_files = Scan.repeat1 (Parse.position Parse.path) -- base_dir; val exe = Parse.reserved "exe" >> K true || Parse.reserved "executable" >> K false; - - val executable = - \<^keyword>\(\ |-- Parse.!!! (exe --| \<^keyword>\)\) >> SOME || Scan.succeed NONE; + val executable = \<^keyword>\(\ |-- Parse.!!! (exe --| \<^keyword>\)\) >> SOME || Scan.succeed NONE; val export_files = Scan.repeat1 Parse.path_binding -- executable; @@ -151,8 +155,7 @@ Outer_Syntax.command \<^command_keyword>\compile_generated_files\ "compile generated files and export results" (Parse.and_list files_in -- - Scan.optional (\<^keyword>\external_files\ |-- - Parse.!!! (Scan.repeat1 (Parse.position Parse.path))) [] -- + Scan.optional (\<^keyword>\external_files\ |-- Parse.!!! (Parse.and_list1 external_files)) [] -- Scan.optional (\<^keyword>\export_files\ |-- Parse.!!! (Parse.and_list1 export_files)) [] -- Scan.optional (\<^keyword>\export_prefix\ |-- Parse.path_binding) ("compiled", Position.none) -- (Parse.where_ |-- Parse.!!! Parse.ML_source) diff -r 997f256c98e3 -r a884b2967dd7 src/Pure/Tools/generated_files.ML --- a/src/Pure/Tools/generated_files.ML Thu Apr 04 15:26:18 2019 +0200 +++ b/src/Pure/Tools/generated_files.ML Thu Apr 04 16:47:09 2019 +0200 @@ -34,11 +34,15 @@ val export_generated_files_cmd: Proof.context -> ((string * Position.T) list * (string * Position.T) option) list -> unit val with_compile_dir: (Path.T -> unit) -> unit - val compile_generated_files: Proof.context -> (Path.binding list * theory) list -> - Path.T list -> (Path.binding list * bool option) list -> Path.binding -> Input.source -> unit + val compile_generated_files: Proof.context -> + (Path.binding list * theory) list -> + (Path.T list * Path.T) list -> + (Path.binding list * bool option) list -> + Path.binding -> Input.source -> unit val compile_generated_files_cmd: Proof.context -> ((string * Position.T) list * (string * Position.T) option) list -> - (string * Position.T) list -> ((string * Position.T) list * bool option) list -> + ((string * Position.T) list * (string * Position.T)) list -> + ((string * Position.T) list * bool option) list -> string * Position.T -> Input.source -> unit end; @@ -259,7 +263,9 @@ val files = maps get_files_in args; val _ = List.app (fn (file, pos) => report_file ctxt pos file) files; val _ = List.app (write_file dir o #1) files; - val _ = external |> List.app (fn file => Isabelle_System.copy_file file dir); + val _ = + external |> List.app (fn (files, base_dir) => + files |> List.app (fn file => Isabelle_System.copy_file_base (base_dir, file) dir)); val _ = ML_Context.eval_in (SOME (Config.put compile_dir (Path.implode dir) ctxt)) ML_Compiler.flags (Input.pos_of source) @@ -290,7 +296,12 @@ fun compile_generated_files_cmd ctxt args external export export_prefix source = compile_generated_files ctxt (map (check_files_in ctxt) args) - (map (Resources.check_file ctxt NONE) external) + (external |> map (fn (raw_files, raw_base_dir) => + let + val base_dir = Resources.check_dir ctxt NONE raw_base_dir; + fun check (s, pos) = (Resources.check_file ctxt (SOME base_dir) (s, pos); Path.explode s); + val files = map check raw_files; + in (files, base_dir) end)) ((map o apfst o map) Path.explode_binding export) (Path.explode_binding export_prefix) source;