Skip to content
Snippets Groups Projects
Commit 57d6ca11 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

Merge branch 'fix/andre/load-module-with-space' into 'master'

[Kernel] fix -load-module/-load-script with filenames containing spaces

Closes #823

See merge request frama-c/frama-c!2570
parents d08807ea 4691c9c7
No related branches found
No related tags found
No related merge requests found
...@@ -102,8 +102,6 @@ ML_LINT_KO+=src/kernel_services/parsetree/cabshelper.mli ...@@ -102,8 +102,6 @@ ML_LINT_KO+=src/kernel_services/parsetree/cabshelper.mli
ML_LINT_KO+=src/kernel_services/parsetree/logic_ptree.mli ML_LINT_KO+=src/kernel_services/parsetree/logic_ptree.mli
ML_LINT_KO+=src/kernel_services/plugin_entry_points/db.ml ML_LINT_KO+=src/kernel_services/plugin_entry_points/db.ml
ML_LINT_KO+=src/kernel_services/plugin_entry_points/db.mli ML_LINT_KO+=src/kernel_services/plugin_entry_points/db.mli
ML_LINT_KO+=src/kernel_services/plugin_entry_points/dynamic.ml
ML_LINT_KO+=src/kernel_services/plugin_entry_points/dynamic.mli
ML_LINT_KO+=src/kernel_services/plugin_entry_points/emitter.ml ML_LINT_KO+=src/kernel_services/plugin_entry_points/emitter.ml
ML_LINT_KO+=src/kernel_services/plugin_entry_points/emitter.mli ML_LINT_KO+=src/kernel_services/plugin_entry_points/emitter.mli
ML_LINT_KO+=src/kernel_services/plugin_entry_points/journal.ml ML_LINT_KO+=src/kernel_services/plugin_entry_points/journal.ml
......
...@@ -47,8 +47,9 @@ MINOR_VERSION=$(shell $(SED) -E 's/^[0-9]+\.([0-9]+).*/\1/' VERSION) ...@@ -47,8 +47,9 @@ MINOR_VERSION=$(shell $(SED) -E 's/^[0-9]+\.([0-9]+).*/\1/' VERSION)
$(CONFIG_FILE): $(CONFIG_FILE).in VERSION VERSION_CODENAME share/Makefile.config Makefile.generating configure.in $(CONFIG_FILE): $(CONFIG_FILE).in VERSION VERSION_CODENAME share/Makefile.config Makefile.generating configure.in
$(SED) \ $(SED) \
-e "s|@VERSION@|$(VERSION)|" \ -e "s|@VERSION@|$(VERSION)|" \
-e "s|@VERSION_CODENAME@|$(VERSION_CODENAME)|" \ -e "s|@VERSION_CODENAME@|$(VERSION_CODENAME)|" \
-e "s|@CURR_DATE@|$$(LC_ALL=C date)|" \ -e "s|@CURR_DATE@|$$(LC_ALL=C date)|" \
-e "s|@LABLGTK@|$(LABLGTK)|" \
-e "s|@OCAMLC@|$(OCAMLC)|" \ -e "s|@OCAMLC@|$(OCAMLC)|" \
-e "s|@OCAMLOPT@|$(OCAMLOPT)|" \ -e "s|@OCAMLOPT@|$(OCAMLOPT)|" \
-e "s|@WARNINGS@|$(WARNINGS)|" \ -e "s|@WARNINGS@|$(WARNINGS)|" \
......
...@@ -32,6 +32,8 @@ let minor_version = @MINOR_VERSION@ ...@@ -32,6 +32,8 @@ let minor_version = @MINOR_VERSION@
let is_gui = ref false let is_gui = ref false
let lablgtk = "@LABLGTK@"
let ocamlc = "@OCAMLC@" let ocamlc = "@OCAMLC@"
let ocamlopt = "@OCAMLOPT@" let ocamlopt = "@OCAMLOPT@"
let ocaml_wflags = "@WARNINGS@" let ocaml_wflags = "@WARNINGS@"
......
...@@ -46,6 +46,10 @@ val is_gui: bool ref ...@@ -46,6 +46,10 @@ val is_gui: bool ref
(** Is the Frama-C GUI running? (** Is the Frama-C GUI running?
@since Beryllium-20090601-beta1 *) @since Beryllium-20090601-beta1 *)
val lablgtk: string
(** Name of the lablgtk version against which Frama-C has been compiled.
blank if only command-line mode is available. *)
val ocamlc: string val ocamlc: string
(** Name of the bytecode compiler. (** Name of the bytecode compiler.
@since Boron-20100401 *) @since Boron-20100401 *)
......
...@@ -55,24 +55,24 @@ exception Unbound_value = Tbl.Unbound_value ...@@ -55,24 +55,24 @@ exception Unbound_value = Tbl.Unbound_value
let dynlib_error name = function let dynlib_error name = function
| Dynlink.Error e -> | Dynlink.Error e ->
error ~name ~message:"cannot load module" ~details:(Dynlink.error_message e) ; error ~name ~message:"cannot load module" ~details:(Dynlink.error_message e) ;
| Sys_error _ as e -> | Sys_error _ as e ->
error ~name ~message:"system error" ~details:(Printexc.to_string e) error ~name ~message:"system error" ~details:(Printexc.to_string e)
| Unloadable details -> | Unloadable details ->
error ~name ~message:"incompatible with current set-up" ~details error ~name ~message:"incompatible with current set-up" ~details
(* the three next errors may be raised in case of incompatibilities with (* the three next errors may be raised in case of incompatibilities with
another plug-in *) another plug-in *)
| Incompatible_type s -> | Incompatible_type s ->
error ~name ~message:"code incompatibility" ~details:s error ~name ~message:"code incompatibility" ~details:s
| Unbound_value s -> | Unbound_value s ->
error ~name ~message:"code incompatibility" ~details:("unbound value " ^ s) error ~name ~message:"code incompatibility" ~details:("unbound value " ^ s)
| Type.No_abstract_type s -> | Type.No_abstract_type s ->
error ~name ~message:"code incompatibility" ~details:("unbound abstract type " ^ s) error ~name ~message:"code incompatibility" ~details:("unbound abstract type " ^ s)
| Log.AbortError _ | Log.AbortFatal _ | Log.FeatureRequest _ as e -> | Log.AbortError _ | Log.AbortFatal _ | Log.FeatureRequest _ as e ->
raise e raise e
| e -> | e ->
error ~name ~message:("unexpected exception: " ^ Printexc.to_string e) error ~name ~message:("unexpected exception: " ^ Printexc.to_string e)
~details:(Printexc.get_backtrace ()) ~details:(Printexc.get_backtrace ())
let dynlib_module name file = let dynlib_module name file =
Klog.feedback ~dkey "Loading module '%s' from '%s'." name file ; Klog.feedback ~dkey "Loading module '%s' from '%s'." name file ;
...@@ -241,13 +241,15 @@ let load_script base = ...@@ -241,13 +241,15 @@ let load_script base =
let fmt = Format.formatter_of_buffer cmd in let fmt = Format.formatter_of_buffer cmd in
begin begin
if Dynlink.is_native then if Dynlink.is_native then
Format.fprintf fmt "%s -shared -o %s.cmxs" Fc_config.ocamlopt base Format.fprintf fmt "%s -shared -o %S.cmxs" Fc_config.ocamlopt base
else else
Format.fprintf fmt "%s -c" Fc_config.ocamlc ; Format.fprintf fmt "%s -c" Fc_config.ocamlc ;
Format.fprintf fmt " -g %s -warn-error a -I %s" Fc_config.ocaml_wflags Fc_config.libdir ; Format.fprintf fmt
if !Fc_config.is_gui then Format.pp_print_string fmt " -package lablgtk2" ; " -g %s -warn-error a -I %s" Fc_config.ocaml_wflags Fc_config.libdir ;
if !Fc_config.is_gui && Fc_config.lablgtk <> "" then
Format.fprintf fmt " -package %s" Fc_config.lablgtk;
List.iter (fun p -> Format.fprintf fmt " -I %s" p) !load_path ; List.iter (fun p -> Format.fprintf fmt " -I %s" p) !load_path ;
Format.fprintf fmt " %s.ml" base ; Format.fprintf fmt " %S.ml" base ;
Format.pp_print_flush fmt () ; Format.pp_print_flush fmt () ;
let cmd = Buffer.contents cmd in let cmd = Buffer.contents cmd in
Klog.feedback ~dkey "running '%s'" cmd ; Klog.feedback ~dkey "running '%s'" cmd ;
...@@ -321,31 +323,31 @@ let load_module m = ...@@ -321,31 +323,31 @@ let load_module m =
let base,ext = split_ext m in let base,ext = split_ext m in
match ext with match ext with
| ".ml" -> | ".ml" ->
begin begin
(* force script compilation *) (* force script compilation *)
match is_file base ".ml" with
| Some _ -> load_script base
| None -> Klog.error "Missing source file '%s'" m
end
| "" | "." | ".cmo" | ".cma" | ".cmxs" ->
begin
(* load object or compile script or find package *)
match is_object base with
| Some file -> dynlib_module (Filename.basename base) file
| None ->
match is_file base ".ml" with match is_file base ".ml" with
| Some _ -> load_script base | Some _ -> load_script base
| None -> Klog.error "Missing source file '%s'" m
end
| "" | "." | ".cmo" | ".cma" | ".cmxs" ->
begin
(* load object or compile script or find package *)
match is_object base with
| Some file -> dynlib_module (Filename.basename base) file
| None -> | None ->
match is_file base ".ml" with if is_package m && mem_package m then load_packages [m]
| Some _ -> load_script base else
| None -> let fc =
if is_package m && mem_package m then load_packages [m] "frama-c-" ^ String.lowercase_ascii m
else in
let fc = if mem_package fc then load_packages [fc]
"frama-c-" ^ String.lowercase_ascii m else Klog.error "package or module '%s' not found" m
in end
if mem_package fc then load_packages [fc]
else Klog.error "package or module '%s' not found" m
end
| _ -> | _ ->
Klog.error "don't know what to do with '%s' (unexpected %s)" m ext Klog.error "don't know what to do with '%s' (unexpected %s)" m ext
(* ************************************************************************* *) (* ************************************************************************* *)
(** {2 Registering and accessing dynamic values} *) (** {2 Registering and accessing dynamic values} *)
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
(* ************************************************************************* *) (* ************************************************************************* *)
val register: val register:
?comment:string -> ?comment:string ->
plugin:string -> plugin:string ->
string -> 'a Type.t -> journalize:bool -> 'a -> 'a string -> 'a Type.t -> journalize:bool -> 'a -> 'a
(** [register ~plugin name ty v] registers [v] with the name (** [register ~plugin name ty v] registers [v] with the name
[name], the type [ty] and the plug-in [plugin]. [name], the type [ty] and the plug-in [plugin].
...@@ -71,7 +71,7 @@ val iter_comment : (string -> string -> unit) -> unit ...@@ -71,7 +71,7 @@ val iter_comment : (string -> string -> unit) -> unit
(* ************************************************************************* *) (* ************************************************************************* *)
(** Module to use for accessing parameters of plug-ins. (** Module to use for accessing parameters of plug-ins.
Assume that the plug-in is already loaded. Assume that the plug-in is already loaded.
@plugin development guide *) @plugin development guide *)
module Parameter : sig module Parameter : sig
...@@ -99,7 +99,7 @@ module Parameter : sig ...@@ -99,7 +99,7 @@ module Parameter : sig
(** Not for casual users *) (** Not for casual users *)
(**/**) (**/**)
(** Boolean parameters. (** Boolean parameters.
@plugin development guide *) @plugin development guide *)
module Bool: sig module Bool: sig
include Common with type t = bool include Common with type t = bool
......
[kernel] Parsing tests/misc/with-space.i (no preprocessing)
[kernel] module successfully loaded
let () = Db.Main.extend (fun () ->
Kernel.feedback "module successfully loaded"
)
/* run.config
OPT: -load-module @PTEST_DIR@/with\ space/module.ml
*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment