Skip to content

Commit

Permalink
[Android] internal header
Browse files Browse the repository at this point in the history
Code clean, add internal header and cleanup script for android build.

Signed-off-by: Jaeyun Jung <[email protected]>
  • Loading branch information
jaeyun-jung committed Jan 15, 2025
1 parent cc4fa1c commit dd9e8b1
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 25 deletions.
21 changes: 19 additions & 2 deletions daemon/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
#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);\
Expand All @@ -33,6 +33,23 @@
#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>

Expand Down
13 changes: 3 additions & 10 deletions daemon/mlops-agent-android.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,10 @@
#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.
Expand Down
15 changes: 3 additions & 12 deletions daemon/mlops-agent-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;

Expand Down
35 changes: 35 additions & 0 deletions daemon/mlops-agent-internal.h
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
* @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__ */
5 changes: 4 additions & 1 deletion mlops-agent.mk → jni/mlops-agent.mk
Original file line number Diff line number Diff line change
@@ -1,6 +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

0 comments on commit dd9e8b1

Please sign in to comment.