diff --git a/conf/airframes/airframe.dtd b/conf/airframes/airframe.dtd index e81427915e..62f4c5feeb 100644 --- a/conf/airframes/airframe.dtd +++ b/conf/airframes/airframe.dtd @@ -21,7 +21,7 @@ - + diff --git a/sw/tools/gen_aircraft.ml b/sw/tools/gen_aircraft.ml index bd1073a6d4..21f35ec38c 100644 --- a/sw/tools/gen_aircraft.ml +++ b/sw/tools/gen_aircraft.ml @@ -69,7 +69,7 @@ let targets_of_field = fun field -> let get_modules = fun dir m -> match String.lowercase (Xml.tag m) with - "load" -> dir // ExtXml.attrib m "name" + "load" -> (dir // ExtXml.attrib m "name", Xml.children m) | tag -> failwith (sprintf "Warning: tag load is undefined; found '%s'" tag) @@ -83,14 +83,14 @@ let dump_module_section = fun xml f -> let files = ref [] in List.iter (fun x -> if ExtXml.tag_is x "modules" then - let modules_names =List.map (get_modules modules_dir) (Xml.children x) in - List.iter (fun name -> files := name :: !files) modules_names; - let modules_list = List.map Xml.parse_file modules_names in + let modules_names = List.map (get_modules modules_dir) (Xml.children x) in + List.iter (fun (name,_) -> files := name :: !files) modules_names; + let modules_list = List.map (fun (m,p) -> (Xml.parse_file m, p)) modules_names in (* Print modules directories and includes for all targets *) fprintf f "\n# include modules directory for all targets\n"; let target_list = ref [] in let dir_list = ref [] in - List.iter (fun m -> + List.iter (fun (m,_) -> let dir = try Xml.attrib m "dir" with _ -> ExtXml.attrib m "name" in dir_list := List.merge String.compare !dir_list [dir]; List.iter (fun l -> @@ -98,20 +98,33 @@ let dump_module_section = fun xml f -> target_list := List.merge String.compare !target_list (targets_of_field l); ) (Xml.children m) ) modules_list; - List.iter (fun target -> fprintf f "%s.CFLAGS += -I modules\n" target) !target_list; + List.iter (fun target -> fprintf f "%s.CFLAGS += -I modules -I arch/$(ARCH)/modules\n" target) !target_list; List.iter (fun dir -> let dir_name = (String.uppercase dir)^"_DIR" in fprintf f "%s = modules/%s\n" dir_name dir) !dir_list; (* Parse each makefile *) - List.iter (fun modul -> + List.iter (fun (modul,params) -> let name = ExtXml.attrib modul "name" in let dir = try Xml.attrib modul "dir" with _ -> name in let dir_name = (String.uppercase dir)^"_DIR" in + (* Extract the list of all the targes for this module *) + let module_target_list = ref [] in + List.iter (fun l -> + if ExtXml.tag_is l "makefile" then module_target_list := List.merge String.compare !module_target_list (targets_of_field l) + ) (Xml.children modul); fprintf f "\n# makefile for module %s\n" name; - (*fprintf f "%s = modules/%s\n" dir_name name;*) + (* Print parameters as global copilation defines *) + List.iter (fun target -> + List.iter (fun param -> try + let name = Xml.attrib param "name" + and value = Xml.attrib param "value" in + fprintf f "%s.CFLAGS += -D%s=%s\n" target name value + with _ -> () + ) params + ) !module_target_list; + (* Look for makefile section *) List.iter (fun l -> if ExtXml.tag_is l "makefile" then begin let targets = targets_of_field l in - (* build the list of all the targets *) - (*List.iter (fun t -> fprintf f "%s.CFLAGS += -I $(%s)\n" t dir_name ) targets;*) + (* Look for defines, flags, files, ... *) List.iter (fun field -> match String.lowercase (Xml.tag field) with "flag" ->