ECC-688 migrate system header and symbols tests

This commit is contained in:
Tiago Quintino 2018-05-11 13:07:03 +01:00
parent d3b43d8323
commit f5bd10fc55
3 changed files with 39 additions and 33 deletions

View File

@ -31,6 +31,20 @@ ecbuild_requires_macro_version( 2.7.2 )
ecbuild_declare_project() ecbuild_declare_project()
###############################################################################
# system checks needed for eccodes_config.h and some options like MEMFS
check_include_files( assert.h ECCODES_HAVE_ASSERT_H )
check_include_files( string.h ECCODES_HAVE_STRING_H )
check_include_files( sys/types.h ECCODES_HAVE_SYS_TYPES_H )
check_include_files( sys/stat.h ECCODES_HAVE_SYS_STAT_H )
check_include_files( fcntl.h ECCODES_HAVE_FCNTL_H )
check_include_files( unistd.h ECCODES_HAVE_UNISTD_H )
check_symbol_exists( fseeko "stdio.h" ECCODES_HAVE_FSEEKO )
check_symbol_exists( posix_memalign "stdlib.h" ECCODES_HAVE_POSIX_MEMALIGN )
check_symbol_exists( fmemopen "stdio.h" ECCODES_HAVE_FMEMOPEN )
check_symbol_exists( funopen "stdio.h" ECCODES_HAVE_FUNOPEN )
############################################################################### ###############################################################################
# some variables/options of this project # some variables/options of this project
@ -96,7 +110,7 @@ endif()
ecbuild_add_option( FEATURE MEMFS ecbuild_add_option( FEATURE MEMFS
DESCRIPTION "Memory based access to definitions/samples" DESCRIPTION "Memory based access to definitions/samples"
DEFAULT OFF DEFAULT OFF
CONDITION EC_HAVE_FMEMOPEN OR EC_HAVE_FUNOPEN CONDITION ECCODES_HAVE_FMEMOPEN OR ECCODES_HAVE_FUNOPEN
REQUIRED_PACKAGES PythonInterp REQUIRED_PACKAGES PythonInterp
) )
@ -276,25 +290,6 @@ set( ECCODES_IFS_SAMPLES_PATH ${the_default_data_prefix}/${ECCODES_IFS_SAMPLES_S
############################################################################### ###############################################################################
### config header ### config header
# system checks needed for eccodes_config.h
ecbuild_cache_check_include_files( assert.h EC_HAVE_ASSERT_H )
ecbuild_cache_check_include_files( string.h EC_HAVE_STRING_H )
ecbuild_cache_check_symbol_exists( fseeko "stdio.h" EC_HAVE_FSEEKO )
ecbuild_cache_check_include_files( sys/types.h EC_HAVE_SYS_TYPES_H )
ecbuild_cache_check_include_files( sys/stat.h EC_HAVE_SYS_STAT_H )
ecbuild_cache_check_include_files( fcntl.h EC_HAVE_FCNTL_H )
ecbuild_cache_check_include_files( unistd.h EC_HAVE_UNISTD_H )
ecbuild_cache_check_symbol_exists( posix_memalign "stdlib.h" EC_HAVE_POSIX_MEMALIGN )
ecbuild_generate_config_headers() ecbuild_generate_config_headers()
configure_file( eccodes_config.h.in eccodes_config.h ) configure_file( eccodes_config.h.in eccodes_config.h )

View File

@ -40,35 +40,46 @@
/* headers */ /* headers */
#ifdef EC_HAVE_ASSERT_H #cmakedefine ECCODES_HAVE_ASSERT_H
#cmakedefine ECCODES_HAVE_STRING_H
#cmakedefine ECCODES_HAVE_SYS_TYPES_H
#cmakedefine ECCODES_HAVE_SYS_STAT_H
#cmakedefine ECCODES_HAVE_FCNTL_H
#cmakedefine ECCODES_HAVE_UNISTD_H
#cmakedefine ECCODES_HAVE_FSEEKO
#cmakedefine ECCODES_HAVE_POSIX_MEMALIGN
#cmakedefine ECCODES_HAVE_FMEMOPEN
#cmakedefine ECCODES_HAVE_FUNOPEN
#if defined(EC_HAVE_ASSERT_H) || defined(ECCODES_HAVE_ASSERT_H)
#define HAVE_ASSERT_H 1 #define HAVE_ASSERT_H 1
#endif #endif
#ifdef EC_HAVE_STRING_H #if defined(EC_HAVE_STRING_H) || defined(ECCODES_HAVE_STRING_H)
#define HAVE_STRING_H 1 #define HAVE_STRING_H 1
#endif #endif
#ifdef EC_HAVE_FSEEKO #if defined(EC_HAVE_SYS_TYPES_H) || defined(ECCODES_HAVE_SYS_TYPES_H)
#define HAVE_FSEEKO 1
#endif
#ifdef EC_HAVE_SYS_TYPES_H
#define HAVE_SYS_TYPES_H 1 #define HAVE_SYS_TYPES_H 1
#endif #endif
#ifdef EC_HAVE_SYS_STAT_H #if defined(EC_HAVE_SYS_STAT_H) || defined(ECCODES_HAVE_SYS_STAT_H)
#define HAVE_SYS_STAT_H 1 #define HAVE_SYS_STAT_H 1
#endif #endif
#ifdef EC_HAVE_FCNTL_H #if defined(EC_HAVE_FCNTL_H) || defined(ECCODES_HAVE_FCNTL_H)
#define HAVE_FCNTL_H 1 #define HAVE_FCNTL_H 1
#endif #endif
#ifdef EC_HAVE_UNISTD_H #if defined(EC_HAVE_UNISTD_H) || defined(ECCODES_HAVE_UNISTD_H)
#define HAVE_UNISTD_H 1 #define HAVE_UNISTD_H 1
#endif #endif
#ifdef EC_HAVE_POSIX_MEMALIGN #if defined(EC_HAVE_FSEEKO) || defined(ECCODES_HAVE_FSEEKO)
#define HAVE_FSEEKO 1
#endif
#if defined(EC_HAVE_POSIX_MEMALIGN) || defined(ECCODES_HAVE_POSIX_MEMALIGN)
#define POSIX_MEMALIGN 1 #define POSIX_MEMALIGN 1
#endif #endif

View File

@ -76,7 +76,7 @@ for directory in dirs:
print(""" print("""
#include "eccodes_config.h" #include "eccodes_config.h"
#ifdef EC_HAVE_FMEMOPEN #ifdef ECCODES_HAVE_FMEMOPEN
#define _GNU_SOURCE #define _GNU_SOURCE
#endif #endif
@ -99,7 +99,7 @@ for k, v in sorted(items):
print("""}; print("""};
#if defined(EC_HAVE_FUNOPEN) && !defined(EC_HAVE_FMEMOPEN) #if defined(ECCODES_HAVE_FUNOPEN) && !defined(ECCODES_HAVE_FMEMOPEN)
typedef struct mem_file { typedef struct mem_file {
const char* buffer; const char* buffer;