[Kst] branches/work/kst/portto4/kst/misc/getdata-windows

Peter Kümmel syntheticpp at gmx.net
Thu Dec 2 16:05:51 CET 2010


SVN commit 1202857 by kuemmel:

getdata: msvc support, build tests

 M  +27 -17    cmake/CMakeLists.txt  
 M  +1 -1      cmake/bindings/cxx/CMakeLists.txt  
 M  +17 -64    cmake/src/CMakeLists.txt  
 M  +83 -97    msvc.patch  


--- branches/work/kst/portto4/kst/misc/getdata-windows/cmake/CMakeLists.txt #1202856:1202857
@@ -3,39 +3,43 @@
 project( getdata )
 
 
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/bin) 
+#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/bin)
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/lib) 
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/lib) 
 
 
-if(NOT GETDATA_DIR)
-	set(GETDATA_DIR ${CMAKE_SOURCE_DIR}/..)
+if(NOT GD_DIR)
+	set(GD_DIR ${CMAKE_SOURCE_DIR}/..)
 endif()
 
 
 macro(GD_FILES name folder)
-	file(GLOB ${name}_folder_sources ${GETDATA_DIR}/${folder}/*.c) 
-	file(GLOB ${name}_folder_sources_cpp ${GETDATA_DIR}/${folder}/*.cpp)
-	file(GLOB ${name}_folder_headers ${GETDATA_DIR}/${folder}/*.h) 
+	file(GLOB ${name}_folder_sources ${GD_DIR}/${folder}/*.c) 
+	file(GLOB ${name}_folder_sources_cpp ${GD_DIR}/${folder}/*.cpp)
+	file(GLOB ${name}_folder_headers ${GD_DIR}/${folder}/*.h) 
 	set(${name}_sources ${${name}_sources} ${${name}_folder_sources} ${${name}_folder_sources_cpp})
 	set(${name}_headers ${${name}_headers} ${${name}_folder_headers})
 	include_directories(${CMAKE_SOURCE_DIR}/${folder})
 endmacro()
 
-
+#TODO add configure step with cmake
 if(MSVC)
-	# ALPHA quality!
 	add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
 	add_definitions(
 		-D__MSVCRT__
+		-D_USE_MATH_DEFINES
+		-DHAVE_DIRENT_H
+		-DHAVE_LIBGEN_H
 		-DSTDC_HEADERS
 		-DHAVE_INTTYPES_H
 		-DHAVE_IO_H
 		-DHAVE_STDINT_H
+		-DHAVE_STRUCT__STAT64
+		-DHAVE__STAT64
 		-DGD_NO_C99_API
-		#-DGD_C89_API
-		-DPACKAGE_VERSION=1
-		-D_USE_MATH_DEFINES
+		-DPACKAGE_NAME=\"GetData\"
+		-DPACKAGE_VERSION=\"0.7\"
+		-DPACKAGE_BUGREPORT=\"www\"
 		)
 	set(CMAKE_DEBUG_POSTFIX d)
     configure_file(inttypes.h ${CMAKE_CURRENT_BINARY_DIR}/inttypes.h COPYONLY)
@@ -44,11 +48,12 @@
 	#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Za")
 	
 	# Suppress warnings
-	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0")
+	string(REGEX REPLACE "/W[0-4]" "/W0" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+	
+	include_directories(${GD_DIR}/src/msvc)
 endif()
 
 if(MINGW)
-	#TODO add configure step with cmake!
 	add_definitions(
 			-D__MSVCRT__
 			-D__MSVCRT_VERSION__=0x0601
@@ -70,17 +75,22 @@
 			)
 endif()
 
+set(GD_ENABLE_C99_API 0)
+configure_file(${GD_DIR}/src/getdata.h.in ${CMAKE_BINARY_DIR}/getdata.h @ONLY)
 
-configure_file(${GETDATA_DIR}/src/getdata.h.in ${CMAKE_BINARY_DIR}/getdata.h COPYONLY)
+include_directories(${GD_DIR}/src ${CMAKE_CURRENT_BINARY_DIR})
 
-include_directories(${GETDATA_DIR}/src ${CMAKE_CURRENT_BINARY_DIR})
-
 if (NOT CMAKE_INSTALL_PREFIX)
 	set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/installed)
 endif()
 
 add_subdirectory(src)
-#add_subdirectory(bindings)
+add_subdirectory(bindings)
 
+if(GD_TEST)
+	enable_testing()
+	add_subdirectory(test)
+endif()
 
 
+
--- branches/work/kst/portto4/kst/misc/getdata-windows/cmake/bindings/cxx/CMakeLists.txt #1202856:1202857
@@ -2,7 +2,7 @@
 GD_FILES(s bindings/cxx)
 GD_FILES(h bindings/cxx/getdata)
 
-include_directories(${GETDATA_DIR}/bindings/cxx)
+include_directories(${GD_DIR}/bindings/cxx)
 
 add_library(getdata++ STATIC ${h_headers} ${s_sources})
 
--- branches/work/kst/portto4/kst/misc/getdata-windows/cmake/src/CMakeLists.txt #1202856:1202857
@@ -1,81 +1,34 @@
 
-set(BZIP2_C bzip.c)
-set(DEBUG_C debug.c)
-set(GZIP_C gzip.c)
-set(LZMA_C lzma.c)
-set(LEGACY_C legacy.c)
-set(SLIM_C slim.c)
+set(files_ignored
+	${GD_DIR}/src/bzip.c
+	${GD_DIR}/src/debug.c
+	${GD_DIR}/src/gzip.c
+	${GD_DIR}/src/lzma.c
+	${GD_DIR}/src/legacy.c
+	${GD_DIR}/src/slim.c
+	)
 
 GD_FILES(gd src)
 
 if(MSVC)
-	set(gdsrc 
-		#${GETDATA_DIR}/src/add.c
-		#${GETDATA_DIR}/src/ascii.c
-		${GETDATA_DIR}/src/${BZIP2_C}
-		#${GETDATA_DIR}/src/close.c
-		#${GETDATA_DIR}/src/common.c
-		#${GETDATA_DIR}/src/compat.c
-		#${GETDATA_DIR}/src/constant.c
-		${GETDATA_DIR}/src/${DEBUG_C}
-		#${GETDATA_DIR}/src/del.c
-		#${GETDATA_DIR}/src/encoding.c
-		#${GETDATA_DIR}/src/endian.c
-		#${GETDATA_DIR}/src/entry.c
-		${GETDATA_DIR}/src/errors.c #config.h needed
-		#${GETDATA_DIR}/src/field_list.c
-		#${GETDATA_DIR}/src/flimits.c
-		#${GETDATA_DIR}/src/flush.c
-		#${GETDATA_DIR}/src/fragment.c
-		#${GETDATA_DIR}/src/getdata.c
-		#${GETDATA_DIR}/src/globals.c 
-		#${GETDATA_DIR}/src/${GZIP_C}
-		#${GETDATA_DIR}/src/index.c
-		#${GETDATA_DIR}/src/include.c
-		${GETDATA_DIR}/src/${LEGACY_C}
-		${GETDATA_DIR}/src/${LZMA_C}
-		#${GETDATA_DIR}/src/meta_list.c
-		#${GETDATA_DIR}/src/mod.c
-		#${GETDATA_DIR}/src/move.c
-		#${GETDATA_DIR}/src/name.c
-		#${GETDATA_DIR}/src/native.c
-		#${GETDATA_DIR}/src/nfields.c
-		#${GETDATA_DIR}/src/nframes.c
-		#${GETDATA_DIR}/src/nmeta.c
-		#${GETDATA_DIR}/src/open.c
-		#${GETDATA_DIR}/src/parse.c
-		#${GETDATA_DIR}/src/protect.c
-		#${GETDATA_DIR}/src/putdata.c 
-		#${GETDATA_DIR}/src/raw.c 
-		${GETDATA_DIR}/src/${SLIM_C}
-		#${GETDATA_DIR}/src/spf.c
-		#${GETDATA_DIR}/src/string.c
-		#${GETDATA_DIR}/src/types.c
-		${GETDATA_DIR}/src/${GETDATA_LEGACY_H}
-		${GETDATA_DIR}/src/internal.h		
+	set(gd_sources 
+		${gd_sources}
+		${GD_DIR}/src/msvc/dirent.h
+		${GD_DIR}/src/msvc/dirent.c
+		${GD_DIR}/src/msvc/dirname.c
+		${GD_DIR}/src/msvc/libgen.h
+		${GD_DIR}/src/msvc/unistd.h
 	)
-	
-	# MSVC doesn't support C99, try as C++
-	#set_source_files_properties(${gd_sources} PROPERTIES LANGUAGE CXX)
-	list(REMOVE_ITEM gd_sources ${gdsrc})
 endif()
 
-if(MINGW)
-	list(REMOVE_ITEM gd_sources
-		${GETDATA_DIR}/src/${BZIP2_C}
-		${GETDATA_DIR}/src/${DEBUG_C}
-		${GETDATA_DIR}/src/${GZIP_C}
-		${GETDATA_DIR}/src/${LZMA_C}
-		${GETDATA_DIR}/src/${LEGACY_C}
-		${GETDATA_DIR}/src/${SLIM_C})
-endif()
 
+list(REMOVE_ITEM gd_sources ${files_ignored})
 
 add_library(getdata STATIC ${gd_sources} ${gd_headers} ${CMAKE_BINARY_DIR}/getdata.h)
 
 
-
 install(FILES ${CMAKE_BINARY_DIR}/getdata.h DESTINATION include)
 install(TARGETS getdata DESTINATION lib)
 
 
+
--- branches/work/kst/portto4/kst/misc/getdata-windows/msvc.patch #1202856:1202857
@@ -1,32 +1,6 @@
-Index: src/open.c
-===================================================================
---- src/open.c	(Revision 489)
-+++ src/open.c	(Arbeitskopie)
-@@ -39,10 +39,13 @@
- #include <libgen.h>
- #endif
- 
-+
-+
- /* attempt to open or create a new dirfile - set error appropriately */
- static FILE* _GD_CreateDirfile(DIRFILE* D, const char* format_file,
-     const char* filedir)
- {
-+  FILE* fp = NULL;
-   struct stat statbuf;
-   char fullname[FILENAME_MAX];
-   DIR* dir;
-@@ -50,7 +53,6 @@
-   struct dirent* lamb;
-   int dir_error = 0;
-   int format_error = 0;
--  FILE* fp = NULL;
- 
-   dtrace("%p, \"%s\", \"%s\"", D, format_file, filedir);
- 
 Index: src/flush.c
 ===================================================================
---- src/flush.c	(Revision 489)
+--- src/flush.c	(Revision 492)
 +++ src/flush.c	(Arbeitskopie)
 @@ -26,7 +26,6 @@
  #include <errno.h>
@@ -44,11 +18,12 @@
  #define GD_VERS_GE_1  0xFFFFFFFFFFFFFFFELLU
  #define GD_VERS_GE_2  0xFFFFFFFFFFFFFFFCLLU
  #define GD_VERS_GE_3  0xFFFFFFFFFFFFFFF8LLU
-@@ -734,7 +734,28 @@
+@@ -734,7 +734,29 @@
  #define GD_VERS_LE_6  0x000000000000007fLLU
  #define GD_VERS_LE_7  0x00000000000000ffLLU
  #define GD_VERS_LE_8  0x00000000000001ffLLU
 +#else
++// TODO no long long
 +#define GD_VERS_GE_1  0xFFFFFFFFFFFFFFFELU
 +#define GD_VERS_GE_2  0xFFFFFFFFFFFFFFFCLU
 +#define GD_VERS_GE_3  0xFFFFFFFFFFFFFFF8LU
@@ -73,21 +48,38 @@
  uint64_t _GD_FindVersion(DIRFILE *D)
  {
    unsigned int i;
-Index: src/ascii.c
+Index: src/putdata.c
 ===================================================================
---- src/ascii.c	(Revision 489)
-+++ src/ascii.c	(Arbeitskopie)
-@@ -25,7 +25,6 @@
- #include <inttypes.h>
- #include <sys/stat.h>
- #include <sys/types.h>
--#include <unistd.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <string.h>
+--- src/putdata.c	(Revision 492)
++++ src/putdata.c	(Arbeitskopie)
+@@ -528,7 +528,7 @@
+         D->fragment[E->fragment_index].cname);
+   else {
+     gd_type_t type = _GD_ConstType(D, E->EN(scalar,const_type));
+-    _GD_ConvertType(D, data_in, data_type, E->e->u.scalar.d + first *
++    _GD_ConvertType(D, data_in, data_type, (char*)(E->e->u.scalar.d) + first *
+         GD_SIZE(type), type, len);
+   }
+ 
+Index: src/parse.c
+===================================================================
+--- src/parse.c	(Revision 492)
++++ src/parse.c	(Arbeitskopie)
+@@ -88,6 +88,11 @@
+   return t;
+ }
+ 
++#ifdef _MSC_VER
++//TODO no long long 
++_gd_int64_t strtoull(const char* str, char** endptr, int base) { return 0; }
++#endif
++
+ /* Returns a newly malloc'd string containing the scalar field name, or NULL on
+  * numeric literal or error */
+ static char* _GD_SetScalar(DIRFILE* D, const char* token, void* data, int type,
 Index: src/mod.c
 ===================================================================
---- src/mod.c	(Revision 489)
+--- src/mod.c	(Revision 492)
 +++ src/mod.c	(Arbeitskopie)
 @@ -30,6 +30,10 @@
  #include <libgen.h>
@@ -102,14 +94,21 @@
    return (A > B) ? A : B;
 Index: src/internal.h
 ===================================================================
---- src/internal.h	(Revision 489)
+--- src/internal.h	(Revision 492)
 +++ src/internal.h	(Arbeitskopie)
-@@ -27,18 +27,32 @@
+@@ -27,12 +27,33 @@
  #endif
  
  #include "getdata.h"
 +
++#ifdef HAVE_UNISTD_H
++#include <unistd.h>
++#endif
 +
++#ifdef HAVE_STDINT_H
++#include <stdint.h>
++#endif
++
  #include <string.h>
 +#include <errno.h>
 +#include <fcntl.h>
@@ -123,29 +122,15 @@
 +typedef int mode_t;
 +#define fsync _commit
 +#define snprintf _snprintf
++#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
++#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
 +#endif
 +
 +
  #ifdef GD_NO_C99_API
  #  define GD_DCOMPLEXP_t double *
  #  define GD_DCOMPLEXA(v) double v[2]
- #  define GD_DCOMPLEXV(v) double v[][2]
-+#ifndef _MSC_VER 
- #  define cabs(z)  sqrt((z)[0] * (z)[0] + (z)[1] * (z)[1])
- #  define carg(z)  atan2((z)[1], (z)[0])
-+#endif
- #  define creal(z) ((z)[0])
- #  define cimag(z) ((z)[1])
- #  define _gd_a2c _gd_c2c
-@@ -86,6 +100,7 @@
- #endif
- #endif
- 
-+
- /* For FILENAME_MAX */
- #include <stdio.h>
- 
-@@ -122,7 +137,11 @@
+@@ -122,7 +143,11 @@
  # define __wur
  #endif
  
@@ -157,33 +142,36 @@
  
  /* disable the "unspecified order" remark in ICC */
  #ifdef __INTEL_COMPILER
-@@ -253,7 +272,7 @@
- #define rmdir _rmdir
+@@ -254,18 +279,25 @@
  #endif
  
--#if defined __CYGWIN__ || defined __APPLE__
-+#if defined __CYGWIN__ || defined __APPLE__  || _MSC_VER
- #  define gd_stat64 stat
- #elif HAVE_STAT64
+ #if defined __CYGWIN__ || defined __APPLE__
+-#  define gd_stat64 stat
+-#elif HAVE_STAT64
++#define HAVE_NO_STAT64
++#define HAVE_NO_STRUCT_STAT64
++#endif
++
++#if HAVE_STAT64
  #  define gd_stat64 stat64
-@@ -265,7 +284,7 @@
+ #elif HAVE__STAT64
+ #  define gd_stat64 _stat64
++#elif HAVE_NO_STAT64
++#  define gd_stat64 stat
+ #endif
+ 
+ #if HAVE_STRUCT_STAT64
  typedef struct stat64 gd_stat64_t;
++#elif HAVE_STRUCT__STAT64
++typedef struct _stat64 gd_stat64_t;
  #elif HAVE_STRUCT___STAT64
  typedef struct __stat64 gd_stat64_t;
 -#elif defined __CYGWIN__ || defined __APPLE__
-+#elif defined __CYGWIN__ || defined __APPLE__ || _MSC_VER
++#elif HAVE_NO_STRUCT_STAT64
  typedef struct stat gd_stat64_t;
  #endif
  
-@@ -285,6 +304,7 @@
- #define write _write
- #endif
- 
-+
- #ifndef HAVE_GETDELIM
- ssize_t getdelim(char**, size_t*, int, FILE*);
- #endif
-@@ -719,7 +739,13 @@
+@@ -719,7 +751,13 @@
  int _GD_SlimClose(struct _gd_raw_file* file);
  off64_t _GD_SlimSize(struct _gd_raw_file* file, gd_type_t data_type);
  
@@ -200,47 +188,45 @@
  }
 Index: src/getdata.h.in
 ===================================================================
---- src/getdata.h.in	(Revision 489)
+--- src/getdata.h.in	(Revision 492)
 +++ src/getdata.h.in	(Arbeitskopie)
-@@ -56,10 +56,18 @@
+@@ -52,14 +52,20 @@
+ /* The most recent standards version supported by this library */
+ #define GD_DIRFILE_STANDARDS_VERSION 8
+ 
++#include <math.h>
++
+ /* one or more of these should give us:
   *    size_t, off_t, __REDIRECT, &c., if present
   */
  #include <sys/types.h>
-+
-+#ifdef HAVE_UNISTD_H
- #include <unistd.h>
-+#endif
+-#include <unistd.h>
  
-+#ifdef HAVE_STDINT_H
-+#include <stdint.h>
-+#endif
 +
 +
++
  /* If this symbol is defined here, the C99-API is not present in the library */
--#undef GD_NO_C99_API
-+// TODO check for C99 #undef GD_NO_C99_API
++#if @GD_ENABLE_C99_API@
+ #undef GD_NO_C99_API
++#endif
  
  #if defined(GD_NO_C99_API) && ! defined(GD_C89_API)
  # define GD_C89_API
-@@ -225,9 +233,15 @@
- /* GD_NO_ENTRY is not part of this count */
- #define GD_N_ENTYPES 14
- 
-+#ifdef _MSC_VER // TODO
-+typedef short _gd_int16_t;
-+typedef unsigned short _gd_uint16_t;
-+typedef __int64 _gd_int64_t;
-+#else
+@@ -228,6 +234,11 @@
  #undef _gd_int16_t
  #undef _gd_uint16_t
  #undef _gd_int64_t
++#ifdef _MSC_VER 
++typedef short _gd_int16_t;
++typedef unsigned short _gd_uint16_t;
++typedef __int64 _gd_int64_t;
 +#endif
  #if ! defined GD_C89_API
  #  include <inttypes.h>
  #  define GD_DCOMPLEXM(v) double _Complex v
 Index: src/raw.c
 ===================================================================
---- src/raw.c	(Revision 489)
+--- src/raw.c	(Revision 492)
 +++ src/raw.c	(Arbeitskopie)
 @@ -24,7 +24,7 @@
  #include <stdlib.h>


More information about the Kst mailing list