Upgrade nanopb to v0.4.8

Upgrade the nanopb to 0.4.8 and add the following fixes:
  - remove the nanopb patch as it has become obsolete.
  - stop using the nanopb protoc wrapper when building the generator as
    this seems to cause build issues.
  - use the new nanopb_PYTHON_INSTDIR_OVERRIDE variable to set the
    install location for the generator. Modify TS cmake script to search
    the generator in the install content instead of the nanopb source.
  - pass discovered python settings to nanopb build using the initial
    cache. This speeds up the build and allows easier control of python
    discovery for integration systems.
  - solve nanopb os.makedirs race by creating the directory from cmake.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Gyorgy Szing <gyorgy.szing@arm.com>
Change-Id: Idc36cf9a446493e4eb994fc9808f96277f11c0bc
diff --git a/external/nanopb/nanopb-init-cache.cmake.in b/external/nanopb/nanopb-init-cache.cmake.in
index fb8104d..c53b6e5 100644
--- a/external/nanopb/nanopb-init-cache.cmake.in
+++ b/external/nanopb/nanopb-init-cache.cmake.in
@@ -12,11 +12,18 @@
 set(nanopb_BUILD_RUNTIME On CACHE BOOL "")
 set(nanopb_BUILD_GENERATOR On CACHE BOOL "")
 set(nanopb_MSVC_STATIC_RUNTIME Off BOOL "")
-set(nanopb_PROTOC_PATH ${CMAKE_SOURCE_DIR}/generator/protoc CACHE STRING "")
+
+# Specify location of python binary and avoid discovery.
+set(Python_EXECUTABLE "@Python_EXECUTABLE@" CACHE PATH "Location of python3 executable")
 
 string(TOUPPER @CMAKE_CROSSCOMPILING@ CMAKE_CROSSCOMPILING) # CMake expects TRUE
 if (CMAKE_CROSSCOMPILING)
 	set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE STRING "")
 endif()
 
+# Override the install directory of the generator. TS will first look at
+# NEWLIB_INSTALL_DIR (aka. BUILD_INSTALL_DIR), then let cmake do system specific
+# search.
+set(nanopb_PYTHON_INSTDIR_OVERRIDE "@BUILD_INSTALL_DIR@/lib/python" CACHE PATH "")
+
 @_cmake_fragment@