Index: tools/gen_common_defs.sh =================================================================== diff -u -rb6566527169163c6500c50891a501052288d7a7b -r32e628abcbbd3fd70866505d9f2836a6f732ef06 --- tools/gen_common_defs.sh (.../gen_common_defs.sh) (revision b6566527169163c6500c50891a501052288d7a7b) +++ tools/gen_common_defs.sh (.../gen_common_defs.sh) (revision 32e628abcbbd3fd70866505d9f2836a6f732ef06) @@ -1,17 +1,17 @@ #!/bin/bash ########################################################################### # -# Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +# Copyright (c) 2021-2024 Diality Inc. - All Rights Reserved. # # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # -# @file gen_common_defs.sh +# @file gen_common_defs.sh # -# @author (last) Quang Nguyen -# @date (last) 06-Jan-2021 -# @author (original) Quang Nguyen -# @date (original) 06-Jan-2020 +# @author (last) Quang Nguyen +# @date (last) 27-May-2021 +# @author (original) Peter Lucia +# @date (original) 06-Apr-2021 # ############################################################################ @@ -27,10 +27,22 @@ PREFIX_MATCH=$4 CPP_HEADER=$5 +TEMP_FILE="temp.txt" + rm -rf "$COMMON_REPO" git clone -b "$COMMON_BRANCH" ssh://git@dvm-linux02:7999/comm/common.git "$COMMON_REPO" if [ $? -ne 0 ]; then echo "Could not clone common"; exit 1; fi -grep -oh "$PREFIX_MATCH.* = .*," -- "$COMMON_REPO/$CPP_HEADER" > "$OUTPUT_FILE" +if [ $(grep -oc "$PREFIX_MATCH.* = .*," -- "$COMMON_REPO/$CPP_HEADER") -gt 1 ] +then + echo "Enumeration has assigned number" + grep -oh "$PREFIX_MATCH.* = .*," -- "$COMMON_REPO/$CPP_HEADER" > "$OUTPUT_FILE" +else + echo "Enumeration has auto assigned number" + grep -oh "^ $PREFIX_MATCH[^;]*\/\/" -- "$COMMON_REPO/$CPP_HEADER" | grep -oh "$PREFIX_MATCH[^, ]*" > "$TEMP_FILE" + awk 'BEGIN{i=0} /.*/{printf "%s = %d\n",$0,i; i++}' "$TEMP_FILE" > "$OUTPUT_FILE" + rm "$TEMP_FILE" +fi + if [ $? -ne 0 ]; then echo "Error during grep"; exit 1; fi