[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [5806] unload modules if the target is not supported
From: |
Gautier Hattenberger |
Subject: |
[paparazzi-commits] [5806] unload modules if the target is not supported ( this may require a clean_ac) |
Date: |
Mon, 06 Sep 2010 13:01:07 +0000 |
Revision: 5806
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5806
Author: gautier
Date: 2010-09-06 13:01:02 +0000 (Mon, 06 Sep 2010)
Log Message:
-----------
unload modules if the target is not supported (this may require a clean_ac)
Modified Paths:
--------------
paparazzi3/trunk/Makefile.ac
paparazzi3/trunk/sw/tools/gen_aircraft.ml
paparazzi3/trunk/sw/tools/gen_modules.ml
Modified: paparazzi3/trunk/Makefile.ac
===================================================================
--- paparazzi3/trunk/Makefile.ac 2010-09-06 10:32:53 UTC (rev 5805)
+++ paparazzi3/trunk/Makefile.ac 2010-09-06 13:01:02 UTC (rev 5806)
@@ -56,7 +56,6 @@
MODULES_DIR=$(PAPARAZZI_HOME)/conf/modules/
AIRCRAFT_MD5=$(AIRCRAFT_CONF_DIR)/aircraft.md5
-
# "make Q=''" to get full echo
Q=@
@@ -130,13 +129,12 @@
$(Q)$(TOOLS)/gen_modules.out $(MODULES_DIR) $(SETTINGS_MODULES) $< > $@
$(Q)chmod a+r $@
-
-ac_h :
+%.ac_h :
$(Q)if (expr "$(AIRCRAFT)"); then : ; else echo "AIRCRAFT undefined:
type 'make AIRCRAFT=AircraftName ...'"; exit 1; fi
- @echo BUILD $(AIRCRAFT)
- $(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME)
Q=$(Q) $(TOOLS)/gen_aircraft.out $(AIRCRAFT)
+ @echo BUILD $(AIRCRAFT), TARGET $*
+ $(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME)
TARGET=$* Q=$(Q) $(TOOLS)/gen_aircraft.out $(AIRCRAFT)
-%.compile: ac_h
+%.compile: %.ac_h
cd $(AIRBORNE); $(MAKE) TARGET=$* all
%.wr_fuses: %.compile
Modified: paparazzi3/trunk/sw/tools/gen_aircraft.ml
===================================================================
--- paparazzi3/trunk/sw/tools/gen_aircraft.ml 2010-09-06 10:32:53 UTC (rev
5805)
+++ paparazzi3/trunk/sw/tools/gen_aircraft.ml 2010-09-06 13:01:02 UTC (rev
5806)
@@ -446,7 +446,9 @@
assert(Sys.command (sprintf "mv %s %s" temp_makefile_ac makefile_ac) = 0)
end;
- make "all_ac_h" "";
+ (* Get TARGET env, needed to build modules.h according to the target *)
+ let t = Printf.sprintf "TARGET=%s" (try Sys.getenv "TARGET" with _ -> "")
in
+ make "all_ac_h" t;
make_opt "radio_ac_h" "RADIO" "radio";
make_opt "flight_plan_ac_h" "FLIGHT_PLAN" "flight_plan"
with
Modified: paparazzi3/trunk/sw/tools/gen_modules.ml
===================================================================
--- paparazzi3/trunk/sw/tools/gen_modules.ml 2010-09-06 10:32:53 UTC (rev
5805)
+++ paparazzi3/trunk/sw/tools/gen_modules.ml 2010-09-06 13:01:02 UTC (rev
5806)
@@ -324,6 +324,36 @@
fprintf out_set " </dl_settings>\n";
fprintf out_set "</settings>\n"
+let get_targets_of_module = fun m ->
+ let pipe_regexp = Str.regexp "|" in
+ let targets_of_field = fun field -> try
+ Str.split pipe_regexp (ExtXml.attrib_or_default field "target" "ap|sim")
with _ -> [] in
+ let rec singletonize = fun l ->
+ match l with
+ [] | [_] -> l
+ | x :: ((y :: t) as yt) -> if x = y then singletonize yt else x ::
singletonize yt
+ in
+ let targets = List.map (fun x ->
+ match String.lowercase (Xml.tag x) with
+ "makefile" -> targets_of_field x
+ | _ -> []
+ ) (Xml.children m) in
+ (* return a singletonized list *)
+ singletonize (List.sort compare (List.flatten targets))
+
+let unload_unused_modules = fun modules ->
+ let target = try Sys.getenv "TARGET" with _ -> "" in
+ let is_target_in_module = fun m ->
+ let target_is_in_module = List.exists (fun x -> String.compare target x =
0) (get_targets_of_module m) in
+ if not target_is_in_module then
+ Printf.fprintf stderr "Module %s unloaded, target %s not supported\n"
(Xml.attrib m "name") target;
+ target_is_in_module
+ in
+ if String.length target = 0 then
+ modules
+ else
+ List.find_all is_target_in_module modules
+
let h_name = "MODULES_H"
let () =
@@ -349,6 +379,7 @@
let main_freq = try (int_of_string (Xml.attrib modules "main_freq")) with
_ -> !freq in
freq := main_freq;
let modules_list = List.map (get_modules modules_dir) (Xml.children
modules) in
+ let modules_list = unload_unused_modules modules_list in
let modules_name =
(List.map (fun l -> try Xml.attrib l "name" with _ -> "") (Xml.children
modules)) @
(List.map (fun m -> try Xml.attrib m "name" with _ -> "") modules_list)
in
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [5806] unload modules if the target is not supported ( this may require a clean_ac),
Gautier Hattenberger <=