From d9f6ac4b324136f8d94f240f8cdf4007751fb4c1 Mon Sep 17 00:00:00 2001 From: Aleksandar Bozhinovski Date: Thu, 12 Apr 2012 14:34:03 +0200 Subject: Auto-generate LcdVersion.cpp and lcm_version.c LCD/LCM compatibility check was broken by introducing of mingw cross compiler. The functionality is brought back by auto-generating LcdVersion.cpp and lcm_version.c ST-Ericsson ID: 427380 ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10204 Change-Id: I6c18973d2a38484bdf3003b0edbf3f7b6dd8c34f Depends-On: I709f594c76bf1d0d0bf88ee205ef94bc772eed10 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/55202 Reviewed-by: QABUILD Tested-by: Blaze MILADINOV Reviewed-by: Viktor MLADENOVSKI --- Android.mk | 29 ++++- Makefile | 6 +- lcmodule/Makefile | 16 ++- .../source/lcm_version.c | 18 --- source/LcdVersion.cpp | 23 ---- source/LcmInterface.cpp | 10 +- source/gen_version_files.sh | 136 +++++++++++++++++++++ 7 files changed, 181 insertions(+), 57 deletions(-) delete mode 100644 lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c delete mode 100644 source/LcdVersion.cpp create mode 100755 source/gen_version_files.sh diff --git a/Android.mk b/Android.mk index 92f1b08..4afef56 100644 --- a/Android.mk +++ b/Android.mk @@ -108,14 +108,15 @@ LOCAL_MODULE_CLASS := SHARED_LIBRARIES # Automatic Code Generation LOCAL_AUTO_DIR := $(local-intermediates-dir)/source/autogen LOCAL_CONFIG_PATH := $(LOCAL_PATH)/source/config +SCRIPT_PATH := $(LOCAL_PATH)/source -# Generate lcdriver_error_codes.h -GEN := $(LOCAL_AUTO_DIR)/lcdriver_error_codes.h +# Generate lcdriver_error_codes.h, error_codes_desc.cpp +GEN := $(LOCAL_AUTO_DIR)/lcdriver_error_codes.h $(LOCAL_AUTO_DIR)/error_codes_desc.cpp $(GEN) : $(shell mkdir -p $(LOCAL_AUTO_DIR)) $(GEN) : PRIVATE_INPUT_XML := $(LOCAL_CONFIG_PATH)/lcdriver_error_codes.xml $(GEN) : PRIVATE_INPUT_XSL = $(XSL_LOCAL_PATH)/source/config/$(patsubst %.h,%_h.xsl,$(patsubst %.cpp,%_cpp.xsl,$(@F))) $(GEN) : $(PRIVATE_INPUT_XML) $(PRIVATE_INPUT_XSL) -$(GEN) : PRIVATE_CUSTOM_TOOL = java -classpath $(PRIVATE_CLASSPATH) -in $(PRIVATE_INPUT_XML) -xsl $(PRIVATE_INPUT_XSL) -out $@ -PARAM target lcm +$(GEN) : PRIVATE_CUSTOM_TOOL = java -classpath $(PRIVATE_CLASSPATH) -in $(PRIVATE_INPUT_XML) -xsl $(PRIVATE_INPUT_XSL) -out $@ -PARAM target lcm -PARAM errorCodesLcmXml $(PRIVATE_LC_LCD_DIR)../../lcmodule/source/cnh1606344_ldr_communication_module/config/error_codes.xml $(GEN) : $(transform-generated-source) @echo $@ @@ -148,6 +149,16 @@ $(GEN) : LOCAL_GENERATED_SOURCES += $(GEN) +# Generate LcdVersion.cpp +GEN := $(LOCAL_AUTO_DIR)/LcdVersion.cpp +$(GEN) : $(shell mkdir -p $(LOCAL_AUTO_DIR)) +$(GEN) : $(shell bash $(SCRIPT_PATH)/gen_version_files.sh --lcd $(abspath $(LOCAL_AUTO_DIR)) $(abspath $(LOCAL_PATH))) +$(GEN) : + $(transform-generated-source) + @echo $@ + +LOCAL_GENERATED_SOURCES += $(GEN) + LOCAL_SRC_FILES := \ source/utilities/Serialization.cpp\ source/utilities/Logger.cpp\ @@ -163,7 +174,6 @@ LOCAL_SRC_FILES := \ source/LcmInterface.cpp\ source/LCDriverThread.cpp\ source/LCDriverMethods.cpp\ - source/LcdVersion.cpp\ source/LCDriverEntry.cpp\ source/LCDriver.cpp\ source/LCM/Hash.cpp\ @@ -238,6 +248,16 @@ $(GEN) : LOCAL_GENERATED_SOURCES += $(GEN) +# Generate lcm_version.c +GEN := $(LOCAL_AUTO_DIR)/lcm_version.c +$(GEN) : $(shell mkdir -p $(LOCAL_AUTO_DIR)) +$(GEN) : $(shell bash $(SCRIPT_PATH)/gen_version_files.sh --lcm $(abspath $(LOCAL_AUTO_DIR)) $(abspath $(LOCAL_PATH))) +$(GEN) : + $(transform-generated-source) + @echo $@ + +LOCAL_GENERATED_SOURCES += $(GEN) + LOCAL_SRC_FILES := \ lcmodule/source/cnh1605204_ldr_transport_layer/source/bulk_protocol.c\ lcmodule/source/cnh1605204_ldr_transport_layer/source/command_protocol.c\ @@ -256,7 +276,6 @@ LOCAL_SRC_FILES := \ lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_header.c\ lcmodule/source/cnh1605205_ldr_network_layer/source/protrom_network.c\ lcmodule/source/cnh1606344_ldr_communication_module/source/communication_service.c\ - lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c\ lcmodule/source/cnh1606344_ldr_communication_module/source/protrom_family.c\ lcmodule/source/cnh1606344_ldr_communication_module/source/z_family.c\ lcmodule/source/cnh1606344_ldr_communication_module/source/r15_family.c\ diff --git a/Makefile b/Makefile index 9b8c826..7844165 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,6 @@ LIBSRC := \ source/LcmInterface.cpp\ source/LCDriverThread.cpp\ source/LCDriverMethods.cpp\ - source/LcdVersion.cpp\ source/LCDriverEntry.cpp\ source/LCDriver.cpp\ source/LCM/Buffers.cpp\ @@ -57,6 +56,7 @@ LIBSRC := \ source/security_algorithms/sha/sha2.cpp\ $(AUTO_DIR_LIB)/commands_marshal.cpp\ $(AUTO_DIR_LIB)/a2_commands_marshal.cpp\ + $(AUTO_DIR_LIB)/LcdVersion.cpp\ $(AUTO_DIR_LIB)/error_codes_desc.cpp ifeq ($(BUILD_WIN),) LIBSRC += \ @@ -88,6 +88,7 @@ AUTOGEN_FILES := $(AUTO_DIR_LIB)/command_ids.h\ $(AUTO_DIR_LIB)/a2_commands.h\ $(AUTO_DIR_LIB)/a2_commands_impl.h\ $(AUTO_DIR_LIB)/a2_commands_marshal.cpp\ + $(AUTO_DIR_LIB)/LcdVersion.cpp\ $(AUTO_DIR_LIB)/error_codes_desc.cpp @@ -316,6 +317,9 @@ $(AUTO_DIR_LIB)/error_codes_desc.cpp: $(LCD_CONFIG)lcdriver_error_codes.xml $(LC @echo "Generating autogen $(AUTO_DIR_LIB)/error_codes_desc.cpp..." @java -classpath $(XALAN_PATH)xalan.jar org.apache.xalan.xslt.Process -in $(LCD_CONFIG)lcdriver_error_codes.xml -xsl $(LCD_CONFIG)error_codes_desc_cpp.xsl -out $@ -PARAM errorCodesLcmXml $(LCM_ERR_DESC_PATH) +$(AUTO_DIR_LIB)/LcdVersion.cpp: setup_folders + bash $(LCD_DIR)source/gen_version_files.sh --lcd $(abspath $(AUTO_DIR_LIB)) $(abspath $(LCD_DIR)) + #setting up needed folders $(BUILDFOLDER): | configfile @mkdir -p $@ 2> /dev/null diff --git a/lcmodule/Makefile b/lcmodule/Makefile index 2834db2..63424c3 100644 --- a/lcmodule/Makefile +++ b/lcmodule/Makefile @@ -55,7 +55,8 @@ AUTOGEN_FILES := $(AUTO_DIR_LIB)/commands.h\ $(AUTO_DIR_LOADER)/custom_commands.h\ $(AUTO_DIR_LOADER)/custom_command_marshal.c\ $(AUTO_DIR_LOADER)/ces_commands.c\ - $(AUTO_DIR_LOADER)/ces_commands.h + $(AUTO_DIR_LOADER)/ces_commands.h\ + $(LCM_AUTO_DIR)/lcm_version.c LIBSRC :=${TRANSPORT_PATH}/source/bulk_protocol.c\ @@ -75,11 +76,11 @@ LIBSRC :=${TRANSPORT_PATH}/source/bulk_protocol.c\ ${NETWORK_PATH}/source/protrom_header.c\ ${NETWORK_PATH}/source/protrom_network.c\ ${LCM_CNH_PATH}/source/communication_service.c\ - ${LCM_CNH_PATH}/source/lcm_version.c\ ${LCM_CNH_PATH}/source/protrom_family.c\ ${LCM_CNH_PATH}/source/z_family.c\ ${LCM_CNH_PATH}/source/r15_family.c\ ${LCM_CNH_PATH}/source/a2_family.c\ + $(LCM_AUTO_DIR)/lcm_version.c\ ${LCM_PATH}/source/serialization.c ifeq ($(BUILD_WIN),) LIBSRC += ${LCM_PATH}/source/cnh1605551_ldr_utilities/critical_section/critical_section_linux.c @@ -199,6 +200,10 @@ $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: ${LCM_PATH}/source/%.c $(AUTOGEN_FILES) @mkdir -p $(dir $@) $(CC) $(INCLUDES) $(CFLAGS) -c -m32 $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F) +$(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/lcm_version.o: $(LCM_AUTO_DIR)/lcm_version.c $(AUTOGEN_FILES) + @mkdir -p $(dir $@) + $(CC) $(INCLUDES) $(CFLAGS) -c -m32 $< -o $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/$(@F) + ifeq ($(BUILD_WIN),1) $(BUILDFOLDER)/$(LIB_x32_OBJ_DIR)/%.o: out/autogen/outLCM.rc $(AUTOGEN_FILES) @mkdir -p $(dir $@) @@ -228,6 +233,10 @@ $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: ${LCM_PATH}/source/%.c $(AUTOGEN_FILES) @mkdir -p $(dir $@) $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F) +$(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/lcm_version.o: $(LCM_AUTO_DIR)/lcm_version.c $(AUTOGEN_FILES) + @mkdir -p $(dir $@) + $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/$(@F) + ifeq ($(BUILD_WIN),2) $(BUILDFOLDER)/$(LIB_x64_OBJ_DIR)/%.o: out/autogen/outLCM.rc $(AUTOGEN_FILES) @mkdir -p $(dir $@) @@ -286,6 +295,9 @@ $(AUTO_DIR_LOADER)/custom_commands.h: $(LCM_CUST_CONFIG)/custom_commands.xml $(L $(AUTO_DIR_LOADER)/custom_command_marshal.c: $(LCM_CUST_CONFIG)/custom_commands.xml $(LCM_CUST_CONFIG)/custom_command_marshal.xsl | setup_folders java -classpath $(LCM_PATH)/tools/xalan-j_2_7_1/xalan.jar org.apache.xalan.xslt.Process -in $(LCM_CUST_CONFIG)/custom_commands.xml -xsl $(LCM_CUST_CONFIG)/custom_command_marshal.xsl -out $@ +$(LCM_AUTO_DIR)/lcm_version.c: setup_folders + bash ${LCM_PATH}/../source/gen_version_files.sh --lcm $(abspath $(LCM_AUTO_DIR)) $(abspath $(LCM_PATH)) + #setting up needed folders $(BUILDFOLDER): | configfile @mkdir -p $@ 2> /dev/null diff --git a/lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c b/lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c deleted file mode 100644 index b95f288..0000000 --- a/lcmodule/source/cnh1606344_ldr_communication_module/source/lcm_version.c +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright (C) ST-Ericsson SA 2011 - * License terms: 3-clause BSD license - ******************************************************************************/ -/** - * @addtogroup ldr_communication_serv - * @{ - */ -/** - * var char LCM_CurrentVersion[] - * brief ASCII string holding the LCM version. - * The LCM_CurrentVersion string is compared with - * LCD_LCM_CompatibilityList in file LcdVersion.cpp in LCD code. - */ - -char LCM_CurrentVersion[] = "P5Y"; - -/** @} */ diff --git a/source/LcdVersion.cpp b/source/LcdVersion.cpp deleted file mode 100644 index 9e908b0..0000000 --- a/source/LcdVersion.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (C) ST-Ericsson SA 2011 - * License terms: 3-clause BSD license - ******************************************************************************/ -#include "lcdriver_error_codes.h" -#include "LcmInterface.h" -#include "Error.h" -#ifdef _WIN32 -#include "WinApiWrappers.h" -#else -#include "LinuxApiWrappers.h" -#include -#define GetProcAddress dlsym -#endif -/** - * var char *LCD_LCM_CompatibilityList[] - * brief ASCII string list holding the permitted LCM versions. - * This table contains compatibility information for the versions of LCM. - * Current LCM version is defined in file lcm_version.c in LCM code. - */ -const char *LCD_LCM_CompatibilityList[] = {"P5Y", - NULL - }; diff --git a/source/LcmInterface.cpp b/source/LcmInterface.cpp index 516e111..cee1714 100644 --- a/source/LcmInterface.cpp +++ b/source/LcmInterface.cpp @@ -16,7 +16,7 @@ #endif char *LcmInterface::m_pchLCMLibPath = 0; -extern const char *LCD_LCM_CompatibilityList[]; +extern const char LCD_LCM_Compatibility[]; ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// @@ -203,21 +203,15 @@ ErrorCode_e LcmInterface::CommunicationCheckVersion(char *LCMVersion_p, LCM_t LC { int ReturnValue = LCM_LOAD_INCOMPATIBLE_PC_VERSION; - int i = 0; if (LCMType == LDR_LCM) { ReturnValue = LCM_LOAD_INCOMPATIBLE_LDR_VERSION; } - do { - if (strcmp(LCMVersion_p, LCD_LCM_CompatibilityList[i]) == 0) { + if (strcmp(LCMVersion_p, LCD_LCM_Compatibility) == 0) { ReturnValue = E_SUCCESS; - break; } - i++; - } while (LCD_LCM_CompatibilityList[i] != NULL); - return static_cast(ReturnValue); } diff --git a/source/gen_version_files.sh b/source/gen_version_files.sh new file mode 100755 index 0000000..6e7e587 --- /dev/null +++ b/source/gen_version_files.sh @@ -0,0 +1,136 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# Copyright (C) ST-Ericsson SA 2012 +# License terms: 3-clause BSD license +# ------------------------------------------------------------------------------ + +#-------- Global vars init values ----------- + +#script version +SCRIPT_VERSION="v1.0" + +#printout stream channels +error_channel=/dev/stderr +normal_channel=/dev/stdout +stream_channel=$normal_channel + +#git revision info +VERSION="" + +chdir=$3 +path=$2 +LCD_RC_PATH=$path/LcdVersion.cpp +LCM_RC_PATH=$path/lcm_version.c + +# ------------------------------INTERNAL FUNCTIONS ---------------------------- + +function show_err() +{ + cat >> $stream_channel << INLINE_DOC + +Syntax ERROR! +Try reading the script help info +$0 --help + +INLINE_DOC +} + +function get_help() +{ + cat >> $stream_channel << INLINE_DOC +================================ HELP ================================ +The purpose of this script is generating source (.c or .cpp) files +that will hold information for the compatibility of the versions of +LCM and LCD .dll files. First input parameter is --lcm or --lcd +which tells the script which file to be generated. +Second parameter is the path where the file should be generated. +Third parameter is the location of the directory which holds the .git repository. + +INLINE_DOC +} + +function get_init_data() +{ + cd $chdir + VERSION=`git describe --tags --always --long` +} + +# +# Loader Communication module +# +function process_lcm() +{ + cat > $LCM_RC_PATH << INLINE_DOC +/******************************************************************************* + * Copyright (C) ST-Ericsson SA 2012 + * License terms: 3-clause BSD license + ******************************************************************************/ +/** + * @addtogroup ldr_communication_serv + * @{ + */ +/** + * var char LCM_CurrentVersion[] + * brief ASCII string holding the LCM version. + * The LCM_CurrentVersion string is compared with + * LCD_LCM_Compatibility[] in file LcdVersion.cpp in LCD code. + */ + +INLINE_DOC +echo "char LCM_CurrentVersion[] = \"$VERSION\";" >> $LCM_RC_PATH +cat >> $LCM_RC_PATH << INLINE_DOC + +/** @} */ + +INLINE_DOC +} + +# +# Loader Communication Driver +# +function process_lcd() +{ + cat > $LCD_RC_PATH << INLINE_DOC +/******************************************************************************* + * Copyright (C) ST-Ericsson SA 2011 + * License terms: 3-clause BSD license + ******************************************************************************/ +#include "lcdriver_error_codes.h" +#include "LcmInterface.h" +#include "Error.h" +#ifdef _WIN32 +#include "WinApiWrappers.h" +#else +#include "LinuxApiWrappers.h" +#include +#define GetProcAddress dlsym +#endif +/** + * var char LCD_LCM_Compatibility[] + * brief ASCII string holding the LCD version. + * This string is compared with the version of the LCM. + * Current LCM version is defined in file lcm_version.c in LCM code. + */ +INLINE_DOC +echo "char LCD_LCM_Compatibility[] = \"$VERSION\";" >> $LCD_RC_PATH +cat >> $LCD_RC_PATH << INLINE_DOC + +INLINE_DOC +} + +# ------------------------------- main script routine ------------------------- +get_init_data +case $1 in + + --lcm) + process_lcm;; + --lcd) + process_lcd;; + + -h|?|--help) + get_help;; + *) + stream_channel=$error_channel + show_err;; +esac + -- cgit v1.2.3