Commits

wlav committed c6d9d62

more support for test using the dummy backend

Comments (0)

Files changed (3)

pypy/module/cppyy/test/Makefile

   ROOTSYS := ${ROOTSYS}
 endif
 
-ifeq ($(ROOTSYS),)
-  genreflex=genreflex
-  cppflags=-I$(shell root-config --incdir) -L$(shell root-config --libdir)
+ifeq ($(DUMMY),t)
+  cppflags=
 else
-  genreflex=$(ROOTSYS)/bin/genreflex
-  ifeq ($(wildcard $(ROOTSYS)/include),)     # standard locations used?
-    cppflags=-I$(shell root-config --incdir) -L$(shell root-config --libdir)
+  ifeq ($(ROOTSYS),)
+    genreflex=genreflex
+    cppflags=-I$(ROOTSYS)/include -L$(ROOTSYS)/lib64 -L$(ROOTSYS)/lib
   else
-    cppflags=-I$(ROOTSYS)/include -L$(ROOTSYS)/lib64 -L$(ROOTSYS)/lib
+    genreflex=$(ROOTSYS)/bin/genreflex
+    ifeq ($(wildcard $(ROOTSYS)/include),)       # standard locations used?
+      cppflags=-I$(shell root-config --incdir) -L$(shell root-config --libdir)
+    else
+      cppflags=-I$(ROOTSYS)/include -L$(ROOTSYS)/lib64 -L$(ROOTSYS)/lib
+    endif
   endif
 endif
 
   cppflags+=-dynamiclib -single_module -arch x86_64 -undefined dynamic_lookup
 endif
 
-ifeq ($(CINT),)
+ifeq ($(DUMMY),t)
+  cppflags2=-O3 -fPIC -rdynamic
+else ifeq ($(CINT),)
   ifeq ($(shell $(genreflex) --help | grep -- --with-methptrgetter),)
     genreflexflags=
     cppflags2=-O3 -fPIC
     genreflexflags=--with-methptrgetter
     cppflags2=-Wno-pmf-conversions -O3 -fPIC
   endif
-else
-  cppflags2=-O3 -fPIC -rdynamic
 endif
 
-ifeq ($(CINT),)
+ifeq ($(CINT),t)
+%Dict.so: %_cint.cxx %.cxx
+	g++ -o $@ $^ -shared $(cppflags) $(cppflags2)
+	rlibmap -f -o $*Dict.rootmap -l $@ -c $*_LinkDef.h
+
+%_cint.cxx: %.h %_LinkDef.h
+	rootcint -f $@ -c $*.h $*_LinkDef.h
+
+else ifeq ($(DUMMY),t)
+%Dict.so: %.cxx
+	g++ -o $@ $^ -shared $(cppflags) $(cppflags2)
+
+else # reflex
 %Dict.so: %_rflx.cpp %.cxx
 	echo $(cppflags)
 	g++ -o $@ $^ -shared -lReflex $(cppflags) $(cppflags2)
 
 %_rflx.cpp: %.h %.xml
 	$(genreflex) $< $(genreflexflags) --selection=$*.xml --rootmap=$*Dict.rootmap --rootmap-lib=$*Dict.so
-else
-%Dict.so: %_cint.cxx %.cxx
-	g++ -o $@ $^ -shared $(cppflags) $(cppflags2)
-	rlibmap -f -o $*Dict.rootmap -l $@ -c $*_LinkDef.h
 
-%_cint.cxx: %.h %_LinkDef.h
-	rootcint -f $@ -c $*.h $*_LinkDef.h
 endif
 
 ifeq ($(CINT),)
+ifeq ($(DUMMY),)
 # TODO: methptrgetter causes these tests to crash, so don't use it for now
 std_streamsDict.so: std_streams.cxx std_streams.h std_streams.xml
 	$(genreflex) std_streams.h --selection=std_streams.xml
 	g++ -o $@ std_streams_rflx.cpp std_streams.cxx -shared -lReflex $(cppflags) $(cppflags2)
 endif
+endif
 
 .PHONY: clean
 clean:

pypy/module/cppyy/test/conftest.py

 import py
+
+if py.path.local.sysfind('genreflex') is None:
+    # build the dummy CAPI
+
+    import os
+    from rpython.translator.tool.cbuild import ExternalCompilationInfo
+    from rpython.translator import platform
+
+    from rpython.rtyper.lltypesystem import rffi
+
+    pkgpath = py.path.local(__file__).dirpath().join(os.pardir)
+    srcpath = pkgpath.join('src')
+    incpath = pkgpath.join('include')
+
+    eci = ExternalCompilationInfo(
+        separate_module_files=[srcpath.join('dummy_backend.cxx')],
+        include_dirs=[incpath],
+        use_cpp_linker=True,
+    )
+
+    soname = platform.platform.compile(
+        [], eci,
+        outputfilename='libcppyy_backend',
+        standalone=False)
+
+    import pypy.module.cppyy.capi.loadable_capi as lcapi
+    lcapi.reflection_library = str(soname)

pypy/module/cppyy/test/test_cppyy.py

 import py, os, sys
 
+isdummy = ''
 if py.path.local.sysfind('genreflex') is None:
-    py.test.skip("genreflex is not installed")
+    isdummy = 'DUMMY=t'
 
 from pypy.module.cppyy import interp_cppyy, executor
 
 def setup_module(mod):
     if sys.platform == 'win32':
         py.test.skip("win32 not supported so far")
-    err = os.system("cd '%s' && make example01Dict.so" % currpath)
+    err = os.system("cd '%s' && make %s example01Dict.so" % (currpath, isdummy))
     if err:
         raise OSError("'make' failed (see stderr)")