Fix tracing in libts
Libts deployments did not include posix_trace.c in the build and as
a result setting TRACE_LEVEL to any value above TRACE_LEVEL_NONE
resulted in a build error.
- Add the missing C file to the build to fix this error.
- Make the arm-linux version of libts to implement tracing
the same way as linux-pc.
Change-Id: I1db6117a0e8aa4955de063e7b22618d4a254973f
Signed-off-by: Gabor Toth <gabor.toth2@arm.com>
diff --git a/environments/arm-linux/component.cmake b/environments/arm-linux/component.cmake
new file mode 100644
index 0000000..97229bd
--- /dev/null
+++ b/environments/arm-linux/component.cmake
@@ -0,0 +1,25 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+if (NOT DEFINED TGT)
+ message(FATAL_ERROR "mandatory parameter TGT is not defined.")
+endif()
+
+if (NOT DEFINED TRACE_PREFIX)
+ message(FATAL_ERROR "mandatory parameter TRACE_PREFIX is not defined.")
+endif()
+
+# Default to trace output disabled
+set(TRACE_LEVEL "TRACE_LEVEL_NONE" CACHE STRING "Trace level")
+
+target_compile_definitions(${TGT} PRIVATE
+ TRACE_LEVEL=${TRACE_LEVEL}
+ TRACE_PREFIX="${TRACE_PREFIX}"
+)
+
+target_sources(${TGT} PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/posix_trace.c"
+ )
diff --git a/environments/arm-linux/posix_trace.c b/environments/arm-linux/posix_trace.c
new file mode 100644
index 0000000..f219b6d
--- /dev/null
+++ b/environments/arm-linux/posix_trace.c
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
+ */
+
+#include <stdio.h>
+
+#include "trace.h"
+
+#if TRACE_LEVEL >= TRACE_LEVEL_ERROR
+
+void trace_puts(const char *str)
+{
+ puts(str);
+}
+
+#endif /* TRACE_LEVEL >= TRACE_LEVEL_ERROR */