Use cmake subversion capabilities to generate buildno.h and version.h.

svn path=/branches/cmake-bringup/; revision=50454
This commit is contained in:
Sylvain Petreolle 2011-01-21 20:29:45 +00:00
parent 1da8f22b84
commit 5f1a2314f2
4 changed files with 118 additions and 7 deletions

View file

@ -0,0 +1,18 @@
/* Do not edit - Machine generated */
#ifndef _INC_REACTOS_BUILDNO
#define _INC_REACTOS_BUILDNO
#define KERNEL_VERSION_BUILD @KERNEL_VERSION_BUILD@
#define KERNEL_VERSION_BUILD_HEX 0x@KERNEL_VERSION_BUILD_HEX@
#define KERNEL_VERSION_BUILD_STR "@KERNEL_VERSION_BUILD@@REVISION@"
#define KERNEL_VERSION_BUILD_RC "@KERNEL_VERSION_BUILD@@REVISION@\0"
#define KERNEL_RELEASE_RC "@KERNEL_VERSION@\0"
#define KERNEL_RELEASE_STR "@KERNEL_VERSION@"
#define KERNEL_VERSION_RC "@KERNEL_VERSION@\0"
#define KERNEL_VERSION_STR "@KERNEL_VERSION@"
#define REACTOS_DLL_VERSION_MAJOR @REACTOS_DLL_VERSION_MAJOR@
#define REACTOS_DLL_RELEASE_RC "@DLL_VERSION_STR@\0"
#define REACTOS_DLL_RELEASE_STR "@DLL_VERSION_STR@"
#define REACTOS_DLL_VERSION_RC "@DLL_VERSION_STR@\0"
#define REACTOS_DLL_VERSION_STR "@DLL_VERSION_STR@"
#endif
/* EOF */

View file

@ -0,0 +1,64 @@
macro(today RESULT)
if (WIN32)
#execute_process(COMMAND "cmd" "/c" "date" "/T" OUTPUT_VARIABLE ${RESULT})
#string(REGEX REPLACE "(..)/(..)/(....).*" "\\3\\2\\1" ${RESULT} ${${RESULT}})
execute_process(COMMAND "${REACTOS_SOURCE_DIR}/tools/getdate.cmd" OUTPUT_VARIABLE ${RESULT})
string(STRIP ${${RESULT}} ${RESULT})
elseif(UNIX)
execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE ${${RESULT}})
else (WIN32)
message(SEND_ERROR "date not implemented")
set(${RESULT} 00000000)
endif (WIN32)
endmacro(today)
macro(inttohex INTVALUE OUTPUT_VARIABLE)
list(APPEND HEXLIST 0 1 2 3 4 5 6 7 8 9 a b c d e f)
list(GET HEXLIST ${INTVALUE} ${OUTPUT_VARIABLE})
endmacro()
macro(converttohex INTVALUE OUTPUT_VARIABLE)
set(REMAINING ${INTVALUE})
while(REMAINING)
math(EXPR REMAINDER "${REMAINING}%16")
inttohex(${REMAINDER} HEXCHAR)
math(EXPR REMAINING "${REMAINING}/16")
set(${OUTPUT_VARIABLE} "${HEXCHAR}${${OUTPUT_VARIABLE}}")
endwhile()
endmacro()
today(KERNEL_VERSION_BUILD)
set(KERNEL_VERSION_MAJOR "0")
set(KERNEL_VERSION_MINOR "4")
set(KERNEL_VERSION_PATCH_LEVEL "0")
set(COPYRIGHT_YEAR "2011")
# KERNEL_VERSION_BUILD_TYPE is "SVN", "RC1", "RC2" or "" (for the release)
set(KERNEL_VERSION_BUILD_TYPE "SVN")
set(KERNEL_VERSION "${KERNEL_VERSION_MAJOR}.${KERNEL_VERSION_MINOR}")
if(KERNEL_VERSION_PATCH_LEVEL)
set(KERNEL_VERSION "${KERNEL_VERSION}.${KERNEL_VERSION_PATCH_LEVEL}-${KERNEL_VERSION_BUILD_TYPE}")
else()
set(KERNEL_VERSION "${KERNEL_VERSION}-${KERNEL_VERSION_BUILD_TYPE}")
endif()
math(EXPR REACTOS_DLL_VERSION_MAJOR "${KERNEL_VERSION_MAJOR}+42")
set(DLL_VERSION_STR "${REACTOS_DLL_VERSION_MAJOR}.${KERNEL_VERSION_MINOR}-${KERNEL_VERSION_BUILD_TYPE}")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.svn")
find_package(Subversion)
if(Subversion_FOUND)
subversion_wc_info(${CMAKE_CURRENT_SOURCE_DIR} SVNINFO)
if(SVNINFO_WC_REVISION)
set(REVISION "-r${SVNINFO_WC_REVISION}")
converttohex(${SVNINFO_WC_REVISION} KERNEL_VERSION_BUILD_HEX)
endif()
endif()
else()
set(REVISION "-rUNKNOWN")
set(HEXREVISION "0x0")
endif()
configure_file(include/reactos/version.h.cmake ${REACTOS_BINARY_DIR}/include/reactos/version.h)
configure_file(include/reactos/buildno.h.cmake ${REACTOS_BINARY_DIR}/include/reactos/buildno.h)

View file

@ -0,0 +1,31 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/internal/version.h
* PURPOSE: Defines the current version
* PROGRAMMER: David Welch (welch@mcmail.com)
* REVISIONS:
* 1999-11-06 (ea)
* Moved from include/internal in include/reactos
* to be used by buildno.
* 2002-01-17 (ea)
* KERNEL_VERSION removed. Use
* reactos/buildno.h:KERNEL_VERSION_STR instead.
*/
#ifndef __VERSION_H
#define __VERSION_H
#define KERNEL_VERSION_MAJOR @KERNEL_VERSION_MAJOR@
#define KERNEL_VERSION_MINOR @KERNEL_VERSION_MINOR@
#define KERNEL_VERSION_PATCH_LEVEL @KERNEL_VERSION_PATCH_LEVEL@
#define COPYRIGHT_YEAR "@COPYRIGHT_YEAR@"
/* KERNEL_VERSION_BUILD_TYPE is L"SVN", L"RC1", L"RC2" or L"" (for the release) */
#define KERNEL_VERSION_BUILD_TYPE "@KERNEL_VERSION_BUILD_TYPE@"
#endif
/* EOF */