mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 05:42:49 +08:00
[modules] display warnings when module or its options are loaded twice
This commit is contained in:
@@ -18,7 +18,9 @@
|
|||||||
<!ELEMENT variable EMPTY>
|
<!ELEMENT variable EMPTY>
|
||||||
|
|
||||||
<!ELEMENT modules (module*)>
|
<!ELEMENT modules (module*)>
|
||||||
<!ELEMENT module EMPTY>
|
<!ELEMENT module (configure|define)*>
|
||||||
|
<!ELEMENT configure EMPTY>
|
||||||
|
<!ELEMENT define EMPTY>
|
||||||
|
|
||||||
<!ELEMENT includes (include*)>
|
<!ELEMENT includes (include*)>
|
||||||
|
|
||||||
@@ -113,6 +115,14 @@ values CDATA #IMPLIED>
|
|||||||
name CDATA #REQUIRED
|
name CDATA #REQUIRED
|
||||||
type CDATA #IMPLIED>
|
type CDATA #IMPLIED>
|
||||||
|
|
||||||
|
<!ATTLIST define
|
||||||
|
name CDATA #REQUIRED
|
||||||
|
value CDATA #IMPLIED>
|
||||||
|
|
||||||
|
<!ATTLIST configure
|
||||||
|
name CDATA #REQUIRED
|
||||||
|
value CDATA #REQUIRED>
|
||||||
|
|
||||||
<!ATTLIST blocks>
|
<!ATTLIST blocks>
|
||||||
|
|
||||||
<!ATTLIST block
|
<!ATTLIST block
|
||||||
|
|||||||
@@ -201,12 +201,26 @@ let get_modules_of_flight_plan = fun xml ->
|
|||||||
(** [singletonize_modules xml]
|
(** [singletonize_modules xml]
|
||||||
* Returns a list of singletonized modules were options are merged
|
* 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 ->
|
let rec loop = fun l ->
|
||||||
match l with
|
match l with
|
||||||
| [] | [_] -> l
|
| [] | [_] -> l
|
||||||
| x::xs ->
|
| x::xs ->
|
||||||
let (duplicates, rest) = List.partition (fun m -> m.file = x.file) xs in
|
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;
|
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));
|
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
|
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]
|
(** [get_modules_of_config ?target flight_plan airframe]
|
||||||
* Returns a list of pair (modules ("load" node), targets) from airframe file and flight plan.
|
* Returns a list of pair (modules ("load" node), targets) from airframe file and flight plan.
|
||||||
* The modules are singletonized and options are merged *)
|
* 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
|
let af_modules = get_modules_of_airframe ?target af_xml
|
||||||
and fp_modules = get_modules_of_flight_plan fp_xml in
|
and fp_modules = get_modules_of_flight_plan fp_xml in
|
||||||
(* singletonize modules list *)
|
(* singletonize modules list *)
|
||||||
singletonize_modules (af_modules @ fp_modules)
|
singletonize_modules ?verbose ?target (af_modules @ fp_modules)
|
||||||
|
|
||||||
(** [get_modules_name xml]
|
(** [get_modules_name xml]
|
||||||
* Returns a list of loaded modules' name *)
|
* Returns a list of loaded modules' name *)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ val get_modules_of_flight_plan : Xml.xml -> module_conf list
|
|||||||
(** [get_modules_of_config ?target flight_plan airframe]
|
(** [get_modules_of_config ?target flight_plan airframe]
|
||||||
* Returns a list of pair (modules ("load" node), targets) from airframe file and flight plan.
|
* Returns a list of pair (modules ("load" node), targets) from airframe file and flight plan.
|
||||||
* The modules are singletonized and options are merged *)
|
* 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_targets target targets]
|
||||||
* Test if [target] is allowed [targets]
|
* Test if [target] is allowed [targets]
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ let module_xml2mk = fun f target firmware m ->
|
|||||||
) m.xml
|
) m.xml
|
||||||
|
|
||||||
let modules_xml2mk = fun f target xml fp ->
|
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 *)
|
(* print modules directories and includes for all targets *)
|
||||||
fprintf f "\n# include modules directory for all targets\n";
|
fprintf f "\n# include modules directory for all targets\n";
|
||||||
(* get dir list *)
|
(* get dir list *)
|
||||||
|
|||||||
Reference in New Issue
Block a user