Commit c3f84884 authored by Robert Schmidt's avatar Robert Schmidt

Generate T headers using cmake

parent 392ef79b
...@@ -1882,43 +1882,19 @@ add_library(oai_iqplayer MODULE ...@@ -1882,43 +1882,19 @@ add_library(oai_iqplayer MODULE
) )
set(CMAKE_MODULE_PATH "${OPENAIR_DIR}/cmake_targets/tools/MODULES" "${CMAKE_MODULE_PATH}") set(CMAKE_MODULE_PATH "${OPENAIR_DIR}/cmake_targets/tools/MODULES" "${CMAKE_MODULE_PATH}")
#include T directory even if the T is off because T macros are in the code # include T directory even if the T is off because T macros are in the code
#no matter what # no matter what. Note: sone files are generated, so we have both source and
include_directories("${OPENAIR_DIR}/common/utils/T") # binary directories
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common/utils/T
${CMAKE_CURRENT_BINARY_DIR}/common/utils/T)
if (${T_TRACER}) if (${T_TRACER})
set(T_SOURCE set(T_SOURCE
${OPENAIR_DIR}/common/utils/T/T_IDs.h
${OPENAIR_DIR}/common/utils/T/T.c ${OPENAIR_DIR}/common/utils/T/T.c
${OPENAIR_DIR}/common/utils/T/local_tracer.c) ${OPENAIR_DIR}/common/utils/T/local_tracer.c)
set(T_LIB "rt") set(T_LIB "rt")
endif (${T_TRACER}) endif (${T_TRACER})
#Some files in the T directory are generated.
#This rule and the following deal with it.
add_custom_command (
OUTPUT ${OPENAIR_DIR}/common/utils/T/T_IDs.h
COMMAND make check_vcd
WORKING_DIRECTORY ${OPENAIR_DIR}/common/utils/T
DEPENDS ${OPENAIR_DIR}/common/utils/T/T_messages.txt
${OPENAIR_DIR}/common/utils/LOG/vcd_signal_dumper.c
${OPENAIR_DIR}/common/utils/LOG/vcd_signal_dumper.h
)
execute_process (
COMMAND make check_vcd
WORKING_DIRECTORY ${OPENAIR_DIR}/common/utils/T
)
#This rule is specifically needed to generate T files
#before anything else in a project that uses the T.
#See below, there are some 'add_dependencies' showing that.
#Basically we create a custom target and we make other
#targets depend on it. That forces cmake to generate
#T files before anything else.
add_custom_target (
generate_T
DEPENDS ${OPENAIR_DIR}/common/utils/T/T_IDs.h
)
################################# #################################
# add executables for operation # add executables for operation
...@@ -2380,6 +2356,7 @@ if (${T_TRACER}) ...@@ -2380,6 +2356,7 @@ if (${T_TRACER})
oai_eth_transpro oai_mobipass coding HASHTABLE UTIL OMG_SUMO oai_eth_transpro oai_mobipass coding HASHTABLE UTIL OMG_SUMO
SECURITY SCHED_LIB SCHED_NR_LIB SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB default_sched remote_sched RAL SECURITY SCHED_LIB SCHED_NR_LIB SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB default_sched remote_sched RAL
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_VNF_LIB NFAPI_USER_LIB NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_VNF_LIB NFAPI_USER_LIB
MISC_NFAPI_LTE_LIB MISC_NFAPI_NR_LIB
PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX
L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON MAC_NR MAC_UE_NR ngap L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON MAC_NR MAC_UE_NR ngap
CN_UTILS GTPV1U SCTP_CLIENT MME_APP LIB_NAS_UE NB_IoT SIMU SIMU_ETH OPENAIR0_LIB CN_UTILS GTPV1U SCTP_CLIENT MME_APP LIB_NAS_UE NB_IoT SIMU SIMU_ETH OPENAIR0_LIB
......
...@@ -8,3 +8,4 @@ if(ENABLE_WEBSRV) ...@@ -8,3 +8,4 @@ if(ENABLE_WEBSRV)
add_subdirectory(websrv) add_subdirectory(websrv)
endif() endif()
add_subdirectory(T)
add_executable(genids genids.c)
add_custom_command(OUTPUT T_IDs.h
COMMAND ./genids ${CMAKE_CURRENT_SOURCE_DIR}/T_messages.txt T_IDs.h
DEPENDS genids
COMMENT "Generating T_IDs.h from T_messages.txt"
)
add_custom_command(OUTPUT T_messages.txt.h
COMMAND xxd -i T_messages.txt ${CMAKE_CURRENT_BINARY_DIR}/T_messages.txt.h
COMMENT "Generating T_messages.txt.h from T_messages.txt"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_executable(_check_vcd check_vcd.c tracer/database.c tracer/utils.c T_IDs.h T_messages.txt.h)
target_include_directories(_check_vcd PRIVATE
.. ../itti ../../../openair2/COMMON tracer
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_options(_check_vcd PRIVATE -Wall)
target_link_libraries(_check_vcd PRIVATE m pthread)
add_custom_target(check_vcd
COMMAND _check_vcd ${CMAKE_CURRENT_SOURCE_DIR}/T_messages.txt ${CMAKE_CURRENT_SOURCE_DIR}/../LOG/vcd_signal_dumper.h
DEPENDS _check_vcd
COMMENT "Checking validity of VCD files"
)
# This rule is specifically needed to generate T files before anything else in
# a project that uses the T.
# See root CMakeLists.txt, there are some 'add_dependencies' showing that.
# Basically we create a custom target and we make other targets depend on it.
# That forces cmake to generate T files before anything else.
add_custom_target(generate_T DEPENDS T_IDs.h check_vcd)
# even if T is off, we need the headers as many targets depend on it
# for this, create an INTERFACE (header-only) library T_headers. To ensure the
# headers have really been created, we make this headers library explicitly
# depend on the generated headers.
add_library(T_headers INTERFACE)
add_dependencies(T_headers T_IDs.h T_messages.txt.h)
target_include_directories(T_headers INTERFACE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
...@@ -20,7 +20,7 @@ T_IDs.h: $(GENIDS) T_messages.txt ...@@ -20,7 +20,7 @@ T_IDs.h: $(GENIDS) T_messages.txt
check_vcd: T_IDs.h T_messages.txt.h check_vcd: T_IDs.h T_messages.txt.h
gcc -Wall -I. -I.. -I../itti -I../../../openair2/COMMON -Itracer -o _check_vcd check_vcd.c tracer/database.c tracer/utils.c -lm -pthread gcc -Wall -I. -I.. -I../itti -I../../../openair2/COMMON -Itracer -o _check_vcd check_vcd.c tracer/database.c tracer/utils.c -lm -pthread
./_check_vcd || (rm -f ./_check_vcd ./T_IDs.h ./T_messages.txt.h && false) ./_check_vcd T_messages.txt ../LOG/vcd_signal_dumper.h || (rm -f ./_check_vcd ./T_IDs.h ./T_messages.txt.h && false)
rm -f ./_check_vcd rm -f ./_check_vcd
.PHONY: check_vcd .PHONY: check_vcd
......
...@@ -67,14 +67,17 @@ void err(char *fmt, ...) ...@@ -67,14 +67,17 @@ void err(char *fmt, ...)
exit(1); exit(1);
} }
int main(void) int main(int argc, char *argv[])
{ {
/* to disable the checks done by this program, uncomment the following /* to disable the checks done by this program, uncomment the following
* line, ie. remove the leading '//' * line, ie. remove the leading '//'
*/ */
//return 0; //return 0;
void *database = parse_database("T_messages.txt"); if (argc != 3) err("usage: %s <T_messages.txt> <vcd_signal_dumper.h>", argv[0]);
char *T_msg_txt = argv[1];
char *vcd_sig_dmp = argv[2];
void *database = parse_database(T_msg_txt);
int number_of_events; int number_of_events;
int first_var = -1; int first_var = -1;
int last_var; int last_var;
...@@ -212,8 +215,8 @@ int main(void) ...@@ -212,8 +215,8 @@ int main(void)
* VCD_VARIABLE_ABC or VCD_FUNCTION_XYZ * VCD_VARIABLE_ABC or VCD_FUNCTION_XYZ
*/ */
i = first_var; i = first_var;
in = fopen("../LOG/vcd_signal_dumper.h", "r"); in = fopen(vcd_sig_dmp, "r");
if (in == NULL) err("could not open ../LOG/vcd_signal_dumper.h"); if (in == NULL) err("could not open %s\n", vcd_sig_dmp);
while (1) { while (1) {
char *x = " VCD_SIGNAL_DUMPER_VARIABLES_"; char *x = " VCD_SIGNAL_DUMPER_VARIABLES_";
ssize_t r; ssize_t r;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment