mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-07 09:36:19 +08:00
33 lines
940 B
OCaml
Executable File
33 lines
940 B
OCaml
Executable File
#!/usr/bin/ocamlrun /usr/bin/ocaml
|
|
#load "unix.cma";;
|
|
let (//) = Filename.concat
|
|
let paparazzi_home =
|
|
try
|
|
Sys.getenv "PAPARAZZI_HOME"
|
|
with
|
|
_ -> Filename.concat (Sys.getenv "HOME") "paparazzi"
|
|
|
|
let () =
|
|
let n = Array.length Sys.argv in
|
|
try
|
|
let rec loop = fun i ->
|
|
if Sys.argv.(i) = "-a" && (i+1) < n then
|
|
let ac = Sys.argv.(i+1) in
|
|
(* Shift other args *)
|
|
for j = i+2 to n-1 do Sys.argv.(j-2) <- Sys.argv.(j) done;
|
|
ac
|
|
else if i = n then raise Not_found
|
|
else loop (i+1) in
|
|
let ac = loop 0 in
|
|
let com = paparazzi_home // "var" // ac // "sim/simsitl" in
|
|
if not (Sys.file_exists com) then begin
|
|
Printf.fprintf stderr "Error: '%s' is missing. Build target sim for A/C %s ?\n" com ac;
|
|
exit 1
|
|
end;
|
|
let args = Array.sub Sys.argv 0 (n-2) in
|
|
args.(0) <- com;
|
|
prerr_endline com;
|
|
Unix.execv com args
|
|
with _ ->
|
|
failwith "Usage: launchsitl -a <ac_name> <options>"
|