mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-22 14:56:13 +00:00
Changed: #1444 Add details for user-agent
This commit is contained in:
parent
19fa9a35dc
commit
e3d0ed9c20
5 changed files with 187 additions and 0 deletions
|
@ -91,6 +91,7 @@ NL_CONFIGURE_CHECKS()
|
||||||
#Platform specifics
|
#Platform specifics
|
||||||
|
|
||||||
SETUP_EXTERNAL()
|
SETUP_EXTERNAL()
|
||||||
|
NL_GEN_REVISION_H()
|
||||||
|
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
SET(WINSOCK2_LIB ws2_32.lib)
|
SET(WINSOCK2_LIB ws2_32.lib)
|
||||||
|
|
108
code/CMakeModules/FindMercurial.cmake
Normal file
108
code/CMakeModules/FindMercurial.cmake
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
# - Extract information from a subversion working copy
|
||||||
|
# The module defines the following variables:
|
||||||
|
# Mercurial_HG_EXECUTABLE - path to hg command line client
|
||||||
|
# Mercurial_VERSION_HG - version of hg command line client
|
||||||
|
# Mercurial_FOUND - true if the command line client was found
|
||||||
|
# MERCURIAL_FOUND - same as Mercurial_FOUND, set for compatiblity reasons
|
||||||
|
#
|
||||||
|
# The minimum required version of Mercurial can be specified using the
|
||||||
|
# standard syntax, e.g. FIND_PACKAGE(Mercurial 1.4)
|
||||||
|
#
|
||||||
|
# If the command line client executable is found two macros are defined:
|
||||||
|
# Mercurial_WC_INFO(<dir> <var-prefix>)
|
||||||
|
# Mercurial_WC_LOG(<dir> <var-prefix>)
|
||||||
|
# Mercurial_WC_INFO extracts information of a subversion working copy at
|
||||||
|
# a given location. This macro defines the following variables:
|
||||||
|
# <var-prefix>_WC_URL - url of the repository (at <dir>)
|
||||||
|
# <var-prefix>_WC_ROOT - root url of the repository
|
||||||
|
# <var-prefix>_WC_REVISION - current revision
|
||||||
|
# <var-prefix>_WC_LAST_CHANGED_AUTHOR - author of last commit
|
||||||
|
# <var-prefix>_WC_LAST_CHANGED_DATE - date of last commit
|
||||||
|
# <var-prefix>_WC_LAST_CHANGED_REV - revision of last commit
|
||||||
|
# <var-prefix>_WC_INFO - output of command `hg info <dir>'
|
||||||
|
# Mercurial_WC_LOG retrieves the log message of the base revision of a
|
||||||
|
# subversion working copy at a given location. This macro defines the
|
||||||
|
# variable:
|
||||||
|
# <var-prefix>_LAST_CHANGED_LOG - last log of base revision
|
||||||
|
# Example usage:
|
||||||
|
# FIND_PACKAGE(Mercurial)
|
||||||
|
# IF(MERCURIAL_FOUND)
|
||||||
|
# Mercurial_WC_INFO(${PROJECT_SOURCE_DIR} Project)
|
||||||
|
# MESSAGE("Current revision is ${Project_WC_REVISION}")
|
||||||
|
# Mercurial_WC_LOG(${PROJECT_SOURCE_DIR} Project)
|
||||||
|
# MESSAGE("Last changed log is ${Project_LAST_CHANGED_LOG}")
|
||||||
|
# ENDIF(MERCURIAL_FOUND)
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2006-2009 Kitware, Inc.
|
||||||
|
# Copyright 2006 Tristan Carel
|
||||||
|
#
|
||||||
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
# see accompanying file Copyright.txt for details.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
|
# License text for the above reference.)
|
||||||
|
|
||||||
|
FIND_PROGRAM(Mercurial_HG_EXECUTABLE hg
|
||||||
|
DOC "mercurial command line client")
|
||||||
|
MARK_AS_ADVANCED(Mercurial_HG_EXECUTABLE)
|
||||||
|
|
||||||
|
IF(Mercurial_HG_EXECUTABLE)
|
||||||
|
EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} --version
|
||||||
|
OUTPUT_VARIABLE Mercurial_VERSION_HG
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
STRING(REGEX REPLACE ".*version ([\\.0-9]+).*"
|
||||||
|
"\\1" Mercurial_VERSION_HG "${Mercurial_VERSION_HG}")
|
||||||
|
|
||||||
|
MACRO(Mercurial_WC_INFO dir prefix)
|
||||||
|
EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} tip
|
||||||
|
WORKING_DIRECTORY ${dir}
|
||||||
|
OUTPUT_VARIABLE ${prefix}_WC_INFO
|
||||||
|
ERROR_VARIABLE Mercurial_hg_info_error
|
||||||
|
RESULT_VARIABLE Mercurial_hg_info_result
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
IF(NOT ${Mercurial_hg_info_result} EQUAL 0)
|
||||||
|
MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} tip\" failed with output:\n${Mercurial_hg_info_error}")
|
||||||
|
ELSE(NOT ${Mercurial_hg_info_result} EQUAL 0)
|
||||||
|
|
||||||
|
STRING(REGEX REPLACE "^(.*\n)?Repository Root: ([^\n]+).*"
|
||||||
|
"\\2" ${prefix}_WC_ROOT "${${prefix}_WC_INFO}")
|
||||||
|
STRING(REGEX REPLACE "^(.*\n)?changeset: *([0-9]+).*"
|
||||||
|
"\\2" ${prefix}_WC_REVISION "${${prefix}_WC_INFO}")
|
||||||
|
STRING(REGEX REPLACE "^(.*\n)?Last Changed Author: ([^\n]+).*"
|
||||||
|
"\\2" ${prefix}_WC_LAST_CHANGED_AUTHOR "${${prefix}_WC_INFO}")
|
||||||
|
STRING(REGEX REPLACE "^(.*\n)?Last Changed Rev: ([^\n]+).*"
|
||||||
|
"\\2" ${prefix}_WC_LAST_CHANGED_REV "${${prefix}_WC_INFO}")
|
||||||
|
STRING(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*"
|
||||||
|
"\\2" ${prefix}_WC_LAST_CHANGED_DATE "${${prefix}_WC_INFO}")
|
||||||
|
|
||||||
|
ENDIF(NOT ${Mercurial_hg_info_result} EQUAL 0)
|
||||||
|
|
||||||
|
ENDMACRO(Mercurial_WC_INFO)
|
||||||
|
|
||||||
|
MACRO(Mercurial_WC_LOG dir prefix)
|
||||||
|
# This macro can block if the certificate is not signed:
|
||||||
|
# hg ask you to accept the certificate and wait for your answer
|
||||||
|
# This macro requires a hg server network access (Internet most of the time)
|
||||||
|
# and can also be slow since it access the hg server
|
||||||
|
EXECUTE_PROCESS(COMMAND
|
||||||
|
${Mercurial_HG_EXECUTABLE} --non-interactive log -r BASE ${dir}
|
||||||
|
OUTPUT_VARIABLE ${prefix}_LAST_CHANGED_LOG
|
||||||
|
ERROR_VARIABLE Mercurial_hg_log_error
|
||||||
|
RESULT_VARIABLE Mercurial_hg_log_result
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
IF(NOT ${Mercurial_hg_log_result} EQUAL 0)
|
||||||
|
MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} log -r BASE ${dir}\" failed with output:\n${Mercurial_hg_log_error}")
|
||||||
|
ENDIF(NOT ${Mercurial_hg_log_result} EQUAL 0)
|
||||||
|
ENDMACRO(Mercurial_WC_LOG)
|
||||||
|
ENDIF(Mercurial_HG_EXECUTABLE)
|
||||||
|
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Mercurial DEFAULT_MSG Mercurial_HG_EXECUTABLE)
|
44
code/CMakeModules/GetRevision.cmake
Normal file
44
code/CMakeModules/GetRevision.cmake
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3)
|
||||||
|
|
||||||
|
# ROOT_DIR should be set to root of the repository (where to find the .svn or .hg directory)
|
||||||
|
# SOURCE_DIR should be set to root of your code (where to find CMakeLists.txt)
|
||||||
|
|
||||||
|
SET(CMAKE_MODULE_PATH "${SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
|
||||||
|
|
||||||
|
MACRO(NOW RESULT)
|
||||||
|
IF (WIN32)
|
||||||
|
EXECUTE_PROCESS(COMMAND "wmic" "os" "get" "localdatetime" OUTPUT_VARIABLE DATETIME)
|
||||||
|
STRING(REGEX REPLACE ".*\n([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).*" "\\1-\\2-\\3 \\4:\\5:\\6" ${RESULT} ${DATETIME})
|
||||||
|
ELSEIF(UNIX)
|
||||||
|
EXECUTE_PROCESS(COMMAND "date" "+'%Y-%m-%d %H:%M:%S'" OUTPUT_VARIABLE ${RESULT})
|
||||||
|
ELSE (WIN32)
|
||||||
|
MESSAGE(SEND_ERROR "date not implemented")
|
||||||
|
SET(${RESULT} 000000)
|
||||||
|
ENDIF (WIN32)
|
||||||
|
ENDMACRO(NOW)
|
||||||
|
|
||||||
|
IF(EXISTS "${ROOT_DIR}/.svn/")
|
||||||
|
FIND_PACKAGE(Subversion)
|
||||||
|
|
||||||
|
IF(SUBVERSION_FOUND)
|
||||||
|
Subversion_WC_INFO(${ROOT_DIR} ER)
|
||||||
|
SET(REVISION ${ER_WC_REVISION})
|
||||||
|
ENDIF(SUBVERSION_FOUND)
|
||||||
|
ENDIF(EXISTS "${ROOT_DIR}/.svn/")
|
||||||
|
|
||||||
|
IF(EXISTS "${ROOT_DIR}/.hg/")
|
||||||
|
FIND_PACKAGE(Mercurial)
|
||||||
|
|
||||||
|
IF(MERCURIAL_FOUND)
|
||||||
|
Mercurial_WC_INFO(${ROOT_DIR} ER)
|
||||||
|
SET(REVISION ${ER_WC_REVISION})
|
||||||
|
ENDIF(MERCURIAL_FOUND)
|
||||||
|
ENDIF(EXISTS "${ROOT_DIR}/.hg/")
|
||||||
|
|
||||||
|
IF(REVISION)
|
||||||
|
IF(EXISTS ${SOURCE_DIR}/revision.h.in)
|
||||||
|
NOW(BUILD_DATE)
|
||||||
|
CONFIGURE_FILE(${SOURCE_DIR}/revision.h.in revision.h.txt)
|
||||||
|
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy revision.h.txt revision.h) # copy_if_different
|
||||||
|
ENDIF(EXISTS ${SOURCE_DIR}/revision.h.in)
|
||||||
|
ENDIF(REVISION)
|
|
@ -9,6 +9,33 @@ MACRO(NL_GEN_PC name)
|
||||||
ENDIF(NOT WIN32 AND WITH_INSTALL_LIBRARIES)
|
ENDIF(NOT WIN32 AND WITH_INSTALL_LIBRARIES)
|
||||||
ENDMACRO(NL_GEN_PC)
|
ENDMACRO(NL_GEN_PC)
|
||||||
|
|
||||||
|
###
|
||||||
|
# Helper macro that generates revision.h from revision.h.in
|
||||||
|
###
|
||||||
|
MACRO(NL_GEN_REVISION_H)
|
||||||
|
IF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in)
|
||||||
|
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
|
||||||
|
ADD_DEFINITIONS(-DHAVE_REVISION_H)
|
||||||
|
SET(HAVE_REVISION_H ON)
|
||||||
|
|
||||||
|
# a custom target that is always built
|
||||||
|
ADD_CUSTOM_TARGET(revision ALL
|
||||||
|
DEPENDS ${CMAKE_BINARY_DIR}/revision.h)
|
||||||
|
|
||||||
|
# creates revision.h using cmake script
|
||||||
|
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/revision.h
|
||||||
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}
|
||||||
|
-DROOT_DIR=${CMAKE_SOURCE_DIR}/..
|
||||||
|
-P ${CMAKE_SOURCE_DIR}/CMakeModules/GetRevision.cmake)
|
||||||
|
|
||||||
|
# revision.h is a generated file
|
||||||
|
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/revision.h
|
||||||
|
PROPERTIES GENERATED TRUE
|
||||||
|
HEADER_FILE_ONLY TRUE)
|
||||||
|
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in)
|
||||||
|
ENDMACRO(NL_GEN_REVISION_H)
|
||||||
|
|
||||||
###
|
###
|
||||||
#
|
#
|
||||||
###
|
###
|
||||||
|
|
7
code/revision.h.in
Normal file
7
code/revision.h.in
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef REVISION_H
|
||||||
|
#define REVISION_H
|
||||||
|
|
||||||
|
#cmakedefine REVISION "${REVISION}"
|
||||||
|
#cmakedefine BUILD_DATE "${BUILD_DATE}"
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue