mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
[pprz] change the old paparazzi launch script from ocaml to python
This new script is doing the same than before but don't rely on the ocaml install which was a problem when mixing opam and system install. Note that when updating, git will complain about the already existing file 'paparazzi'. So it is necessary to delete the old file (or run 'make clean') before updating the code.
This commit is contained in:
@@ -54,8 +54,6 @@ paparazzi.sublime-workspace
|
||||
/var
|
||||
/dox
|
||||
|
||||
/paparazzi
|
||||
|
||||
# /conf/
|
||||
/conf/conf.xml
|
||||
/conf/conf.xml.20*
|
||||
|
||||
@@ -137,7 +137,7 @@ conf/%.xml :conf/%_example.xml
|
||||
conf/tools/blacklisted: conf/tools/blacklisted_example
|
||||
cp conf/tools/blacklisted_example conf/tools/blacklisted
|
||||
|
||||
ground_segment: _print_building update_google_version conf libpprz subdirs commands static
|
||||
ground_segment: _print_building update_google_version conf libpprz subdirs static
|
||||
ground_segment.opt: ground_segment cockpit.opt tmtc.opt
|
||||
|
||||
static: cockpit tmtc generators sim_static joystick static_h
|
||||
@@ -246,20 +246,10 @@ ac_h ac fbw ap: static conf generators ext
|
||||
sim: sim_static
|
||||
|
||||
|
||||
#
|
||||
# Commands
|
||||
#
|
||||
|
||||
# stuff to build and upload the lpc bootloader ...
|
||||
include Makefile.lpctools
|
||||
lpctools: lpc21iap
|
||||
|
||||
commands: paparazzi
|
||||
|
||||
paparazzi:
|
||||
cat src/paparazzi | sed s#OCAMLRUN#$(OCAMLRUN)# | sed s#OCAML#$(OCAML)# > $@
|
||||
chmod a+x $@
|
||||
|
||||
|
||||
#
|
||||
# doxygen html documentation
|
||||
@@ -276,7 +266,7 @@ dox:
|
||||
#
|
||||
|
||||
clean:
|
||||
$(Q)rm -fr dox build-stamp configure-stamp conf/%gconf.xml paparazzi
|
||||
$(Q)rm -fr dox build-stamp configure-stamp conf/%gconf.xml
|
||||
$(Q)rm -f $(GEN_HEADERS)
|
||||
$(Q)MESSAGES_INSTALL=$(MESSAGES_INSTALL) $(MAKE) -C $(PPRZLINK_DIR) uninstall
|
||||
$(Q)rm -fr $(MAVLINK_DIR)
|
||||
@@ -348,6 +338,6 @@ test_sim: all
|
||||
|
||||
.PHONY: all print_build_version _print_building _save_build_version update_google_version init dox ground_segment ground_segment.opt \
|
||||
subdirs $(SUBDIRS) conf ext libpprz libpprzlink cockpit cockpit.opt tmtc tmtc.opt generators\
|
||||
static sim_static lpctools commands opencv_bebop\
|
||||
static sim_static lpctools opencv_bebop\
|
||||
clean cleanspaces ab_clean dist_clean distclean dist_clean_irreversible \
|
||||
test test_examples test_math test_sim test_all_confs
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env /usr/bin/python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
dirname = os.path.dirname(os.path.abspath(__file__))
|
||||
PAPARAZZI_HOME = os.getenv("PAPARAZZI_HOME",dirname)
|
||||
PAPARAZZI_SRC = os.getenv("PAPARAZZI_SRC",PAPARAZZI_HOME)
|
||||
env = os.environ
|
||||
env['PAPARAZZI_HOME'] = PAPARAZZI_HOME
|
||||
env['PAPARAZZI_SRC'] = PAPARAZZI_SRC
|
||||
|
||||
if len(sys.argv) > 1 and sys.argv[1] == "-python":
|
||||
path = os.path.normpath(os.path.join(dirname, 'sw', 'supervision', 'python', 'main.py'))
|
||||
args = sys.argv[2:]
|
||||
os.execve(path, args, env)
|
||||
else:
|
||||
path = os.path.normpath(os.path.join(dirname, 'sw', 'supervision', 'paparazzicenter'))
|
||||
args = sys.argv[1:]
|
||||
os.execve(path, args, env)
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
#!OCAMLRUN OCAML
|
||||
#load "unix.cma";;
|
||||
let (//) = Filename.concat
|
||||
let dirname = Filename.dirname Sys.argv.(0)
|
||||
let dirname = if Filename.is_relative dirname && dirname <> Filename.current_dir_name then Sys.getcwd () // dirname else dirname
|
||||
let env =
|
||||
Array.map (fun var ->
|
||||
let value = try Sys.getenv var with _ -> dirname in
|
||||
let value = if value = "." then Sys.getcwd () else value in
|
||||
Printf.sprintf "%s=%s" var value)
|
||||
[|"PAPARAZZI_SRC"; "PAPARAZZI_HOME"|]
|
||||
let com =
|
||||
if Array.length (Sys.argv) > 1 then begin
|
||||
Printf.printf "%d\n" (Array.length (Sys.argv));
|
||||
if Sys.argv.(1) = "-python" then
|
||||
dirname // "sw/supervision/python/main.py"
|
||||
else
|
||||
dirname // "sw/supervision/paparazzicenter"
|
||||
end
|
||||
else
|
||||
dirname // "sw/supervision/paparazzicenter";;
|
||||
Sys.argv.(0) <- com;;
|
||||
let env = Array.append env (Unix.environment ());;
|
||||
Unix.execve com Sys.argv env
|
||||
Reference in New Issue
Block a user