kopia lustrzana https://github.com/ha7ilm/csdr
python bindings
rodzic
d1c5628f50
commit
7988ccd28f
|
@ -3,7 +3,11 @@ nmux
|
|||
ddcd
|
||||
*.o
|
||||
*.so
|
||||
*.so.*
|
||||
tags
|
||||
dumpvect.*.vect
|
||||
grc_tests/top_block.py
|
||||
*.swp
|
||||
csdrpy.i
|
||||
csdrpy.py*
|
||||
csdrpy_wrap.*
|
||||
|
|
36
Makefile
36
Makefile
|
@ -43,16 +43,18 @@ PARAMS_MISC = -Wno-unused-result
|
|||
#PARAMS_DEBUG = $(if $(DEBUG_ON),-g,)
|
||||
FFTW_PACKAGE = fftw-3.3.3
|
||||
PREFIX ?= /usr
|
||||
PYVERSION ?= 2.7
|
||||
SOVERSION = 0.15
|
||||
|
||||
.PHONY: clean-vect clean
|
||||
.PHONY: clean-vect clean-python clean
|
||||
all: csdr nmux
|
||||
libcsdr.so: fft_fftw.c fft_rpi.c libcsdr_wrapper.c libcsdr.c libcsdr_gpl.c fastddc.c fastddc.h fft_fftw.h fft_rpi.h ima_adpcm.h libcsdr_gpl.h libcsdr.h predefined.h
|
||||
@echo NOTE: you may have to manually edit Makefile to optimize for your CPU \(especially if you compile on ARM, please edit PARAMS_NEON\).
|
||||
@echo Auto-detected optimization parameters: $(PARAMS_SIMD)
|
||||
@echo
|
||||
rm -f dumpvect*.vect
|
||||
gcc -std=gnu99 $(PARAMS_LOOPVECT) $(PARAMS_SIMD) $(LIBSOURCES) $(PARAMS_LIBS) $(PARAMS_MISC) -fpic -shared -Wl,-soname,libcsdr.so.$(SOVERSION) -o libcsdr.so
|
||||
gcc -std=gnu99 $(PARAMS_LOOPVECT) $(PARAMS_SIMD) $(LIBSOURCES) $(PARAMS_LIBS) $(PARAMS_MISC) -fpic -shared -Wl,-soname,libcsdr.so.$(SOVERSION) -o libcsdr.so.$(SOVERSION)
|
||||
@ln -fs libcsdr.so.$(SOVERSION) libcsdr.so
|
||||
-./parsevect dumpvect*.vect
|
||||
csdr: csdr.c libcsdr.so
|
||||
gcc -std=gnu99 $(PARAMS_LOOPVECT) $(PARAMS_SIMD) csdr.c $(PARAMS_LIBS) -L. -lcsdr $(PARAMS_MISC) -o csdr
|
||||
|
@ -65,20 +67,20 @@ arm-cross: clean-vect
|
|||
arm-linux-gnueabihf-gcc -std=gnu99 -O3 -fshort-double -ffast-math -dumpbase dumpvect-arm -fdump-tree-vect-details -mfloat-abi=softfp -march=armv7-a -mtune=cortex-a9 -mfpu=neon -mvectorize-with-neon-quad -Wno-unused-result -Wformat=0 $(SOURCES) -lm -o ./csdr
|
||||
clean-vect:
|
||||
rm -f dumpvect*.vect
|
||||
clean: clean-vect
|
||||
rm -f libcsdr.so csdr ddcd nmux
|
||||
clean: clean-vect clean-python
|
||||
rm -f libcsdr.so.$(SOVERSION) csdr ddcd nmux *.o *.so
|
||||
install: all
|
||||
install -m 0755 libcsdr.so $(PREFIX)/lib
|
||||
install -m 0755 libcsdr.so.$(SOVERSION) $(PREFIX)/lib
|
||||
install -m 0755 csdr $(PREFIX)/bin
|
||||
install -m 0755 csdr-fm $(PREFIX)/bin
|
||||
install -m 0755 nmux $(PREFIX)/bin
|
||||
#-install -m 0755 ddcd $(PREFIX)/bin
|
||||
@ldconfig || echo please run ldconfig
|
||||
uninstall:
|
||||
rm $(PREFIX)/lib/libcsdr.so $(PREFIX)/bin/csdr $(PREFIX)/bin/csdr-fm
|
||||
rm $(PREFIX)/lib/libcsdr.so.$(SOVERSION) $(PREFIX)/bin/csdr $(PREFIX)/bin/csdr-fm
|
||||
ldconfig
|
||||
disasm:
|
||||
objdump -S libcsdr.so > libcsdr.disasm
|
||||
objdump -S libcsdr.so.$(SOVERSION) > libcsdr.disasm
|
||||
emcc-clean:
|
||||
-rm sdr.js/sdr.js
|
||||
-rm sdr.js/sdrjs-compiled.js
|
||||
|
@ -98,3 +100,23 @@ emcc:
|
|||
cat sdr.js/sdrjs-header.js sdr.js/sdrjs-compiled.js sdr.js/sdrjs-footer.js > sdr.js/sdr.js
|
||||
emcc-beautify:
|
||||
bash -c 'type js-beautify >/dev/null 2>&1; if [ $$? -eq 0 ]; then js-beautify sdr.js/sdr.js >sdr.js/sdr.js.beautiful; mv sdr.js/sdr.js.beautiful sdr.js/sdr.js; fi'
|
||||
|
||||
python: libcsdr.so clean-python
|
||||
@echo "/* This file is autogenerated. Any changes should be made to csdrpy.i.in */" > csdrpy.i
|
||||
@echo 'generating "csdrpy.i"'
|
||||
@cat csdrpy.i.in >> csdrpy.i
|
||||
@cat fastddc.h >> csdrpy.i
|
||||
@cat fft_fftw.h >> csdrpy.i
|
||||
@cat fft_rpi.h >> csdrpy.i
|
||||
@cat ima_adpcm.h >> csdrpy.i
|
||||
@cat libcsdr_gpl.h >> csdrpy.i
|
||||
@cat libcsdr.h >> csdrpy.i
|
||||
swig -python csdrpy.i
|
||||
gcc -c -fPIC csdrpy_wrap.c -I/usr/include/python$(PYVERSION) -I.
|
||||
gcc -shared csdrpy_wrap.o -L. -lcsdr -lfftw3f -lm -o _csdrpy.so
|
||||
|
||||
clean-python:
|
||||
rm -f csdrpy_wrap.c csdrpy_wrap.o _csdrpy.so csdrpy.py* csdrpy.i
|
||||
|
||||
python-install: libcsdr.so
|
||||
install -m 0755 csdrpy.py _csdrpy.so $(PREFIX)/lib/python$(PYVERSION)/
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
%module csdrpy
|
||||
|
||||
%{
|
||||
#define SWIG_FILE_WITH_INIT
|
||||
#define LIBCSDR_GPL
|
||||
#define USE_FFTW
|
||||
#define USE_IMA_ADPCM
|
||||
|
||||
#include "predefined.h"
|
||||
#include "fastddc.h"
|
||||
#include "libcsdr.h"
|
||||
#include "libcsdr_gpl.h"
|
||||
#include "fft_fftw.h"
|
||||
#include "fft_rpi.h"
|
||||
#include "ima_adpcm.h"
|
||||
%}
|
||||
|
||||
%feature("autodoc", "2");
|
||||
|
||||
/* contents of libcsdr.h will be appended below for processing by swig */
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import csdrpy
|
||||
|
||||
csdrpy_syms = filter(lambda x: x.startswith('_') == False, dir(csdrpy))
|
||||
csdrpy_syms = set(csdrpy_syms)
|
||||
|
||||
assert( csdrpy.is_nan(1.0) == False)
|
||||
assert( csdrpy.is_nan(float('NaN')) == True)
|
||||
assert( csdrpy.log2n(1) == 0 )
|
||||
assert( csdrpy.log2n(256) == 8)
|
||||
|
||||
print 'Loaded {0} symbols'.format(len(csdrpy_syms))
|
||||
print 'csdr python binding works! :)'
|
Ładowanie…
Reference in New Issue