[Android] internal header
authorJaeyun Jung <jy1210.jung@samsung.com>
Tue, 14 Jan 2025 09:05:15 +0000 (18:05 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Wed, 15 Jan 2025 03:32:34 +0000 (12:32 +0900)
Code clean, add internal header and cleanup script for android build.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
daemon/log.h
daemon/mlops-agent-android.c
daemon/mlops-agent-interface.c
daemon/mlops-agent-internal.h [new file with mode: 0755]
jni/mlops-agent.mk [new file with mode: 0644]
mlops-agent.mk [deleted file]

index 2afe4bf2646a46b6da41d30d567476ac51fee9ec..0d40c201bf02915dcd0d80d4e8f3b8287948bab5 100644 (file)
 #ifndef __LOG_H__
 #define __LOG_H__
 
+#define AGENT_LOG_TAG "ml-agent"
+
 #if defined(__TIZEN__)
 #include <dlog.h>
 
-#define AGENT_LOG_TAG "ml-agent"
-
 #define LOG_V(prio, tag, fmt, arg...) \
   ({ do { \
     dlog_print(prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg);\
 #define ml_logw(fmt, arg...) LOG_V(DLOG_WARN, AGENT_LOG_TAG, fmt, ##arg)
 #define ml_loge(fmt, arg...) LOG_V(DLOG_ERROR, AGENT_LOG_TAG, fmt, ##arg)
 #define ml_logf(fmt, arg...) LOG_V(DLOG_FATAL, AGENT_LOG_TAG, fmt, ##arg)
+#elif defined(__ANDROID__)
+#include <android/log.h>
+
+#define ml_logd(...) \
+    __android_log_print (ANDROID_LOG_DEBUG, AGENT_LOG_TAG, __VA_ARGS__)
+
+#define ml_logi(...) \
+    __android_log_print (ANDROID_LOG_INFO, AGENT_LOG_TAG, __VA_ARGS__)
+
+#define ml_logw(...) \
+    __android_log_print (ANDROID_LOG_WARN, AGENT_LOG_TAG, __VA_ARGS__)
+
+#define ml_loge(...) \
+    __android_log_print (ANDROID_LOG_ERROR, AGENT_LOG_TAG, __VA_ARGS__)
+
+#define ml_logf(...) \
+    __android_log_print (ANDROID_LOG_FATAL, AGENT_LOG_TAG, __VA_ARGS__)
 #else
 #include <glib.h>
 
index 4a9e087a5eeef187b2a8a694eb3f5a38cbe6864a..37b391cfd1c035be30d21862062d209a1f316ef0 100644 (file)
 #include <errno.h>
 #include <glib.h>
 #include <stdint.h>
-#include "include/mlops-agent-interface.h"
 
-#define STR_IS_VALID(s) ((s) && (s)[0] != '\0')
-
-typedef enum
-{
-  ML_AGENT_SERVICE_PIPELINE = 0,
-  ML_AGENT_SERVICE_MODEL,
-  ML_AGENT_SERVICE_RESOURCE,
-  ML_AGENT_SERVICE_END
-} ml_agent_service_type_e;
+#include "log.h"
+#include "mlops-agent-interface.h"
+#include "mlops-agent-internal.h"
 
 /**
  * @brief An interface exported for setting the description of a pipeline.
index 94540b1661c0ad3d9dc61a97ad90c84f3a1df5df..d18a0290de5a8e27a27ddf68deadfe0c0ffa025c 100644 (file)
@@ -14,7 +14,8 @@
 #include <json-glib/json-glib.h>
 
 #include "log.h"
-#include "include/mlops-agent-interface.h"
+#include "mlops-agent-interface.h"
+#include "mlops-agent-internal.h"
 #include "dbus-interface.h"
 #include "model-dbus.h"
 #include "pipeline-dbus.h"
@@ -126,17 +127,7 @@ _resolve_rpk_path_in_json (const char *json_str)
 {
   return g_strdup (json_str);
 }
-#endif
-
-#define STR_IS_VALID(s) ((s) && (s)[0] != '\0')
-
-typedef enum
-{
-  ML_AGENT_SERVICE_PIPELINE = 0,
-  ML_AGENT_SERVICE_MODEL,
-  ML_AGENT_SERVICE_RESOURCE,
-  ML_AGENT_SERVICE_END
-} ml_agent_service_type_e;
+#endif /* __TIZEN__ */
 
 typedef gpointer ml_agent_proxy_h;
 
diff --git a/daemon/mlops-agent-internal.h b/daemon/mlops-agent-internal.h
new file mode 100755 (executable)
index 0000000..b2aead4
--- /dev/null
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: Apache-2.0 */
+/**
+ * @file    mlops-agent-internal.h
+ * @date    14 January 2025
+ * @brief   Internal header for ml-agent interface.
+ * @see     https://github.com/nnstreamer/deviceMLOps.MLAgent
+ * @author  Jaeyun Jung <jy1210.jung@samsung.com>
+ * @bug     No known bugs except for NYI items
+ */
+
+#ifndef __MLOPS_AGENT_INTERNAL_H__
+#define __MLOPS_AGENT_INTERNAL_H__
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <stdint.h>
+
+#define STR_IS_VALID(s) ((s) && (s)[0] != '\0')
+
+/**
+ * @brief Internal enumeration for service type.
+ */
+typedef enum
+{
+  ML_AGENT_SERVICE_PIPELINE = 0,
+  ML_AGENT_SERVICE_MODEL,
+  ML_AGENT_SERVICE_RESOURCE,
+  ML_AGENT_SERVICE_END
+} ml_agent_service_type_e;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __MLOPS_AGENT_INTERNAL_H__ */
diff --git a/jni/mlops-agent.mk b/jni/mlops-agent.mk
new file mode 100644 (file)
index 0000000..706d573
--- /dev/null
@@ -0,0 +1,9 @@
+ifndef MLOPS_AGENT_ROOT
+$(error MLOPS_AGENT_ROOT is not defined!)
+endif
+
+# mlops agent headers
+MLOPS_AGENT_INCLUDE := $(MLOPS_AGENT_ROOT)/daemon/include
+
+# mlops agent sources
+MLOPS_AGENT_SRCS := $(MLOPS_AGENT_ROOT)/daemon/mlops-agent-android.c
diff --git a/mlops-agent.mk b/mlops-agent.mk
deleted file mode 100644 (file)
index 66c8b4c..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# mlops agent headers
-MLOPS_AGENT_INCLUDE := $(MLOPS_AGENT_ROOT)/daemon/include
-
-# mlops agent sources
-MLOPS_AGENT_SRCS := $(MLOPS_AGENT_ROOT)/daemon/mlops-agent-android.c
-