Simplify hello world example, fix build for external
Test: compile hello world for qcom_hexagonv60_nanohub and
google_hexagonv62_slpi
Change-Id: I1e2cf37eabb09c82795751b69ba4189ef3f43872
diff --git a/apps/hello_world/Makefile b/apps/hello_world/Makefile
index c98268d..981d01c 100644
--- a/apps/hello_world/Makefile
+++ b/apps/hello_world/Makefile
@@ -5,13 +5,22 @@
# Environment Checks ###########################################################
ifeq ($(CHRE_PREFIX),)
-$(error "The CHRE_PREFIX environment variable must be set to a path to the \
- CHRE project root. Example: export CHRE_PREFIX=$$HOME/chre")
+ifneq ($(ANDROID_BUILD_TOP),)
+CHRE_PREFIX = $(ANDROID_BUILD_TOP)/system/chre
+else
+$(error "You must run 'lunch' to setup ANDROID_BUILD_TOP, or explicitly define \
+ the CHRE_PREFIX environment variable to point to the CHRE root \
+ directory.")
+endif
endif
# Nanoapp Configuration ########################################################
NANOAPP_NAME = hello_world
+NANOAPP_ID = 0x0123456789000001
+NANOAPP_VERSION = 0x00000001
+
+NANOAPP_NAME_STRING = \"Hello\ World\"
# Common Compiler Flags ########################################################
diff --git a/apps/hello_world/hello_world.cc b/apps/hello_world/hello_world.cc
index 8a7051b..3b49b75 100644
--- a/apps/hello_world/hello_world.cc
+++ b/apps/hello_world/hello_world.cc
@@ -15,11 +15,15 @@
*/
#include <chre.h>
-#include <cinttypes>
+#include <inttypes.h>
-#include "chre/util/nanoapp/log.h"
-
-#define LOG_TAG "[HelloWorld]"
+/**
+ * @file
+ * A very basic example nanoapp that just logs activity in its entry points.
+ * Note that code wrapped in #ifdef CHRE_NANOAPP_INTERNAL is only relevant when
+ * a nanoapp is to be statically built into the CHRE system binary, which would
+ * make it a "system nanoapp" rather than a true dynamically loadable nanoapp.
+ */
#ifdef CHRE_NANOAPP_INTERNAL
namespace chre {
@@ -27,20 +31,19 @@
#endif // CHRE_NANOAPP_INTERNAL
bool nanoappStart() {
- LOGI("App started on platform ID %" PRIx64, chreGetPlatformId());
+ chreLog(CHRE_LOG_INFO, "Hello, world!");
return true;
}
void nanoappHandleEvent(uint32_t senderInstanceId,
uint16_t eventType,
- const void *eventData) {
- uint64_t currentTime = chreGetTime();
- LOGI("Received event 0x%" PRIx16 " at time %" PRIu64,
- eventType, currentTime);
+ const void * /*eventData*/) {
+ chreLog(CHRE_LOG_INFO, "Received event 0x%" PRIx16 " from 0x%" PRIx32 " at "
+ "time %" PRIu64, eventType, senderInstanceId, chreGetTime());
}
void nanoappEnd() {
- LOGI("Stopped");
+ chreLog(CHRE_LOG_INFO, "Goodbye, world!");
}
#ifdef CHRE_NANOAPP_INTERNAL