[settings] filter modules' settings with target attribute like regular settings

This commit is contained in:
Gautier Hattenberger
2016-02-02 18:26:38 +01:00
parent fc8ab48ddc
commit f8145a2ba1
3 changed files with 22 additions and 2 deletions
+1
View File
@@ -92,6 +92,7 @@ name CDATA #REQUIRED
<!ATTLIST settings <!ATTLIST settings
name CDATA #IMPLIED name CDATA #IMPLIED
target CDATA #IMPLIED
> >
<!ATTLIST dl_settings <!ATTLIST dl_settings
+12 -1
View File
@@ -213,7 +213,18 @@ let is_element_unselected = fun ?(verbose=false) target modules name ->
| "module" -> | "module" ->
let unselected = List.for_all (fun m -> m.file <> name) modules in let unselected = List.for_all (fun m -> m.file <> name) modules in
if unselected && verbose then if unselected && verbose then
begin Printf.printf "Info: module '%s' unloaded for target '%s'\n" name target; flush stdout end; begin Printf.printf "Info: module '%s' unloaded for target '%s'\n" name target; flush stdout end
else begin
if verbose then
(* display possible unloading of settings when the module itself is loaded *)
List.iter (fun n ->
let tag = Xml.tag n
and targets = ExtXml.attrib_or_default n "target" "" in
let valid = test_targets target (Str.split (Str.regexp "|") targets) in
if tag = "settings" && not (targets = "") && not valid then
begin Printf.printf "Info: settings of module '%s' unloaded for target '%s'\n" name target; flush stdout end;
) (Xml.children xml)
end;
unselected unselected
| _ -> false | _ -> false
with _ -> false with _ -> false
+9 -1
View File
@@ -317,7 +317,15 @@ let join_xml_files = fun xml_files ->
end end
else false else false
) (Xml.children xml) ) (Xml.children xml)
then List.filter (fun t -> Xml.tag t = "settings") (Xml.children xml) then
List.filter (fun t ->
(* filter xml nodes and keep them if:
* it is a settings node
* the current target is supported in the 'target' attribute
* if no 'target' attribute always keep it
*)
Xml.tag t = "settings" && supports_target target (ExtXml.attrib_or_default t "target" target)
) (Xml.children xml)
else [] else []
end end
else begin else begin