Browse Source

python wrapper now contains nearly everything

but very raw, types should become objects in oo-enabled target languages
Julius Pfrommer 10 years ago
parent
commit
e2e903d1f9
6 changed files with 28 additions and 31 deletions
  1. 3 3
      Makefile.am
  2. 1 1
      configure.ac
  3. 11 0
      wrappers/Makefile.am
  4. 2 0
      wrappers/open62541.h
  5. 3 17
      wrappers/open62541.i
  6. 8 10
      wrappers/python/Makefile.am

+ 3 - 3
Makefile.am

@@ -11,7 +11,7 @@ endif
 if DEBUG
 AM_CFLAGS += -g3 -O0
 else
-AM_CFLAGS += -O2 
+AM_CFLAGS += -Os
 endif
 
 if COVERAGE
@@ -41,9 +41,9 @@ SUBDIRS += examples/src
 endif
 
 if PYTHON_WRAPPER
-SUBDIRS += wrappers/python
+SUBDIRS += wrappers wrappers/python
 endif
 
 if LUA_WRAPPER
-SUBDIRS += wrappers/lua
+SUBDIRS += wrappers wrappers/lua
 endif

+ 1 - 1
configure.ac

@@ -140,6 +140,6 @@ AM_COND_IF([LUA_WRAPPER],
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_LIBTOOL
 AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_FILES(Makefile src/Makefile tests/Makefile examples/src/Makefile doc/Makefile wrappers/python/Makefile wrappers/lua/Makefile)
+AC_CONFIG_FILES(Makefile src/Makefile tests/Makefile examples/src/Makefile doc/Makefile wrappers/Makefile wrappers/python/Makefile wrappers/lua/Makefile)
 AC_OUTPUT
 

+ 11 - 0
wrappers/Makefile.am

@@ -0,0 +1,11 @@
+# We expand open62541.h with the preprocessor. SWIG can't handle all our macros.
+# The standard libs are not included into the expanded header file.
+
+# the lib is stated as a dependency to refresh if a header changes in ../src
+open62541_expanded.h: open62541.h open62541.i $(top_builddir)/lib/libopen62541.a
+	gcc -E open62541.h > open62541_expanded.h -I../src -D_STDIO_H=1 -D_STDDEF_H=1 -D_STDLIB_H=1 -D_STRING_H=1 -D_CTYPE_H=1 -D_UNISTD_H=1 -D_STDINT_H=1
+
+all: open62541_expanded.h
+
+clean-local:
+	rm -rf open62541_expanded.h

+ 2 - 0
wrappers/open62541.h

@@ -0,0 +1,2 @@
+#include "ua_types.h"
+#include "ua_application.h"

+ 3 - 17
wrappers/open62541.i

@@ -1,23 +1,9 @@
-/*
- swig -python -I../src -I../examples/src open62541.i
- gcc -c open62541_wrap.c -I/usr/include/python2.7 -I../examples/src -I../src -fPIC
- ld -shared open62541_wrap.o ../lib/libopen62541.so ../examples/src/networklayer.so -o _open62541.so
-*/
-
 %module open62541
 %{
 /* Includes the header in the wrapper code */
-#include "networklayer.h"
-#include "ua_application.h"
+#include "open62541_expanded.h"
 %}
 
 /* Parse the header file to generate wrappers */
-typedef int UA_Int32;
-//%include "stdint.i"
-//%include "ua_types.h"
-%include "networklayer.h"
-%include "ua_application.h"
-
-extern NL_Description NL_Description_TcpBinary;
-extern Application appMockup;
-void appMockup_init();
+%include "stdint.i"
+%include "open62541_expanded.h"

+ 8 - 10
wrappers/python/Makefile.am

@@ -1,20 +1,18 @@
-INCLUDEDIRS = -I$(top_builddir)/src -I$(top_builddir)/src/util -I$(top_builddir)/examples/src
-AM_CFLAGS = $(GLOBAL_AM_CFLAGS) $(INCLUDEDIRS)
 WRAPPER_DIR = $(top_builddir)/wrappers
+#AM_CFLAGS = $(GLOBAL_AM_CFLAGS) -I$(WRAPPER_DIR)
+AM_CFLAGS = -fPIC -I$(WRAPPER_DIR)
 
-open62541.py open62541_wrap_python.c:
-	swig -python $(INCLUDEDIRS) -o ./open62541_wrap_python.c $(WRAPPER_DIR)/open62541.i
-
-networklayer.so:
-	gcc -c $(AM_CFLAGS) $(top_builddir)/examples/src/networklayer.c -o networklayer.so
+open62541.py open62541_wrap_python.c: $(WRAPPER_DIR)/open62541.i \
+									  $(WRAPPER_DIR)/open62541_expanded.h
+	swig -python -o ./open62541_wrap_python.c $(WRAPPER_DIR)/open62541.i
 
 open62541_wrap_python.o: open62541_wrap_python.c
 	gcc -c $(subst -pedantic, , $(AM_CFLAGS)) -I/usr/include/python2.7 open62541_wrap_python.c
 
-_open62541.so: networklayer.so open62541_wrap_python.o
-	ld -shared open62541_wrap_python.o networklayer.so $(top_builddir)/lib/libopen62541.so -o _open62541.so
+_open62541.so: open62541_wrap_python.o
+	ld -shared open62541_wrap_python.o $(top_builddir)/lib/libopen62541.a -o _open62541.so
 
 all: open62541.py _open62541.so
 
 clean-local:
-	rm -rf networklayer.so open62541.py open62541.pyc _open62541.so open62541_wrap_python.c open62541_wrap_python.o || true;
+	rm -rf open62541.py open62541.pyc _open62541.so open62541_wrap_python.c open62541_wrap_python.o || true;