mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-29 02:38:07 +08:00
cleanup trailing whitespaces in gen_* files
This commit is contained in:
+186
-186
@@ -41,35 +41,35 @@ let check_unique_id_and_name = fun conf ->
|
|||||||
let ids = Hashtbl.create 5
|
let ids = Hashtbl.create 5
|
||||||
and names = Hashtbl.create 5 in
|
and names = Hashtbl.create 5 in
|
||||||
List.iter
|
List.iter
|
||||||
(fun x ->
|
(fun x ->
|
||||||
if String.lowercase (Xml.tag x) = "aircraft" then
|
if String.lowercase (Xml.tag x) = "aircraft" then
|
||||||
let id = ExtXml.attrib x "ac_id"
|
let id = ExtXml.attrib x "ac_id"
|
||||||
and name = ExtXml.attrib x "name" in
|
and name = ExtXml.attrib x "name" in
|
||||||
if Hashtbl.mem ids id then begin
|
if Hashtbl.mem ids id then begin
|
||||||
let other_name = Hashtbl.find ids id in
|
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)
|
failwith (sprintf "Error: A/C Id '%s' duplicated in %s (%s and %s)" id conf_xml name other_name)
|
||||||
end;
|
end;
|
||||||
if Hashtbl.mem names name then begin
|
if Hashtbl.mem names name then begin
|
||||||
let other_id = Hashtbl.find names name in
|
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)
|
failwith (sprintf "Error: A/C name '%s' duplicated in %s (ids %s and %s)" name conf_xml id other_id)
|
||||||
end;
|
end;
|
||||||
Hashtbl.add ids id name;
|
Hashtbl.add ids id name;
|
||||||
Hashtbl.add names name id)
|
Hashtbl.add names name id)
|
||||||
(Xml.children conf)
|
(Xml.children conf)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let pipe_regexp = Str.regexp "|"
|
let pipe_regexp = Str.regexp "|"
|
||||||
let targets_of_field = fun field ->
|
let targets_of_field = fun field ->
|
||||||
try
|
try
|
||||||
Str.split pipe_regexp (ExtXml.attrib_or_default field "target" "ap|sim")
|
Str.split pipe_regexp (ExtXml.attrib_or_default field "target" "ap|sim")
|
||||||
with
|
with
|
||||||
_ -> []
|
_ -> []
|
||||||
|
|
||||||
(** singletonize a sorted list *)
|
(** singletonize a sorted list *)
|
||||||
let rec singletonize = fun l ->
|
let rec singletonize = fun l ->
|
||||||
match l with
|
match l with
|
||||||
[] | [_] -> l
|
[] | [_] -> l
|
||||||
| x :: ((y :: t) as yt) -> if x = y then singletonize yt else x :: singletonize yt
|
| x :: ((y :: t) as yt) -> if x = y then singletonize yt else x :: singletonize yt
|
||||||
|
|
||||||
(** union of two lists *)
|
(** union of two lists *)
|
||||||
@@ -87,28 +87,28 @@ let union_of_lists = fun l ->
|
|||||||
let get_modules = fun dir xml ->
|
let get_modules = fun dir xml ->
|
||||||
(* extract all "modules" sections *)
|
(* extract all "modules" sections *)
|
||||||
let modules = List.map (fun x ->
|
let modules = List.map (fun x ->
|
||||||
match String.lowercase (Xml.tag x) with
|
match String.lowercase (Xml.tag x) with
|
||||||
"modules" -> Xml.children x
|
"modules" -> Xml.children x
|
||||||
| _ -> []
|
| _ -> []
|
||||||
) (Xml.children xml) in
|
) (Xml.children xml) in
|
||||||
(* flatten the list (result is a list of "load" xml nodes) *)
|
(* flatten the list (result is a list of "load" xml nodes) *)
|
||||||
let modules = List.flatten modules in
|
let modules = List.flatten modules in
|
||||||
(* build a list (file name, (xml, xml list of flags)) *)
|
(* build a list (file name, (xml, xml list of flags)) *)
|
||||||
let extract = List.map (fun m ->
|
let extract = List.map (fun m ->
|
||||||
match String.lowercase (Xml.tag m) with
|
match String.lowercase (Xml.tag m) with
|
||||||
"load" -> let file = dir // ExtXml.attrib m "name" in
|
"load" -> let file = dir // ExtXml.attrib m "name" in
|
||||||
(file, (ExtXml.parse_file file, Xml.children m))
|
(file, (ExtXml.parse_file file, Xml.children m))
|
||||||
| tag -> failwith (sprintf "Warning: tag load is undefined; found '%s'" tag)
|
| tag -> failwith (sprintf "Warning: tag load is undefined; found '%s'" tag)
|
||||||
) modules in
|
) modules in
|
||||||
(* return a list of name and a list of pairs (xml, xml list) *)
|
(* return a list of name and a list of pairs (xml, xml list) *)
|
||||||
List.split extract
|
List.split extract
|
||||||
|
|
||||||
(** [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 *)
|
||||||
let get_targets_of_module = fun m ->
|
let get_targets_of_module = fun m ->
|
||||||
let targets = List.map (fun x ->
|
let targets = List.map (fun x ->
|
||||||
match String.lowercase (Xml.tag x) with
|
match String.lowercase (Xml.tag x) with
|
||||||
"makefile" -> targets_of_field x
|
"makefile" -> targets_of_field x
|
||||||
| _ -> []
|
| _ -> []
|
||||||
) (Xml.children m) in
|
) (Xml.children m) in
|
||||||
(* return a singletonized list *)
|
(* return a singletonized list *)
|
||||||
singletonize (List.sort compare (List.flatten targets))
|
singletonize (List.sort compare (List.flatten targets))
|
||||||
@@ -120,8 +120,8 @@ let get_modules_dir = fun modules ->
|
|||||||
|
|
||||||
(**
|
(**
|
||||||
Search and dump the module section :
|
Search and dump the module section :
|
||||||
xml : the parsed airframe.xml
|
xml : the parsed airframe.xml
|
||||||
f : makefile.ac
|
f : makefile.ac
|
||||||
**)
|
**)
|
||||||
let dump_module_section = fun xml f ->
|
let dump_module_section = fun xml f ->
|
||||||
(* get modules *)
|
(* get modules *)
|
||||||
@@ -142,71 +142,71 @@ let dump_module_section = fun xml f ->
|
|||||||
List.iter (fun dir -> let dir_name = (String.uppercase dir)^"_DIR" in fprintf f "%s = modules/%s\n" dir_name dir) dir_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 module *)
|
(* parse each module *)
|
||||||
List.iter (fun (m, flags) ->
|
List.iter (fun (m, flags) ->
|
||||||
let name = ExtXml.attrib m "name" in
|
let name = ExtXml.attrib m "name" in
|
||||||
let dir = try Xml.attrib m "dir" with _ -> name in
|
let dir = try Xml.attrib m "dir" with _ -> name in
|
||||||
let dir_name = (String.uppercase dir)^"_DIR" in
|
let dir_name = (String.uppercase dir)^"_DIR" in
|
||||||
(* get the list of all the targets for this module *)
|
(* get the list of all the targets for this module *)
|
||||||
let module_target_list = get_targets_of_module m in
|
let module_target_list = get_targets_of_module m in
|
||||||
(* print global flags as compilation defines and flags *)
|
(* print global flags as compilation defines and flags *)
|
||||||
fprintf f "\n# makefile for module %s in modules/%s\n" name dir;
|
fprintf f "\n# makefile for module %s in modules/%s\n" name dir;
|
||||||
List.iter (fun flag ->
|
List.iter (fun flag ->
|
||||||
match String.lowercase (Xml.tag flag) with
|
match String.lowercase (Xml.tag flag) with
|
||||||
"define" ->
|
"define" ->
|
||||||
let value = Xml.attrib flag "value"
|
let value = Xml.attrib flag "value"
|
||||||
and name = Xml.attrib flag "name" in
|
and name = Xml.attrib flag "name" in
|
||||||
fprintf f "%s = %s\n" name value
|
fprintf f "%s = %s\n" name value
|
||||||
| "flag" | "param" ->
|
| "flag" | "param" ->
|
||||||
List.iter (fun target ->
|
List.iter (fun target ->
|
||||||
let name = ExtXml.attrib flag "name"
|
let name = ExtXml.attrib flag "name"
|
||||||
and value = try "="^(Xml.attrib flag "value") with _ -> "" in
|
and value = try "="^(Xml.attrib flag "value") with _ -> "" in
|
||||||
fprintf f "%s.CFLAGS += -D%s%s\n" target name value
|
fprintf f "%s.CFLAGS += -D%s%s\n" target name value
|
||||||
) module_target_list
|
) module_target_list
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
) flags;
|
) flags;
|
||||||
(* Look for makefile section *)
|
(* Look for makefile section *)
|
||||||
List.iter (fun l ->
|
List.iter (fun l ->
|
||||||
if ExtXml.tag_is l "makefile" then begin
|
if ExtXml.tag_is l "makefile" then begin
|
||||||
let targets = targets_of_field l in
|
let targets = targets_of_field l in
|
||||||
(* Look for defines, flags, files, ... *)
|
(* Look for defines, flags, files, ... *)
|
||||||
List.iter (fun field ->
|
List.iter (fun field ->
|
||||||
match String.lowercase (Xml.tag field) with
|
match String.lowercase (Xml.tag field) with
|
||||||
"flag" ->
|
"flag" ->
|
||||||
List.iter (fun target ->
|
List.iter (fun target ->
|
||||||
let value = try "="^(Xml.attrib field "value") with _ -> ""
|
let value = try "="^(Xml.attrib field "value") with _ -> ""
|
||||||
and name = Xml.attrib field "name" in
|
and name = Xml.attrib field "name" in
|
||||||
let flag_type = match (ExtXml.attrib_or_default field "type" "define") with
|
let flag_type = match (ExtXml.attrib_or_default field "type" "define") with
|
||||||
"define" | "D" -> "D"
|
"define" | "D" -> "D"
|
||||||
| "include" | "I" -> "I"
|
| "include" | "I" -> "I"
|
||||||
| _ -> "D" in
|
| _ -> "D" in
|
||||||
fprintf f "%s.CFLAGS += -%s%s%s\n" target flag_type name value
|
fprintf f "%s.CFLAGS += -%s%s%s\n" target flag_type name value
|
||||||
) targets
|
) targets
|
||||||
| "file" ->
|
| "file" ->
|
||||||
let name = Xml.attrib field "name" in
|
let name = Xml.attrib field "name" in
|
||||||
List.iter (fun target -> fprintf f "%s.srcs += $(%s)/%s\n" target dir_name name) targets
|
List.iter (fun target -> fprintf f "%s.srcs += $(%s)/%s\n" target dir_name name) targets
|
||||||
| "file_arch" ->
|
| "file_arch" ->
|
||||||
let name = Xml.attrib field "name" in
|
let name = Xml.attrib field "name" in
|
||||||
List.iter (fun target -> fprintf f "%s.srcs += arch/$(ARCH)/$(%s)/%s\n" target dir_name name) targets
|
List.iter (fun target -> fprintf f "%s.srcs += arch/$(ARCH)/$(%s)/%s\n" target dir_name name) targets
|
||||||
| "file_hw" ->
|
| "file_hw" ->
|
||||||
let name = Xml.attrib field "name" in
|
let name = Xml.attrib field "name" in
|
||||||
List.iter (fun target -> fprintf f "%s.srcs += arch/$(ARCH)/$(%s)/%s\n" target dir_name name) targets
|
List.iter (fun target -> fprintf f "%s.srcs += arch/$(ARCH)/$(%s)/%s\n" target dir_name name) targets
|
||||||
| "define" ->
|
| "define" ->
|
||||||
let value = Xml.attrib field "value"
|
let value = Xml.attrib field "value"
|
||||||
and name = Xml.attrib field "name" in
|
and name = Xml.attrib field "name" in
|
||||||
fprintf f "%s = %s\n" name value
|
fprintf f "%s = %s\n" name value
|
||||||
| "raw" ->
|
| "raw" ->
|
||||||
begin match Xml.children field with
|
begin match Xml.children field with
|
||||||
[Xml.PCData s] -> fprintf f "%s\n" s
|
[Xml.PCData s] -> fprintf f "%s\n" s
|
||||||
| _ -> fprintf stderr "Warning: wrong makefile section in module '%s'\n" name
|
| _ -> fprintf stderr "Warning: wrong makefile section in module '%s'\n" name
|
||||||
end
|
end
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
) (Xml.children l)
|
) (Xml.children l)
|
||||||
end) (Xml.children m)
|
end) (Xml.children m)
|
||||||
) modules;
|
) modules;
|
||||||
(** returns a list of modules file name *)
|
(** returns a list of modules file name *)
|
||||||
files
|
files
|
||||||
|
|
||||||
(**
|
(**
|
||||||
Search and dump the makefile sections
|
Search and dump the makefile sections
|
||||||
**)
|
**)
|
||||||
let dump_makefile_section = fun xml makefile_ac airframe_infile location ->
|
let dump_makefile_section = fun xml makefile_ac airframe_infile location ->
|
||||||
List.iter (fun x ->
|
List.iter (fun x ->
|
||||||
@@ -220,7 +220,7 @@ let dump_makefile_section = fun xml makefile_ac airframe_infile location ->
|
|||||||
| _ -> failwith (sprintf "Warning: wrong makefile section in '%s': %s\n" airframe_infile (Xml.to_string_fmt x))
|
| _ -> failwith (sprintf "Warning: wrong makefile section in '%s': %s\n" airframe_infile (Xml.to_string_fmt x))
|
||||||
end
|
end
|
||||||
| (_, _) -> ()
|
| (_, _) -> ()
|
||||||
end)
|
end)
|
||||||
(Xml.children xml)
|
(Xml.children xml)
|
||||||
|
|
||||||
(**
|
(**
|
||||||
@@ -326,10 +326,10 @@ let is_older = fun target_file dep_files ->
|
|||||||
not (Sys.file_exists target_file) ||
|
not (Sys.file_exists target_file) ||
|
||||||
let target_file_time = (U.stat target_file).U.st_mtime in
|
let target_file_time = (U.stat target_file).U.st_mtime in
|
||||||
let rec loop = function
|
let rec loop = function
|
||||||
[] -> false
|
[] -> false
|
||||||
| f::fs ->
|
| f::fs ->
|
||||||
target_file_time < (U.stat f).U.st_mtime ||
|
target_file_time < (U.stat f).U.st_mtime ||
|
||||||
loop fs in
|
loop fs in
|
||||||
loop dep_files
|
loop dep_files
|
||||||
|
|
||||||
|
|
||||||
@@ -339,115 +339,115 @@ let make_element = fun t a c -> Xml.Element (t,a,c)
|
|||||||
(******************************* MAIN ****************************************)
|
(******************************* MAIN ****************************************)
|
||||||
let () =
|
let () =
|
||||||
try
|
try
|
||||||
if Array.length Sys.argv <> 2 then
|
if Array.length Sys.argv <> 2 then
|
||||||
failwith (sprintf "Usage: %s <A/C ident (conf.xml)>" Sys.argv.(0));
|
failwith (sprintf "Usage: %s <A/C ident (conf.xml)>" Sys.argv.(0));
|
||||||
let aircraft = Sys.argv.(1) in
|
let aircraft = Sys.argv.(1) in
|
||||||
let conf = Xml.parse_file conf_xml in
|
let conf = Xml.parse_file conf_xml in
|
||||||
check_unique_id_and_name conf;
|
check_unique_id_and_name conf;
|
||||||
let aircraft_xml =
|
let aircraft_xml =
|
||||||
try
|
try
|
||||||
ExtXml.child conf ~select:(fun x -> Xml.attrib x "name" = aircraft) "aircraft"
|
ExtXml.child conf ~select:(fun x -> Xml.attrib x "name" = aircraft) "aircraft"
|
||||||
with
|
with
|
||||||
Not_found -> failwith (sprintf "Aircraft '%s' not found in '%s'" aircraft conf_xml)
|
Not_found -> failwith (sprintf "Aircraft '%s' not found in '%s'" aircraft conf_xml)
|
||||||
in
|
in
|
||||||
|
|
||||||
let value = fun attrib -> ExtXml.attrib aircraft_xml attrib in
|
let value = fun attrib -> ExtXml.attrib aircraft_xml attrib in
|
||||||
|
|
||||||
let aircraft_dir = Env.paparazzi_home // "var" // aircraft in
|
let aircraft_dir = Env.paparazzi_home // "var" // aircraft in
|
||||||
let aircraft_conf_dir = aircraft_dir // "conf" in
|
let aircraft_conf_dir = aircraft_dir // "conf" in
|
||||||
|
|
||||||
mkdir (Env.paparazzi_home // "var");
|
mkdir (Env.paparazzi_home // "var");
|
||||||
mkdir aircraft_dir;
|
mkdir aircraft_dir;
|
||||||
mkdir (aircraft_dir // "fbw");
|
mkdir (aircraft_dir // "fbw");
|
||||||
mkdir (aircraft_dir // "autopilot");
|
mkdir (aircraft_dir // "autopilot");
|
||||||
mkdir (aircraft_dir // "sim");
|
mkdir (aircraft_dir // "sim");
|
||||||
mkdir aircraft_conf_dir;
|
mkdir aircraft_conf_dir;
|
||||||
mkdir (aircraft_conf_dir // "airframes");
|
mkdir (aircraft_conf_dir // "airframes");
|
||||||
mkdir (aircraft_conf_dir // "flight_plans");
|
mkdir (aircraft_conf_dir // "flight_plans");
|
||||||
mkdir (aircraft_conf_dir // "radios");
|
mkdir (aircraft_conf_dir // "radios");
|
||||||
mkdir (aircraft_conf_dir // "settings");
|
mkdir (aircraft_conf_dir // "settings");
|
||||||
mkdir (aircraft_conf_dir // "telemetry");
|
mkdir (aircraft_conf_dir // "telemetry");
|
||||||
|
|
||||||
let settings =
|
let settings =
|
||||||
try value "settings" with
|
try value "settings" with
|
||||||
_ ->
|
_ ->
|
||||||
fprintf stderr "\nWARNING: No 'settings' attribute specified for A/C '%s', using 'settings/basic.xml'\n\n%!" aircraft;
|
fprintf stderr "\nWARNING: No 'settings' attribute specified for A/C '%s', using 'settings/basic.xml'\n\n%!" aircraft;
|
||||||
"settings/basic.xml" in
|
"settings/basic.xml" in
|
||||||
|
|
||||||
(** Expands the configuration of the A/C into one single file *)
|
(** Expands the configuration of the A/C into one single file *)
|
||||||
let conf_aircraft = Env.expand_ac_xml aircraft_xml in
|
let conf_aircraft = Env.expand_ac_xml aircraft_xml in
|
||||||
let configuration =
|
let configuration =
|
||||||
make_element
|
make_element
|
||||||
"configuration"
|
"configuration"
|
||||||
[]
|
[]
|
||||||
[make_element "conf" [] [conf_aircraft]; Pprz.messages_xml ()] in
|
[make_element "conf" [] [conf_aircraft]; Pprz.messages_xml ()] in
|
||||||
let conf_aircraft_file = aircraft_conf_dir // "conf_aircraft.xml" in
|
let conf_aircraft_file = aircraft_conf_dir // "conf_aircraft.xml" in
|
||||||
let f = open_out conf_aircraft_file in
|
let f = open_out conf_aircraft_file in
|
||||||
Printf.fprintf f "%s\n" (ExtXml.to_string_fmt configuration);
|
Printf.fprintf f "%s\n" (ExtXml.to_string_fmt configuration);
|
||||||
close_out f;
|
close_out f;
|
||||||
|
|
||||||
(** Computes and store a signature of the configuration *)
|
(** Computes and store a signature of the configuration *)
|
||||||
let md5sum = Digest.to_hex (Digest.file conf_aircraft_file) in
|
let md5sum = Digest.to_hex (Digest.file conf_aircraft_file) in
|
||||||
let md5sum_file = aircraft_conf_dir // "aircraft.md5" in
|
let md5sum_file = aircraft_conf_dir // "aircraft.md5" in
|
||||||
(* Store only if different from previous one *)
|
(* Store only if different from previous one *)
|
||||||
if not (Sys.file_exists md5sum_file
|
if not (Sys.file_exists md5sum_file
|
||||||
&& md5sum = input_line (open_in md5sum_file)) then begin
|
&& md5sum = input_line (open_in md5sum_file)) then begin
|
||||||
let f = open_out md5sum_file in
|
let f = open_out md5sum_file in
|
||||||
Printf.fprintf f "%s\n" md5sum;
|
Printf.fprintf f "%s\n" md5sum;
|
||||||
close_out f;
|
close_out f;
|
||||||
|
|
||||||
(** Save the configuration for future use *)
|
(** Save the configuration for future use *)
|
||||||
let d = U.localtime (U.gettimeofday ()) in
|
let d = U.localtime (U.gettimeofday ()) in
|
||||||
let filename = sprintf "%02d_%02d_%02d__%02d_%02d_%02d_%s_%s.conf" (d.U.tm_year mod 100) (d.U.tm_mon+1) (d.U.tm_mday) (d.U.tm_hour) (d.U.tm_min) (d.U.tm_sec) md5sum aircraft in
|
let filename = sprintf "%02d_%02d_%02d__%02d_%02d_%02d_%s_%s.conf" (d.U.tm_year mod 100) (d.U.tm_mon+1) (d.U.tm_mday) (d.U.tm_hour) (d.U.tm_min) (d.U.tm_sec) md5sum aircraft in
|
||||||
let d = Env.paparazzi_home // "var" // "conf" in
|
let d = Env.paparazzi_home // "var" // "conf" in
|
||||||
mkdir d;
|
mkdir d;
|
||||||
let f = open_out (d // filename) in
|
let f = open_out (d // filename) in
|
||||||
Printf.fprintf f "%s\n" (ExtXml.to_string_fmt configuration);
|
Printf.fprintf f "%s\n" (ExtXml.to_string_fmt configuration);
|
||||||
close_out f end;
|
close_out f end;
|
||||||
|
|
||||||
let airframe_file = value "airframe" in
|
let airframe_file = value "airframe" in
|
||||||
|
|
||||||
let airframe_dir = Filename.dirname airframe_file in
|
let airframe_dir = Filename.dirname airframe_file in
|
||||||
let var_airframe_dir = aircraft_conf_dir // airframe_dir in
|
let var_airframe_dir = aircraft_conf_dir // airframe_dir in
|
||||||
mkdir var_airframe_dir;
|
mkdir var_airframe_dir;
|
||||||
assert (Sys.command (sprintf "cp %s %s" (paparazzi_conf // airframe_file) var_airframe_dir) = 0);
|
assert (Sys.command (sprintf "cp %s %s" (paparazzi_conf // airframe_file) var_airframe_dir) = 0);
|
||||||
|
|
||||||
(** Calls the Makefile with target and options *)
|
(** Calls the Makefile with target and options *)
|
||||||
let make = fun target options ->
|
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") airframe_file (value "telemetry") settings md5sum options target in
|
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") airframe_file (value "telemetry") settings md5sum options target in
|
||||||
begin (** Quiet is speficied in the Makefile *)
|
begin (** Quiet is speficied in the Makefile *)
|
||||||
try if Sys.getenv "Q" <> "@" then raise Not_found with
|
try if Sys.getenv "Q" <> "@" then raise Not_found with
|
||||||
Not_found -> prerr_endline c
|
Not_found -> prerr_endline c
|
||||||
end;
|
end;
|
||||||
let returned_code = Sys.command c in
|
let returned_code = Sys.command c in
|
||||||
if returned_code <> 0 then
|
if returned_code <> 0 then
|
||||||
exit returned_code in
|
exit returned_code in
|
||||||
|
|
||||||
(** Calls the makefile if the optional attribute is available *)
|
(** Calls the makefile if the optional attribute is available *)
|
||||||
let make_opt = fun target var attr ->
|
let make_opt = fun target var attr ->
|
||||||
try
|
try
|
||||||
let value = Xml.attrib aircraft_xml attr in
|
let value = Xml.attrib aircraft_xml attr in
|
||||||
make target (sprintf "%s=%s" var value)
|
make target (sprintf "%s=%s" var value)
|
||||||
with
|
with
|
||||||
Xml.No_attribute _ -> () in
|
Xml.No_attribute _ -> () in
|
||||||
|
|
||||||
let temp_makefile_ac = Filename.temp_file "Makefile.ac" "tmp" in
|
let temp_makefile_ac = Filename.temp_file "Makefile.ac" "tmp" in
|
||||||
let abs_airframe_file = paparazzi_conf // airframe_file in
|
let abs_airframe_file = paparazzi_conf // airframe_file in
|
||||||
|
|
||||||
let modules_files = extract_makefile abs_airframe_file temp_makefile_ac in
|
let modules_files = extract_makefile abs_airframe_file temp_makefile_ac in
|
||||||
|
|
||||||
(* Create Makefile.ac only if needed *)
|
(* Create Makefile.ac only if needed *)
|
||||||
let makefile_ac = aircraft_dir // "Makefile.ac" in
|
let makefile_ac = aircraft_dir // "Makefile.ac" in
|
||||||
if is_older makefile_ac (abs_airframe_file :: modules_files) then begin
|
if is_older makefile_ac (abs_airframe_file :: modules_files) then begin
|
||||||
assert(Sys.command (sprintf "mv %s %s" temp_makefile_ac makefile_ac) = 0)
|
assert(Sys.command (sprintf "mv %s %s" temp_makefile_ac makefile_ac) = 0)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(* Get TARGET env, needed to build modules.h according to the target *)
|
(* Get TARGET env, needed to build modules.h according to the target *)
|
||||||
let t = Printf.sprintf "TARGET=%s" (try Sys.getenv "TARGET" with _ -> "") in
|
let t = Printf.sprintf "TARGET=%s" (try Sys.getenv "TARGET" with _ -> "") in
|
||||||
make "all_ac_h" t;
|
make "all_ac_h" t;
|
||||||
make_opt "radio_ac_h" "RADIO" "radio";
|
make_opt "radio_ac_h" "RADIO" "radio";
|
||||||
make_opt "flight_plan_ac_h" "FLIGHT_PLAN" "flight_plan"
|
make_opt "flight_plan_ac_h" "FLIGHT_PLAN" "flight_plan"
|
||||||
with
|
with
|
||||||
Failure f ->
|
Failure f ->
|
||||||
prerr_endline f;
|
prerr_endline f;
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
+18
-18
@@ -2,7 +2,7 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* XML preprocessing for airframe parameters
|
* XML preprocessing for airframe parameters
|
||||||
*
|
*
|
||||||
* Copyright (C) 2003-2006 Pascal Brisset, Antoine Drouin
|
* Copyright (C) 2003-2006 Pascal Brisset, Antoine Drouin
|
||||||
*
|
*
|
||||||
* This file is part of paparazzi.
|
* This file is part of paparazzi.
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with paparazzi; see the file COPYING. If not, write to
|
* along with paparazzi; see the file COPYING. If not, write to
|
||||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
*)
|
*)
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ let define_macro name n x =
|
|||||||
| 2 -> printf "x1,x2) (%s*(x1)+ %s*(x2))\n" (a "coeff1") (a "coeff2")
|
| 2 -> printf "x1,x2) (%s*(x1)+ %s*(x2))\n" (a "coeff1") (a "coeff2")
|
||||||
| 3 -> printf "x1,x2,x3) (%s*(x1)+ %s*(x2)+%s*(x3))\n" (a "coeff1") (a "coeff2") (a "coeff3")
|
| 3 -> printf "x1,x2,x3) (%s*(x1)+ %s*(x2)+%s*(x3))\n" (a "coeff1") (a "coeff2") (a "coeff3")
|
||||||
| _ -> failwith "define_macro"
|
| _ -> failwith "define_macro"
|
||||||
|
|
||||||
let define_integer name v n =
|
let define_integer name v n =
|
||||||
let max_val = 1 lsl n in
|
let max_val = 1 lsl n in
|
||||||
let print = fun name num den ->
|
let print = fun name num den ->
|
||||||
@@ -84,11 +84,11 @@ let define_integer name v n =
|
|||||||
let parse_element = fun prefix s ->
|
let parse_element = fun prefix s ->
|
||||||
match Xml.tag s with
|
match Xml.tag s with
|
||||||
"define" -> begin
|
"define" -> begin
|
||||||
try
|
try
|
||||||
define (prefix^ExtXml.attrib s "name") (ExtXml.display_entities (ExtXml.attrib s "value"));
|
define (prefix^ExtXml.attrib s "name") (ExtXml.display_entities (ExtXml.attrib s "value"));
|
||||||
define_integer (prefix^(ExtXml.attrib s "name")) (ExtXml.float_attrib s "value") (ExtXml.int_attrib s "integer");
|
define_integer (prefix^(ExtXml.attrib s "name")) (ExtXml.float_attrib s "value") (ExtXml.int_attrib s "integer");
|
||||||
with _ -> ();
|
with _ -> ();
|
||||||
end
|
end
|
||||||
| "linear" ->
|
| "linear" ->
|
||||||
let name = ExtXml.attrib s "name"
|
let name = ExtXml.attrib s "name"
|
||||||
and n = int_of_string (ExtXml.attrib s "arity") in
|
and n = int_of_string (ExtXml.attrib s "arity") in
|
||||||
@@ -107,7 +107,7 @@ let parse_servo = fun driver c ->
|
|||||||
let min = fos (ExtXml.attrib c "min" )
|
let min = fos (ExtXml.attrib c "min" )
|
||||||
and neutral = fos (ExtXml.attrib c "neutral")
|
and neutral = fos (ExtXml.attrib c "neutral")
|
||||||
and max = fos (ExtXml.attrib c "max" ) in
|
and max = fos (ExtXml.attrib c "max" ) in
|
||||||
|
|
||||||
let travel_up = (max-.neutral) /. max_pprz
|
let travel_up = (max-.neutral) /. max_pprz
|
||||||
and travel_down = (neutral-.min) /. max_pprz in
|
and travel_down = (neutral-.min) /. max_pprz in
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ let parse_command_laws = fun command ->
|
|||||||
let var = a "var"
|
let var = a "var"
|
||||||
and value = a "value" in
|
and value = a "value" in
|
||||||
let v = preprocess_value value "values" "COMMAND" in
|
let v = preprocess_value value "values" "COMMAND" in
|
||||||
printf " int16_t _var_%s = %s;\\\n" var v
|
printf " int16_t _var_%s = %s;\\\n" var v
|
||||||
| "define" ->
|
| "define" ->
|
||||||
parse_element "" command
|
parse_element "" command
|
||||||
| _ -> xml_error "set|let"
|
| _ -> xml_error "set|let"
|
||||||
@@ -162,7 +162,7 @@ let parse_csc_fields = fun csc_fields ->
|
|||||||
let a = fun s -> ExtXml.attrib csc_fields s in
|
let a = fun s -> ExtXml.attrib csc_fields s in
|
||||||
match Xml.tag csc_fields with
|
match Xml.tag csc_fields with
|
||||||
"field_map" ->
|
"field_map" ->
|
||||||
let servo_id = a "servo_id"
|
let servo_id = a "servo_id"
|
||||||
and field = a "field" in
|
and field = a "field" in
|
||||||
printf " temp.%s = actuators[%s]; \\\n" field servo_id;
|
printf " temp.%s = actuators[%s]; \\\n" field servo_id;
|
||||||
| _ -> xml_error "field_map"
|
| _ -> xml_error "field_map"
|
||||||
@@ -171,8 +171,8 @@ let parse_csc_messages = (let msg_index_ref = ref 0 in fun csc_id csc_messages -
|
|||||||
let a = fun s -> ExtXml.attrib csc_messages s in
|
let a = fun s -> ExtXml.attrib csc_messages s in
|
||||||
match Xml.tag csc_messages with
|
match Xml.tag csc_messages with
|
||||||
"msg" ->
|
"msg" ->
|
||||||
let msg_id = a "id"
|
let msg_id = a "id"
|
||||||
and msg_type = a "type"
|
and msg_type = a "type"
|
||||||
and msg_index = msg_index_ref.contents in
|
and msg_index = msg_index_ref.contents in
|
||||||
msg_index_ref.contents <- msg_index + 1;
|
msg_index_ref.contents <- msg_index + 1;
|
||||||
printf "{\\\n struct Csc%s temp; \\\n" msg_type;
|
printf "{\\\n struct Csc%s temp; \\\n" msg_type;
|
||||||
@@ -204,7 +204,7 @@ let parse_rc_commands = fun rc ->
|
|||||||
let var = a "var"
|
let var = a "var"
|
||||||
and value = a "value" in
|
and value = a "value" in
|
||||||
let v = preprocess_value value "rc_values" "RADIO" in
|
let v = preprocess_value value "rc_values" "RADIO" in
|
||||||
printf " int16_t _var_%s = %s;\\\n" var v
|
printf " int16_t _var_%s = %s;\\\n" var v
|
||||||
| "define" ->
|
| "define" ->
|
||||||
parse_element "" rc
|
parse_element "" rc
|
||||||
| _ -> xml_error "set|let"
|
| _ -> xml_error "set|let"
|
||||||
@@ -221,7 +221,7 @@ let parse_ap_only_commands = fun ap_only ->
|
|||||||
let parse_subsystem_defines = fun options ->
|
let parse_subsystem_defines = fun options ->
|
||||||
match Xml.tag options with
|
match Xml.tag options with
|
||||||
"param" ->
|
"param" ->
|
||||||
printf "// -param: %s\n" (ExtXml.attrib options "name")
|
printf "// -param: %s\n" (ExtXml.attrib options "name")
|
||||||
| "define" ->
|
| "define" ->
|
||||||
printf "#define %s %s\n" (ExtXml.attrib options "name") (ExtXml.attrib options "value")
|
printf "#define %s %s\n" (ExtXml.attrib options "name") (ExtXml.attrib options "value")
|
||||||
| _ -> xml_error "define|param"
|
| _ -> xml_error "define|param"
|
||||||
@@ -230,7 +230,7 @@ let parse_subsystem_defines = fun options ->
|
|||||||
let parse_subsystems = fun subsystem ->
|
let parse_subsystems = fun subsystem ->
|
||||||
match Xml.tag subsystem with
|
match Xml.tag subsystem with
|
||||||
"param" ->
|
"param" ->
|
||||||
printf "// subsystem parameter: %s\n" (ExtXml.attrib subsystem "name")
|
printf "// subsystem parameter: %s\n" (ExtXml.attrib subsystem "name")
|
||||||
| "subsystem" ->
|
| "subsystem" ->
|
||||||
printf "// -%s:\n" (ExtXml.attrib subsystem "name");
|
printf "// -%s:\n" (ExtXml.attrib subsystem "name");
|
||||||
List.iter parse_subsystem_defines (Xml.children subsystem)
|
List.iter parse_subsystem_defines (Xml.children subsystem)
|
||||||
@@ -307,7 +307,7 @@ let rec parse_section = fun s ->
|
|||||||
()
|
()
|
||||||
(** Ignoring this section *)
|
(** Ignoring this section *)
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
|
|
||||||
|
|
||||||
let h_name = "AIRFRAME_H"
|
let h_name = "AIRFRAME_H"
|
||||||
|
|
||||||
@@ -319,7 +319,7 @@ let hex_to_bin = fun s ->
|
|||||||
b.[4*i] <- '\\';
|
b.[4*i] <- '\\';
|
||||||
Scanf.sscanf (String.sub s (2*i) 2) "%2x"
|
Scanf.sscanf (String.sub s (2*i) 2) "%2x"
|
||||||
(fun x ->
|
(fun x ->
|
||||||
String.blit (sprintf "%03o" x) 0 b (4*i+1) 3)
|
String.blit (sprintf "%03o" x) 0 b (4*i+1) 3)
|
||||||
done;
|
done;
|
||||||
b
|
b
|
||||||
|
|
||||||
|
|||||||
+283
-284
File diff suppressed because it is too large
Load Diff
+11
-11
@@ -2,7 +2,7 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* XML preprocessing for modules
|
* XML preprocessing for modules
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Gautier Hattenberger
|
* Copyright (C) 2009 Gautier Hattenberger
|
||||||
*
|
*
|
||||||
* This file is part of paparazzi.
|
* This file is part of paparazzi.
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with paparazzi; see the file COPYING. If not, write to
|
* along with paparazzi; see the file COPYING. If not, write to
|
||||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
*)
|
*)
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ let remove_dup = fun l ->
|
|||||||
match l with
|
match l with
|
||||||
[] | [_] -> l
|
[] | [_] -> l
|
||||||
| x::((x'::_) as xs) ->
|
| x::((x'::_) as xs) ->
|
||||||
if x = x' then loop xs else x::loop xs in
|
if x = x' then loop xs else x::loop xs in
|
||||||
loop (List.sort compare l)
|
loop (List.sort compare l)
|
||||||
|
|
||||||
let print_periodic_functions = fun modules ->
|
let print_periodic_functions = fun modules ->
|
||||||
@@ -117,7 +117,7 @@ let print_periodic_functions = fun modules ->
|
|||||||
let functions_modulo = List.flatten (List.map (fun m ->
|
let functions_modulo = List.flatten (List.map (fun m ->
|
||||||
let periodic = List.filter (fun i -> (String.compare (Xml.tag i) "periodic") == 0) (Xml.children m) in
|
let periodic = List.filter (fun i -> (String.compare (Xml.tag i) "periodic") == 0) (Xml.children m) in
|
||||||
let module_name = ExtXml.attrib m "name" in
|
let module_name = ExtXml.attrib m "name" in
|
||||||
List.map (fun x ->
|
List.map (fun x ->
|
||||||
try
|
try
|
||||||
let p = float_of_string (Xml.attrib x "period") in
|
let p = float_of_string (Xml.attrib x "period") in
|
||||||
let _ = try let _ = Xml.attrib x "freq" in fprintf stderr "Warning: both period and freq are defined but only period is used for function %s\n" (ExtXml.attrib x "fun") with _ -> () in
|
let _ = try let _ = Xml.attrib x "freq" in fprintf stderr "Warning: both period and freq are defined but only period is used for function %s\n" (ExtXml.attrib x "fun") with _ -> () in
|
||||||
@@ -178,7 +178,7 @@ let print_periodic_functions = fun modules ->
|
|||||||
lprintf out_h "}\n";
|
lprintf out_h "}\n";
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if (test_delay func) then begin
|
if (test_delay func) then begin
|
||||||
(** Delay is set by user *)
|
(** Delay is set by user *)
|
||||||
@@ -267,16 +267,16 @@ let get_modules = fun dir m ->
|
|||||||
let name = ExtXml.attrib m "name" in
|
let name = ExtXml.attrib m "name" in
|
||||||
let xml = Xml.parse_file (dir^name) in
|
let xml = Xml.parse_file (dir^name) in
|
||||||
xml
|
xml
|
||||||
end
|
end
|
||||||
| _ -> xml_error "load"
|
| _ -> xml_error "load"
|
||||||
|
|
||||||
let test_section_modules = fun xml ->
|
let test_section_modules = fun xml ->
|
||||||
List.fold_right (fun x r -> ExtXml.tag_is x "modules" || r) (Xml.children xml) false
|
List.fold_right (fun x r -> ExtXml.tag_is x "modules" || r) (Xml.children xml) false
|
||||||
|
|
||||||
(** Check dependencies *)
|
(** Check dependencies *)
|
||||||
let pipe_regexp = Str.regexp "|"
|
let pipe_regexp = Str.regexp "|"
|
||||||
let dep_of_field = fun field att ->
|
let dep_of_field = fun field att ->
|
||||||
try
|
try
|
||||||
Str.split pipe_regexp (Xml.attrib field att)
|
Str.split pipe_regexp (Xml.attrib field att)
|
||||||
with
|
with
|
||||||
_ -> []
|
_ -> []
|
||||||
@@ -310,7 +310,7 @@ let write_settings = fun xml_file out_set modules ->
|
|||||||
match Xml.tag i with
|
match Xml.tag i with
|
||||||
"periodic" ->
|
"periodic" ->
|
||||||
if not (is_status_lock i) then begin
|
if not (is_status_lock i) then begin
|
||||||
if (not !setting_exist) then begin
|
if (not !setting_exist) then begin
|
||||||
fprintf out_set " <dl_settings name=\"Modules\">\n";
|
fprintf out_set " <dl_settings name=\"Modules\">\n";
|
||||||
setting_exist := true;
|
setting_exist := true;
|
||||||
end;
|
end;
|
||||||
@@ -326,7 +326,7 @@ let write_settings = fun xml_file out_set modules ->
|
|||||||
|
|
||||||
let get_targets_of_module = fun m ->
|
let get_targets_of_module = fun m ->
|
||||||
let pipe_regexp = Str.regexp "|" in
|
let pipe_regexp = Str.regexp "|" in
|
||||||
let targets_of_field = fun field -> try
|
let targets_of_field = fun field -> try
|
||||||
Str.split pipe_regexp (ExtXml.attrib_or_default field "target" "ap|sim") with _ -> [] in
|
Str.split pipe_regexp (ExtXml.attrib_or_default field "target" "ap|sim") with _ -> [] in
|
||||||
let rec singletonize = fun l ->
|
let rec singletonize = fun l ->
|
||||||
match l with
|
match l with
|
||||||
@@ -380,7 +380,7 @@ let () =
|
|||||||
freq := main_freq;
|
freq := main_freq;
|
||||||
let modules_list = List.map (get_modules modules_dir) (Xml.children modules) in
|
let modules_list = List.map (get_modules modules_dir) (Xml.children modules) in
|
||||||
let modules_list = unload_unused_modules modules_list in
|
let modules_list = unload_unused_modules modules_list in
|
||||||
let modules_name =
|
let modules_name =
|
||||||
(List.map (fun l -> try Xml.attrib l "name" with _ -> "") (Xml.children modules)) @
|
(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
|
(List.map (fun m -> try Xml.attrib m "name" with _ -> "") modules_list) in
|
||||||
check_dependencies modules_list modules_name;
|
check_dependencies modules_list modules_name;
|
||||||
|
|||||||
+33
-33
@@ -2,7 +2,7 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* XML preprocessing for dynamic tuning
|
* XML preprocessing for dynamic tuning
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Pascal Brisset, Antoine Drouin
|
* Copyright (C) 2006 Pascal Brisset, Antoine Drouin
|
||||||
*
|
*
|
||||||
* This file is part of paparazzi.
|
* This file is part of paparazzi.
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with paparazzi; see the file COPYING. If not, write to
|
* along with paparazzi; see the file COPYING. If not, write to
|
||||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
*)
|
*)
|
||||||
|
|
||||||
@@ -44,50 +44,50 @@ let rec flatten = fun xml r ->
|
|||||||
match Xml.children xml with
|
match Xml.children xml with
|
||||||
[] -> r
|
[] -> r
|
||||||
| x::xs ->
|
| x::xs ->
|
||||||
List.iter (fun y -> assert(ExtXml.tag_is y (Xml.tag x))) xs;
|
List.iter (fun y -> assert(ExtXml.tag_is y (Xml.tag x))) xs;
|
||||||
List.fold_right flatten (x::xs) r
|
List.fold_right flatten (x::xs) r
|
||||||
|
|
||||||
|
|
||||||
module StringSet = Set.Make(struct type t = string let compare = compare end)
|
module StringSet = Set.Make(struct type t = string let compare = compare end)
|
||||||
|
|
||||||
|
|
||||||
let print_dl_settings = fun settings ->
|
let print_dl_settings = fun settings ->
|
||||||
let settings = flatten settings [] in
|
let settings = flatten settings [] in
|
||||||
|
|
||||||
(** include headers **)
|
(** include headers **)
|
||||||
let modules = ref StringSet.empty in
|
let modules = ref StringSet.empty in
|
||||||
List.iter
|
List.iter
|
||||||
(fun s ->
|
(fun s ->
|
||||||
try
|
try
|
||||||
modules := StringSet.add (ExtXml.attrib s "module") !modules
|
modules := StringSet.add (ExtXml.attrib s "module") !modules
|
||||||
with ExtXml.Error e -> ()
|
with ExtXml.Error e -> ()
|
||||||
)
|
)
|
||||||
settings;
|
settings;
|
||||||
|
|
||||||
lprintf "\n";
|
lprintf "\n";
|
||||||
StringSet.iter (fun m -> lprintf "#include \"%s.h\"\n" m) !modules;
|
StringSet.iter (fun m -> lprintf "#include \"%s.h\"\n" m) !modules;
|
||||||
lprintf "#include \"modules.h\"\n";
|
lprintf "#include \"modules.h\"\n";
|
||||||
lprintf "\n";
|
lprintf "\n";
|
||||||
|
|
||||||
(** Macro to call to set one variable *)
|
(** Macro to call to set one variable *)
|
||||||
lprintf "#define DlSetting(_idx, _value) { \\\n";
|
lprintf "#define DlSetting(_idx, _value) { \\\n";
|
||||||
right ();
|
right ();
|
||||||
lprintf "switch (_idx) { \\\n";
|
lprintf "switch (_idx) { \\\n";
|
||||||
right ();
|
right ();
|
||||||
let idx = ref 0 in
|
let idx = ref 0 in
|
||||||
List.iter
|
List.iter
|
||||||
(fun s ->
|
(fun s ->
|
||||||
let v = ExtXml.attrib s "var" in
|
let v = ExtXml.attrib s "var" in
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
let h = ExtXml.attrib s "handler" and
|
let h = ExtXml.attrib s "handler" and
|
||||||
m = ExtXml.attrib s "module" in
|
m = ExtXml.attrib s "module" in
|
||||||
lprintf "case %d: %s_%s( _value ); _value = %s; break;\\\n" !idx (Filename.basename m) h v
|
lprintf "case %d: %s_%s( _value ); _value = %s; break;\\\n" !idx (Filename.basename m) h v
|
||||||
with
|
with
|
||||||
ExtXml.Error e -> lprintf "case %d: %s = _value; break;\\\n" !idx v
|
ExtXml.Error e -> lprintf "case %d: %s = _value; break;\\\n" !idx v
|
||||||
end;
|
end;
|
||||||
incr idx
|
incr idx
|
||||||
)
|
)
|
||||||
settings;
|
settings;
|
||||||
lprintf "default: break;\\\n";
|
lprintf "default: break;\\\n";
|
||||||
left ();
|
left ();
|
||||||
@@ -106,10 +106,10 @@ let print_dl_settings = fun settings ->
|
|||||||
let idx = ref 0 in
|
let idx = ref 0 in
|
||||||
lprintf "switch (i) { \\\n";
|
lprintf "switch (i) { \\\n";
|
||||||
right ();
|
right ();
|
||||||
List.iter
|
List.iter
|
||||||
(fun s ->
|
(fun s ->
|
||||||
let v = ExtXml.attrib s "var" in
|
let v = ExtXml.attrib s "var" in
|
||||||
lprintf "case %d: var = %s; break;\\\n" !idx v; incr idx)
|
lprintf "case %d: var = %s; break;\\\n" !idx v; incr idx)
|
||||||
settings;
|
settings;
|
||||||
lprintf "default: var = 0.; break;\\\n";
|
lprintf "default: var = 0.; break;\\\n";
|
||||||
left ();
|
left ();
|
||||||
@@ -126,16 +126,16 @@ let print_dl_settings = fun settings ->
|
|||||||
let idx = ref 0 in
|
let idx = ref 0 in
|
||||||
lprintf "switch (i) { \\\n";
|
lprintf "switch (i) { \\\n";
|
||||||
right ();
|
right ();
|
||||||
List.iter
|
List.iter
|
||||||
(fun s ->
|
(fun s ->
|
||||||
let v = ExtXml.attrib s "var" in
|
let v = ExtXml.attrib s "var" in
|
||||||
lprintf "case %d: return %s;\n" !idx v; incr idx)
|
lprintf "case %d: return %s;\n" !idx v; incr idx)
|
||||||
settings;
|
settings;
|
||||||
lprintf "default: return 0.;\n";
|
lprintf "default: return 0.;\n";
|
||||||
lprintf "}\n";
|
lprintf "}\n";
|
||||||
left ();
|
left ();
|
||||||
lprintf "}\n"
|
lprintf "}\n"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -190,12 +190,12 @@ let join_xml_files = fun xml_files ->
|
|||||||
and rc_settings = ref [] in
|
and rc_settings = ref [] in
|
||||||
List.iter (fun xml_file ->
|
List.iter (fun xml_file ->
|
||||||
let xml = Xml.parse_file xml_file in
|
let xml = Xml.parse_file xml_file in
|
||||||
let these_rc_settings =
|
let these_rc_settings =
|
||||||
try Xml.children (ExtXml.child xml "rc_settings") with
|
try Xml.children (ExtXml.child xml "rc_settings") with
|
||||||
Not_found -> [] in
|
Not_found -> [] in
|
||||||
let these_dl_settings =
|
let these_dl_settings =
|
||||||
try Xml.children (ExtXml.child xml "dl_settings") with
|
try Xml.children (ExtXml.child xml "dl_settings") with
|
||||||
Not_found -> [] in
|
Not_found -> [] in
|
||||||
rc_settings := these_rc_settings @ !rc_settings;
|
rc_settings := these_rc_settings @ !rc_settings;
|
||||||
dl_settings := these_dl_settings @ !dl_settings)
|
dl_settings := these_dl_settings @ !dl_settings)
|
||||||
xml_files;
|
xml_files;
|
||||||
@@ -211,11 +211,11 @@ let _ =
|
|||||||
for i = 2 to Array.length Sys.argv - 1 do
|
for i = 2 to Array.length Sys.argv - 1 do
|
||||||
xml_files := Sys.argv.(i) :: !xml_files;
|
xml_files := Sys.argv.(i) :: !xml_files;
|
||||||
done;
|
done;
|
||||||
|
|
||||||
try
|
try
|
||||||
printf "/* This file has been generated from %s */\n" (String.concat " " !xml_files);
|
printf "/* This file has been generated from %s */\n" (String.concat " " !xml_files);
|
||||||
printf "/* Please DO NOT EDIT */\n\n";
|
printf "/* Please DO NOT EDIT */\n\n";
|
||||||
|
|
||||||
printf "#ifndef %s\n" h_name;
|
printf "#ifndef %s\n" h_name;
|
||||||
define h_name "";
|
define h_name "";
|
||||||
nl ();
|
nl ();
|
||||||
|
|||||||
Reference in New Issue
Block a user