Skip to content

Commit

Permalink
Update release string logic to check for git dir by default
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicgs committed Mar 10, 2017
1 parent a3bcbc6 commit ed5d4f1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
26 changes: 26 additions & 0 deletions cmake/set_release.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set(LATEST_RELEASE "2017-03-R2")

execute_process(
COMMAND git log -n 1 --format=%h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE GIT_EXIT_ERROR
ERROR_QUIET
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (GIT_EXIT_ERROR)
# We're probably not in a git repo
set(RELEASE ${LATEST_RELEASE})
else (GIT_EXIT_ERROR)
# We're in a git repo
execute_process(
COMMAND git status -s --untracked-files=no
OUTPUT_VARIABLE DIRTY
)
if ( NOT "${DIRTY}" STREQUAL "" )
set(DIRTY_FLAG "*")
else()
set(DIRTY_FLAG "")
endif()
set(RELEASE "git-${GIT_VERSION}${DIRTY_FLAG}")
endif (GIT_EXIT_ERROR)
20 changes: 3 additions & 17 deletions lib/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,9 @@
#
# Based slightly upon the hackrf cmake setup.

# FIXME Set static release version here to avoid pulling from git
set(RELEASE "")
set(DIRTY_FLAG "")

if ( "${RELEASE}" STREQUAL "" )
# automatic git version when working out of git
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC RELEASE)

execute_process(COMMAND git status -s --untracked-files=no OUTPUT_VARIABLE DIRTY)
if ( NOT "${DIRTY}" STREQUAL "" )
set(DIRTY_FLAG "*")
endif()
endif()

add_definitions( -DRELEASE="${RELEASE}${DIRTY_FLAG}" )
message(STATUS "Setting version string ${RELEASE}${DIRTY_FLAG}")
include(${PROJECT_SOURCE_DIR}/../cmake/set_release.cmake)
add_definitions( -DRELEASE="${RELEASE}" )
message(STATUS "Setting version string ${RELEASE}")

# Source
set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth_packet.c
Expand Down

0 comments on commit ed5d4f1

Please sign in to comment.