[build] fix module parsing

some extra modules where included when several firmware of the same
times are defined in an airframe
test is now done on the complete xml, instead of only the name
This commit is contained in:
Gautier Hattenberger
2016-10-12 00:17:48 +02:00
parent 4acd680ccf
commit 76163865c7
+5 -7
View File
@@ -198,7 +198,7 @@ let expand_includes = fun ac_id xml ->
else x @ [c] else x @ [c]
) [] children) ) [] children)
exception Firmware_Found of string exception Firmware_Found of Xml.xml
(** [get_modules_of_airframe xml] (** [get_modules_of_airframe xml]
* Returns a list of module configuration from airframe file *) * Returns a list of module configuration from airframe file *)
let rec get_modules_of_airframe = fun ?target xml -> let rec get_modules_of_airframe = fun ?target xml ->
@@ -210,10 +210,9 @@ let rec get_modules_of_airframe = fun ?target xml ->
| Some t -> begin try | Some t -> begin try
Xml.iter (fun x -> Xml.iter (fun x ->
if Xml.tag x = "firmware" then begin if Xml.tag x = "firmware" then begin
let name = ExtXml.attrib x "name" in Xml.iter (fun xt ->
Xml.iter (fun x -> if Xml.tag xt = "target" then begin
if Xml.tag x = "target" then begin if Xml.attrib xt "name" = t then raise (Firmware_Found x)
if Xml.attrib x "name" = t then raise (Firmware_Found name)
end) x end) x
end) xml; end) xml;
None None
@@ -236,9 +235,8 @@ let rec get_modules_of_airframe = fun ?target xml ->
else failwith ("Unkown module " ^ file) else failwith ("Unkown module " ^ file)
end end
| Xml.Element (tag, _attrs, children) when tag = "firmware" -> | Xml.Element (tag, _attrs, children) when tag = "firmware" ->
let name = Xml.attrib xml "name" in
begin match firmware with begin match firmware with
| Some f when f = name -> | Some f when String.compare (Xml.to_string f) (Xml.to_string xml) = 0 ->
List.fold_left (fun acc xml -> List.fold_left (fun acc xml ->
iter_modules targets acc xml) modules children iter_modules targets acc xml) modules children
| None -> | None ->