mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-30 15:32:37 +08:00
[svn-r27846] Fix generated files process.
Add script for post processing of flex/bison files.
This commit is contained in:
parent
0e4ee6d829
commit
9edd184ae9
1
MANIFEST
1
MANIFEST
@ -2330,6 +2330,7 @@
|
||||
./config/cmake/hdf5-config.cmake.in
|
||||
./config/cmake/hdf5-config-version.cmake.in
|
||||
./config/cmake/HDFCompilerFlags.cmake
|
||||
./config/cmake/HDF5_Process_Flex_Files.cmake
|
||||
./config/cmake/HDF5Macros.cmake
|
||||
./config/cmake/HDF5UseFortran.cmake
|
||||
./config/cmake/libhdf5.settings.cmake.in
|
||||
|
@ -39,75 +39,4 @@ macro (H5_SET_LIB_OPTIONS libtarget libname libtype)
|
||||
endif (${libtype} MATCHES "SHARED")
|
||||
endif (HDF5_BUILD_FRAMEWORKS)
|
||||
endif (APPLE)
|
||||
|
||||
endmacro (H5_SET_LIB_OPTIONS)
|
||||
|
||||
macro (H5_GEN_PERL_FILES)
|
||||
find_package (Perl)
|
||||
if (PERL_FOUND)
|
||||
add_custom_command (
|
||||
OUTPUT ${HDF5_BINARY_DIR}/H5Edefin.h
|
||||
PRE_BUILD
|
||||
COMMAND ${PERL_EXECUTABLE}
|
||||
ARGS ${HDF5_SOURCE_DIR}/bin/make_err ${HDF5_SOURCE_DIR}/src/H5err.txt
|
||||
DEPENDS ${HDF5_SOURCE_DIR}/src/H5err.txt
|
||||
COMMENT " Creating err header"
|
||||
)
|
||||
|
||||
add_custom_command (
|
||||
OUTPUT ${HDF5_BINARY_DIR}/H5version.h
|
||||
PRE_BUILD
|
||||
COMMAND ${PERL_EXECUTABLE}
|
||||
ARGS ${HDF5_SOURCE_DIR}/bin/make_vers ${HDF5_SOURCE_DIR}/src/H5vers.txt
|
||||
DEPENDS ${HDF5_SOURCE_DIR}/src/H5vers.txt
|
||||
COMMENT " Creating API version macro"
|
||||
)
|
||||
|
||||
add_custom_command (
|
||||
OUTPUT ${HDF5_BINARY_DIR}/H5overflow.h
|
||||
PRE_BUILD
|
||||
COMMAND ${PERL_EXECUTABLE}
|
||||
ARGS ${HDF5_SOURCE_DIR}/bin/make_overflow ${HDF5_SOURCE_DIR}/src/H5overflow.txt
|
||||
DEPENDS ${HDF5_SOURCE_DIR}/src/H5overflow.txt
|
||||
COMMENT " Creating Assignment overflow macro"
|
||||
)
|
||||
|
||||
add_custom_target(run_perl_scripts ALL
|
||||
DEPENDS ${HDF5_BINARY_DIR}/H5Edefin.h ${HDF5_BINARY_DIR}/H5version.h ${HDF5_BINARY_DIR}/H5overflow.h
|
||||
)
|
||||
else (PERL_FOUND)
|
||||
message (STATUS "Cannot generate headers - perl not found")
|
||||
endif (PERL_FOUND)
|
||||
endmacro (H5_GEN_PERL_FILES)
|
||||
|
||||
macro (H5_GEN_FLEX_FILES)
|
||||
find_package (BISON)
|
||||
if (BISON_FOUND)
|
||||
find_package (FLEX)
|
||||
if (FLEX_FOUND)
|
||||
BISON_TARGET (H5LT_PARSER H5LTparse.y ${CMAKE_CURRENT_BINARY_DIR}/H5LTparse.c COMPILE_FLAGS -d)
|
||||
if (WIN32)
|
||||
FLEX_TARGET (H5LT_SCANNER H5LTanalyze.l ${CMAKE_CURRENT_BINARY_DIR}/H5LTanalyze.c COMPILE_FLAGS --wincompat)
|
||||
else (WIN32)
|
||||
FLEX_TARGET (H5LT_SCANNER H5LTanalyze.l ${CMAKE_CURRENT_BINARY_DIR}/H5LTanalyze.c)
|
||||
endif (WIN32)
|
||||
ADD_FLEX_BISON_DEPENDENCY(H5LT_SCANNER H5LT_PARSER)
|
||||
|
||||
if (BISON_H5LT_PARSER_DEFINED AND FLEX_H5LT_SCANNER_DEFINED)
|
||||
set_source_files_properties (${FLEX_H5LT_SCANNER_OUTPUTS}
|
||||
PROPERTIES OBJECT_DEPENDS ${BISON_H5LT_PARSER_OUTPUTS})
|
||||
set (HL_SRCS
|
||||
${BISON_H5LT_PARSER_OUTPUTS}
|
||||
${FLEX_H5LT_SCANNER_OUTPUTS}
|
||||
)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
else (BISON_H5LT_PARSER_DEFINED AND FLEX_H5LT_SCANNER_DEFINED)
|
||||
message (STATUS "Error during generate of files")
|
||||
endif (BISON_H5LT_PARSER_DEFINED AND FLEX_H5LT_SCANNER_DEFINED)
|
||||
else (FLEX_FOUND)
|
||||
message (STATUS "Cannot generate files - flex not found")
|
||||
endif (FLEX_FOUND)
|
||||
else (BISON_FOUND)
|
||||
message (STATUS "Cannot generate files - bison not found")
|
||||
endif (BISON_FOUND)
|
||||
endmacro (H5_GEN_FLEX_FILES)
|
||||
|
81
config/cmake/HDF5_Process_Flex_Files.cmake
Normal file
81
config/cmake/HDF5_Process_Flex_Files.cmake
Normal file
@ -0,0 +1,81 @@
|
||||
# post process flex/bison files
|
||||
|
||||
message (STATUS "File: ${FILE_PARSE} ${FILE_ANALYZE}")
|
||||
|
||||
if (FILE_PARSE)
|
||||
# fix H5LTparse.c to declare H5LTyyparse return type as an hid_t
|
||||
# instead of int. Currently the generated function H5LTyyparse is
|
||||
# generated with a return value of type int, which is a mapping to the
|
||||
# flex yyparse function. The return value in the HL library should be
|
||||
# an hid_t.
|
||||
# I propose to not use flex to generate this function, but for now I am
|
||||
# adding a perl command to find and replace this function declaration in
|
||||
# H5LTparse.c.
|
||||
file (READ ${FILE_PARSE} TEST_STREAM)
|
||||
string (REGEX REPLACE "int\nyyparse" "hid_t\nyyparse" TEST_STREAM "${TEST_STREAM}")
|
||||
string (REGEX REPLACE "int H5LTyyparse" "hid_t H5LTyyparse" TEST_STREAM "${TEST_STREAM}")
|
||||
file (WRITE ${FILE_PARSE} "${TEST_STREAM}")
|
||||
message (STATUS "replacing signature in H5LTparse.c")
|
||||
|
||||
# Add code that disables warnings in the flex/bison-generated code.
|
||||
#
|
||||
# Note that the GCC pragmas did not exist until gcc 4.2. Earlier versions
|
||||
# will simply ignore them, but we want to avoid those warnings.
|
||||
file (READ ${FILE_PARSE} TEST_STREAM)
|
||||
file (WRITE ${FILE_PARSE} "
|
||||
#if __GNUC__ >= 4 && __GNUC_MINOR__ >=2\n
|
||||
#pragma GCC diagnostic ignored \"-Wconversion\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wimplicit-function-declaration\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wlarger-than=\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wmissing-prototypes\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wnested-externs\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wold-style-definition\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wsign-compare\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wsign-conversion\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wswitch-default\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wunused-function\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wunused-macros\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wredundant-decls\"\n
|
||||
#elif defined __SUNPRO_CC\n
|
||||
#pragma disable_warn\n
|
||||
#elif defined _MSC_VER\n
|
||||
#pragma warning(push, 1)\n
|
||||
#endif\n
|
||||
")
|
||||
file (APPEND ${FILE_PARSE} "${TEST_STREAM}")
|
||||
message (STATUS "processing pragma in ${FILE_PARSE}")
|
||||
endif (FILE_PARSE)
|
||||
|
||||
if (FILE_ANALYZE)
|
||||
# Add code that disables warnings in the flex/bison-generated code.
|
||||
#
|
||||
# Note that the GCC pragmas did not exist until gcc 4.2. Earlier versions
|
||||
# will simply ignore them, but we want to avoid those warnings.
|
||||
file (READ ${FILE_ANALYZE} TEST_STREAM)
|
||||
file (WRITE ${FILE_ANALYZE} "
|
||||
#if __GNUC__ >= 4 && __GNUC_MINOR__ >=2\n
|
||||
#pragma GCC diagnostic ignored \"-Wconversion\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wimplicit-function-declaration\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wlarger-than=\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wmissing-prototypes\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wnested-externs\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wold-style-definition\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wsign-compare\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wsign-conversion\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wswitch-default\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wunused-function\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wunused-macros\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n
|
||||
#pragma GCC diagnostic ignored \"-Wredundant-decls\"\n
|
||||
#elif defined __SUNPRO_CC\n
|
||||
#pragma disable_warn\n
|
||||
#elif defined _MSC_VER\n
|
||||
#pragma warning(push, 1)\n
|
||||
#endif\n
|
||||
")
|
||||
file (APPEND ${FILE_ANALYZE} "${TEST_STREAM}")
|
||||
message (STATUS "processing pragma in ${FILE_ANALYZE}")
|
||||
endif (FILE_ANALYZE)
|
@ -8,8 +8,6 @@ set (CMAKE_INSTALL_FRAMEWORK_PREFIX "Library/Frameworks" CACHE STRING "Framework
|
||||
|
||||
set (HDF_PACKAGE_EXT "" CACHE STRING "Name of HDF package extension" FORCE)
|
||||
|
||||
set (HDF5_GENERATE_HEADERS ON CACHE BOOL "Rebuild Generated Files" FORCE)
|
||||
|
||||
set (HDF5_BUILD_FORTRAN ON CACHE BOOL "Build FORTRAN support" FORCE)
|
||||
|
||||
set (HDF5_BUILD_GENERATORS OFF CACHE BOOL "Build Test Generators" FORCE)
|
||||
|
@ -12,8 +12,6 @@ set (BUILD_TESTING ON CACHE BOOL "Build HDF5 Unit Testing" FORCE)
|
||||
|
||||
set (HDF_PACKAGE_EXT "" CACHE STRING "Name of HDF package extension" FORCE)
|
||||
|
||||
set (HDF5_GENERATE_HEADERS ON CACHE BOOL "Rebuild Generated Files" FORCE)
|
||||
|
||||
set (HDF5_BUILD_CPP_LIB ON CACHE BOOL "Build HDF5 C++ Library" FORCE)
|
||||
|
||||
set (HDF5_BUILD_EXAMPLES ON CACHE BOOL "Build HDF5 Library Examples" FORCE)
|
||||
|
@ -1,4 +1,4 @@
|
||||
# runTest.cmake executes a command and captures the output in a file. File is then compared
|
||||
# userblockTest.cmake executes a command and captures the output in a file. File is then compared
|
||||
# against a reference file. Exit status of command can also be compared.
|
||||
|
||||
# arguments checking
|
||||
@ -56,9 +56,9 @@ if (TEST_CHECKUB STREQUAL "YES")
|
||||
endif (NOT ${TEST_RESULT} STREQUAL "0")
|
||||
file (READ ${TEST_HFILE}.len.txt TEST_O_STRING_LEN)
|
||||
endif (TEST_OFILE)
|
||||
|
||||
|
||||
MATH( EXPR TEST_STRING_SIZE "${TEST_U_STRING_LEN} + ${TEST_O_STRING_LEN}" )
|
||||
|
||||
|
||||
if (NOT TEST_O_STRING_LEN STREQUAL "0")
|
||||
#$JAM_BIN/getub -c $s2 $origfile > $cmpfile
|
||||
EXECUTE_PROCESS (
|
||||
@ -72,7 +72,7 @@ if (TEST_CHECKUB STREQUAL "YES")
|
||||
)
|
||||
#cat $ufile >> $cmpfile
|
||||
file (STRINGS ${TEST_UFILE} TEST_STREAM NEWLINE_CONSUME)
|
||||
file (APPEND ${TEST_HFILE}-ub.cmp "${TEST_STREAM}")
|
||||
file (APPEND ${TEST_HFILE}-ub.cmp "${TEST_STREAM}")
|
||||
else (NOT TEST_O_STRING_LEN STREQUAL "0")
|
||||
file (STRINGS ${TEST_UFILE} TEST_STREAM NEWLINE_CONSUME)
|
||||
file (WRITE ${TEST_HFILE}-ub.cmp ${TEST_STREAM})
|
||||
|
@ -26,6 +26,35 @@ if (HDF5_GENERATE_HEADERS)
|
||||
set_source_files_properties (${CMAKE_CURRENT_BINARY_DIR}/H5LTanalyze.c GENERATED)
|
||||
set_source_files_properties (${CMAKE_CURRENT_BINARY_DIR}/H5LTparse.c GENERATED)
|
||||
set_source_files_properties (${CMAKE_CURRENT_BINARY_DIR}/H5LTparse.h GENERATED)
|
||||
|
||||
add_custom_command (
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/H5LTparse.timestamp
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
-D "FILE_PARSE=H5LTparse.c"
|
||||
-P "${HDF_RESOURCES_DIR}/HDF5_Process_Flex_Files.cmake"
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/H5LTparse.timestamp
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/H5LTparse.c
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
add_custom_command (
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/H5LTanalyze.timestamp
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
-D "FILE_ANALYZE=H5LTanalyze.c"
|
||||
-P "${HDF_RESOURCES_DIR}/HDF5_Process_Flex_Files.cmake"
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/H5LTanalyze.timestamp
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/H5LTanalyze.c
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
add_custom_target (process_gen_H5LT DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/H5LTparse.timestamp ${CMAKE_CURRENT_BINARY_DIR}/H5LTanalyze.timestamp)
|
||||
|
||||
# add_custom_target (process_gen_H5LT
|
||||
# COMMAND "${CMAKE_COMMAND}"
|
||||
# -D "FILE_PARSE=${CMAKE_CURRENT_BINARY_DIR}/H5LTparse.c"
|
||||
# -D "FILE_ANALYSE=${CMAKE_CURRENT_BINARY_DIR}/H5LTanalyze.c"
|
||||
# -P "${HDF5_RESOURCE_DIR}/HDF5_Process_Flex_Files.cmake"
|
||||
# DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/H5LTparse.c ${CMAKE_CURRENT_BINARY_DIR}/H5LTanalyze.c"
|
||||
# COMMENT "Prepending pragma statements"
|
||||
# )
|
||||
else (BISON_H5LT_PARSER_DEFINED AND FLEX_H5LT_SCANNER_DEFINED)
|
||||
message (STATUS "Error during generate of files")
|
||||
endif (BISON_H5LT_PARSER_DEFINED AND FLEX_H5LT_SCANNER_DEFINED)
|
||||
@ -82,6 +111,11 @@ set_target_properties (${HDF5_HL_LIB_TARGET} PROPERTIES
|
||||
)
|
||||
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_LIB_TARGET}")
|
||||
set (install_targets ${HDF5_HL_LIB_TARGET})
|
||||
if (HDF5_GENERATE_HEADERS)
|
||||
add_dependencies(${HDF5_HL_LIB_TARGET} process_gen_H5LT)
|
||||
else (HDF5_GENERATE_HEADERS)
|
||||
add_dependencies(${HDF5_HL_LIB_TARGET} "${HDF5_HL_SRC_SOURCE_DIR}/H5LTanalyze.c;${HDF5_HL_SRC_SOURCE_DIR}/H5LTparse.c")
|
||||
endif (HDF5_GENERATE_HEADERS)
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
add_library (${HDF5_HL_LIBSH_TARGET} SHARED ${HL_SRCS} ${HL_HEADERS})
|
||||
@ -96,6 +130,11 @@ if (BUILD_SHARED_LIBS)
|
||||
)
|
||||
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_LIBSH_TARGET}")
|
||||
set (install_targets ${install_targets} ${HDF5_HL_LIBSH_TARGET})
|
||||
if (HDF5_GENERATE_HEADERS)
|
||||
add_dependencies(${HDF5_HL_LIBSH_TARGET} process_gen_H5LT)
|
||||
else (HDF5_GENERATE_HEADERS)
|
||||
add_dependencies(${HDF5_HL_LIBSH_TARGET} "${HDF5_HL_SRC_SOURCE_DIR}/H5LTanalyze.c;${HDF5_HL_SRC_SOURCE_DIR}/H5LTparse.c")
|
||||
endif (HDF5_GENERATE_HEADERS)
|
||||
endif (BUILD_SHARED_LIBS)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
@ -776,6 +776,8 @@ set (H5_GENERATED_HEADERS
|
||||
${HDF5_SRC_DIR}/H5overflow.h
|
||||
)
|
||||
|
||||
option (HDF5_GENERATE_HEADERS "Rebuild Generated Files" ON)
|
||||
mark_as_advanced (HDF5_GENERATE_HEADERS)
|
||||
if (HDF5_GENERATE_HEADERS)
|
||||
find_package (Perl)
|
||||
if (PERL_FOUND)
|
||||
@ -826,7 +828,11 @@ TARGET_C_PROPERTIES (H5detect STATIC " " " ")
|
||||
if (MSVC OR MINGW)
|
||||
target_link_libraries (H5detect "ws2_32.lib")
|
||||
endif (MSVC OR MINGW)
|
||||
add_dependencies(H5detect generate_precompiled)
|
||||
if (HDF5_GENERATE_HEADERS)
|
||||
add_dependencies(H5detect generate_precompiled)
|
||||
else (HDF5_GENERATE_HEADERS)
|
||||
add_dependencies(H5detect "${HDF5_SRC_DIR}/H5version.h;${HDF5_SRC_DIR}/H5overflow.h")
|
||||
endif (HDF5_GENERATE_HEADERS)
|
||||
|
||||
set (CMD $<TARGET_FILE:H5detect>)
|
||||
add_custom_command (
|
||||
@ -841,7 +847,11 @@ TARGET_C_PROPERTIES (H5make_libsettings STATIC " " " ")
|
||||
if (MSVC OR MINGW)
|
||||
target_link_libraries (H5make_libsettings "ws2_32.lib")
|
||||
endif (MSVC OR MINGW)
|
||||
add_dependencies(H5make_libsettings generate_precompiled)
|
||||
if (HDF5_GENERATE_HEADERS)
|
||||
add_dependencies(H5detect generate_precompiled)
|
||||
else (HDF5_GENERATE_HEADERS)
|
||||
add_dependencies(H5make_libsettings "${HDF5_SRC_DIR}/H5version.h;${HDF5_SRC_DIR}/H5overflow.h")
|
||||
endif (HDF5_GENERATE_HEADERS)
|
||||
|
||||
set (CMD $<TARGET_FILE:H5make_libsettings>)
|
||||
add_custom_command (
|
||||
|
Loading…
Reference in New Issue
Block a user