mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-17 00:07:51 +00:00
Merge pull request #2977
f55bf48
cmake: fix git tag + commit detection and version.js generation (xiphon)
This commit is contained in:
commit
10a47d783e
3 changed files with 47 additions and 48 deletions
|
@ -28,37 +28,40 @@
|
||||||
#
|
#
|
||||||
# Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
# Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||||
|
|
||||||
# Check what commit we're on
|
function (git_get_version_tag git directory result_var)
|
||||||
execute_process(COMMAND "${GIT}" rev-parse --short=9 HEAD RESULT_VARIABLE RET OUTPUT_VARIABLE COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE)
|
execute_process(COMMAND "${git}" rev-parse --short HEAD
|
||||||
|
WORKING_DIRECTORY ${directory}
|
||||||
|
OUTPUT_VARIABLE COMMIT
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
if(NOT COMMIT)
|
||||||
|
message(WARNING "${directory}: cannot determine current commit. Make sure that you are building from a Git working tree")
|
||||||
|
set(${result_var} "unknown" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(RET)
|
execute_process(COMMAND "${git}" describe --tags --exact-match
|
||||||
# Something went wrong, set the version tag to -unknown
|
WORKING_DIRECTORY ${directory}
|
||||||
|
OUTPUT_VARIABLE TAG
|
||||||
message(WARNING "Cannot determine current commit. Make sure that you are building either from a Git working tree or from a source archive.")
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
set(VERSIONTAG "unknown")
|
)
|
||||||
configure_file("src/version.js.in" "${TO}")
|
if(TAG)
|
||||||
else()
|
message(STATUS "${directory}: building tagged release ${TAG}-${COMMIT}")
|
||||||
string(SUBSTRING ${COMMIT} 0 9 COMMIT)
|
set(${result_var} "${TAG}-${COMMIT}" PARENT_SCOPE)
|
||||||
message(STATUS "You are currently on commit ${COMMIT}")
|
return()
|
||||||
|
endif()
|
||||||
# Get all the tags
|
|
||||||
execute_process(COMMAND "${GIT}" rev-list --tags --max-count=1 --abbrev-commit RESULT_VARIABLE RET OUTPUT_VARIABLE TAGGEDCOMMIT OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
|
|
||||||
if(NOT TAGGEDCOMMIT)
|
|
||||||
message(WARNING "Cannot determine most recent tag. Make sure that you are building either from a Git working tree or from a source archive.")
|
|
||||||
set(VERSIONTAG "${COMMIT}")
|
|
||||||
else()
|
|
||||||
message(STATUS "The most recent tag was at ${TAGGEDCOMMIT}")
|
|
||||||
|
|
||||||
# Check if we're building that tagged commit or a different one
|
|
||||||
if(COMMIT STREQUAL TAGGEDCOMMIT)
|
|
||||||
message(STATUS "You are building a tagged release")
|
|
||||||
set(VERSIONTAG "release")
|
|
||||||
else()
|
|
||||||
message(STATUS "You are ahead of or behind a tagged release")
|
|
||||||
set(VERSIONTAG "${COMMIT}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
configure_file("src/version.js.in" "${TO}")
|
execute_process(COMMAND "${git}" describe --tags --long
|
||||||
endif()
|
WORKING_DIRECTORY ${directory}
|
||||||
|
OUTPUT_VARIABLE MOST_RECENT_TAG
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
if(MOST_RECENT_TAG)
|
||||||
|
message(STATUS "${directory}: ahead of or behind a tagged release, building ${MOST_RECENT_TAG}")
|
||||||
|
set(${result_var} "${MOST_RECENT_TAG}" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "${directory}: building ${COMMIT} commit")
|
||||||
|
set(${result_var} "${COMMIT}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
|
@ -26,27 +26,24 @@
|
||||||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||||
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
function (write_static_version_header hash)
|
function (write_static_version_header VERSION_TAG_GUI VERSION_TAG_CORE)
|
||||||
set(VERSIONTAG "${hash}")
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/version.js.in" "${CMAKE_CURRENT_SOURCE_DIR}/version.js")
|
||||||
configure_file("${CMAKE_SOURCE_DIR}/version.js.in" "${CMAKE_SOURCE_DIR}/version.js")
|
|
||||||
endfunction ()
|
endfunction ()
|
||||||
|
|
||||||
find_package(Git QUIET)
|
find_package(Git QUIET)
|
||||||
if ("$Format:$" STREQUAL "")
|
if ("$Format:$" STREQUAL "")
|
||||||
# We're in a tarball; use hard-coded variables.
|
# We're in a tarball; use hard-coded variables.
|
||||||
write_static_version_header("release")
|
write_static_version_header("release" "release")
|
||||||
elseif (GIT_FOUND OR Git_FOUND)
|
elseif (GIT_FOUND OR Git_FOUND)
|
||||||
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
|
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
|
||||||
add_custom_command(
|
|
||||||
OUTPUT "${CMAKE_SOURCE_DIR}/version.js"
|
include(GitGetVersionTag)
|
||||||
COMMAND "${CMAKE_COMMAND}"
|
git_get_version_tag(${GIT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} VERSION_TAG_GUI)
|
||||||
"-D" "GIT=${GIT_EXECUTABLE}"
|
git_get_version_tag(${GIT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/monero VERSION_TAG_CORE)
|
||||||
"-D" "TO=${CMAKE_SOURCE_DIR}/version.js"
|
write_static_version_header(${VERSION_TAG_GUI} ${VERSION_TAG_CORE})
|
||||||
"-P" "cmake/GenVersionGui.cmake"
|
|
||||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "WARNING: Git was not found!")
|
message(STATUS "WARNING: Git was not found!")
|
||||||
write_static_version_header("unknown")
|
write_static_version_header("unknown" "unknown")
|
||||||
endif ()
|
endif ()
|
||||||
add_custom_target(genversiongui ALL
|
add_custom_target(genversiongui ALL
|
||||||
DEPENDS "${CMAKE_SOURCE_DIR}/version.js")
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/version.js")
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
var GUI_VERSION = "@VERSIONTAG@"
|
var GUI_VERSION = "@VERSION_TAG_GUI@";
|
||||||
var GUI_MONERO_VERSION = "@VERSIONTAG@"
|
var GUI_MONERO_VERSION = "@VERSION_TAG_CORE@";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue