MLECO-2921: Minor changes for HAL projects

Ensuring individual HAL projects can be configured without the
need to be wrapped. Tests can now be added to build individual
components and check for any unintended dependencies creeping
in.

Change-Id: I057699c3c3cc0fc280615db30a25fbe4c28ae8ea
Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
diff --git a/source/hal/CMakeLists.txt b/source/hal/CMakeLists.txt
index 74256bb..8f32c00 100644
--- a/source/hal/CMakeLists.txt
+++ b/source/hal/CMakeLists.txt
@@ -22,7 +22,6 @@
 cmake_minimum_required(VERSION 3.15.6)
 
 set(HAL_TARGET hal)
-
 project(${HAL_TARGET}
     DESCRIPTION     "HAL library"
     LANGUAGES       C CXX)
diff --git a/source/hal/source/components/lcd/CMakeLists.txt b/source/hal/source/components/lcd/CMakeLists.txt
index 7378713..d260091 100644
--- a/source/hal/source/components/lcd/CMakeLists.txt
+++ b/source/hal/source/components/lcd/CMakeLists.txt
@@ -52,6 +52,14 @@
     PRIVATE
     CLCD_CONFIG_BASE=${CLCD_CONFIG_BASE})
 
+## Logging utilities:
+if (NOT TARGET log)
+    if (NOT DEFINED LOG_PROJECT_DIR)
+        message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.")
+    endif()
+    add_subdirectory(${LOG_PROJECT_DIR} ${CMAKE_BINARY_DIR}/log)
+endif()
+
 ## Add dependencies
 target_link_libraries(${LCD_MPS3_COMPONENT_TARGET} PUBLIC
     ${LCD_IFACE_TARGET}
diff --git a/source/hal/source/components/npu/CMakeLists.txt b/source/hal/source/components/npu/CMakeLists.txt
index 9d0bf42..48f21bc 100644
--- a/source/hal/source/components/npu/CMakeLists.txt
+++ b/source/hal/source/components/npu/CMakeLists.txt
@@ -40,6 +40,15 @@
 set(ETHOS_U_PRIV_ENABLED "1"             CACHE STRING "Ethos-U NPU Privilege enable")
 
 # Driver needs to know what MAC configuration to build for.
+if (NOT DEFINED ETHOS_U_NPU_CONFIG_ID)
+    set(ETHOS_U_NPU_CONFIG_ID "H128")
+endif()
+
+## Memory mode target definition
+if (NOT DEFINED ETHOS_U_NPU_ID)
+    set(ETHOS_U_NPU_ID U55)
+endif()
+
 if(ETHOS_U_NPU_CONFIG_ID MATCHES "^[A-Z]([0-9]+$)")
     set(ETHOSU_MACS ${CMAKE_MATCH_1})
 else()
@@ -48,11 +57,6 @@
 set(ETHOSU_TARGET_NPU_CONFIG
         "ethos-${ETHOS_U_NPU_ID}-${ETHOSU_MACS}" CACHE STRING "Target Ethos-U configuration for driver.")
 
-## Memory mode target definition
-if (NOT DEFINED ETHOS_U_NPU_ID)
-    set(ETHOS_U_NPU_ID U55)
-endif()
-
 if (NOT DEFINED ETHOS_U_NPU_MEMORY_MODE)
     set(ETHOS_U_NPU_MEMORY_MODE Shared_Sram)
 endif()
@@ -80,6 +84,14 @@
 # Include the build for Ethos-U driver
 add_subdirectory(${ETHOS_U_NPU_DRIVER_SRC_PATH} ${CMAKE_BINARY_DIR}/ethos-u-driver)
 
+## Logging utilities:
+if (NOT TARGET log)
+    if (NOT DEFINED LOG_PROJECT_DIR)
+        message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.")
+    endif()
+    add_subdirectory(${LOG_PROJECT_DIR} ${CMAKE_BINARY_DIR}/log)
+endif()
+
 # For Ethos-U driver, we need to override the default region configs
 # Region numbers are decided by Vela and they do not need to conform to set rules.
 # Traditionally they have been used as:
diff --git a/source/hal/source/components/npu_ta/CMakeLists.txt b/source/hal/source/components/npu_ta/CMakeLists.txt
index 73bbef7..edb1fdd 100644
--- a/source/hal/source/components/npu_ta/CMakeLists.txt
+++ b/source/hal/source/components/npu_ta/CMakeLists.txt
@@ -53,8 +53,17 @@
             " be defined when ETHOS_U_NPU_ENABLED=${ETHOS_U_NPU_ENABLED}")
 endif()
 
+## TA driver
 add_subdirectory(${ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH} ${CMAKE_BINARY_DIR}/timing_adapter)
 
+## Logging utilities:
+if (NOT TARGET log)
+    if (NOT DEFINED LOG_PROJECT_DIR)
+        message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.")
+    endif()
+    add_subdirectory(${LOG_PROJECT_DIR} ${CMAKE_BINARY_DIR}/log)
+endif()
+
 # Create static library
 add_library(${ETHOS_U_NPU_TA_COMPONENT} STATIC)
 
diff --git a/source/hal/source/platform/mps3/CMakeLists.txt b/source/hal/source/platform/mps3/CMakeLists.txt
index 2f0174b..2c03dee 100644
--- a/source/hal/source/platform/mps3/CMakeLists.txt
+++ b/source/hal/source/platform/mps3/CMakeLists.txt
@@ -85,6 +85,14 @@
 ## Platform component: PMU
 add_subdirectory(${COMPONENTS_DIR}/platform_pmu ${CMAKE_BINARY_DIR}/platform_pmu)
 
+## Logging utilities:
+if (NOT TARGET log)
+    if (NOT DEFINED LOG_PROJECT_DIR)
+        message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.")
+    endif()
+    add_subdirectory(${LOG_PROJECT_DIR} ${CMAKE_BINARY_DIR}/log)
+endif()
+
 # Add dependencies:
 target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC
     log
diff --git a/source/hal/source/platform/mps3/source/timer_mps3.c b/source/hal/source/platform/mps3/source/timer_mps3.c
index 7ce3002..b6e3c7c 100644
--- a/source/hal/source/platform/mps3/source/timer_mps3.c
+++ b/source/hal/source/platform/mps3/source/timer_mps3.c
@@ -98,6 +98,8 @@
         "NPU TOTAL",
         unit_cycles,
         counters);
+#else
+    UNUSED(i);
 #endif /* defined (ARM_NPU) */
 
 #if defined(CPU_PROFILE_ENABLED)
@@ -126,7 +128,6 @@
     UNUSED(Get_SysTick_Cycle_Count);
 #if !defined(ARM_NPU)
     UNUSED(add_pmu_counter);
-    UNUSED(i);
 #endif /* !defined(ARM_NPU) */
 #endif /* !defined(CPU_PROFILE_ENABLED) */
 }
diff --git a/source/hal/source/platform/native/source/timer_native.c b/source/hal/source/platform/native/source/timer_native.c
index 7cd832c..ae5b497 100644
--- a/source/hal/source/platform/native/source/timer_native.c
+++ b/source/hal/source/platform/native/source/timer_native.c
@@ -20,8 +20,6 @@
 
 #include "timer_native.h"
 
-#include "log_macros.h"
-
 #include <time.h>
 #include <string.h>
 
diff --git a/source/hal/source/platform/simple/CMakeLists.txt b/source/hal/source/platform/simple/CMakeLists.txt
index 119f711..1b8da30 100644
--- a/source/hal/source/platform/simple/CMakeLists.txt
+++ b/source/hal/source/platform/simple/CMakeLists.txt
@@ -77,6 +77,14 @@
 ## Platform component: PMU
 add_subdirectory(${COMPONENTS_DIR}/platform_pmu ${CMAKE_BINARY_DIR}/platform_pmu)
 
+## Logging utilities:
+if (NOT TARGET log)
+    if (NOT DEFINED LOG_PROJECT_DIR)
+        message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.")
+    endif()
+    add_subdirectory(${LOG_PROJECT_DIR} ${CMAKE_BINARY_DIR}/log)
+endif()
+
 # Add dependencies:
 target_link_libraries(${PLATFORM_DRIVERS_TARGET}  PUBLIC
         cmsis_device
diff --git a/source/hal/source/platform/simple/source/timer_simple_platform.c b/source/hal/source/platform/simple/source/timer_simple_platform.c
index 3bb91d0..8086abd 100644
--- a/source/hal/source/platform/simple/source/timer_simple_platform.c
+++ b/source/hal/source/platform/simple/source/timer_simple_platform.c
@@ -90,6 +90,8 @@
             "NPU TOTAL",
             "cycles",
             counters);
+#else  /* defined (ARM_NPU) */
+    UNUSED(i);
 #endif /* defined (ARM_NPU) */
 
 #if defined(CPU_PROFILE_ENABLED)
@@ -104,7 +106,6 @@
     UNUSED(Get_SysTick_Cycle_Count);
 #if !defined(ARM_NPU)
     UNUSED(add_pmu_counter);
-    UNUSED(i);
 #endif /* !defined(ARM_NPU) */
 #endif /* !defined(CPU_PROFILE_ENABLED) */
 }