diff --git a/Makefile.ac b/Makefile.ac index 0f3132a51e..9e51eabf41 100644 --- a/Makefile.ac +++ b/Makefile.ac @@ -65,7 +65,11 @@ init: demo: $(SUPERVISION) -all_ac_h: $(AIRFRAME_H) $(RADIO_H) $(FLIGHT_PLAN_H) $(FLIGHT_PLAN_XML) $(SETTINGS_H) $(TUNING_H) $(MAKEFILE_AC) $(PERIODIC_H) $(MODULES_H) +all_ac_h: $(AIRFRAME_H) $(SETTINGS_H) $(TUNING_H) $(MAKEFILE_AC) $(PERIODIC_H) $(MODULES_H) + +radio_ac_h : $(RADIO_H) + +flight_plan_ac_h : $(FLIGHT_PLAN_H) $(FLIGHT_PLAN_XML) makefile_ac: $(MAKEFILE_AC) diff --git a/sw/airborne/inter_mcu.h b/sw/airborne/inter_mcu.h index a3a04bddfb..61e83f3de9 100644 --- a/sw/airborne/inter_mcu.h +++ b/sw/airborne/inter_mcu.h @@ -38,7 +38,9 @@ #include #include "std.h" +#if defined RADIO_CONTROL || RADIO_CONTROL_AUTO1 #include "radio.h" +#endif #include "paparazzi.h" #include "airframe.h" #include "radio_control.h" diff --git a/sw/lib/ocaml/env.ml b/sw/lib/ocaml/env.ml index 00d82ef778..11d86aec7d 100644 --- a/sw/lib/ocaml/env.ml +++ b/sw/lib/ocaml/env.ml @@ -54,8 +54,7 @@ let gcs_icons_path = paparazzi_home // "data" // "pictures" // "gcs_icons" let expand_ac_xml = fun ac_conf -> let prefix = fun s -> sprintf "%s/conf/%s" paparazzi_home s in - let parse = fun a -> - let file = prefix (ExtXml.attrib ac_conf a) in + let parse_file = fun a file -> try Xml.parse_file file with @@ -66,10 +65,19 @@ let expand_ac_xml = fun ac_conf -> let s = Xml.error e in prerr_endline (sprintf "Parse error in %s: %s" file s); make_element "cannot_parse" ["file",file;"error", s] [] in - let fp = parse "flight_plan" - and af = parse "airframe" - and rc = parse "radio" - and st = parse "settings" - and tm = parse "telemetry" in - let children = Xml.children ac_conf@[fp; af; rc; st; tm] in + + let parse = fun a -> + let file = prefix (ExtXml.attrib ac_conf a) in + parse_file a file in + + let parse_opt = fun a others -> + try + parse a :: others + with + ExtXml.Error _ -> others in + + let pervasives = [parse "airframe"; parse "settings"; parse "telemetry"] in + let optionals = parse_opt "radio" (parse_opt "flight_plan" pervasives) in + + let children = Xml.children ac_conf@optionals in make_element (Xml.tag ac_conf) (Xml.attribs ac_conf) children diff --git a/sw/tools/gen_aircraft.ml b/sw/tools/gen_aircraft.ml index ae3f030c2b..e270dc236a 100644 --- a/sw/tools/gen_aircraft.ml +++ b/sw/tools/gen_aircraft.ml @@ -3,7 +3,7 @@ * * Call to Makefile.ac with the appropriate attributes from conf.xml * - * Copyright (C) 2003-2008 Pascal Brisset, Antoine Drouin, ENAC + * Copyright (C) 2003-2009 Pascal Brisset, Antoine Drouin, ENAC * * This file is part of paparazzi. * @@ -36,7 +36,8 @@ let mkdir = fun d -> Unix.mkdir d 0o755 let check_unique_id = fun conf -> - let ids = Hashtbl.create 5 in + let ids = Hashtbl.create 5 + and names = Hashtbl.create 5 in List.iter (fun x -> if String.lowercase (Xml.tag x) = "aircraft" then @@ -46,10 +47,17 @@ let check_unique_id = fun conf -> let other_name = Hashtbl.find ids id in failwith (sprintf "Error: A/C Id '%s' duplicated in %s (%s and %s)" id conf_xml name other_name) end; - Hashtbl.add ids id name) + if Hashtbl.mem names name then begin + let other_id = Hashtbl.find names name in + failwith (sprintf "Error: A/C name '%s' duplicated in %s (ids %s and %s)" name conf_xml id other_id) + end; + Hashtbl.add ids id name; + Hashtbl.add names name id) (Xml.children conf) -let _ = + + +let () = if Array.length Sys.argv <> 2 then failwith (sprintf "Usage: %s " Sys.argv.(0)); let aircraft = Sys.argv.(1) in @@ -97,8 +105,8 @@ let _ = Printf.fprintf f "%s\n" md5sum; close_out f; - let make = fun target -> - let c = sprintf "make -f Makefile.ac AIRCRAFT=%s AC_ID=%s AIRFRAME_XML=%s RADIO=%s FLIGHT_PLAN=%s TELEMETRY=%s SETTINGS=\"%s\" MD5SUM=\"%s\" %s" aircraft (value "ac_id") (value "airframe") (value "radio") (value "flight_plan") (value "telemetry") settings md5sum target in + let make = fun target options -> + let c = sprintf "make -f Makefile.ac AIRCRAFT=%s AC_ID=%s AIRFRAME_XML=%s TELEMETRY=%s SETTINGS=\"%s\" MD5SUM=\"%s\" %s %s" aircraft (value "ac_id") (value "airframe") (value "telemetry") settings md5sum options target in prerr_endline c; begin (** Quiet is speficied in the Makefile *) try if Sys.getenv "Q" <> "@" then raise Not_found with @@ -107,5 +115,15 @@ let _ = let returned_code = Sys.command c in if returned_code <> 0 then exit returned_code in - make "makefile_ac"; - make "all_ac_h" + + let make_opt = fun target var attr -> + try + let value = Xml.attrib aircraft_xml attr in + make target (sprintf "%s=%s" var value) + with + Xml.No_attribute _ -> () in + + make "makefile_ac" ""; + make "all_ac_h" ""; + make_opt "radio_ac_h" "RADIO" "radio"; + make_opt "flight_plan_ac_h" "FLIGHT_PLAN" "flight_plan"