Skip to content

Commit 05927b1

Browse files
lauxinwjren1
authored andcommitted
tools: acrn-crashlog: compile without telemetrics client
Define a macro HAVE_TELEMETRICS_CLIENT to distinguish the compiling environment which is not include telemetrics client. Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com> Reviewed-by: Jack Ren <jack.ren@intel.com>
1 parent a9e36bd commit 05927b1

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

tools/acrn-crashlog/Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@ export INCLUDE
1919
export BUILDDIR
2020
export CC
2121
export RM
22-
export CFLAGS
2322

24-
SYSTEMD_LIBS = -lsystemd
23+
EXTRA_LIBS = -lsystemd
2524
LDCNF := $(shell ldconfig -p)
2625
LIB_EXIST = $(findstring libsystemd-journal.so, $(LDCNF))
2726
ifeq ($(strip $(LIB_EXIST)),libsystemd-journal.so)
28-
SYSTEMD_LIBS = -lsystemd-journal
27+
EXTRA_LIBS = -lsystemd-journal
28+
endif
29+
LIB_EXIST = $(findstring libtelemetry.so, $(LDCNF))
30+
ifeq ($(strip $(LIB_EXIST)),libtelemetryxx.so)
31+
CFLAGS += -DHAVE_TELEMETRICS_CLIENT
32+
EXTRA_LIBS += -ltelemetry
2933
endif
30-
export SYSTEMD_LIBS
34+
export CFLAGS
35+
export EXTRA_LIBS
3136

3237
.PHONY:all
3338
all:

tools/acrn-crashlog/acrnprobe/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ MINOR_VERSION=0
33

44
BASEDIR := $(shell pwd)
55

6-
LIBS = -lpthread -lxml2 -lcrypto -lrt $(SYSTEMD_LIBS) -ltelemetry
6+
LIBS = -lpthread -lxml2 -lcrypto -lrt $(EXTRA_LIBS)
77
INCLUDE += -I $(BASEDIR)/include -I /usr/include/libxml2
88
CFLAGS += $(INCLUDE)
99
CFLAGS += -g -O0 -std=gnu11

tools/acrn-crashlog/acrnprobe/event_handler.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ static void *event_handle(void *unused __attribute__((unused)))
157157
if (!sender)
158158
continue;
159159

160-
sender->send(e);
160+
if (sender->send)
161+
sender->send(e);
161162
}
162163

163164
if ((e->dir))

tools/acrn-crashlog/acrnprobe/sender.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include "property.h"
2424
#include "startupreason.h"
2525
#include "log_sys.h"
26+
27+
#ifdef HAVE_TELEMETRICS_CLIENT
2628
#include "telemetry.h"
2729

2830
#define CRASH_SEVERITY 4
@@ -34,6 +36,7 @@ struct telemd_data_t {
3436
char *eventid;
3537
uint32_t severity;
3638
};
39+
#endif
3740

3841
/* get_log_file_* only used to copy regular file which can be mmaped */
3942
static void get_log_file_complete(struct log_t *log, char *desdir)
@@ -272,6 +275,7 @@ static void get_log_cmd(struct log_t *log, char *desdir)
272275
out_via_fork(log, desdir);
273276
}
274277

278+
#ifdef HAVE_TELEMETRICS_CLIENT
275279
static bool telemd_send_data(char *payload, char *eventid, uint32_t severity,
276280
char *class)
277281
{
@@ -389,6 +393,7 @@ static void telemd_get_log(struct log_t *log, void *data)
389393
telemd_send_data(msg, d->eventid, d->severity, d->class);
390394
free(msg);
391395
}
396+
#endif
392397

393398
static void crashlog_get_log(struct log_t *log, void *data)
394399
{
@@ -427,6 +432,7 @@ static void crashlog_get_log(struct log_t *log, void *data)
427432
LOGW("get (%s) spend %ds\n", log->name, spent);
428433
}
429434

435+
#ifdef HAVE_TELEMETRICS_CLIENT
430436
static void telemd_send_crash(struct event_t *e)
431437
{
432438
struct crash_t *crash;
@@ -774,6 +780,7 @@ static void telemd_send(struct event_t *e)
774780
LOGE("unsupoorted event type %d\n", e->event_type);
775781
}
776782
}
783+
#endif
777784

778785
static void crashlog_send_crash(struct event_t *e)
779786
{
@@ -1122,9 +1129,11 @@ int init_sender(void)
11221129
ret = prepare_history();
11231130
if (ret)
11241131
return -1;
1132+
#ifdef HAVE_TELEMETRICS_CLIENT
11251133
} else if (!strncmp(sender->name, "telemd",
11261134
strlen(sender->name))) {
11271135
sender->send = telemd_send;
1136+
#endif
11281137
}
11291138
}
11301139

tools/acrn-crashlog/usercrash/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ all: include/version.h check_obj usercrash_s usercrash_c debugger
66
CURRDIR := $(shell pwd)
77
INCLUDE += -I $(CURRDIR)/include/
88

9-
LIBS = -levent -lpthread $(SYSTEMD_LIBS)
9+
LIBS = -levent -lpthread $(EXTRA_LIBS)
1010

1111
usercrash_s: $(BUILDDIR)/usercrash/obj/protocol.o \
1212
$(BUILDDIR)/usercrash/obj/server.o \

0 commit comments

Comments
 (0)