mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-30 19:47:50 +08:00
[build] fix target filtering
This commit is contained in:
@@ -126,6 +126,9 @@ let get_module = fun m global_targets ->
|
|||||||
param = Xml.children m; targets = targets }
|
param = Xml.children m; targets = targets }
|
||||||
| _ -> Xml2h.xml_error "module or load"
|
| _ -> Xml2h.xml_error "module or load"
|
||||||
|
|
||||||
|
(** [test_targets target targets]
|
||||||
|
* Test if [target] is allowed [targets]
|
||||||
|
* Return true if target is allowed, false if target is not in list or rejected (prefixed by !) *)
|
||||||
let test_targets = fun target targets ->
|
let test_targets = fun target targets ->
|
||||||
List.exists (fun t ->
|
List.exists (fun t ->
|
||||||
let l = String.length t in
|
let l = String.length t in
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ val get_module : Xml.xml -> string list -> module_conf
|
|||||||
* Returns a list of pair (modules ("load" node), targets) from airframe file *)
|
* Returns a list of pair (modules ("load" node), targets) from airframe file *)
|
||||||
val get_modules_of_airframe : ?target: string -> Xml.xml -> module_conf list
|
val get_modules_of_airframe : ?target: string -> Xml.xml -> module_conf list
|
||||||
|
|
||||||
|
(** [test_targets target targets]
|
||||||
|
* Test if [target] is allowed [targets]
|
||||||
|
* Return true if target is allowed, false if target is not in list or rejected (prefixed by !) *)
|
||||||
|
val test_targets : string -> string list -> bool
|
||||||
|
|
||||||
(** [get_targets_of_module xml] Returns the list of targets of a module *)
|
(** [get_targets_of_module xml] Returns the list of targets of a module *)
|
||||||
val get_targets_of_module : Xml.xml -> string list
|
val get_targets_of_module : Xml.xml -> string list
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ let file_xml2mk = fun f ?(arch = false) dir_name target xml ->
|
|||||||
else format_of_string "%s.srcs += %s/%s\n" in
|
else format_of_string "%s.srcs += %s/%s\n" in
|
||||||
fprintf f fmt target dir_name name
|
fprintf f fmt target dir_name name
|
||||||
|
|
||||||
let module_xml2mk = fun f (*modules*) target m ->
|
let module_xml2mk = fun f target m ->
|
||||||
if not (List.mem target m.targets) then () else
|
if not (List.mem target m.targets) then () else
|
||||||
let name = ExtXml.attrib m.xml "name" in
|
let name = ExtXml.attrib m.xml "name" in
|
||||||
let dir = try Xml.attrib m.xml "dir" with Xml.No_attribute _ -> name in
|
let dir = try Xml.attrib m.xml "dir" with Xml.No_attribute _ -> name in
|
||||||
@@ -103,7 +103,11 @@ let module_xml2mk = fun f (*modules*) target m ->
|
|||||||
(* Look for makefile section *)
|
(* Look for makefile section *)
|
||||||
ExtXml.iter_tag "makefile"
|
ExtXml.iter_tag "makefile"
|
||||||
(fun section ->
|
(fun section ->
|
||||||
(* Look for defines, flags, files, ... *)
|
(* Look for defines, flags, files, ... if target is matching *)
|
||||||
|
let section =
|
||||||
|
let targets = Gen_common.targets_of_field section Env.default_module_targets in
|
||||||
|
if Gen_common.test_targets target targets then section else Xml.Element ("makefile", [], [])
|
||||||
|
in
|
||||||
Xml.iter
|
Xml.iter
|
||||||
(fun field ->
|
(fun field ->
|
||||||
match String.lowercase (Xml.tag field) with
|
match String.lowercase (Xml.tag field) with
|
||||||
@@ -170,7 +174,7 @@ let subsystem_xml2mk = fun f firmware s ->
|
|||||||
fprintf f "\tinclude $(CFG_SHARED)/%s\n" s_name;
|
fprintf f "\tinclude $(CFG_SHARED)/%s\n" s_name;
|
||||||
fprintf f "endif\n"
|
fprintf f "endif\n"
|
||||||
|
|
||||||
let mod_or_subsys_xml2mk = fun f (*modules*) global_targets firmware target xml ->
|
let mod_or_subsys_xml2mk = fun f global_targets firmware target xml ->
|
||||||
try
|
try
|
||||||
let m = Gen_common.get_module xml global_targets in
|
let m = Gen_common.get_module xml global_targets in
|
||||||
module_xml2mk f target m;
|
module_xml2mk f target m;
|
||||||
|
|||||||
Reference in New Issue
Block a user