diff --git a/conf/flight_plans/flight_plan.dtd b/conf/flight_plans/flight_plan.dtd index 3afaee44a7..61a9ab4d35 100644 --- a/conf/flight_plans/flight_plan.dtd +++ b/conf/flight_plans/flight_plan.dtd @@ -18,7 +18,9 @@ - + + + @@ -113,6 +115,14 @@ values CDATA #IMPLIED> name CDATA #REQUIRED type CDATA #IMPLIED> + + + + (** [singletonize_modules xml] * Returns a list of singletonized modules were options are merged *) -let singletonize_modules = fun xml -> +let singletonize_modules = fun ?(verbose=false) ?target xml -> let rec loop = fun l -> match l with | [] | [_] -> l | x::xs -> let (duplicates, rest) = List.partition (fun m -> m.file = x.file) xs in + if List.length duplicates > 0 && verbose then begin + (* print info message on stderr *) + let t = match target with None -> "" | Some t -> Printf.sprintf " for target %s" t in + Printf.eprintf "Info: module '%s' has been loaded several times%s, merging options\n" x.filename t; + List.iter (fun opt -> + let name = Xml.attrib opt "name" in + List.iter (fun d -> + List.iter (fun d_opt -> + if Xml.attrib d_opt "name" = name then + Printf.eprintf "Warning: - option '%s' is defined multiple times, this may cause compilation errors\n" name + ) d.param; + ) duplicates; + ) x.param; + end; let m = { name = x.name; xml = x.xml; file = x.file; filename = x.filename; vpath = x.vpath; param = List.flatten (List.map (fun m -> m.param) ([x] @ duplicates)); targets = singletonize (List.flatten (List.map (fun m -> m.targets) ([x] @ duplicates))) } in @@ -217,11 +231,11 @@ let singletonize_modules = fun xml -> (** [get_modules_of_config ?target flight_plan airframe] * Returns a list of pair (modules ("load" node), targets) from airframe file and flight plan. * The modules are singletonized and options are merged *) -let get_modules_of_config = fun ?target af_xml fp_xml -> +let get_modules_of_config = fun ?target ?verbose af_xml fp_xml -> let af_modules = get_modules_of_airframe ?target af_xml and fp_modules = get_modules_of_flight_plan fp_xml in (* singletonize modules list *) - singletonize_modules (af_modules @ fp_modules) + singletonize_modules ?verbose ?target (af_modules @ fp_modules) (** [get_modules_name xml] * Returns a list of loaded modules' name *) diff --git a/sw/lib/ocaml/gen_common.mli b/sw/lib/ocaml/gen_common.mli index c8fa98b5ef..3c278de910 100644 --- a/sw/lib/ocaml/gen_common.mli +++ b/sw/lib/ocaml/gen_common.mli @@ -58,7 +58,7 @@ val get_modules_of_flight_plan : Xml.xml -> module_conf list (** [get_modules_of_config ?target flight_plan airframe] * Returns a list of pair (modules ("load" node), targets) from airframe file and flight plan. * The modules are singletonized and options are merged *) -val get_modules_of_config : ?target: string -> Xml.xml -> Xml.xml -> module_conf list +val get_modules_of_config : ?target:string -> ?verbose:bool -> Xml.xml -> Xml.xml -> module_conf list (** [test_targets target targets] * Test if [target] is allowed [targets] diff --git a/sw/tools/generators/gen_aircraft.ml b/sw/tools/generators/gen_aircraft.ml index 0c66b74a58..15b2d4b0df 100644 --- a/sw/tools/generators/gen_aircraft.ml +++ b/sw/tools/generators/gen_aircraft.ml @@ -146,7 +146,7 @@ let module_xml2mk = fun f target firmware m -> ) m.xml let modules_xml2mk = fun f target xml fp -> - let modules = Gen_common.get_modules_of_config ~target xml fp in + let modules = Gen_common.get_modules_of_config ~target ~verbose:true xml fp in (* print modules directories and includes for all targets *) fprintf f "\n# include modules directory for all targets\n"; (* get dir list *)