Skip to content

Commit de0c990

Browse files
Felix Herrmannssugiura
Felix Herrmann
authored andcommitted
set DLT_NETWORK_TRACE_ENABLE by cmakedefine
Signed-off-by: Felix Herrmann <[email protected]> Signed-off-by: KHANH LUONG HONG DUY <[email protected]>
1 parent ff7e65a commit de0c990

File tree

7 files changed

+64
-4
lines changed

7 files changed

+64
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ automotive-dlt.spec
55
automotive-dlt.pc
66
config.h
77
include/dlt/dlt_version.h
8+
include/dlt/dlt_user.h
89
.project
910
.cproject
1011
.settings

Android.bp

+15-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ genrule {
4747
out: ["dlt_version.h"],
4848
}
4949

50+
// Generate dlt_user.h without Cmake
51+
genrule {
52+
name: "dlt_user_header",
53+
tool_files: ["util/create_dlt_user.py"],
54+
srcs: [
55+
"include/dlt/dlt_user.h.in",
56+
],
57+
cmd: "$(location util/create_dlt_user.py) $(in) $(out)",
58+
out: ["dlt_user.h"],
59+
}
60+
5061
cc_binary {
5162

5263
name: "dlt-daemon",
@@ -106,7 +117,10 @@ cc_library_shared {
106117
"include/dlt",
107118
],
108119

109-
export_generated_headers: ["dlt_version_header"],
120+
export_generated_headers: [
121+
"dlt_version_header",
122+
"dlt_user_header"
123+
],
110124

111125
srcs: [
112126
"src/lib/dlt_client.c",

CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ endif()
9696

9797
include_directories(
9898
${PROJECT_SOURCE_DIR}
99-
${PROJECT_SOURCE_DIR}/include/dlt
10099
${PROJECT_BINARY_DIR}/include/dlt
100+
${PROJECT_SOURCE_DIR}/include/dlt
101101
${PROJECT_SOURCE_DIR}/src/shared
102102
${PROJECT_SOURCE_DIR}/src/core_dump_handler
103103
${PROJECT_SOURCE_DIR}/src/offlinelogstorage
@@ -181,6 +181,7 @@ add_subdirectory(cmake)
181181
if(HAVE_MQUEUE_H AND HAVE_FUNC_MQOPEN AND HAVE_FUNC_MQCLOSE AND
182182
HAVE_FUNC_MQUNLINK AND HAVE_FUNC_MQSEND AND HAVE_FUNC_MQRECEIVE)
183183
add_definitions(-DDLT_NETWORK_TRACE_ENABLE)
184+
set(DLT_NETWORK_TRACE_ENABLE 1)
184185
else()
185186
message(STATUS "Disable network trace interface since message queue is not supported")
186187
endif()

doc/dlt_for_developers.md

+3
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,9 @@ be set to 0, and the corresponding pointer must be set to NULL.
674674
DLT_TRACE_NETWORK(mycontext, DLT_NW_TRACE_CAN, headerlen, header, payloadlen, payload);
675675
```
676676

677+
Note that when DLT_NETWORK_TRACE_ENABLE is disabled, the mqueue.h will not be
678+
included.
679+
677680
### DLT C++ Extension
678681

679682
The DLT C++ extension was added to DLT in version 2.13. This approach solves

include/dlt/CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
# For further information see http://www.genivi.org/.
1414
#######
1515

16-
install(FILES dlt.h dlt_user.h dlt_user_macros.h dlt_client.h dlt_protocol.h
16+
configure_file(dlt_user.h.in dlt_user.h)
17+
18+
install(FILES dlt.h dlt_user_macros.h dlt_client.h dlt_protocol.h
1719
dlt_common.h dlt_types.h dlt_shm.h dlt_offline_trace.h
1820
dlt_filetransfer.h dlt_common_api.h
19-
${PROJECT_BINARY_DIR}/include/dlt/dlt_version.h
21+
${CMAKE_CURRENT_BINARY_DIR}/dlt_version.h
22+
${CMAKE_CURRENT_BINARY_DIR}/dlt_user.h
2023
DESTINATION include/dlt
2124
COMPONENT devel)
2225

include/dlt/dlt_user.h include/dlt/dlt_user.h.in

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
\{
7575
*/
7676

77+
#ifndef DLT_NETWORK_TRACE_ENABLE
78+
#cmakedefine DLT_NETWORK_TRACE_ENABLE
79+
#endif
80+
7781
#ifdef DLT_NETWORK_TRACE_ENABLE
7882
# include <mqueue.h>
7983
#else

util/create_dlt_user_h.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/python3
2+
# This software has been developed by Advanced Driver Information Technology.
3+
# Copyright(c) 2020 Advanced Driver Information Technology GmbH,
4+
# Advanced Driver Information Technology Corporation, Robert Bosch GmbH,
5+
# Robert Bosch Car Multimedia GmbH and DENSO Corporation.
6+
#
7+
# This file is part of GENIVI Project DLT - Diagnostic Log and Trace.
8+
#
9+
# This Source Code Form is subject to the terms of the
10+
# Mozilla Public License (MPL), v. 2.0.
11+
# If a copy of the MPL was not distributed with this file,
12+
# You can obtain one at http://mozilla.org/MPL/2.0/.
13+
#
14+
# For further information see http://www.genivi.org/.
15+
import pathlib
16+
import argparse
17+
18+
19+
def main(header_in_file, header_out_file):
20+
header_in = pathlib.Path(header_in_file)
21+
header_out = pathlib.Path(header_out_file)
22+
with header_in.open() as hi, header_out.open('w') as ho:
23+
for line in hi:
24+
if line.startswith("#cmakedefine"):
25+
continue
26+
ho.write(line)
27+
28+
29+
if __name__ == '__main__':
30+
parser = argparse.ArgumentParser()
31+
parser.add_argument('header_in')
32+
parser.add_argument('header_out')
33+
args = parser.parse_args()
34+
main(args.header_in, args.header_out)

0 commit comments

Comments
 (0)