summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2018-06-08 14:30:04 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2018-06-08 14:30:04 +0100
commit4461b0f9b301233b245853b9b71b3770c24c5aac (patch)
tree7208a4fd6819f6301b7ade76e69b4fb6dc2269c5
parent62d21ddac1dbce91cb3c904da39d33ca81d51d99 (diff)
downloadmariadb-git-4461b0f9b301233b245853b9b71b3770c24c5aac.tar.gz
MDEV-16424 replace cmake/bison.cmake with cmake's builtin FindBison module
-rw-r--r--cmake/bison.cmake106
-rw-r--r--cmake/make_dist.cmake.in17
-rw-r--r--libmysqld/CMakeLists.txt4
-rw-r--r--sql/CMakeLists.txt89
-rw-r--r--sql/gen_lex_token.cc2
-rw-r--r--sql/sql_digest.cc2
-rw-r--r--sql/sql_lex.h6
7 files changed, 61 insertions, 165 deletions
diff --git a/cmake/bison.cmake b/cmake/bison.cmake
deleted file mode 100644
index d825e407b22..00000000000
--- a/cmake/bison.cmake
+++ /dev/null
@@ -1,106 +0,0 @@
-# Copyright (c) 2009 Sun Microsystems, Inc.
-# Use is subject to license terms.
-#
-# 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
-
-IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
- # On Solaris, /opt/csw often contains a newer bison
- IF(NOT BISON_EXECUTABLE AND EXISTS /opt/csw/bin/bison)
- SET(BISON_EXECUTABLE /opt/csw/bin/bison)
- ENDIF()
-ENDIF()
-IF(WIN32)
- SET(BISON_PATH_HINTS
- HINTS
- C:/gnuwin32/bin
- C:/cygwin64/bin
- C:/cygwin/bin)
-ENDIF()
-FIND_PROGRAM(BISON_EXECUTABLE bison
- ${BISON_PATH_HINTS}
- DOC "path to the bison executable")
-MARK_AS_ADVANCED(BISON_EXECUTABLE "")
-IF(NOT BISON_EXECUTABLE)
- MESSAGE("Warning: Bison executable not found in PATH")
-ELSEIF(BISON_EXECUTABLE AND NOT BISON_USABLE)
- # Check version as well
- EXEC_PROGRAM(${BISON_EXECUTABLE} ARGS --version OUTPUT_VARIABLE BISON_VERSION_STR)
- # Get first line in case it's multiline
- STRING(REGEX REPLACE "([^\n]+).*" "\\1" FIRST_LINE "${BISON_VERSION_STR}")
- # get version information
- STRING(REGEX REPLACE ".* ([0-9]+)\\.([0-9]+)" "\\1" BISON_VERSION_MAJOR "${FIRST_LINE}")
- STRING(REGEX REPLACE ".* ([0-9]+)\\.([0-9]+)" "\\2" BISON_VERSION_MINOR "${FIRST_LINE}")
- IF (BISON_VERSION_MAJOR LESS 2)
- MESSAGE("Warning: bison version is old. please update to version 2")
- ELSE()
- SET(BISON_USABLE 1 CACHE INTERNAL "Bison version 2 or higher")
- ENDIF()
-ENDIF()
-
-# Use bison to generate C++ and header file
-MACRO (RUN_BISON input_yy output_cc output_h name_prefix)
- IF(BISON_TOO_OLD)
- IF(EXISTS ${output_cc} AND EXISTS ${output_h})
- SET(BISON_USABLE FALSE)
- ENDIF()
- ENDIF()
- IF(BISON_USABLE)
- # Workaround for VS regenerating output even
- # when outputs are up-to-date. At least, fix output timestamp
- # after build so that files that depend on generated header are
- # not rebuilt.
- IF(CMAKE_GENERATOR MATCHES "Visual Studio")
- FIND_PROGRAM(TOUCH_EXECUTABLE touch DOC "Path to touch executable"
- PATHS "C:/Program Files/Git/usr/bin"
- "C:/Program Files (x86)/Git/usr/bin")
- IF(TOUCH_EXECUTABLE)
- SET(VS_FIX_OUTPUT_TIMESTAMPS
- COMMAND ${TOUCH_EXECUTABLE} -r ${input_yy} ${output_cc}
- COMMAND ${TOUCH_EXECUTABLE} -r ${input_yy} ${output_h})
- ENDIF()
- ENDIF()
-
- ADD_CUSTOM_COMMAND(
- OUTPUT ${output_cc}
- ${output_h}
- COMMAND ${BISON_EXECUTABLE} -y -p ${name_prefix}
- --output=${output_cc}
- --defines=${output_h}
- ${input_yy}
- ${VS_FIX_OUTPUT_TIMESTAMPS}
- DEPENDS ${input_yy}
- )
- ELSE()
- # Bison is missing or not usable, e.g too old
- IF(EXISTS ${output_cc} AND EXISTS ${output_h})
- IF(${input_yy} IS_NEWER_THAN ${output_cc} OR ${input_yy} IS_NEWER_THAN ${output_h})
- # Possibly timestamps are messed up in source distribution.
- MESSAGE("Warning: no usable bison found, ${input_yy} will not be rebuilt.")
- ENDIF()
- ELSE()
- # Output files are missing, bail out.
- SET(ERRMSG
- "Bison (GNU parser generator) is required to build MySQL."
- "Please install bison."
- )
- IF(WIN32)
- SET(ERRMSG ${ERRMSG}
- "You can download bison from http://gnuwin32.sourceforge.net/packages/bison.htm "
- "Choose 'Complete package, except sources' installation. We recommend to "
- "install bison into a directory without spaces, e.g C:\\GnuWin32.")
- ENDIF()
- MESSAGE(FATAL_ERROR ${ERRMSG})
- ENDIF()
- ENDIF()
-ENDMACRO()
diff --git a/cmake/make_dist.cmake.in b/cmake/make_dist.cmake.in
index 885cfa2a706..43498f1f888 100644
--- a/cmake/make_dist.cmake.in
+++ b/cmake/make_dist.cmake.in
@@ -67,8 +67,8 @@ IF(NOT GIT_EXECUTABLE)
# Save bison output first.
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
${CMAKE_BINARY_DIR}/sql_yacc.cc COPYONLY)
- CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.h
- ${CMAKE_BINARY_DIR}/sql_yacc.h COPYONLY)
+ CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.hh
+ ${CMAKE_BINARY_DIR}/sql_yacc.hh COPYONLY)
IF(CMAKE_GENERATOR MATCHES "Makefiles")
# make clean
@@ -81,10 +81,10 @@ IF(NOT GIT_EXECUTABLE)
# Restore bison output
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql_yacc.cc
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc COPYONLY)
- CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql_yacc.h
+ CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql_yacc.hh
${CMAKE_BINARY_DIR}/sql/sql_yacc.h COPYONLY)
FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.cc)
- FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.h)
+ FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.hh)
ENDIF()
EXECUTE_PROCESS(
@@ -102,10 +102,15 @@ IF(NOT GIT_EXECUTABLE)
ENDIF()
# Copy bison output
-CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.h
- ${PACKAGE_DIR}/sql/sql_yacc.h COPYONLY)
+CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.hh
+ ${PACKAGE_DIR}/sql/sql_yacc.hh COPYONLY)
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
${PACKAGE_DIR}/sql/sql_yacc.cc COPYONLY)
+# Copy bison output
+CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.hh
+ ${PACKAGE_DIR}/sql/sql_yacc_ora.hh COPYONLY)
+CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc
+ ${PACKAGE_DIR}/sql/sql_yacc_orac.cc COPYONLY)
# Add documentation, if user has specified where to find them
IF(MYSQL_DOCS_LOCATION)
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index f1fcfac58f5..d7450eb3e87 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -28,9 +28,9 @@ ${SSL_INTERNAL_INCLUDE_DIRS}
)
SET(GEN_SOURCES
-${CMAKE_BINARY_DIR}/sql/sql_yacc.h
+${CMAKE_BINARY_DIR}/sql/sql_yacc.hh
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
-${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.h
+${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.hh
${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc
${CMAKE_BINARY_DIR}/sql/lex_hash.h
)
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 7253f7ba447..0037ff23153 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -45,23 +45,10 @@ ${CMAKE_BINARY_DIR}/sql
${WSREP_INCLUDES}
)
-SET(GEN_SOURCES
-${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
-${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
-${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.h
-${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
-${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
-${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
-)
-SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES}
- PROPERTIES GENERATED 1)
-IF(NOT CMAKE_CROSSCOMPILING)
- ADD_EXECUTABLE(gen_lex_token gen_lex_token.cc
- ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h)
-ENDIF()
+
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
@@ -151,7 +138,10 @@ SET (SQL_SOURCE
table_cache.cc encryption.cc temporary_tables.cc
proxy_protocol.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_builtin.cc
- ${GEN_SOURCES}
+ ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
+ ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
+ ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
+ ${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
${MYSYS_LIBWRAP_SOURCE}
)
@@ -173,7 +163,6 @@ MYSQL_ADD_PLUGIN(sql_sequence ha_sequence.cc STORAGE_ENGINE MANDATORY STATIC_ONL
RECOMPILE_FOR_EMBEDDED)
ADD_LIBRARY(sql STATIC ${SQL_SOURCE})
-ADD_DEPENDENCIES(sql GenServerSource)
DTRACE_INSTRUMENT(sql)
TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS}
mysys mysys_ssl dbug strings vio pcre
@@ -339,40 +328,48 @@ IF(WITH_MYSQLD_LDFLAGS)
"${MYSQLD_LINK_FLAGS} ${WITH_MYSQLD_LDFLAGS}")
ENDIF()
-INCLUDE(${CMAKE_SOURCE_DIR}/cmake/bison.cmake)
+
+FIND_PACKAGE(BISON 2.0)
+
# Handle out-of-source build from source package with possibly broken
# bison. Copy bison output to from source to build directory, if not already
# there
-IF (NOT BISON_USABLE)
-IF (NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
- IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc)
- IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc)
- CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc
- ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc COPYONLY)
- CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.h
- ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h COPYONLY)
+IF (NOT BISON_FOUND)
+ IF (NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
+ FOREACH(file sql_yacc.cc sql_yacc.hh sql_yacc_ora.cc sql_yacc_ora.hh)
+ IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file} AND (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${file}))
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}
+ ${CMAKE_CURRENT_BINARY_DIR}/${file} COPYONLY)
ENDIF()
+ ENDFOREACH()
ENDIF()
-ENDIF()
-ENDIF()
-RUN_BISON(
- ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.yy
- ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
- ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
- MYSQL
-)
+ IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc)
+ # Output files are missing, bail out.
+ SET(ERRMSG
+ "Bison (GNU parser generator) is required to build MySQL."
+ "Please install bison."
+ )
+ IF(WIN32)
+ SET(ERRMSG ${ERRMSG}
+ "You can download bison from http://gnuwin32.sourceforge.net/packages/bison.htm "
+ "Choose 'Complete package, except sources' installation. We recommend to "
+ "install bison into a directory without spaces, e.g C:\\GnuWin32.")
+ ENDIF()
+ MESSAGE(FATAL_ERROR ${ERRMSG})
+ ENDIF()
+ELSE()
+ BISON_TARGET(gen_sql_yacc ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.yy ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
+ COMPILE_FLAGS "-p MYSQL")
-RUN_BISON(
- ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc_ora.yy
- ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
- ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.h
- ORA
-)
+ BISON_TARGET(gen_sql_yacc_ora ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc_ora.yy ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
+ COMPILE_FLAGS "-p ORA")
+ENDIF()
-# Gen_lex_hash
IF(NOT CMAKE_CROSSCOMPILING)
+ ADD_EXECUTABLE(gen_lex_token gen_lex_token.cc
+ ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.hh)
ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc)
ENDIF()
@@ -388,12 +385,12 @@ TARGET_LINK_LIBRARIES(mysql_tzinfo_to_sql mysys mysys_ssl)
ADD_CUSTOM_TARGET(
GenServerSource
- DEPENDS ${GEN_SOURCES}
+ DEPENDS
+ ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
+ ${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
+ ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
)
-#Need this only for embedded
-SET_TARGET_PROPERTIES(GenServerSource PROPERTIES EXCLUDE_FROM_ALL TRUE)
-
IF(WIN32 OR HAVE_DLOPEN AND NOT DISABLE_SHARED)
ADD_LIBRARY(udf_example MODULE udf_example.c udf_example.def)
SET_TARGET_PROPERTIES(udf_example PROPERTIES PREFIX "")
@@ -406,8 +403,8 @@ CONFIGURE_FILE(
ADD_CUSTOM_TARGET(dist
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/make_dist.cmake
- DEPENDS ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc.h
- DEPENDS ${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.h
+ DEPENDS ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc.hh
+ DEPENDS ${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.hh
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
diff --git a/sql/gen_lex_token.cc b/sql/gen_lex_token.cc
index b36df5e94be..c03bfe66f47 100644
--- a/sql/gen_lex_token.cc
+++ b/sql/gen_lex_token.cc
@@ -19,7 +19,7 @@
/* We only need the tokens here */
#define YYSTYPE_IS_DECLARED
-#include <sql_yacc.h>
+#include <sql_yacc.hh>
#include <lex.h>
#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
diff --git a/sql/sql_digest.cc b/sql/sql_digest.cc
index 54ed1c3f225..a8afd33c46a 100644
--- a/sql/sql_digest.cc
+++ b/sql/sql_digest.cc
@@ -32,7 +32,7 @@
#include "sql_get_diagnostics.h"
/* Generated code */
-#include "sql_yacc.h"
+#include "sql_yacc.hh"
#define LEX_TOKEN_WITH_DEFINITION
#include "lex_token.h"
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 70caa3b92b9..77e477b7cb4 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -269,10 +269,10 @@ struct LEX_TYPE
#else
#include "lex_symbol.h"
#ifdef MYSQL_LEX
-#include "item_func.h" /* Cast_target used in sql_yacc.h */
-#include "sql_get_diagnostics.h" /* Types used in sql_yacc.h */
+#include "item_func.h" /* Cast_target used in sql_yacc.hh */
+#include "sql_get_diagnostics.h" /* Types used in sql_yacc.hh */
#include "sp_pcontext.h"
-#include "sql_yacc.h"
+#include "sql_yacc.hh"
#define LEX_YYSTYPE YYSTYPE *
#else
#define LEX_YYSTYPE void *