8 changed files with 288 additions and 3 deletions
-
21CMakeLists.txt
-
30cmake/info_bin.cmake
-
132cmake/info_macros.cmake.in
-
31cmake/info_src.cmake
-
8cmake/make_dist.cmake.in
-
6mysql-test/r/file_contents.result
-
56mysql-test/t/file_contents.test
-
7support-files/mysql.spec.sh
@ -0,0 +1,30 @@ |
|||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
|||
# |
|||
# This program is free software; you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation; version 2 of the License. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License |
|||
# along with this program; if not, write to the Free Software |
|||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|||
|
|||
|
|||
# The sole purpose of this cmake control file is to create the "INFO_BIN" file. |
|||
|
|||
# By having a separate cmake file for this, it is ensured this happens |
|||
# only in the build (Unix: "make") phase, not when cmake runs. |
|||
# This, in turn, avoids creating stuff in the source directory - |
|||
# it should get into the binary directory only. |
|||
|
|||
|
|||
# Get the macros which the "INFO_*" files. |
|||
INCLUDE(${CMAKE_BINARY_DIR}/info_macros.cmake) |
|||
|
|||
# Here is where the action is. |
|||
CREATE_INFO_BIN() |
|||
|
@ -0,0 +1,132 @@ |
|||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
|||
# |
|||
# This program is free software; you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation; version 2 of the License. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License |
|||
# along with this program; if not, write to the Free Software |
|||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|||
|
|||
|
|||
# Handle/create the "INFO_*" files describing a MySQL (server) binary. |
|||
# This is part of the fix for bug#42969. |
|||
|
|||
|
|||
# Several of cmake's variables need to be translated from '@' notation |
|||
# to '${}', this is done by the "configure" call in top level "CMakeLists.txt". |
|||
# If further variables are used in this file, add them to this list. |
|||
|
|||
SET(VERSION "@VERSION@") |
|||
SET(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@") |
|||
SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@") |
|||
SET(CMAKE_GENERATOR "@CMAKE_GENERATOR@") |
|||
SET(CMAKE_SIZEOF_VOID_P "@CMAKE_SIZEOF_VOID_P@") |
|||
SET(BZR_EXECUTABLE "@BZR_EXECUTABLE@") |
|||
SET(CMAKE_CROSSCOMPILING "@CMAKE_CROSSCOMPILING@") |
|||
SET(CMAKE_HOST_SYSTEM "@CMAKE_HOST_SYSTEM@") |
|||
SET(CMAKE_HOST_SYSTEM_PROCESSOR "@CMAKE_HOST_SYSTEM_PROCESSOR@") |
|||
SET(CMAKE_SYSTEM "@CMAKE_SYSTEM@") |
|||
SET(CMAKE_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@") |
|||
|
|||
|
|||
# Create an "INFO_SRC" file with information about the source (only). |
|||
# We use "bzr version-info", if possible, and the "VERSION" contents. |
|||
# |
|||
# Outside development (BZR tree), the "INFO_SRC" file will not be modified |
|||
# provided it exists (from "make dist" or a source tarball creation). |
|||
|
|||
MACRO(CREATE_INFO_SRC target_dir) |
|||
SET(INFO_SRC "${target_dir}/INFO_SRC") |
|||
|
|||
IF(EXISTS ${CMAKE_SOURCE_DIR}/.bzr) |
|||
# Sources are in a BZR repository: Always update. |
|||
EXECUTE_PROCESS( |
|||
COMMAND ${BZR_EXECUTABLE} version-info ${CMAKE_SOURCE_DIR} |
|||
OUTPUT_VARIABLE VERSION_INFO |
|||
RESULT_VARIABLE RESULT |
|||
) |
|||
FILE(WRITE ${INFO_SRC} "${VERSION_INFO}\n") |
|||
# to debug, add: FILE(APPEND ${INFO_SRC} "\nResult ${RESULT}\n") |
|||
# For better readability ... |
|||
FILE(APPEND ${INFO_SRC} "\nMySQL source ${VERSION}\n") |
|||
ELSEIF(EXISTS ${INFO_SRC}) |
|||
# Outside a BZR tree, there is no need to change an existing "INFO_SRC", |
|||
# it cannot be improved. |
|||
ELSEIF(EXISTS ${CMAKE_SOURCE_DIR}/Docs/INFO_SRC) |
|||
# If we are building from a source distribution, it also contains "INFO_SRC". |
|||
# Similar, the export used for a release build already has the file. |
|||
FILE(READ ${CMAKE_SOURCE_DIR}/Docs/INFO_SRC SOURCE_INFO) |
|||
FILE(WRITE ${INFO_SRC} "${SOURCE_INFO}\n") |
|||
ELSEIF(EXISTS ${CMAKE_SOURCE_DIR}/INFO_SRC) |
|||
# This is not the proper location, but who knows ... |
|||
FILE(READ ${CMAKE_SOURCE_DIR}/INFO_SRC SOURCE_INFO) |
|||
FILE(WRITE ${INFO_SRC} "${SOURCE_INFO}\n") |
|||
ELSE() |
|||
# This is a fall-back. |
|||
FILE(WRITE ${INFO_SRC} "\nMySQL source ${VERSION}\n") |
|||
ENDIF() |
|||
ENDMACRO(CREATE_INFO_SRC) |
|||
|
|||
|
|||
# This is for the "real" build, must be run again with each cmake run |
|||
# to make sure we report the current flags (not those of some previous run). |
|||
|
|||
MACRO(CREATE_INFO_BIN) |
|||
SET(INFO_BIN "Docs/INFO_BIN") |
|||
|
|||
FILE(WRITE ${INFO_BIN} "===== Information about the build process: =====\n") |
|||
IF (WIN32) |
|||
EXECUTE_PROCESS(COMMAND cmd /c date /T OUTPUT_VARIABLE TMP_DATE) |
|||
ELSEIF(UNIX) |
|||
EXECUTE_PROCESS(COMMAND date "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE TMP_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) |
|||
ELSE() |
|||
SET(TMP_DATE "(no date command known for this platform)") |
|||
ENDIF() |
|||
SITE_NAME(HOSTNAME) |
|||
FILE(APPEND ${INFO_BIN} "Build was run at ${TMP_DATE} on host '${HOSTNAME}'\n\n") |
|||
|
|||
# According to the cmake docs, these variables should always be set. |
|||
# However, they are empty in my tests, using cmake 2.6.4 on Linux, various Unix, and Windows. |
|||
# Still, include this code, so we will profit if a build environment does provide that info. |
|||
IF(CMAKE_HOST_SYSTEM) |
|||
FILE(APPEND ${INFO_BIN} "Build was done on ${CMAKE_HOST_SYSTEM} using ${CMAKE_HOST_SYSTEM_PROCESSOR}\n") |
|||
ENDIF() |
|||
IF(CMAKE_CROSSCOMPILING) |
|||
FILE(APPEND ${INFO_BIN} "Build was done for ${CMAKE_SYSTEM} using ${CMAKE_SYSTEM_PROCESSOR}\n") |
|||
ENDIF() |
|||
|
|||
# ${CMAKE_VERSION} doesn't work in 2.6.0, use the separate components. |
|||
FILE(APPEND ${INFO_BIN} "Build was done using cmake ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} \n\n") |
|||
|
|||
IF (WIN32) |
|||
FILE(APPEND ${INFO_BIN} "===== Compiler / generator used: =====\n") |
|||
FILE(APPEND ${INFO_BIN} ${CMAKE_GENERATOR} "\n\n") |
|||
ELSEIF(UNIX) |
|||
FILE(APPEND ${INFO_BIN} "===== Compiler flags used (from the 'sql/' subdirectory): =====\n") |
|||
IF(EXISTS sql/CMakeFiles/sql.dir/flags.make) |
|||
EXECUTE_PROCESS(COMMAND egrep "^# compile|^C_|^CXX_" sql/CMakeFiles/sql.dir/flags.make OUTPUT_VARIABLE COMPILE_FLAGS) |
|||
FILE(APPEND ${INFO_BIN} ${COMPILE_FLAGS} "\n") |
|||
ELSE() |
|||
FILE(APPEND ${INFO_BIN} "File 'sql/CMakeFiles/sql.dir/flags.make' is not yet found.\n\n") |
|||
ENDIF() |
|||
ENDIF() |
|||
FILE(APPEND ${INFO_BIN} "Pointer size: ${CMAKE_SIZEOF_VOID_P}\n\n") |
|||
|
|||
FILE(APPEND ${INFO_BIN} "===== Feature flags used: =====\n") |
|||
IF(EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt) |
|||
# Attention: "-N" prevents cmake from entering a recursion, and it must be a separate flag from "-L". |
|||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -N -L ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE FEATURE_FLAGS) |
|||
FILE(APPEND ${INFO_BIN} ${FEATURE_FLAGS} "\n") |
|||
ELSE() |
|||
FILE(APPEND ${INFO_BIN} "File 'CMakeCache.txt' is not yet found.\n\n") |
|||
ENDIF() |
|||
|
|||
FILE(APPEND ${INFO_BIN} "===== EOF =====\n") |
|||
ENDMACRO(CREATE_INFO_BIN) |
|||
|
@ -0,0 +1,31 @@ |
|||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
|||
# |
|||
# This program is free software; you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation; version 2 of the License. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License |
|||
# along with this program; if not, write to the Free Software |
|||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|||
|
|||
|
|||
# The sole purpose of this cmake control file is to create the "INFO_SRC" file. |
|||
|
|||
# As long as and "bzr pull" (or "bzr commit") is followed by a "cmake", |
|||
# the call in top level "CMakeLists.txt" is sufficient. |
|||
# This file is to provide a separate target for the "make" phase, |
|||
# to ensure the BZR revision-id is correct even after a sequence |
|||
# cmake ; make ; bzr pull ; make |
|||
|
|||
|
|||
# Get the macros which handle the "INFO_*" files. |
|||
INCLUDE(${CMAKE_BINARY_DIR}/info_macros.cmake) |
|||
|
|||
# Here is where the action is. |
|||
CREATE_INFO_SRC(${CMAKE_BINARY_DIR}/Docs) |
|||
|
@ -0,0 +1,6 @@ |
|||
|
|||
Checking 'INFO_SRC' and 'INFO_BIN' |
|||
INFO_SRC: Found MySQL version number / Found BZR revision id |
|||
INFO_BIN: Found 'Compiler ... used' line / Found 'Feature flags' line |
|||
|
|||
End of tests |
@ -0,0 +1,56 @@ |
|||
# |
|||
# Testing files that were built to be packaged, both for existence and for contents |
|||
# |
|||
|
|||
# |
|||
# Bug #42969: Create MANIFEST files |
|||
# |
|||
# Use a Perl script to verify that files "docs/INFO_BIN" and "docs/INFO_SRC" do exist |
|||
# and have the expected contents. |
|||
|
|||
--perl |
|||
print "\nChecking 'INFO_SRC' and 'INFO_BIN'\n"; |
|||
$dir_docs = $ENV{'MYSQL_LIBDIR'}; |
|||
if($dir_docs =~ m|/usr/|) { |
|||
# RPM package |
|||
$dir_docs =~ s|/lib|/share/doc|; |
|||
if(-d "$dir_docs/packages/MySQL-server") { |
|||
# SuSE |
|||
$dir_docs = "$dir_docs/packages/MySQL-server"; |
|||
} else { |
|||
# RedHat: version number in directory name |
|||
$dir_docs = glob "$dir_docs/MySQL-server*"; |
|||
} |
|||
} else { |
|||
# tar.gz package, Windows, or developer work (in BZR) |
|||
$dir_docs =~ s|/lib||; |
|||
if(-d "$dir_docs/docs") { |
|||
$dir_docs = "$dir_docs/docs"; # package |
|||
} else { |
|||
$dir_docs = "$dir_docs/Docs"; # development tree |
|||
} |
|||
} |
|||
$found_version = "No line 'MySQL source #.#.#'"; |
|||
$found_revision = "No line 'revision-id: .....'"; |
|||
open(I_SRC,"<","$dir_docs/INFO_SRC") or print "Cannot open 'INFO_SRC' in '$dir_docs'\n"; |
|||
while(defined ($line = <I_SRC>)) { |
|||
if ($line =~ m|^MySQL source \d\.\d\.\d+|) {$found_version = "Found MySQL version number";} |
|||
if ($line =~ m|^revision-id: .*@.*-2\d{13}-\w+$|) {$found_revision = "Found BZR revision id";} |
|||
} |
|||
close I_SRC; |
|||
print "INFO_SRC: $found_version / $found_revision\n"; |
|||
$found_compiler = "No line about compiler information"; |
|||
$found_features = "No line 'Feature flags'"; |
|||
open(I_BIN,"<","$dir_docs/INFO_BIN") or print "Cannot open 'INFO_BIN' in '$dir_docs'\n"; |
|||
while(defined ($line = <I_BIN>)) { |
|||
# "generator" on Windows, "flags" on Unix: |
|||
if (($line =~ m| Compiler / generator used: |) || |
|||
($line =~ m| Compiler flags used |)) {$found_compiler = "Found 'Compiler ... used' line";} |
|||
if ($line =~ m| Feature flags used:|) {$found_features = "Found 'Feature flags' line";} |
|||
} |
|||
close I_BIN; |
|||
print "INFO_BIN: $found_compiler / $found_features\n"; |
|||
EOF |
|||
|
|||
--echo |
|||
--echo End of tests |
Write
Preview
Loading…
Cancel
Save
Reference in new issue