From aff78e0f5e4f480467241cfe4fabfc09dd020f7c Mon Sep 17 00:00:00 2001
From: Lorenz Meier <lm@inf.ethz.ch>
Date: Sun, 25 Oct 2015 11:20:28 +0100
Subject: [PATCH] CMake / Ninja: Use console flag so upload targets can print
 their normal output and receive input.

---
 Makefile                          | 5 +++--
 cmake/common/px4_base.cmake       | 1 +
 src/firmware/posix/CMakeLists.txt | 1 +
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 7cba819317..2a0e843f94 100644
--- a/Makefile
+++ b/Makefile
@@ -68,11 +68,11 @@ ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
 j ?= 4
 
 # disable ninja by default for now because it hides upload progress
-#NINJA_BUILD := $(shell ninja --version 2>/dev/null)
+NINJA_BUILD := $(shell ninja --version 2>/dev/null)
 ifdef NINJA_BUILD
     PX4_CMAKE_GENERATOR ?= "Ninja"
     PX4_MAKE = ninja
-    PX4_MAKE_ARGS = 
+    PX4_MAKE_ARGS =
 else
 
 ifdef SYSTEMROOT
@@ -89,6 +89,7 @@ endif
 # --------------------------------------------------------------------
 # describe how to build a cmake config
 define cmake-build
++@if [ $(PX4_CMAKE_GENERATOR) == "Ninja" ] && [ -e $(PWD)/build_$@/Makefile ]; then rm -rf $(PWD)/build_$@; fi
 +@if [ ! -e $(PWD)/build_$@/CMakeCache.txt ]; then git submodule update --init --recursive --force && mkdir -p $(PWD)/build_$@ && cd $(PWD)/build_$@ && cmake .. -G$(PX4_CMAKE_GENERATOR) -DCONFIG=$(1); fi
 +$(PX4_MAKE) -C $(PWD)/build_$@ $(PX4_MAKE_ARGS) $(ARGS)
 endef
diff --git a/cmake/common/px4_base.cmake b/cmake/common/px4_base.cmake
index 5c8ea5787a..bd9cf1f406 100644
--- a/cmake/common/px4_base.cmake
+++ b/cmake/common/px4_base.cmake
@@ -433,6 +433,7 @@ function(px4_add_upload)
 		WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
 		COMMENT "uploading ${BUNDLE}"
 		VERBATIM
+		USES_TERMINAL
 		)
 endfunction()
 
diff --git a/src/firmware/posix/CMakeLists.txt b/src/firmware/posix/CMakeLists.txt
index e4c2855c66..88028d176e 100644
--- a/src/firmware/posix/CMakeLists.txt
+++ b/src/firmware/posix/CMakeLists.txt
@@ -28,6 +28,7 @@ add_custom_target(run_sitl
 	COMMAND Tools/sitl_run.sh "${config_sitl_rcS}" "${config_sitl_debugger}"
 	"${config_sitl_viewer}" "${CMAKE_BINARY_DIR}"
 	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+	USES_TERMINAL
 	)
 add_dependencies(run_sitl mainapp)
 
-- 
GitLab