[GRASS-SVN] r42262 - in grass/trunk: include lib/python lib/python/ctypes swig

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 16 11:39:16 EDT 2010


Author: glynn
Date: 2010-05-16 11:39:16 -0400 (Sun, 16 May 2010)
New Revision: 42262

Added:
   grass/trunk/lib/python/ctypes/
   grass/trunk/lib/python/ctypes/Makefile
   grass/trunk/lib/python/ctypes/__init__.py
Modified:
   grass/trunk/include/gisdefs.h
   grass/trunk/lib/python/Makefile
   grass/trunk/swig/Makefile
Log:
Replace SWIG with ctypesgen for Python bindings


Modified: grass/trunk/include/gisdefs.h
===================================================================
--- grass/trunk/include/gisdefs.h	2010-05-16 15:37:24 UTC (rev 42261)
+++ grass/trunk/include/gisdefs.h	2010-05-16 15:39:16 UTC (rev 42262)
@@ -64,9 +64,15 @@
 void *G_incr_void_ptr(const void *, size_t);
 #endif
 
+#ifndef CTYPESGEN
 #define G_malloc(n)     G__malloc(__FILE__, __LINE__, (n))
 #define G_calloc(m, n)  G__calloc(__FILE__, __LINE__, (m), (n))
 #define G_realloc(p, n) G__realloc(__FILE__, __LINE__, (p), (n))
+#else
+#define G_malloc(n)     G__malloc("<ctypesgen>", 0, (n))
+#define G_calloc(m, n)  G__calloc("<ctypesgen>", 0, (m), (n))
+#define G_realloc(p, n) G__realloc("<ctypesgen>", 0, (p), (n))
+#endif
 
 /* area.c */
 int G_begin_cell_area_calculations(void);

Modified: grass/trunk/lib/python/Makefile
===================================================================
--- grass/trunk/lib/python/Makefile	2010-05-16 15:37:24 UTC (rev 42261)
+++ grass/trunk/lib/python/Makefile	2010-05-16 15:39:16 UTC (rev 42262)
@@ -13,7 +13,10 @@
 PYFILES := $(patsubst %,$(DSTDIR)/%.py,$(MODULES) __init__)
 PYCFILES := $(patsubst %,$(DSTDIR)/%.pyc,$(MODULES) __init__)
 
+CLEAN_SUBDIRS = ctypes
+
 default: $(PYFILES) $(PYCFILES) $(GDIR)/__init__.py $(GDIR)/__init__.pyc
+	$(MAKE) -C ctypes
 
 $(PYDIR):
 	$(MKDIR) $@

Added: grass/trunk/lib/python/ctypes/Makefile
===================================================================
--- grass/trunk/lib/python/ctypes/Makefile	                        (rev 0)
+++ grass/trunk/lib/python/ctypes/Makefile	2010-05-16 15:39:16 UTC (rev 42262)
@@ -0,0 +1,84 @@
+MODULE_TOPDIR = ../../..
+
+PACKAGE = "grasslibs"
+
+include $(MODULE_TOPDIR)/include/Make/Other.make
+include $(MODULE_TOPDIR)/include/Make/Doxygen.make
+
+# doxygen:
+DOXNAME=
+DOXINPUT=grasspython.dox
+
+MODULES = date grass raster gmath proj imagery vector display stats \
+	dbmi g3d arraystats cluster trans vedit
+
+date_LIBS       = $(DATETIMELIB)
+grass_LIBS      = $(GISLIB)
+raster_LIBS     = $(RASTERLIB)
+gmath_LIBS      = $(GMATHLIB)
+proj_LIBS       = $(GPROJLIB)
+imagery_LIBS    = $(IMAGERYLIB)
+vector_LIBS     = $(VECTLIB)
+display_LIBS    = $(DISPLAYLIB)
+stats_LIBS      = $(STATSLIB)
+dbmi_LIBS       = $(DBMILIB)
+g3d_LIBS        = $(G3DLIB)
+arraystats_LIBS = $(ARRAYSTATSLIB)
+cluster_LIBS    = $(CLUSTERLIB)
+trans_LIBS      = $(TRANSLIB)
+vedit_LIBS      = $(VEDITLIB)
+
+date_INC        = datetime.h P_datetime.h
+grass_INC       = gis.h gisdefs.h
+raster_INC      = raster.h rasterdefs.h
+gmath_INC       = gmath.h
+proj_INC        = gprojects.h
+imagery_INC     = imagery.h imagedefs.h
+vector_INC      = vector.h vect/dig_structs.h vect/dig_defines.h
+display_INC     = display.h
+stats_INC       = stats.h
+dbmi_INC        = dbmi.h
+g3d_INC         = G3d.h
+arraystats_INC  = arraystats.h
+cluster_INC     = cluster.h
+trans_INC       = transform.h
+vedit_INC       = vedit.h
+
+CTYPESGEN = ctypesgen.py
+CTYPESFLAGS = $(INC) $(LIBPATH)
+EXTRA_CLEAN_FILES := $(foreach M,$(MODULES),$(M).pyc $(M).py)
+
+ifneq ($(MINGW),)
+EXTRA_LIBS = $(INTLLIB)
+endif
+
+include $(MODULE_TOPDIR)/include/Make/Python.make
+
+PYDIR = $(ETC)/python
+GDIR = $(PYDIR)/grass
+DSTDIR = $(GDIR)/lib
+
+PYFILES  := $(patsubst %,$(DSTDIR)/%.py,$(MODULES) __init__)
+PYCFILES  := $(patsubst %,$(DSTDIR)/%.pyc,$(MODULES) __init__)
+LPYFILES := $(patsubst %,%.py,$(MODULES))
+
+default:
+	$(MAKE) $(DSTDIR)
+	$(MAKE) $(LPYFILES) $(PYFILES) $(PYCFILES)
+
+$(DSTDIR)/%.py: %.py | $(DSTDIR)
+	$(INSTALL_DATA) $< $@
+
+%.py: $(%_INC) $(%_LIBS)
+	$(CTYPESGEN) $(CTYPESFLAGS) $($*_LIBS) $(EXTRA_LIBS) $(patsubst %.h,$(ARCH_INCDIR)/%.h,$($*_INC)) -o $@
+
+$(PYDIR):
+	$(MKDIR) $@
+
+$(GDIR): | $(PYDIR)
+	$(MKDIR) $@
+
+$(DSTDIR): | $(GDIR)
+	$(MKDIR) $@
+
+.SECONDARY: $(patsubst %,%.py,$(MODULES))

Added: grass/trunk/lib/python/ctypes/__init__.py
===================================================================
--- grass/trunk/lib/python/ctypes/__init__.py	                        (rev 0)
+++ grass/trunk/lib/python/ctypes/__init__.py	2010-05-16 15:39:16 UTC (rev 42262)
@@ -0,0 +1,16 @@
+import date
+import grass
+import raster
+import gmath
+import proj
+import imagery
+import vector
+import display
+import stats
+import dbmi
+import g3d
+import arraystats
+import cluster
+import trans
+import vedit
+

Modified: grass/trunk/swig/Makefile
===================================================================
--- grass/trunk/swig/Makefile	2010-05-16 15:37:24 UTC (rev 42261)
+++ grass/trunk/swig/Makefile	2010-05-16 15:39:16 UTC (rev 42262)
@@ -5,7 +5,7 @@
 #compile if PYTHON present:
 ifneq ($(USE_PYTHON),)
 ifneq ($(strip $(CXX)),)
-    SUBDIRS += python
+#    SUBDIRS += python
 endif
 endif
 



More information about the grass-commit mailing list