From 8e589adb243e625df307642aa165fb17db4901ca Mon Sep 17 00:00:00 2001
From: Mark Charlebois <charlebm@gmail.com>
Date: Sun, 26 Apr 2015 20:02:58 -0700
Subject: [PATCH] topic_listener: added missing build deps

The posix build would complain that toipc_listener.cpp did not exist
and there was no rule to create it.

The required rule was added to src/systemcmds/topic_listener/module.mk

The script generate_listener.py is run from the Build tree and needs to
access $(PX4_BASE)/msgs so $(PX4_BASE) is now passed as an argument to
generate_listener.py

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
---
 .gitignore                              | 5 +++--
 Tools/generate_listener.py              | 7 ++++++-
 Tools/posix_apps.py                     | 1 -
 src/systemcmds/topic_listener/module.mk | 3 +++
 4 files changed, 12 insertions(+), 4 deletions(-)
 mode change 100644 => 100755 Tools/generate_listener.py

diff --git a/.gitignore b/.gitignore
index 881396fa2f..d3fd211d13 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,5 +48,6 @@ unittests/build
 .vagrant
 *.pretty
 xcode
-src/platforms/linux/px4_messages/
-src/systemcmds/topic_listener.cpp
+src/platforms/posix/px4_messages/
+src/platforms/qurt/px4_messages/
+src/systemcmds/topic_listener/topic_listener.cpp
diff --git a/Tools/generate_listener.py b/Tools/generate_listener.py
old mode 100644
new mode 100755
index 3fa4ea476f..805b390901
--- a/Tools/generate_listener.py
+++ b/Tools/generate_listener.py
@@ -1,8 +1,13 @@
 #!/usr/bin/python
 
 import glob
+import sys
 
-raw_messages = glob.glob("../msg/*.msg")
+# This script is run from Build/<target>_default.build/$(PX4_BASE)/Firmware/src/systemcmds/topic_listener
+
+# argv[1] must be the full path of the top Firmware dir
+
+raw_messages = glob.glob(sys.argv[1]+"/msg/*.msg")
 messages = []
 message_floats = []
 
diff --git a/Tools/posix_apps.py b/Tools/posix_apps.py
index f48977c49a..fe457e778e 100755
--- a/Tools/posix_apps.py
+++ b/Tools/posix_apps.py
@@ -33,7 +33,6 @@
 ############################################################################
 
 import glob
-#builtins = glob.glob("../Build/linux_default.build/builtin_commands/COMMAND*")
 builtins = glob.glob("builtin_commands/COMMAND*")
 
 apps = []
diff --git a/src/systemcmds/topic_listener/module.mk b/src/systemcmds/topic_listener/module.mk
index ea54c3e9e5..14c8deb9f8 100644
--- a/src/systemcmds/topic_listener/module.mk
+++ b/src/systemcmds/topic_listener/module.mk
@@ -35,6 +35,9 @@
 # Build the topic listener tool.
 #
 
+$(PX4_BASE)/src/systemcmds/topic_listener/topic_listener.cpp : $(PX4_BASE)/Tools/generate_listener.py
+	$(PX4_BASE)/Tools/generate_listener.py $(PX4_BASE) > $(PX4_BASE)/src/systemcmds/topic_listener/$@
+
 MODULE_COMMAND	 = listener
 SRCS		 = topic_listener.cpp
 
-- 
GitLab