@@ -62,6 +62,7 @@ function(ic_project
6262 set (optional_keyword_args
6363 BOARD_REV
6464 BUILD_TYPE
65+ FW_VERSION
6566 )
6667 list (APPEND keyword_args
6768 ${required_keyword_args}
@@ -95,6 +96,8 @@ function(ic_project
9596
9697 set_definition ("${out_board_name} " "${_BOARD_NAME} " PARENT_SCOPE )
9798 if_set_definition ("${out_board_rev} " "${_BOARD_REV} " PARENT_SCOPE )
99+ if_set_definition ("${out_fw_version} " "${_FW_VERSION} " PARENT_SCOPE )
100+ if_set_definition ("${out_build_type} " "${_BUILD_TYPE} " PARENT_SCOPE )
98101
99102 # Warn about git tag
100103 execute_process (
@@ -104,27 +107,40 @@ function(ic_project
104107 OUTPUT_QUIET
105108 )
106109 if (res AND NOT res EQUAL 0)
107- message (
108- WARNING
109- "The ${out_fw_version} should be set by git tag but there is no tag"
110- )
110+ if (NOT DEFINED ${out_fw_version} )
111+ message (
112+ WARNING
113+ "The ${out_fw_version} should be set by git tag but there is no tag"
114+ )
115+ endif ()
111116 set (has_git_tag 0)
112117 else ()
113118 set (has_git_tag 1)
119+ execute_process (
120+ COMMAND git describe --tags --dirty=+ --always --abbrev=7
121+ OUTPUT_VARIABLE git_tag
122+ OUTPUT_STRIP_TRAILING_WHITESPACE
123+ )
114124 endif ()
115125
116- # Set firmware version
126+ # Set short git commit hash
117127 execute_process (
118- COMMAND git describe --tags -- dirty=+ --always --abbrev=7
119- OUTPUT_VARIABLE git_tag
128+ COMMAND git describe --dirty=+ --always --abbrev=7 --exclude *
129+ OUTPUT_VARIABLE git_hash
120130 OUTPUT_STRIP_TRAILING_WHITESPACE
121131 )
122- set_definition ("${out_fw_version } " ${git_tag } PARENT_SCOPE )
132+ set_definition ("${out_git_hash } " ${git_hash } PARENT_SCOPE )
123133
124- if_set_definition ("${out_build_type} " "${_BUILD_TYPE} " PARENT_SCOPE )
134+ if (NOT DEFINED ${out_fw_version} )
135+ if (${has_git_tag} )
136+ set_definition ("${out_fw_version} " ${git_tag} PARENT_SCOPE )
137+ else ()
138+ set_definition ("${out_fw_version} " ${git_hash} PARENT_SCOPE )
139+ endif ()
140+ endif ()
125141
126142 # Set git dirty commit
127- string (FIND ${git_tag } + res)
143+ string (FIND ${git_hash } + res)
128144 if (res EQUAL -1)
129145 set_definition ("${out_git_dirty} " 0 PARENT_SCOPE )
130146 else ()
@@ -150,14 +166,6 @@ function(ic_project
150166 set_definition ("${out_git_tag_rev} " "" PARENT_SCOPE )
151167 endif ()
152168
153- # Set short git commit hash
154- execute_process (
155- COMMAND git describe --dirty=+ --always --abbrev=7 --exclude *
156- OUTPUT_VARIABLE git_hash
157- OUTPUT_STRIP_TRAILING_WHITESPACE
158- )
159- set_definition ("${out_git_hash} " ${git_hash} PARENT_SCOPE )
160-
161169 string (TIMESTAMP build_date "%Y%m%d" )
162170 set_definition ("${out_build_date} " ${build_date} PARENT_SCOPE )
163171 string (TIMESTAMP timestamp )
0 commit comments